Reputation: 51918
I have thousands of these shapes:
var someShape = new THREE.Shape( somePts );
var extrudedGeometry = new THREE.ExtrudeGeometry(someShape, {depth: 1, bevelEnabled: false});
var extrudedMesh = new THREE.Mesh(extrudedGeometry, new THREE.MeshPhongMaterial({color: getRandomColor(), transparent: true}));
Each one of these shapes will morph into a different shape with the same amount of vertices. I was thinking of using morph targets, do they run on the gpu?
Is a morph target in three.js implemented behind the scenes as a vertex shader or if I'm trying to do this for thousands of objects should I create my own vertex shader?
Upvotes: 3
Views: 284
Reputation: 31026
I was thinking of using morph targets, do they run on the gpu?
Yes, morph target animation is a form of vertex displacement which is implemented in the vertex shader. Most built-in materials like MeshPhongMaterial
support it by including the respective shader chunks. As a user, you just have to set .morphTargets to true
in order to notify the renderer that a specific material should use morph targets.
three.js R104
Upvotes: 4