≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
Adding multiple CubeSceneNodes [Cubes] to Canvas?
Posted by:
(you are not logged in)
Enter the missing letter in: "Internationa?"
(you are not logged in)
Text:
[quote][b][/b] wrote: [code] <script type="text/javascript"> function CopperlichtStart() { // Skapa 3D-motorn //var engine = new CL3D.CopperLicht('glcanvas'); var engine = new CL3D.CopperLicht('glcanvas', true, 60, true); var arr = new Array(); if (!engine.initRenderer()) return; // this browser doesn't support WebGL // Create a 3D scene and add it to the 3D engine scene = new CL3D.Scene(); engine.addScene(scene); // Set the scene background color scene.setBackgroundColor(CL3D.createColor(1, 0, 0, 0)); //scene.setRedrawMode(CL3D.Scene.REDRAW_WHEN_SCENE_CHANGED); // also, force the 3d engine to update the scene every frame scene.setRedrawMode(CL3D.Scene.REDRAW_EVERY_FRAME); for(var l=0; l<=10; l++) { for (var j=-10;j<=10;j+=3) { arr[l] = new CL3D.CubeSceneNode(); scene.getRootSceneNode().addChild(arr[l]); arr[l].getMaterial(0).Tex1 = engine.getTextureManager().getTexture("resources/crate.gif", true); arr[l].addAnimator(new CL3D.AnimatorRotation(new CL3D.Vect3d(0.0, 0.15, -0.15))); arr[l].Pos.X=j; arr[l].Pos.Y=j+3; arr[l].Pos.Z=0; } } //Create a camera and add it to the scene graph var cam = new CL3D.CameraSceneNode(); // Position cam.Pos.X = 0; cam.Pos.Y = 0; cam.Pos.Z = -80; // Width-to-height ratio or Aspect Ratio var canvas = document.getElementById("glcanvas"); var AR = canvas.width / canvas.height; cam.setAspectRatio(AR); // Field of View cam.setFov(45); scene.getRootSceneNode().addChild(cam); scene.setActiveCamera(cam); // Creating the shaders gives the box its surface. var vshaderScript = document.getElementById("vshader"); var fshaderScript = document.getElementById("fshader"); var newMaterialType = engine.getRenderer().createMaterialType(vshaderScript.text, fshaderScript.text); if (newMaterialType != -1) for(var l=0; l<=10;l++) arr[l].getMaterial(0).Type = newMaterialType; else //Exact error message from shader code is written on the website of Copper Licht alert('Can't Create Shaders'); } </script> </head> [/code] [img]http://img542.imageshack.us/img542/4734/capturessg.png[/img] @niko, I could cubes like below image on the canvas which are added to my scene, but unfortunately I couldn't see all of them. I think I'm doing some mistake with positions. please help me. I can see the cubes rendering in this way, but i want them to distribute on the whole canvas, moreover Is FPS depends on the camera positions as well? because when cam.Pos.Z = 20 FPS dropped to 10 t0 12 in between, where cam.Pos.z= -80; it still manages to reach 60. I want the cubes to look like in this way: [img]http://img51.imageshack.us/img51/3602/capturekpd.png[/img][/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact