5

I've exported an animated model from Blender which doesn't seem to have any issue instantiating. I'm able to create the THREE.Animation and model, but I was finding there was no animation. I realized I needed to set skinning true on each material, but when I do that the entire mesh goes missing.

Below is my (quick and messy) code trying to get everything to work.

function loadModel() {
        var loader = new THREE.JSONLoader();
        loader.load('assets/models/Robot.js', function(geom, mat) {
            _mesh = new THREE.Object3D();
            _scene.add(_mesh);

            geom.computeBoundingBox();

            ensureLoop(geom.animation);
            THREE.AnimationHandler.add(geom.animation);

            for (var i = 0; i < mat.length; i++) {
                var m = mat[i];
                //m.skinning = true; <-- Uncommenting this makes the model disappear
                //m.morphTargets = true; <-- This causes all sorts of WebGL warnings

                m.wrapAround = true;
            }

            var mesh = new THREE.SkinnedMesh(geom, new THREE.MeshFaceMaterial(mat));
            mesh.scale.set(400, 400, 400);
            mesh.position.set(0, -200, 0);
            mesh.rotation.set(Utils.toRadians(-90), 0, 0);
            _mesh.add(mesh);
            _robot = mesh;
            Render.startRender(loop);

            var animation = new THREE.Animation(mesh, geom.animation.name);
            animation.JITCompile = false;
            animation.interpolationType = THREE.AnimationHandler.LINEAR;
            animation.play();

        });
    }

I believe I'm updating the AnimationHandler correctly in my loop

function loop() {
    _mesh.rotation.y += 0.01;

    var delta = 0.75 * _clock.getDelta();
    THREE.AnimationHandler.update(delta);
} 
4

3 回答 3

0

I was having the same problem just now. What worked for me was to remake the model with applied scale and have keyframes for LocRotScale, not just location.

于 2014-08-26T20:51:35.643 回答
0

在导出的 JSON 文件的部分元数据中, morphTargets骨骼的数量都大于 0?

我认为您在这里遵循了示例:

http://threejs.org/examples/#webgl_animation_skinning_morph

其中动画模型使用变形目标和骨骼动画(有关理论概念,请参见 Wikipedia)。

如果动画模型仅使用骨骼动画,如本示例http://alteredqualia.com/three/examples/webgl_animation_skinning_tf2.html

您必须实例化一个THREE.SkinnedMesh对象,然后仅将m.skinning属性设置为true

于 2013-12-12T19:35:30.253 回答
0

最近,我在将搅拌机蒙皮动画导出到 json 时遇到了类似的网格消失问题。事实证明,我使用的网格有双顶点(一个顶点隐藏另一个顶点)。一切看起来都很好虽然在搅拌机中创建顶点组和动画,但是当我通过three.js导入网格时,它在动画开始时一直消失。换句话说,如果顶点组中省略了网格中的 1 个顶点,您将体验到这种消失的行为。为了防止这个问题,我现在使用搅拌机中的“删除双打”功能来验证网格完整性,然后再将其导出为 json。您可能遇到过同样的问题并重做网格工作来修复它......无论如何,这个问题已经很老了,但这个话题到今天仍然有效,

和平INF1

于 2016-11-07T02:02:59.567 回答