When I create a JSON model and load it using THREE.JSONLoader.load, it loads without any problems, but when I try to make a variable out of it and include the data in the main THREE.JSONLoader script. a parse call throws an exception.
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 calls
Uncaught TypeError: Cannot read property 'length' of undefined
the error is somewhere deep inside Three.js:
THREE.Mesh.prototype.updateMorphTargets = function () { if ( this.geometry.morphTargets.length > 0 ) {
The same thing happens when I take working examples made by other people ( http://stemkoski.imtqy.com/Three.js/Model.html ).
I am using Three.js r.58