A 3D Wavefront obj file viewer for HTML5 written in JavaScript
|
|
12 ani în urmă | |
|---|---|---|
| obj | 12 ani în urmă | |
| script | 12 ani în urmă | |
| LICENSE | 12 ani în urmă | |
| README.md | 12 ani în urmă | |
| index.html | 12 ani în urmă |
Just include the ObJS.js in your project, create a ObJS object, and initalize its canvas.
myObJS = new ObJS();
myObJS.initCanvas(canvas);
Where
Then you can load any obj model by calling
myObJS.load(file);
Where
If you want to clear the canvas, just call
myObJS.clear();
Note that the canvas is automatically cleared when a new object is loaded.
The model can be rotated and zoomed in and out with the mouse, but it can also be done programmatically.
To rotate the object, just call
myObJS.rotateX(ang); //Rotate along the X edge
myObJS.rotateY(ang); //Rotate along the Y edge
Where
To zoom in or out the object, call the method
myObJS.zoom("+"); //Zoom in
myObJS.zoom("-"); //Zoom out
You can change parameters such as the elements to draw, their color, transparency, rotation speed, zoom speed... in the script, but much of them can be changed on runtime, so you can use controls.
drawElement(keyword, on);
Where
colorElement(keyword, color);
Where
setAlpha(percent);
Where