-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Closed
Labels
Description
I have an object (exported from Blender) which is uv mapped and has a uv texture image.
If I use JSONLoader() to load it , the callback function is called before the image is loaded.
If I immediately try to render it in the callback, it fails.
If I wait few seconds and render it, it works.
This fails
var loader = new THREE.JSONLoader(true);
loader.load('Carl.js',
function ( geometry, materials ) {
var material = new THREE.MeshFaceMaterial( materials );
mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
renderer.render(scene, camera);
}
);
This works
var loader = new THREE.JSONLoader(true);
loader.load('Carl.js',
function ( geometry, materials ) {
var material = new THREE.MeshFaceMaterial( materials );
mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
setTimeout(
function(){
renderer.render(scene, camera);
},
2000
);
}
);
I took a quick look at the source
JSONLoader calls
Loader.initMaterials() which calls
Loader.createMaterial() which calls
load_image()
load_image loads image asynchronously.
Looks like JSONLoader doesn't wait on this and calls callback function immediately.