for playing around with some web gl rendering i started playing with threeJS a few years ago, but now i will dive a little bit deeper.
So here are my angular template project which i want to share with all of you who also want to play something around with or maybe to built a real app from with it:
I’d like to mention a caveat when working with angular.
It uses zone.js as it’s change detection strategy. This means that zone.js hooks onto requestAnimateFrame, and runs angular’s change detection on each tick.
This is very expensive and you will notice a big performance degradation.
What you need to do is to create a new file in the src folder called ngzone-flags.ts
which you import at the top of your polyfills.ts file.
in this file you should have this:
(window as any).__Zone_disable_requestAnimationFrame = true;
(window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove', 'touchmove'];
This will tell zone.js to not hook these events.
To check if it worked you can use the performance panel in chrome and run in for a while, to then check the callstack for each request animate frame.
There should be no call to zone.js in there.
Hope this helps as it took me a while to realize why my threejs apps where running so slow in angular
Ps.
It could potentially break other angular libraries that are dependant on these events, so keep that in mind.
Unfortunately I already did try the three-full npm package and I didn’t get the expected results… Could you explain to me: How would you import the LensFlareElement Class from a (working) Module with the three-full package?
Sorry for my dull questions but I am relatively new to angular and just to mention that I don’t have any clue about webpack, systemjs and what they all are called. I don’t even know how relevant that should be for a beginner. As far as my concern goes, managing to import unsupported modules shouldn’t be a worry at all
Whereas on the Milestone Page the progressbar indicates 42% complete. So i don’t think that there will be an easy solution in near time for using example based classes, even with third-party libraries or templates.
Anyway I’ll just leave this as a review for the angular template (non-ionic version) and thank you for your time.
What about integration with Physijs? I’ve tried this module everything works fine except for the ammo.js part where I’m getting “something is not a constructor” error
Three 0.111.0 is actually not compatible with TypeScript ~3.5.3 which is the latest Angular Dependency, so if you do a fresh install of my template you have to stay with max version 0.110.0.
Thats the last version i can compile without any errors.
We have to wait until Angular update the TypeScript dependency or try it yourself.
…and as a side note: Install @types/webgl2 and add it to the tsconfig.app.json. In my actual template version i’ve done this already. (see also here: Cannot find name 'WebGL2RenderingContext')
Hey, im having angular 8.2.14. I updated typescript to 3.7.4 and included the disableTypeScriptVersionCheck in my tsconfig.json (I dont have a tsconfig.lib.ts?) and added the 2 lines of code to my polyfills. Tho its not working! What am I doing wrong? I really need that to work soon. : (
ERROR in The Angular Compiler requires TypeScript >=3.4.0 and <3.6.0 but 3.7.4 was found instead.
You could try the 9-rc8 with the options described in the issue or just downgrade your typescript version together with the Three.js Version to the latest working described in my post above.
There is no reply to this but can I assume that this is now dealt with by “this.ngZone.runOutsideAngular” in the animate() method?
This was pushed shortly after your comment, on 29th Jan 2019:
Am I correct in thinking that the ngDestroy needs to be called to ensure disposal of previous scenes (causing accelerated/faster and faster spinning)?
I have added buttons on this StackBlitz to simulate what happens (in my app it gets triggered in other more intricate reloading events): https://angular-three-template.stackblitz.io/
For example, at the start of the animate() function seems a good place to call it…