Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I need some code to load file .obj in webgl can you help me ? if you finish , please sending me (.html,.javascript) email :trungle1988@gmail.com thank you very much |
||||
|
You can import any .obj file in copperCube (download here: http://www.ambiera.com/coppercube/download.html) and then create a copperlicht webgl from it. No need to code anyhting. |
||||
|
I cannot initialize the renderer. The code is very simple, listed below. When executed it reports that webgl isn't supported (because renderer cannot be initialized). But webgl is enabled and works, I can run any webgl demo including those from CopperLicht tutorials. I tried both Chrome (nightly) and Minefield, to no avail. I'm using CopperLicht 1.2.0, which is a single JavaScript file. Am I doing something wrong? Is something wrong with that version of CopperLight? JavaScript file "panorama.js": function main() { // create the 3d engine var engine = new CopperLicht ("display"); if (!engine.initRenderer()) { alert ("Your browser doesn't support WebGL."); return; } } main(); HTML file "panorama.html": <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <script type="text/javascript" src="copperlicht.js"></script> <script type="text/javascript" src="panorama.js"></script> </head> <body> <div style="width:640px; margin:auto; position:relative; font-size: 9pt; color: 777777;"> <canvas id="display" width="640" height="480" style="background-color:000000"> </canvas> </div> </body> </html> |
||||
|
That's actually a problem in your code: The main() is called before the canvas was created, that's why CopperLicht then cannot find an element with the id 'display'. Simply do it this way: 1) In the panorama.js, remove the main() call at the end. 2) In the html file, under the </canvas> add the following: <script>main();</script> Should work then. Note: From the name, it looks like you used a panorama scene in CopperCube. Use a Free3D scene instead, panoramas are not yes supported in WebGL. |
||||
|
Thank you very much!! It works now! I'm not a new programmer, but I'm new in JavaScript. At least that's my poor excuse. I'm trying to create a 360 panorama view, which seems to me like a good use for a skybox. Thanks again for helping me. |
||||
|
|