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