question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dynamically changed shape's vertex not working?

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
georgeou2003commented, Dec 24, 2011

Sorry for not posting the codes, I have solved the problem, by simply setting geometry 's dynamic attributes to be true, geometry.dynamic=true, the problem is solved!

0reactions
chandlerprallcommented, Dec 24, 2011

Erm, yes - that would be the problem! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vertex shape move: vertices not changing - Google Groups
I've been working on a vertex shape move code however, the vertices are not changing. I am wondering if there's something missing in...
Read more >
three js vertices does not update - Stack Overflow
After rendering, you need to reset the needsUpdate flag to true every time the attribute values are changed. three.js r.147.
Read more >
Geometry Nodes - dynamic vertices count of mesh / Error
I have been stuck for the whole afternoon now and I hope that someone has a clue how to solve my problem. I...
Read more >
Dynamic Batching not working even adhering to all rules
Unity shows the vertex count being under 900. Using most simple shader (only a color is output). Forward render mode. No Transparency or...
Read more >
Dynamically Morph A Mesh | Babylon.js Documentation
For now, it concerns only ribbons, tubes, extruded shapes and lines. When talking about morphing, we mean here changing the vertices positions of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found