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 ?
Three. js uses the WebGL engine in the browser for rendering scenes. The API is based on OpenGL (GL stands for graphics library), a desktop graphics API.
js. Three. js is a cross-browser JavaScript library and application programming interface (API) used to create and display animated 3D computer graphics in a web browser using WebGL.
WebGL: is the Javascript API that allows you to create 3D graphics in the browser. Three. js: A framework build on top of WebGL which makes it easier to create 3D graphics in the browser, it uses a canvas + WebGL to display the 3D scene.
If you use Three. js, you don't need to know how to program in WebGL, you just need to understand the WebGL concepts. That means, that you just need to be able to read someone else's WebGL code and understand what you read. That is a lot easier than being expected to write a WebGL program yourself from scratch.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With