I want to update its 8 vertices after the cube I added is rotated ,I try to use verticesNeedUpdate,but no effect
Vertices have local values, by rotating mesh you don’t change them, so there is no need for the update.
if I want to get the verticles after the cube is rotated, what should I do? thanks
this.selectedCube.geometry.vertices
, that will give you an array of vertices,
but if You want the rotated values, you can use:
this.selectedCube.geometry.vertices.map(function(vert){
return vert.clone().applyAxisAngle(new THREE.Vector3(0, 1, 0), rotateBasicDegree )
})
Looks feasible. Thank you very much.
I am facing issue in position shift of the cube after updating matrix to get cube vertices.
I want to update vertices after rotation / position applied on cube dynamically.
This is the code I am using to update matrix:
mesh.updateMatrixWorld();
mesh.updateMatrix();
mesh.geometry.applyMatrix( mesh.matrix );
mesh.matrix.identity();
Same code i am using to update matrix for plane mesh too. In this case after updates plane position and rotation shifts are there.
I tried all below attributes to update dynamically but it did not work:
plane.verticesNeedUpdate = true;
plane.elementsNeedUpdate = true;
plane.morphTargetsNeedUpdate = true;
plane.uvsNeedUpdate = true;
plane.normalsNeedUpdate = true;
plane.colorsNeedUpdate = true;
plane.tangentsNeedUpdate = true;
If it is standard or hard coded cube / plane mesh then i am able to get the vertices but if i am changing the position / rotation and then calling update matrix to get updated vertices each time then it is creating issue in the position shift for the mesh.
@MateuszWis
Hi! Just out of curiousity, wouldn’t it be simplier to use
this.selectedCube.geometry.rotateY( rotateBasicDegree );
instead?
I have used this method ,But the graphics I drew completely deviated from the original position.
Can you suggest how to write this after creating plane geometry / cube geometry how to use this code? Actually I am not aware of this. So I tried with the above code what i had mentioned in the previous reply.
How to get updated vertices of the mesh?
Yes, Same issue i also faced. Let me know if you have any solution for this issue. So that i can also try out.
Something like that?
Thankyou!
Gone through the code. Why the box geometry used there, Are you trying to get plane vertices using box geometry ? If so, please help me how to do that.
Is the above code is helpful to get plane vertices? I did not see related to plane vertices. If I am wrong please correct me, I am not fully aware of threejs.
If it is hardcoded plane , then i am able to get plane vertices . But to get dynamically it is not working.
@kanampalli_himaja
Any chance to see what you try to achieve with a live code example and more clear explanation?