three.js - Using library extensions with TypeScript + requirejs -
i'm messing around three.js , socket.io make little game - i'm wanting use orbitcontrols extension three.js (i've used before in non-ts project) camera controls.
the problem client can't seem find (it compiles fine):
uncaught typeerror: undefined not function
at line:
this.cameracontrols = new three.orbitcontrols(this.camera, this.renderer.domelement);
i'm including in ts file using:
///<reference path="../typings/threejs/three-orbitcontrols.d.ts"/> import orbitcontrols = require("three-orbitcontrols");
at bottom of three-orbitcontrols.d.ts file have usual export seem need @ bottom of typing files:
declare module 'three-orbitcontrols' { export=three.orbitcontrols; }
but i'm not sure if right format, i've tried few things directing requirejs right file in config (since filename bit different):
paths: { "three-orbitcontrols": "three.orbitcontrols" }
interestingly, after compiling gulp (using amd), three-orbitcontrols not appear in require @ top of resulting .js file.
my question is: how include 'extension' library library have ts , requirejs? there form of merge need do? need manually merge d.ts , js files? (i hope not!)
thanks!
how include 'extension' library library have ts , requirejs?
since calling three.
here : new three.orbitcontrols
. need put import orbitcontrols = require("three-orbitcontrols");
on three
so:
import orbitcontrols = require("three-orbitcontrols"); three.orbitcontrols = orbitcontrols;
note: there isn't idiomatic way of doing since there isn't idiomatic way javascript libraries this. solution here specific use case , extension.
Comments
Post a Comment