【问题标题】:Blender json export; "animation" missing搅拌机 json 导出; “动画”不见了
【发布时间】:2015-03-05 02:48:33
【问题描述】:

我试图弄清楚基本动画是如何导出并与 three.js 一起使用的。我在搅拌机中制作了一个几何图形并将其导出为 JSON。由于我使用的是 three.js v 69,因此不推荐使用 THREE.animationHandler。我为我的库版本找到了一个工作示例,但它仅适用于此处提供的 three.js 库附带的示例附带的 JSON:http://threejs.org/examples/models/skinned/knight.js。 我的 JSON 文件输出此错误:TypeError: a is undefined three.min.js:682。

我找不到文件之间的语法差异。

var loader = new THREE.JSONLoader(),  
    animatedMesh;

loader.load( './123.json', function ( geometry, materials ) {
     var originalMaterial = materials[ 0 ];
    originalMaterial.skinning = true;
    animatedMesh = new THREE.SkinnedMesh( geometry, originalMaterial );
    // Instantiate the animation
    var animation = new THREE.Animation(
        animatedMesh,
        geometry.animation
    );
    animation.play();

});
scene.add( animatedMesh );

当我首先在加载程序调用的函数中检查 geometry.animation[0].hierarchy.lenght 时,当我使用我的 JSON 时它会给出错误。当我使用 knight.js 时,我得到了正确数量的动画; 80.

我为测试导出的 JSON:

{   "metadata": {
        "formatVersion" : 3.1,
        "generatedBy"   : "Blender 2.7 Exporter",
        "vertices"      : 8,
        "faces"         : 6,
        "normals"       : 8,
        "colors"        : 0,
        "uvs"           : [],
        "materials"     : 1,
        "morphTargets"  : 0,
        "bones"         : 1
    },

        "scale" : 1.000000,

        "vertices" : [0.282971,-0.059365,-0.277163,0.278713,-0.0459321,0.283946,-0.282552,-0.0482188,0.279742,-0.278294,-0.0616519,-0.281367,0.268505,3.65467,-0.366188,0.264248,3.66811,0.194921,-0.297017,3.66582,0.190716,-0.29276,3.65239,-0.370392],
        "faces"    : [35,0,1,2,3,0,0,1,2,3,35,4,7,6,5,0,4,5,6,7,35,0,4,5,1,0,0,4,7,1,35,1,5,6,2,0,1,7,6,2,35,2,6,7,3,0,2,6,5,3,35,4,0,3,7,0,4,0,3,5],
        "uvs"      : [],
        "normals"  : [0.583941,-0.588641,-0.559008,0.575182,-0.560991,0.595325,-0.579455,-0.565691,0.586657,-0.570696,-0.593341,-0.567644,0.579455,0.565691,-0.586657,-0.575182,0.560991,-0.595325,-0.583941,0.588641,0.559008,0.570696,0.593341,0.567644],

        "skinIndices"  : [0,-1,0,-1,0,-1,0,-1,0,-1,0,-1,0,-1,0,-1],
        "skinWeights"  : [1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0],
        "morphTargets" : [],

        "bones"      : [{"parent":-1,"name":"Bone","pos":[0,0,-0],"rotq":[0.707107,0,-0,0.707107],"scl":[3.4158,3.4158,3.4158]}],
        "animation" : [{"name":"ArmatureAction","fps":24,"length":1.625,"hierarchy":[{"parent":-1,"keys":[{"time":0,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.0416667,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.0833333,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.125,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.166667,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.208333,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.25,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.291667,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.333333,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.375,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.416667,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.458333,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.5,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.541667,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.583333,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.625,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.666667,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.708333,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.75,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.791667,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.833333,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.875,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.916667,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":0.958333,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":1,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":1.04167,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":1.08333,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":1.125,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":1.16667,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":1.20833,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":1.25,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":1.29167,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":1.33333,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":1.375,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":1.41667,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":1.45833,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":1.5,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":1.54167,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":1.58333,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]},{"time":1.625,"pos":[0,0,-0],"rot":[0.698582,-0.00125648,0.00407379,0.715517],"scl":[3.4158,3.4158,3.4158]}]}]}],

        "colors"    : [],
        "materials" : [
            {
                "DbgColor": 15658734,
                "DbgIndex": 0,
                "DbgName": "Material",
                "blending": "NormalBlending",
                "colorAmbient": [0.6400000190734865, 0.6400000190734865, 0.6400000190734865],
                "colorDiffuse": [0.6400000190734865, 0.6400000190734865, 0.6400000190734865],
                "colorEmissive": [0.0, 0.0, 0.0],
                "colorSpecular": [0.5, 0.5, 0.5],
                "depthTest": true,
                "depthWrite": true,
                "shading": "Lambert",
                "specularCoef": 50,
                "transparency": 1.0,
                "transparent": false,
                "vertexColors": false
            }       ]   }

【问题讨论】:

标签: animation three.js blender


【解决方案1】:

这是我的错误,Blender 中有某些条件可以正确导出为 JSON。在某些模型中,它的动画,在我的动画中。正确的代码是: var animation = new THREE.Animation( animatedMesh, geometry.animations[0] );

【讨论】:

    猜你喜欢
    • 2015-08-16
    • 2014-05-24
    • 1970-01-01
    • 2013-09-28
    • 2016-06-28
    • 2012-02-02
    • 1970-01-01
    • 2017-09-03
    • 2014-06-09
    相关资源
    最近更新 更多