How to reshape the mesh real time?


#1

If I create a box, and I want to reshape it to be longer or width more , how can I perform in code without scale it ?
And I wish to get the index of the point and set ( x,y,z ) to it like three.js.

if (dragging && currentIndex !== null) {
    setRaycaster(event);
    raycaster.ray.intersectPlane(plane, planePoint);
    geometry.attributes.position.setXYZ(currentIndex, planePoint.x, planePoint.y, planePoint.z);
    geometry.attributes.position.needsUpdate = true;
}

any way to code it ? @will


#2

Not my area but the voxel canvas project here creates meshes in realtime. You may be able to find some clues/ideas here on how to modify vertices there: https://playcanvas.com/project/448005/overview/voxelcanvas


#3

Does this help?

https://developer.playcanvas.com/en/tutorials/terrain-generation/

This uses the pc.createMesh function.

This is a utility function that creates a pc.Mesh structure for you (that essentially contains all the vertex data).

The code for that function is here:

You can create/edit any mesh in a similar fashion.


#4

yes, I have found it , and render a new mesh every time. this did help me! thanks.