我修改平面幾何體的頂點以創建新幾何體。 但是,當我輸出幾何圖形時,它仍然是一個平面幾何圖形,我的修改過的頂點不包含在內。使用Three.js將修改後的平面幾何體導出爲JSON
如何將我的新幾何體導出爲包含每個更改的JSON?
這裏是我的代碼:
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);
我導出的數據是這樣的:
{
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
}