I’m working on a simple terrain editor using editor api, can we change mesh data like vertex positions in render asset or are there any similar methods ?
Chat GPT suggest me this is that possible ?
const meshInstance = entity.render.meshInstances[0];
const vertexBuffer = meshInstance.mesh.vertexBuffer;
// Lock the vertex buffer to make changes
const iterator = new pc.VertexIterator(vertexBuffer);
for (let i = 0; i < vertexBuffer.numVertices; i++) {
iterator.element.position.set(newX, newY, newZ); // Set new position here
iterator.next();
}
// Unlock the buffer to apply changes
iterator.end();
// Update the bounding box if needed
meshInstance.mesh.updateBounds();