![](/img/trans.png)
[英]How can I set the position of a mesh before I add it to the scene in three.js
[英]How to set time delay in adding mesh to scene in three.js
我需要在一段时间内将网格物体添加到场景中。 不幸的是setTimeout
函数对我不起作用
var geometry = new THREE.BoxGeometry(1, 1, 1);
var material = new THREE.MeshLambertMaterial({color: 0xFF0000, side: THREE.DoubleSide});
function addMesh(mesh)
{
setTimeout(function()
{
Scene.add(mesh);
},3000);
}
for (var i = 0; i < pointzz.length; i += 2) {
var mesh = new THREE.Mesh(geometry, material);
mesh.rotation.x = -Math.PI / 2;
mesh.rotation.y = Math.PI;
mesh.rotation.z = Math.PI;
mesh.name = "mesh";
mesh.position.set(pointzz[i], 0, pointzz[i + 1]);
mesh.scale.set(15, 15, 15);
addMesh(mesh);
}
这里pointzz
包含mesh
的x
和z
坐标。 该代码工作正常。 所有的网格物体都添加到了scene
但是我需要在很小的时间延迟内添加每个网格物体
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.