MostafaMV MostafaMV - 8 months ago 79
Python Question

three.js to webGL to OpenGL

I want to take a three.js code and possibly convert it to a webGL or preferably OpenGL code so that I can use it in a stand-alone program that I'm developing in Python. Is there any straightforward way of doing that ?


As far as I know there isn't any easy way.

Though if you know OpenGL, where "knowing" is when you can do pretty much any task, from rendering a huge amount of vertices to performing texturing, lighting and shadow mapping, etc.

Then you could simply go to any Three.js og WebGL application.

Here is a Three.js application as an example.

Then you can just view-source of the Three.js/WebGL script. Where you automatically can make sense of most of it. Like.

var geometry = new THREE.CubeGeometry(100, 200, 300);

We can easily assume the above code would create a 3D Cube where (100, 200, 300) = (width, height, length). Now we know that we need to create a new VAO and/or VBO which we would calculate the vertices, and as we can see in the example the cube is textured, so we know that we need to store both vertices and texture coordinates within the buffer.

Basically you could read through everything like that. Here are some more examples.

renderer.setSize(window.innerWidth, window.innerHeight);

That would of course set the size of the display.

Also Three.js is just a JavaScript library build on top of WebGL.