-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Closed
Labels
Description
I have a model loaded with jsonloader, and add the mesh to scene using the callback function
function addCube( p, g) {
var materials = [
new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, vertexColors: THREE.VertexColors } ),
new THREE.MeshBasicMaterial( { color: 0x000000, shading: THREE.FlatShading, wireframe: true, transparent: true } )];
mesh = new THREE.Mesh( g, materials );
mesh.position = p;
scene.addObject( mesh );
};However, when I try to dynamically changed the mesh 's vertex position, it seems to fail to reach the geometry of the mesh, the shape of the mesh is not affected at all even if I set the .__dirtyVertices to be true;
for(i=0;i<meshGeometry.vertieces.length;i++)
{
mesh.geometry.vertices[i].position.x-=shiftX;
mesh.geometry.vertices[i].position.y-=shiftY;
mesh.geometry.vertices[i].position.z-=shiftZ;
}
mesh.geometry.__dirtyVertices = true;And the system give an uncaught typeerror, it seems that the browser failed to access the mesh geometry.
Is it because the mesh creation is done in the callback function? I look at another demo here
http://mrdoob.github.com/three.js/examples/webgl_ribbons.html
the mesh creation is done outside the callback funciton, and the mesh vertex position could be dynamiclly changed.
Can anyone tell me how to find a way to solve this problem?