0

私はいくつかの調査を行い、obj ファイルを Three.js の JSON モデルでインポートできる .js ファイルにエクスポートする方法を学びました。しかし、どうすればそのようなモデルをアニメーション化できますか? 翼を羽ばたかせることを学ぶ必要がある .js 形式の鳥モデルがあります。さらに、インターネットから obj ファイルをダウンロードしたとき、それは無料のモデルだったので、オブジェクトのテクスチャ イメージも含まれていますが、obj を 3D モデリング ソフトウェアの Blender 3d にインポートすると、テクスチャをロードできませんが、テキストエディタから開いたときのobjファイル。それを .js 形式に変換すると、テクスチャ マッピング用の bmp 画像に配置された正しい場所にもなりますが、JSON モデルを使用して webgl にモデルをロードするとロードに失敗します。

誰かが私を正しい方向に向けてくれませんか? この考えをすべて学ぶことができます. お願いします、皆さんからの助けが必要です。

Jsモデルファイルのコード

{
    "metadata" :
    {
        "formatVersion" : 3,
        "generatedBy" : "Blender 2.66 Exporter",
        "vertices" : 2652,
        "faces" : 4798,
        "normals" : 2652,
        "colors" : 0,
        "uvs" : [1202],
        "materials" : 4,
        "morphTargets" : 0,
        "bones" : 0
    },

    "scale" : 1.000000,

    "materials" : [ {
        "DbgColor" : 15658734,
        "DbgIndex" : 0,
        "DbgName" : "_5___Default0",
        "blending" : "NormalBlending",
        "colorAmbient" : [0.800000011920929, 0.800000011920929, 0.800000011920929],
        "colorDiffuse" : [0.800000011920929, 0.800000011920929, 0.800000011920929],
        "colorSpecular" : [0.8999999761581421, 0.8999999761581421, 0.8999999761581421],
        "depthTest" : true,
        "depthWrite" : true,
        "mapDiffuse" : "n-201.bmp",
        "mapDiffuseWrap" : ["repeat", "repeat"],
        "shading" : "Lambert",
        "specularCoef" : 2,
        "transparency" : 1.0,
        "transparent" : false,
        "vertexColors" : false
    },
    {
        "DbgColor" : 15597568,
        "DbgIndex" : 1,
        "DbgName" : "_5___Default1",
        "blending" : "NormalBlending",
        "colorAmbient" : [0.800000011920929, 0.800000011920929, 0.800000011920929],
        "colorDiffuse" : [0.800000011920929, 0.800000011920929, 0.800000011920929],
        "colorSpecular" : [0.8999999761581421, 0.8999999761581421, 0.8999999761581421],
        "depthTest" : true,
        "depthWrite" : true,
        "mapDiffuse" : "n-200.bmp",
        "mapDiffuseWrap" : ["repeat", "repeat"],
        "shading" : "Lambert",
        "specularCoef" : 2,
        "transparency" : 1.0,
        "transparent" : false,
        "vertexColors" : false
    },
    {
        "DbgColor" : 60928,
        "DbgIndex" : 2,
        "DbgName" : "_5___Default2",
        "blending" : "NormalBlending",
        "colorAmbient" : [0.800000011920929, 0.800000011920929, 0.800000011920929],
        "colorDiffuse" : [0.800000011920929, 0.800000011920929, 0.800000011920929],
        "colorSpecular" : [0.8999999761581421, 0.8999999761581421, 0.8999999761581421],
        "depthTest" : true,
        "depthWrite" : true,
        "mapDiffuse" : "n-202.bmp",
        "mapDiffuseWrap" : ["repeat", "repeat"],
        "shading" : "Lambert",
        "specularCoef" : 2,
        "transparency" : 1.0,
        "transparent" : false,
        "vertexColors" : false
    },
    {
        "DbgColor" : 238,
        "DbgIndex" : 3,
        "DbgName" : "_5___Default",
        "blending" : "NormalBlending",
        "colorAmbient" : [0.800000011920929, 0.800000011920929, 0.800000011920929],
        "colorDiffuse" : [0.800000011920929, 0.800000011920929, 0.800000011920929],
        "colorSpecular" : [0.8999999761581421, 0.8999999761581421, 0.8999999761581421],
        "depthTest" : true,
        "depthWrite" : true,
        "mapDiffuse" : "n-203.bmp",
        "mapDiffuseWrap" : ["repeat", "repeat"],
        "shading" : "Lambert",
        "specularCoef" : 2,
        "transparency" : 1.0,
        "transparent" : false,
        "vertexColors" : false
    },

    {
        "DbgColor" : 15658496,
        "DbgIndex" : 4,
        "DbgName" : "_5___Default0",
        "blending" : "NormalBlending",
        "colorAmbient" : [0.800000011920929, 0.800000011920929, 0.800000011920929],
        "colorDiffuse" : [0.800000011920929, 0.800000011920929, 0.800000011920929],
        "colorSpecular" : [0.8999999761581421, 0.8999999761581421, 0.8999999761581421],
        "depthTest" : true,
        "depthWrite" : true,
        "mapDiffuse" : "n-201.bmp",
        "mapDiffuseWrap" : ["repeat", "repeat"],
        "shading" : "Lambert",
        "specularCoef" : 2,
        "transparency" : 1.0,
        "transparent" : false,
        "vertexColors" : false
    },

    {
        "DbgColor" : 61166,
        "DbgIndex" : 5,
        "DbgName" : "_5___Default1",
        "blending" : "NormalBlending",
        "colorAmbient" : [0.800000011920929, 0.800000011920929, 0.800000011920929],
        "colorDiffuse" : [0.800000011920929, 0.800000011920929, 0.800000011920929],
        "colorSpecular" : [0.8999999761581421, 0.8999999761581421, 0.8999999761581421],
        "depthTest" : true,
        "depthWrite" : true,
        "mapDiffuse" : "n-200.bmp",
        "mapDiffuseWrap" : ["repeat", "repeat"],
        "shading" : "Lambert",
        "specularCoef" : 2,
        "transparency" : 1.0,
        "transparent" : false,
        "vertexColors" : false
    },

    {
        "DbgColor" : 15597806,
        "DbgIndex" : 6,
        "DbgName" : "_5___Default2",
        "blending" : "NormalBlending",
        "colorAmbient" : [0.800000011920929, 0.800000011920929, 0.800000011920929],
        "colorDiffuse" : [0.800000011920929, 0.800000011920929, 0.800000011920929],
        "colorSpecular" : [0.8999999761581421, 0.8999999761581421, 0.8999999761581421],
        "depthTest" : true,
        "depthWrite" : true,
        "mapDiffuse" : "n-202.bmp",
        "mapDiffuseWrap" : ["repeat", "repeat"],
        "shading" : "Lambert",
        "specularCoef" : 2,
        "transparency" : 1.0,
        "transparent" : false,
        "vertexColors" : false
    },

    {
        "DbgColor" : 419610,
        "DbgIndex" : 7,
        "DbgName" : "_5___Default",
        "blending" : "NormalBlending",
        "colorAmbient" : [0.800000011920929, 0.800000011920929, 0.800000011920929],
        "colorDiffuse" : [0.800000011920929, 0.800000011920929, 0.800000011920929],
        "colorSpecular" : [0.8999999761581421, 0.8999999761581421, 0.8999999761581421],
        "depthTest" : true,
        "depthWrite" : true,
        "mapDiffuse" : "n-203.bmp",
        "mapDiffuseWrap" : ["repeat", "repeat"],
        "shading" : "Lambert",
        "specularCoef" : 2,
        "transparency" : 1.0,
        "transparent" : false,
        "vertexColors" : false
    }],
4

1 に答える 1

0

こちらをご覧ください

http://threejs.org/examples/webgl_morphnormals.html http://threejs.org/examples/webgl_morphtargets_horse.html

最初の例では、ここを見てください。行 90

var loader = new THREE.JSONLoader();
                loader.load( "models/animated/flamingo.js", function( geometry ) {

                    morphColorsToFaceColors( geometry );
                    geometry.computeMorphNormals();

                    var material = new THREE.MeshLambertMaterial( { color: 0xffffff, morphTargets: true, morphNormals: true, vertexColors: THREE.FaceColors, shading: THREE.FlatShading } );
                    var meshAnim = new THREE.MorphAnimMesh( geometry, material );

                    meshAnim.duration = 5000;

                    meshAnim.scale.set( 1.5, 1.5, 1.5 );
                    meshAnim.position.y = 150;

                    scene1.add( meshAnim );
                    morphs.push( meshAnim );

                } );
于 2013-05-09T17:31:35.293 に答える