2017-11-29 13 views
1

私はBlenderで3Dモデルを作成しました。私はThree.jsエクスポータでエクスポートし、JavaScriptでロードします。テクスチャが表示されない限り、すべてが正常に動作します。 Blenderのテクスチャを画像として追加しました。three.js JSONオブジェクトにテクスチャを追加

JSONファイル:

{ 
"normals":[0,-1,0,...] 
"vertices":[-0.0101738,1.5,6.55678,-0.0101738,1.5,...] 
"materials":[{ 
    "DbgIndex":0, 
    "blending":1, 
    "colorSpecular":[1,1,1], 
    "opacity":1, 
    "colorDiffuse":[0.8,0.554325,0.316799], 
    "mapDiffuseWrap":["repeat","repeat"], 
    "transparent":false, 
    "wireframe":false, 
    "DbgColor":15658734, 
    "depthWrite":true, 
    "specularCoef":50, 
    "mapDiffuse":"parket.jpg", 
    "mapDiffuseRepeat":[1,1], 
    "visible":true, 
    "mapDiffuseAnisotropy":1, 
    "shading":"phong", 
    "depthTest":true, 
    "doubleSided":false, 
    "colorEmissive":[0,0,0], 
    "DbgName":"Les" 
},{ 
    "DbgIndex":1, 
    "blending":1, 
    "colorSpecular":[1,1,1], 
    "opacity":1, 
    "colorDiffuse":[0.287043,0.0523764,0.0102247], 
    "transparent":false, 
    "wireframe":false, 
    "DbgColor":15597568, 
    "depthWrite":true, 
    "specularCoef":50, 
    "visible":true, 
    "shading":"phong", 
    "depthTest":true, 
    "doubleSided":false, 
    "colorEmissive":[0,0,0], 
    "DbgName":"\u010crna" 
},{ 
    "DbgIndex":2, 
    "blending":1, 
    "colorSpecular":[1,1,1], 
    "opacity":1, 
    "colorDiffuse":[0.8,0.136903,0.018619], 
    "transparent":false, 
    "wireframe":false, 
    "DbgColor":60928, 
    "depthWrite":true, 
    "specularCoef":50, 
    "visible":true, 
    "shading":"phong", 
    "depthTest":true, 
    "doubleSided":false, 
    "colorEmissive":[0,0,0], 
    "DbgName":"Rjava" 
}], 
"metadata":{ 
    "materials":3, 
    "uvs":0, 
    "generator":"io_three", 
    "type":"Geometry", 
    "vertices":276, 
    "normals":109, 
    "faces":241, 
    "version":3 
}, 
"faces":[35,22,0,1,2,0,0...] 
"uvs":[] 

}

JSONローダー:

   var loader = new THREE.JSONLoader(); 
       loader.load('samosteza.json', function (geometry, material) { 
        mesh = new THREE.Mesh(geometry, material); 
        mesh.scale.x = mesh.scale.y = mesh.scale.z = 30; 
        mesh.translation = THREE.GeometryUtils.center(geometry); 
        mesh.translateY(-150); 
        scene.add(mesh) 
       }, 'parket.jpg'); 

テクスチャを表示する方法を誰もが知っていますか? index.htmlファイルと同じフォルダにテクスチャ( 'parket.jpg')があります。

EDIT:

私はちょうどテクスチャが示されていることが判明、しかしないpropperly。私は木目の質感を持っていて、私が見るのは茶色です。私は別のものでテクスチャを変更しようとしましたが、私は常にオブジェクト上に1つの色を取得し、完全なテクスチャは取得しません。

enter image description here

テクスチャ:

enter image description here

答えて

0

が、これはあなたを助けるだろうことができますか?

+0

いいえ、結果は同じです。 – kac26

+0

ドキュメンテーション "https://threejs.org/docs/index.html#api/loaders/JSONLoader"に基づいて、3番目のパラメータがないはずです...また、ドキュメントには材料[0]があります。もう一度ソースをチェックしますか?また、上記の2行をどこに追加しましたか? – raj

+0

私はちょうどテクスチャが表示されていることを知りましたが、プロペラではありません。私は木目の質感を持っていて、私が見るのは茶色です。私は別のものでテクスチャを変更しようとしましたが、私は常にオブジェクト上に1つの色を取得し、完全なテクスチャは取得しません。 – kac26

関連する問題