具有材质颜色的三个js动画混合器模型 [英] Three js animate blender model with material colors
问题描述
我有一个导出的(三种js json格式)搅拌器模型.该模型具有一些带有颜色的材料.如果我使用THREE.MorphAnimMesh和THREE.MeshPhongMaterial,则动画效果很好,但没有任何材质颜色.如果我使用THREE.MeshFaceMaterial,它具有颜色,但是动画不起作用. 问题是,如何为js模型文件中的材质颜色设置动画?
I have an exported (three js json format) blender model. The model have a few material with colors. If i use THREE.MorphAnimMesh and THREE.MeshPhongMaterial the animation is working fine but no material colors. If i use THREE.MeshFaceMaterial it have colors but animation not working. The question is, how can i animate with material colors from the model js file?
动画有效,但没有颜色.模特是白色的:
animation working but no colors. the model is white:
var material = new THREE.MeshPhongMaterial({ morphTargets: true, morphNormals: true, vertexColors: THREE.FaceColors, shading: THREE.SmoothShading, perPixel: true } );
var meshAnim = new THREE.MorphAnimMesh( geometry, material );
模型具有材料颜色,但动画不起作用:
model have the material colors but animation not working:
var material = new THREE.MeshFaceMaterial({ morphTargets: true, morphNormals: true, vertexColors: THREE.FaceColors });
var meshAnim = new THREE.MorphAnimMesh( geometry, material );
这是模型js文件: http://speedy.sh/rs39u/skeleton-0 .js
顺便说一句,我从示例中看到了flamingo.js文件.它有一个morphColors对象,但是如果我知道的话,我不能从搅拌机中导出它.
btw, i saw the flamingo.js file from the examples. It have a morphColors object but if i know right i cant export this from blender.
推荐答案
知道了.也许有人可以使用它:
Got it. Maybe someone can use it:
for (var i=0; i<geometry.materials.length; i++) {
geometry.materials[i].morphTargets = true;
}
var material = new THREE.MeshFaceMaterial({ morphTargets: true, morphNormals: true, vertexColors: THREE.FaceColors });
var meshAnim = new THREE.MorphAnimMesh( geometry, material );
这篇关于具有材质颜色的三个js动画混合器模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!