Skip to content

Dynamically changed shape's vertex not working? #957

@georgeou2003

Description

@georgeou2003

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions