I created a GLTF model with 2 Morph Targets.
One Sphere => which Morphs to suzanne and also to a Cone.
I loaded them in three.js and was able to produce one of the morphing through the below code.
var params = {
morphTarget: 0
};
var gui = new dat.GUI();
var folder = gui.addFolder('Morph Targets');
folder.add(params, 'morphTarget', 0, 1).step(0.01).onChange(function(value) {
mesh.morphTargetInfluences[0] = value
});
folder.open();
.
.
.
var loader = new THREE.GLTFLoader();
loader.load('models/suzanne2morphs.glb', function(gltf) {
gltf.scene.traverse(function(node) {
if (node.isMesh) mesh = node;
});
mesh.material.morphTarget = true;
scene.add(mesh);
The mesh.morphTargetInfluences[0] = value sets the slider for 1st morph (sphere to suzanne)
and changing it to [1] does morph to cone.
But I don’t know how to loop through it and make mesh.morphTargetInfluences[i] = value to change both morphs at the same time
I am new to this
Can anyone help me solve this