我尝试从Blender加载模型,将PointsMaterial应用于它并为其设置动画。到目前为止,只要我使用THREE.PointsMaterial
以外的材料创建网格,我就能够加载模型并成功制作动画。
当我创建THREE.Points
对象时,动画无法播放。我注意到,当我将PointsMaterial的morphTargets
属性设置为true
时,会发出一条警告,指出PointsMaterial
没有此类属性。 Threejs是否不支持使用变形目标的Points对象动画?
monster指的是动画时有效的网格。它使用加载的几何和材质。 ParticleSystem是THREE.Points
对象。
代码:
function loadObject(path){
var loader = new THREE.JSONLoader();
loader.load(
path,
function(geometry, materials){
var material = materials[ 0 ];
material.morphTargets = true;
material.color.setHex( 0xffaaaa );
monster = new THREE.Mesh( geometry, materials );
monster.position.set( 0, 0, 0 );
var s = .003;
monster.scale.set( s, s, s );
var particleMaterial = new THREE.PointsMaterial({
color: 0xffffff,
size: .005,
morphTargets: true
});
particleSystem = new THREE.Points(geometry, particleMaterial);
particleSystem.morphTargetInfluences = monster.morphTargetInfluences;
particleSystem.morphTargetDictionary = monster.morphTargetDictionary;
particleSystem.position.set(0, 0, 0);
particleSystem.scale.set(s, s, s);
particleSystem.matrixAutoUpdate = false;
particleSystem.updateMatrix();
particleSystem.geometry.verticesNeedUpdate = true;
scene.add(particleSystem);
mixer.clipAction( geometry.animations[ 0 ], particleSystem )
.setDuration( 5 ) // one second
.startAt( - Math.random() ) // random phase (already running)
.play(); // let's go
}
)
}