网页链接: http: //door-in-wall.asg-3d.ru
来源:http ://door-in-wall.asg-3d.ru/source.zip
调用init()后初始化场景:添加相机、灯光、生成几何体(文本和球体),并使用JSonLoader加载3D 模型。相机、灯光和生成的几何图形已立即添加到场景中,但是当JSonLoader加载模型时 - 我无法理解......
// Create 3D Text Mesh
var textMesh3 = new THREE.Mesh( text3d3, textMaterial );
textMesh3.position.x = textMesh1.position.x;
textMesh3.position.y = textMesh2.position.y - text3d1.boundingBox.max.y * 2.6;
scene.add( textMesh3 );
console.log('textMesh3 within init() = ', textMesh3); //textMesh3 = THREE.Mesh
console.log('scene.children.length after load textMesh3 = ', scene.children.length); //scene.children.length = 6
// Add back plane
var loader = new THREE.JSONLoader().load( "js/backplane.js", function ( geometry ) {
geometry.computeBoundingBox();
backPlaneMesh = new THREE.Mesh( geometry, backPlaneMeshMaterial );
backPlaneMesh.position.set(SCREEN_WIDTH, 0, 0);
backPlaneMesh.scale.set(4, 4, 4);
scene.add(backPlaneMesh);
});
console.log('JSONLoader within init() = ', loader); //loader = undefined
console.log('scene.children.length after load JSONLoader = ', scene.children.length); //scene.children.length = 6
我将控制台输出留给了场景console.log (scene.children.length)的后代:第 103、148、167 行。
如果在调用animate()和render()之后检查scene.children.length ,那么它将显示 7 个孩子的存在。
如何以及何时使用 JSONLoader 加载模型?