Carharttguy Posted June 23, 2017 Share Posted June 23, 2017 Hello I use PHPStorm or Webstorm for most projects I do (mostly PHP). I want to try BabylonJS in combination with that software. I follow the tutorial, put an index.html and babylon.2.5.js in the same folder, reference it in a script tag, working like a charm. PHPstorm hints to classes and functions, very cool. But when I want to fill in parameters, I see this: It's something, but not very much. I suspect this is because the babylon.2.5.js file is transpiled from TypeScript. I figured I want to work in TypeScript because that language is nicer imho than Javascript. So again, followed the tutorial. added the d.ts file to my PHPstorm project. That doesn't work at all because PHPStorm cannot find any reference to the BABYLON namespace. So I tried something else, added babylonjs as an external library (apperently someone made that for PHPStorm) but the effect is the same. Is anybody working here with PHPStorm (or webstorm) + TS + BabylonJS and willing to get me started? Thanks! Quote Link to comment Share on other sites More sharing options...
TomaszFurca Posted June 23, 2017 Share Posted June 23, 2017 I use PHPStorm. Just add in the beginning of the TS file /// <reference path="../../babylon/babylon.d.ts"/> Quote Link to comment Share on other sites More sharing options...
Carharttguy Posted June 23, 2017 Author Share Posted June 23, 2017 Thanks TomaszFurca. Simple yet amazing answer. This works like a charm! One small totally unrelated question. When I copy the code from doc.babylonjs.com I get this error: HTMLElement' is not assignable to type 'HTMLCanvasElement'. Property 'height' is missing in type 'HTMLElement. On this line: this._canvas = document.getElementById(canvasElement); Thanks for helping! Quote Link to comment Share on other sites More sharing options...
Jaskar Posted June 23, 2017 Share Posted June 23, 2017 @Carharttguy Hey, It's a typescript type "problem". "document.getElementById" return "HTMLElement" type, and "this._canvas" is "HTMLCanvasElement". For comparison, t's like trying to assign a float to an int. Try to cast it : this._canvas = <HTMLCanvasElement> document.getElementById(canvasElement); Quote Link to comment Share on other sites More sharing options...
Carharttguy Posted June 23, 2017 Author Share Posted June 23, 2017 Awsome, that worked indeed. Now is the time for me to dive in Typescript. Thanks for pointing me in the right direction guys. Very fast and friendly community! To whoever is making the docs: It could be a good idea to check the beginners tutorial, there is this typecasting error + the wrong version of BJS in the html script tag (2.3 instead of 2.5) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.