以下は、単純な長方形のボックスの json ファイルの例です。
{
"metadata" :
{
"formatVersion" : 3.1,
"sourceFile" : "BOX.obj",
"generatedBy" : "OBJConverter",
"vertices" : 8,
"faces" : 6,
"normals" : 6,
"colors" : 0,
"uvs" : 4,
"materials" : 1
},
"scale" : 1.000000,
"materials": [ {
"DbgColor" : 15658734,
"DbgIndex" : 0,
"DbgName" : "wire_135110008",
"colorAmbient" : [0.0, 0.0, 0.0],
"colorDiffuse" : [0.5294, 0.4314, 0.0314],
"colorSpecular" : [0.35, 0.35, 0.35],
"illumination" : 2,
"specularCoef" : 32.0,
"transparency" : 1.0
}],
"vertices": [-0.069100,0.041400,0.069200,-0.069100,0.041400,0.040600,-0.028100,0.041400,0.040600,-0.028100,0.041400,0.069200,-0.069100,0.077200,0.069200,-0.028100,0.077200,0.069200,-0.028100,0.077200,0.040600,-0.069100,0.077200,0.040600],
"morphTargets": [],
"morphColors": [],
"normals": [0,-1,-0,0,1,-0,0,0,1,1,0,-0,0,0,-1,-1,0,-0],
"colors": [],
"uvs": [[1,0,1,1,0,1,0,0]],
"faces": [43,0,1,2,3,0,0,1,2,3,0,0,0,0,43,4,5,6,7,0,3,0,1,2,1,1,1,1,43,0,3,5,4,0,3,0,1,2,2,2,2,2,43,3,2,6,5,0,3,0,1,2,3,3,3,3,43,2,1,7,6,0,3,0,1,2,4,4,4,4,43,1,0,4,7,0,3,0,1,2,5,5,5,5]
}
そして、これが上記のボックスをロードするための私のコードです(ロードされたボックスの設定位置ステートメントはありません):
var jsonLoader = new THREE.BinaryLoader();
jsonLoader.load('models/demo/BOX.js', function (geometry, materials) {
var faceMaterial = new THREE.MeshFaceMaterial(materials);
box = new THREE.Mesh(geometry, faceMaterial);
// Add mesh to the scene
box.scale.set(10, 10, 10);
scene.add(box);
});
ロード後に元の位置を取得しようとしたところ、問題が発生しました。私が得た位置$('#info').html(box.position.x + ', ' + box.position.y + ', ' + box.position.z);
は常に0, 0, 0
です。(#info は結果を表示するための div 要素です)。
手動で位置を設定せずに、ロード後にボックス(または他のモデル)の元の位置を取得するのを手伝ってくれませんか?
ありがとう!