I am trying to write ThreeJS wrapper for Elm, and I am looking into WebGL Elm implementation.
As I understand it does’nt use Elm ports, but just using direct JS calls/hacks?
Can you help me to understand please?
WebGL sourcecode that I am looking:
https://github.com/elm-community/elm-webgl/blob/3.0.4/src/WebGL.elm
https://github.com/elm-community/elm-webgl/blob/3.0.4/src/Native/WebGL.js
The current branch with examples is here:
webgl - examples
and the elm docs are here: webgl
Elm uses a GLSL parser to parse the GLSL code for the fragment and vertex shaders - so you get compile time warnings.
When you say you’re trying to write a ThreeJS wrapper, do you mean like a web component? Or how do you plan on wrapping ThreeJS?
I am thinking to make it same way as WebGL lib make it, that’s why I want to understand how it works in JS context.
Ah, the WebGL module is a kernel module which means it can access kernel code. In this specific case that means it can access JS code. Kernel modules are reserved for the core team of Elm, more or less.
If you want to wrap a JS package for use in Elm, the advised way is typically to turn it into a web component, which Elm can then use.
I was also thinking of having some way of combining three.js with Elm. But I believe neither a web component nor a truthful 1:1 reimplementation without ports would be of any help.
I think, if you want to use three.js, this needs to happen in the JS world. I would try to understand what three.js really brings to the table and how it can be combined with Elms webgl package.
ThreeJS is kinda CRUD 3D scene library, so I think making diff to 3D scene model from Elm is enough for wrapper implementation.
You might find this tutorial helpful: using-web-components it uses the three.js library to implement a 3d scene. (also elm-land is awesome)
Thanks everyone, I see cube from Elm json sent to ThreeJS implemented by Custom Component.
Source code:
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.