Blender导出器 - “未捕获的syntaxError意外令牌”THREE.JSONLoader()

时间:2012-09-12 18:27:02

标签: three.js

您是否遇到过这个错误:"uncaught syntaxError unexpected token"

加载从Blender 2.63a导出的模型和三个导出器插件?

从这个代码复制自three.js github示例

var loader = new THREE.JSONLoader();
loader.load( {"buffalo.js", function(geo){createModel(geo)}});

由于 问候 克里斯

2 个答案:

答案 0 :(得分:3)

检查模型是否有材料。在buffalo.s中搜索字符串:"material" : ,。如果找到该字符串,则表示您的模型未分配材料 - 出现错误的语法错误!转到搅拌机,分配材料,然后再次导出到buffalo.js

不工作:

...
"objects" :
{
"Monkey" : {
    "geometry"  : "geo_Monkey",
    "groups"    : [  ],
    "material"  : ,
    "position"  : [ -0.150241, 5.41906, 2.96394 ],
    "rotation"  : [ 0.874236, 0.0220203, -3.11527 ],
    "quaternion": [ 0.00726118, 0.0155444, -0.423137, -0.905903 ],
    "scale"     : [ 2.9257, 2.86503, 2.68207 ],
    "visible"       : true,
    "castShadow"    : false,
    "receiveShadow" : false,
    "doubleSided"   : false
},

...
},
...

工作:

...
"objects" :
{
"Monkey" : {
    "geometry"  : "geo_Monkey",
    "groups"    : [  ],
    "material"  : "Material",
    "position"  : [ -0.150241, 5.41906, 2.96394 ],
    "rotation"  : [ 0.874236, 0.0220203, -3.11527 ],
    "quaternion": [ 0.00726118, 0.0155444, -0.423137, -0.905903 ],
    "scale"     : [ 2.9257, 2.86503, 2.68207 ],
    "visible"       : true,
    "castShadow"    : false,
    "receiveShadow" : false,
    "doubleSided"   : false
},

...
},
...

答案 1 :(得分:1)

我通过省略加载函数的JSON签名来实现这一点。像这样:

loader = new THREE.JSONLoader();

    loader.load( 'buffalo.js',function( geo )
    {
....

希望这会有所帮助 此致