1

你有没有遇到过这个错误:"uncaught syntaxError unexpected token"

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

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

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

谢谢问候克里斯

4

2 回答 2

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
},

...
},
...
于 2012-12-13T21:51:19.317 回答
1

我通过省略加载函数的 JSON 签名来完成这项工作。像这样:

loader = new THREE.JSONLoader();

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

希望这有助于问候

于 2012-10-16T07:58:36.147 回答