当我创建一个 JSON 模型并使用 THREE.JSONLoader.load 加载它时,它会毫无问题地加载,但是当我尝试从中创建一个变量并将数据包含在主脚本中时,THREE.JSONLoader.parse 调用会引发异常.
var lh_model = {
"metadata" : { "formatVersion" : 3.1, ..., "morphTargets" : 0 },
"vertices": [
0.001000, 0.001000, -0.001000,
102.616974, -61.974983, 19.303007,
102.108978, -62.482986, -7.620989,
123.952972, -49.274994, -3.048992,
123.952972, -48.766994, 14.223002
],
"uvs": [0.9458,0.5134,0.9419,0.5177,0.9513,0.5177,........],
"faces": [ 0, 4, 1, 2 ],
"morphTargets": []
}
var loader = new THREE.JSONLoader();
var geometry = loader.parse(lh_model);
load.parse 导致
Uncaught TypeError: Cannot read property 'length' of undefined
Three.js 深处某处的错误:
THREE.Mesh.prototype.updateMorphTargets = function () {
if ( this.geometry.morphTargets.length > 0 ) {
当我采用其他人制作的工作示例(http://stemkoski.github.io/Three.js/Model.html)时,也会发生同样的情况。
我正在使用 Three.js r.58