对于three.js:12917
,错误为Uncaught TypeError: Cannot read property 'opacity' of undefined
我使用的场景文件是:
{
"metadata": {
"version": 4.3,
"type": "Object",
"generator": "ObjectExporter"
},
"geometries": [
{
"uuid": "7F5BC6A2-4B74-4049-8AF8-40A5EF310430",
"type": "CubeGeometry",
"width": 100,
"height": 100,
"depth": 100,
"widthSegments": 1,
"heightSegments": 1,
"depthSegments": 1
}],
"materials": [
{
"uuid": "95D0C78A-2066-4A8D-9F46-73B3038E55DE",
"type": "MeshBasicMaterial",
"color": 16777215,
"opacity": 1,
"transparent": false,
"wireframe": false
}],
"object": {
"uuid": "E0E0DAAE-012A-49DB-BC1B-2878BCA7F0DA",
"type": "Scene",
"matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
"children": [
{
"uuid": "E60D8291-4E35-4365-A98E-7AEA1D1D433F",
"name": "Cube 1",
"type": "Mesh",
"geometry": "7F5BC6A2-4B74-4049-8AF8-40A5EF310430",
"material": "95D0C78A-2066-4A8D-9F46-73B3038E55DE",
"matrix": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]
}]
}
}
我已经检查过,它确实加载成功并且是有效的JSON(JSONLint); 我还测试了JSONLoader以成功加载JSON模型。 我好像在使用the latest version。这个场景是在THREE.js编辑器中创建的,我担心我不知道如何在它外面创建一个场景。
答案 0 :(得分:3)
每https://github.com/mrdoob/three.js/issues/4259你应该使用ObjectLoader:
function loaded(scene) {
...
renderer.render(scene, camera)
}
new THREE.ObjectLoader().load("scene.js", loaded)
答案 1 :(得分:0)
显然问题在于编辑器创建的场景文件。 我刚试过通过three.js场景示例运行场景文件并得到了同样的错误。