Currently, I am experimenting with THREE.js and socket.io to develop a small game. I am looking to utilize the OrbitControls extension for THREE.js for camera controls, which I have successfully used in a previous project.
However, it seems that the client is having trouble finding it (even though it compiles without errors):
Uncaught TypeError: undefined is not a function
Specifically, the error occurs at this line:
this.cameraControls = new THREE.OrbitControls(this.camera, this.renderer.domElement);
In my TS file, I am importing it like this:
///<reference path="../typings/threejs/three-orbitcontrols.d.ts"/>
import OrbitControls = require("three-orbitcontrols");
At the end of my three-orbitcontrols.d.ts file, I have the usual export statement that is commonly found at the end of some typing files:
declare module 'three-orbitcontrols' {
export=THREE.OrbitControls;
}
However, I am not sure if this is the correct format. I have attempted various approaches, such as configuring requirejs to point to the correct file (as the filename is slightly different):
paths: {
"three-orbitcontrols": "three.orbitcontrols"
}
Interestingly, after compiling with Gulp (using AMD), the three-orbitcontrols does not show up in the require statement at the top of the resulting .js file.
My main question is: What is the proper way to include an 'extension' library for a library you already have using TS and requirejs? Do I need to perform some sort of merging process? Should I manually merge the d.ts and js files together? (I hope that is not the case!)
Thank you!