Skip to content
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

ThreeJS integration #2452

Open
Modcat opened this issue Jan 1, 2021 · 10 comments
Open

ThreeJS integration #2452

Modcat opened this issue Jan 1, 2021 · 10 comments

Comments

@Modcat
Copy link

Modcat commented Jan 1, 2021

It's very unclear if away3D currently has the modern capabilities and is based on a very old library. I would like to see a more up to date library like THREE JS which has already had a conversion kit but with some simple tutorials on integration. All the docs have been written as everything would already have been done and I don't mind writing docs on this. It would be nice if HAXE could transpile THREE into an openFL project and have some basic examples of usage taking out all the heavy lifting. I know there is HAXE THREE but this only exports to HTML5, we need native and the best performance possible.

@TerryCavanagh
Copy link

Just randomly coming across this and, whoa, is this actually possible? You could make a native version of THREE? How would it work? Surely this is a huge undertaking?

@Dimensionscape
Copy link
Member

Dimensionscape commented Jan 2, 2021

It would be nice if HAXE could transpile THREE into an openFL project and have some basic examples of usage taking out all the heavy lifting. I know there is HAXE THREE but this only exports to HTML5, we need native and the best performance possible.

It doesn't quite work like this. A port of three.js would need to be created and designed to work with openfl specifically. This sounds like a pretty big undertaking but kudo's to anyone that is interested in doing this. The advantage of porting away3D is that it was already designed to work with flash and stage3D.

@TerryCavanagh
Copy link

Yeah, that's what I figured - I was wondering if I'd missed out on some fancy new Haxe trickery, haha

@Modcat
Copy link
Author

Modcat commented Jan 2, 2021

@TerryCavanagh @Dimensionscape there is something out there already that converts it: https://lib.haxe.org/p/threejs/73.0.2/ however I wanted fully native and not just a JS export for the thing :-)

@Dimensionscape
Copy link
Member

Dimensionscape commented Jan 2, 2021

@TerryCavanagh @Dimensionscape there is something out there already that converts it: https://lib.haxe.org/p/threejs/73.0.2/ however I wanted fully native and not just a JS export for the thing :-)

This creates externs to the actual three.js library, it doesnt convert anything. This is why it doesn't run on native. We can't use an external js library on native.... it just doesn't work like that, for the exact same reason you cant just take a js library and expect it to compile with Cpp. We can use external js libraries when targeting js, because the output from the haxe compiler is js. This is true for every compilation target.

It needs to be A. Ported to pure haxe or B. Ported to cpp and then externs for the cpp port need to be written, and then integration for openfl's display list/ rendering.

The difference here is that Away3D(originally a flash library) was ported completely to haxe and works on all targets since it does not rely on target specific externs. The even bigger difference is that Away3D was designed to work with flash/stage3D so it's port was very straightforward almost verbatim.

ThreeJs would be even more difficult because it is not designed to work with openfl/flash to begin with.

@Modcat
Copy link
Author

Modcat commented Jan 2, 2021

Ah I see, I just think if someone put the time and effort into one really good HAXE 3D library instead of all the fragmented organisations with their own libraries openFL, Heaps and more and just took one good library and made it happen in HAXE. That would be the most amazing prospect! Also would probably get heavy funding from open fund raising.

@Dimensionscape
Copy link
Member

These technologies are fundamentally different and serve to fulfill different purposes. It would be nice to have a better 3D engine for openfl though. 😄

@jgranick
Copy link
Member

jgranick commented Jan 2, 2021

Yes, ThreeJS could be ported from JavaScript to Haxe. This could actually improve the performance of the library, as I've seen in the past porting JavaScript code to Haxe (then compiling to JavaScript again).

Doing this over the top of Lime would probably not be too difficult of a port (as Lime supports WebGL already)

The problem primarily would be the ongoing maintenance so that it does not become an old version of ThreeJS no one wants to use. It would require someone motivated to keep it going?

@vujadin
Copy link

vujadin commented Jan 2, 2021

I've tried that with https://github.com/vujadin/BabylonHx. At some point one man alone just can't keep up with the dev of the js lib.
Three.js and Babylon.js are updated daily and by many people.

@Modcat
Copy link
Author

Modcat commented Jan 2, 2021

Maybe worth mentioning that Babel should work in HAXE and change it from whatever it's core is. They look mostly feature complete but conversion to native and WASM / WebGPU would increase speed massively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants