0down votefavorite
I have several particles sharing the same shape, with different rotation, position, and scale.
var mesh = new THREE.Mesh(new THREE.Geometry(), material);
var geoArr = [];
function init() {
var template = new THREE.BufferGeometry().fromGeometry(
new THREE.TetrahedronGeometry(5, 0)
);
for (var i = 0; i < 20; ++i) {
var geo = template.clone();
// each geo have different rotate, scale, and translate
geo.rotateX(...);
geo.scale(...);
geo.translate(...);
geoArr.push(geo);
}
var bufferedGeo = THREE.BufferGeometryUtils.mergeBufferGeometries(this.geoArr);
mesh.geometry = bufferedGeo;
}
function render() {
// in each frame, rotate, scale, and translate are supposed to change
for (var i = 0; i < geoArr.length; ++i) {
geo.rotateX(...); // ???
// Should I call rotateX, scale and translate?
// This will accumulate previous settings. How to set like mesh.position?
}
var bufferedGeo = THREE.BufferGeometryUtils.mergeBufferGeometries(this.geoArr);
mesh.geometry = bufferedGeo;
}
I’m not sure if I should use BufferGeometryUtils in this way and how should I set transform in each render frame?
Merging geometries in render loop is because each gemetries is changing position, rotation and scale in a frame. Since buffered geometry contains vertex positions that are transformed in the last frame. How should I revert the transform in last frame and apply new transform otherwise?