I'm struggling to get this code up and running due to some issues with function scopes.
Here is the current state of my code:
var Canoe = function () {
this.mesh = new THREE.Object3D();
var loader = new THREE.JSONLoader();
loader.load( 'models/canoe.json', function ( geometry, materials ) {
var canoeMesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial( materials ));
canoeMesh.castShadow = true;
canoeMesh.receiveShadow = true;
this.mesh.add(canoeMesh);
});
}
This is the error message I keep encountering:
Cannot read property 'add' of undefined
Is there a way for me to properly assign the inner function's created mesh
to the outer variable?