【发布时间】:2018-05-23 12:05:11
【问题描述】:
我已经关注了一些关于 SO 的问题来解决这个问题,但我仍然无法加载外部对象(搅拌机)。
基本上我将它导出为 ThreeJS JSON 文件,这是我的 JSON 文件:
{
"textures":[],
"animations":[{
"fps":24,
"tracks":[],
"name":"default"
}],
"geometries":[{
"materials":[{
"colorEmissive":[0,0,0],
"DbgName":"Material.113",
"DbgIndex":0,
"shading":"phong",
"specularCoef":50,
"transparent":false,
"visible":true,
"blending":1,
"depthWrite":true,
"DbgColor":15658734,
"doubleSided":false,
"wireframe":false,
"colorSpecular":[0.5,0.5,0.5],
"opacity":1,
"depthTest":true,
"colorDiffuse":[0.0396404,0.0396404,0.0396404]
},{
"colorEmissive":[0,0,0],
"DbgName":"Material.112",
"DbgIndex":1,
"shading":"lambert",
"transparent":false,
"visible":true,
"blending":1,
"depthWrite":true,
"DbgColor":15597568,
"doubleSided":false,
"wireframe":false,
"opacity":1,
"depthTest":true,
"colorDiffuse":[0.8,0.443066,0.182712]
},{
"colorEmissive":[0,0,0],
"DbgName":"Material.114",
"DbgIndex":2,
"shading":"phong",
"specularCoef":50,
"transparent":false,
"visible":true,
"blending":1,
"depthWrite":true,
"DbgColor":60928,
"doubleSided":false,
"wireframe":false,
"colorSpecular":[0.5,0.5,0.5],
"opacity":1,
"depthTest":true,
"colorDiffuse":[0.8,0.614231,0.407028]
}],
"data":{
"uvs":[],
"normals":[-0,0,1,-1,-0,0,1,-0,-0,-0,-1,0,-1,4.76837e-07,0,-1,-0,0,-2.38419e-07,-1,2.38419e-07,-2.38419e-07,-1,2.38419e-07,-2.38419e-07,-1,2.38419e-07 },
"type":"Geometry",
"uuid":"639CD2C2-56FB-4D8F-B53B-B8C3E040803C",
"name":"Cube.111Geometry.4"
}],
"object":{
"children":[{
"name":"Cube.001",
"uuid":"1213E565-1F93-497F-B4F0-843C1F17BCAD",
"matrix":[-0.6,0,0,0,0,0,0.6,0,0,0.6,0,0,-0.866864,0.6,2.6259,1],
"visible":true,
"type":"Mesh",
"material":["87C3E87D-CD72-4A6F-963A-84474DFE4059","FABD8A0F-02B0-4665-A21E-5CD1E4DDD518","E4331AC2-6CAC-4BCE-A5BD-89A811DD4D76"],
"castShadow":true,
"receiveShadow":true,
"geometry":"639CD2C2-56FB-4D8F-B53B-B8C3E040803C"
}],
"matrix":[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
"type":"Scene",
"uuid":"23736546-1486-4089-967C-6DA05CB3F49C"
},
"materials":[{
"vertexColors":0,
"color":13398062,
"uuid":"FABD8A0F-02B0-4665-A21E-5CD1E4DDD518",
"depthWrite":true,
"depthTest":true,
"type":"MeshLambertMaterial",
"blending":1,
"emissive":0,
"name":"Material.112"
},{
"vertexColors":0,
"shininess":50,
"color":657930,
"uuid":"87C3E87D-CD72-4A6F-963A-84474DFE4059",
"specular":8355711,
"depthWrite":true,
"depthTest":true,
"type":"MeshPhongMaterial",
"blending":1,
"emissive":0,
"name":"Material.113"
},{
"vertexColors":0,
"shininess":50,
"color":13409383,
"uuid":"E4331AC2-6CAC-4BCE-A5BD-89A811DD4D76",
"specular":8355711,
"depthWrite":true,
"depthTest":true,
"type":"MeshPhongMaterial",
"blending":1,
"emissive":0,
"name":"Material.114"
}],
"metadata":{
"generator":"io_three",
"sourceFile":"DAMA1.blend",
"version":4.4,
"type":"Object"
},
"images":[]
}
我省略了法线数组上的一些数据,但基本上我尝试像这样加载它:
var objLoader =new THREE.ObjectLoader();
objLoader.load('assets/dama.json', function (geometry) {
this.scene.add(geometry);
});
它找到了文件,但我收到这样的错误:无法读取未定义的属性“场景”
也许它与导出的设置有关,但我已经将缓冲几何更改为几何并添加了场景复选框,我做错了什么?:S
【问题讨论】:
标签: javascript json three.js blender