I've been working on modifying the vertices of a plane geometry in order to create new shapes. However, I've run into an issue where when I export the modified geometry as JSON, the changes I made to the vertices are not included in the exported data.
Could someone help me figure out how to properly export my new geometry as JSON while retaining all the modifications I've made?
Below is the code snippet I've been using:
var seg = 5;
var dim = 70;
var zScale = 20;
var geometry = new THREE.PlaneGeometry(dim, dim, seg, seg );
var index = 0;
for (var gridY = 0; gridY < seg; gridY++) {
for (var gridX = 0; gridX < seg; gridX++) {
var z = Math.random() * zScale;
geometry.vertices[index].z = z;
index++;
}
}
geometry.elementsNeedUpdate = true;
geometry.verticesNeedUpdate = true;
var expJson = geometry.toJSON();
console.log(expJson);
However, the exported JSON data currently looks like this:
{
height: 70
heightSegments: 5
metadata: {
generator: "Geometry.toJSON"
type: "PlaneGeometry"
},
version: 4.4
type: "PlaneGeometry"
uuid: "5F071B03-15EA-43CE-B4B3-4944E13D781C"
width: 70
widthSegments: 5
}