Graphics Reference
In-Depth Information
3. Next, we need to create
THREE.Mesh
and add it to the scene:
car = new THREE.Mesh(model,new
THREE.MeshFaceMaterial( materials ));
scene.add(car);
As you can see, we follow the standard way of creating
THREE.Mesh
and
add it to the scene just like any other object.
4. Now that we've got an object in the scene that can be morphed, we can
use the
morphTargetInfluences
property to set how much the object is
morphed into a specific direction. In the example for this recipe, we used the
UI to control this setting as follows:
gui.add(control, 'mt_1',
0,1).step(0.01).listen().onChange(function(a){
car.morphTargetInfluences[1] = a;
});
gui.add(control, 'mt_2',
0,1).step(0.01).listen().onChange(function(a){
car.morphTargetInfluences[2] = a;
});;
gui.add(control, 'mt_3',
0,1).step(0.01).listen().onChange(function(a){
car.morphTargetInfluences[3] = a;
});
The model we used in this recipe has four morph targets (with names
mt_0
,
mt_1
,
mt_2
, and
mt_3
), its base state and three other car models. By in-
creasing the
morphTargetInfluence
object of one of those other models,
we can morph the model into that direction.
As you can see in this recipe, by simply changing the value of a specific
morphTar-
getInfluences
value, you can change the way your model looks.