Skip to content

Commit

Permalink
Always load {scene} object
Browse files Browse the repository at this point in the history
  • Loading branch information
Avaer Kazmer committed Nov 6, 2019
1 parent 70d6b79 commit 87aeb52
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ <h3>Examples</h3>
model = null;
}

model = object;
model = object.scene;
_patchModel(model);
scene.add(model);
window.model = model;
Expand Down
20 changes: 9 additions & 11 deletions model-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ const _loadModelFilesystem = async filesystem => {
console.log(`using model file: ${modelFile.pathname}`);
if (/\.fbx$/.test(modelFile.pathname)) {
const model = await new Promise((accept, reject) => {
new THREE.FBXLoader(manager).load(modelFileUrl, accept, function onprogress() {}, reject);
new THREE.FBXLoader(manager).load(modelFileUrl, scene => {
accept({scene});
}, function onprogress() {}, reject);
});
return model;
} else {
const model = await new Promise((accept, reject) => {
new THREE.GLTFLoader(manager).load(modelFileUrl, object => {
accept(object.scene);
}, xhr => {}, reject);
new THREE.GLTFLoader(manager).load(modelFileUrl, accept, xhr => {}, reject);
});
return model;
}
Expand All @@ -102,14 +102,14 @@ const loadModelUrl = async (href, filename = href) => {
const fileType = _getFileType(filename);
if (fileType === 'gltf') {
const model = await new Promise((accept, reject) => {
new THREE.GLTFLoader().load(href, object => {
accept(object.scene);
}, xhr => {}, reject);
new THREE.GLTFLoader().load(href, accept, xhr => {}, reject);
});
return model;
} else if (fileType === 'fbx') {
const model = await new Promise((accept, reject) => {
new THREE.FBXLoader().load(href, accept, xhr => {}, reject);
new THREE.FBXLoader().load(href, scene => {
accept({scene});
}, xhr => {}, reject);
});
return model;
} else if (fileType === 'zip') {
Expand Down Expand Up @@ -186,9 +186,7 @@ const loadModelUrl = async (href, filename = href) => {
img.src = href;
});
const model = await new Promise((accept, reject) => {
new THREE.GLTFLoader().load(`${basePath}minecraft.glb`, object => {
accept(object.scene);
}, xhr => {}, reject);
new THREE.GLTFLoader().load(`${basePath}minecraft.glb`, accept, xhr => {}, reject);
});
const texture = new THREE.Texture(img, THREE.UVMapping, THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping, THREE.NearestFilter, THREE.LinearMipmapLinearFilter, THREE.RGBAFormat, THREE.UnsignedByteType, 16, THREE.LinearEncoding);
texture.flipY = false;
Expand Down

0 comments on commit 87aeb52

Please sign in to comment.