-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Very crude compatibility with Three.js r110+ and ES6 #39
base: gh-pages
Are you sure you want to change the base?
Conversation
You edited the |
Sorry for the delayed review, and thanks for this effort. arcanis is correct - for this PR to merge, the files in the Beyond that, I agree that it would be preferable to convert this library to ESM style rather than add to the |
I will do that (the files are just concat together one by one right? I don't normally use this kind of javascript build system). I did attempt to convert this into an ESM style model but I haven't been successful by doing basic modifications (I didn't want to change too much of the original code, but it seems like that is necessary to fully convert the module). I will continue to experiment with that. Thanks for your review |
Update: I managed to get a working ESM style module going, but I don't think it is possible to split it up into that many different files (Terrain is now a class). |
Yeah, the build process concats files and then minifies them. I haven't touched how that works since 2015. In this case, the only symbol that would get exported is the Terrain constructor, and everything else gets added as a property on that constructor. So if all the other files get concatenated after core.js, and an |
I have added the code to the .mjs files in src. I'm not sure how to compile them, so I'll leave that to you (or you can let me know what to put in the config). Order is: |
Adds compatibility for up-to-date THREE.js and ES6 web standards (Javascript modules mostly).
Big disclaimer: this is a really stupid way to get compatibility without editing the code much, and it requires additional setup before you can use it!
Note: I only edited the output file (the non-min one), not any src files
See #38 for details on what was changed.
If you are going to use this, two changes are necessary:
window.THREE
toTHREE
(imported from an es6 module). See example belowTHREE.Terrain
, usewindow.THREETerrain
initThree.js
HTML
Make sure you have an import map set up first
Then load your scripts
For a demo on how to use this, please see my game, https://github.com/oliver408i/missilesim
Additional technical notes: THREE.Math functions were changed to their identical THREE.MathUtils ones