您可以轻松地将BufferGeometry存储为json并使用BufferGeometryLoader加载它:
{
"metadata": {
"version": 3,
"type": "Geometry",
"normal": 30,
"position": 30,
"generator": "io_three"
},
"data": {
"index": {
"array": [ 0, 1, 2, 3, …],
"type": "Uint16Array",
"itemSize": 1
},
"attributes": {
"normal": {
"array": [ -1, 0, 0, -1, …],
"type": "Float32Array",
"itemSize": 3
},
"position": {
"array": [ -1, 1, 1, -1, …],
"type": "Float32Array",
"itemSize": 3
}
},
"groups": [
{
"count": 48,
"start": 0,
"materialIndex": 0
}
]
}
}
要加载它,您可以使用以下代码:
var loader = new THREE.BufferGeometryLoader();
loader.load(
'JS/Sample1.json',
function (geometry) {
var mesh = new THREE.Mesh(geometry, new THREE.MeshNormalMaterial({}));
scene.add(mesh);
renderer.render(scene, camera);
}
);
现在的问题是以json格式存储多个几何。是否有可能这样做。如果是,是否有任何说明或示例?
相关分类