Capítulo 834 de 859
Continuing from merging thousands of boxes into one geometry (which makes moving individual boxes hard), this lesson shows how to animate between multiple whole datasets using morph targets, plus a TweenManager that keeps animation working with on-demand (not continuous) rendering.
BufferGeometry draws efficiently but loses the ability to move individual boxes independently.position (and color) attribute as a morph target on a shared base geometry — every target must have exactly the same vertex count, so datasets with missing values at a given point must be handled consistently across all sets (e.g. omit a box everywhere if any dataset lacks data there).TweenManager wrapper tracks active tweens and reports whether any are still running, so the render loop can keep re-rendering only while an animation is in progress and go idle otherwise.const baseGeometry = geometries[0];
baseGeometry.morphAttributes.position = geometries.map((geometry, ndx) => {
const attribute = geometry.getAttribute("position");
attribute.name = `target${ndx}`;
return attribute;
});
const material = new THREE.MeshBasicMaterial({ vertexColors: true });
const mesh = new THREE.Mesh(baseGeometry, material);
TweenManager-style wrapper that reports "still animating or not" lets you combine a tweening library with render-on-demand instead of forcing continuous rendering.