1

错误Uncaught TypeError: Cannot read property 'opacity' of undefined在三个.js:12917

我正在使用的场景文件是:

{
"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 模型。我似乎使用的是最新版本。场景是在 THREE.js 编辑器中创建的,恐怕我不知道如何在它之外创建场景。

4

2 回答 2

3

根据https://github.com/mrdoob/three.js/issues/4259,您应该使用 ObjectLoader:

 function loaded(scene) {
    ...
    renderer.render(scene, camera)
 }

 new THREE.ObjectLoader().load("scene.js", loaded)
于 2014-01-06T08:34:10.673 回答
0

显然问题出在编辑器创建的场景文件上。我刚刚尝试通过 three.js 场景示例运行场景文件并得到相同的错误。

于 2013-11-04T20:56:31.813 回答