I'm trying to incorporate a mesh into the scene with a time delay, but I'm having trouble getting the setTimeout
function to work properly.
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);
}
within the pointzz
array, you will find the x
and z
coordinates of the mesh
. The code functions correctly, as all meshes are added to the scene; however, I'm looking to stagger the addition of each mesh with a slight time delay.