I am drawing a cone by parameters from xml. Is it possible to rotate the cone knowing the radius, the coordinates of the top vertex and the center of the base? example xml coords="-3,-6,0;2.5,7,0;" radius=“10”
What do you mean by rotate ?
Having top and base-centre coordinates, you can first of all build a ConeGeometry (height is equal to top minus base centre; and the radius you have defined.) After that - you can modify the mesh / geometry in all kinds of ways.
I rotate the cone and save the parameters in xml (2 coordinates and radius), then I need to recreate the same cone with the same rotation
In that case - it would be quite handy to just store a transformation matrix of the cone after you rotate it
What are these coords?
top vertex and the center of the base and radius value
So your newly built cone will be something:
new THREE.ConeGeometry( radius, v1.distanceTo(v2));
yes, but it will be no rotation, can I get rotation from this data? i tried with lookAt but not successfully
Why it doesn’t work with
// v1 - base center, v2 - cone's pinnacle let h = v1.distanceTo(v2); let g = new THREE.ConeGeometry( radius, h); g.translate(0, h * 0.5, 0); // base to 0 g.rotateX(Math.PI * 0.5); // align along Z-axis let m = new THREE.MeshBasicMaterial(); // or any other material let o = new THREE.Mesh(g, m); o.position.copy(v1); o.lookAt(v2); scene.add(o);
Haven’t tried it, just from the scratch
Super !!! Y save my day, thank you so much
@kirill321592 you’re welcome