Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
160
rated 0 times [  163] [ 3]  / answers: 1 / hits: 17811  / 11 Years ago, fri, october 18, 2013, 12:00:00

I'm not able to get this example of using the aforementioned combo going in TypeScript.



I have <script src=lib/three.min.js></script> and <script src=lib/OrbitControls.js></script> in my html <head> and the typescript file in <body>:



/// <reference path=libthree.d.ts />
...
this.controls = new THREE.OrbitControls(this.camera); //there's the error
this.controls.addEventListener('change', this.render);
...


and



this.controls.update();


in periodically called render() function. For all I know, the setup is identical to the expample, but gives me a huge error (abbreviated) on compilation of the OrbitControls constructor line:



The property 'OrbitControls' does not exist on value of type '{REVISION:string;   
CullFace: {[x: number ...


I guess there's whole Threejs in that error, since Visual Studio crashes the moment I click on it :). Thanks for your help.


More From » html

 Answers
14

Feeling kind of silly since the solution (or workaround at least) turns out to be quite simple...



Just declare the OrbitControls variable:



declare var THREE.OrbitControls: any; // even declare var THREE.OrbitControls; will do the trick


There are still some compilation errors but it works.


[#74904] Thursday, October 17, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sandra

Total Points: 708
Total Questions: 100
Total Answers: 84

Location: Bosnia and Herzegovina
Member since Thu, Jun 24, 2021
3 Years ago
sandra questions
Tue, Jun 30, 20, 00:00, 4 Years ago
Sun, May 31, 20, 00:00, 4 Years ago
Wed, May 20, 20, 00:00, 4 Years ago
Fri, May 31, 19, 00:00, 5 Years ago
;