Search the Community
Showing results for tags 'BABYLON.SceneLoader.ImportMes'.
-
ok I am trying to create a loop using javascript for function in order to import the same mesh multiple times but with different XYZ coordinates. The outcome of my code below shows only one instance of the mesh. What am i doing wrong ? Here is the code: <body> <canvas id="renderCanvas"></canvas> <script> window.addEventListener('DOMContentLoaded', function(){ // get the canvas DOM element var canvas = document.getElementById('renderCanvas'); // load the 3D engine var engine = new BABYLON.Engine(canvas, true); var createScene = function () { var scene = new BABYLON.Scene(engine); //Adding a light var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 20, 100), scene); //Adding an Arc Rotate Camera var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0.8, 100, BABYLON.Vector3.Zero(), scene); camera.attachControl(canvas, false); for (i=0; i<5; i++) { BABYLON.SceneLoader.ImportMesh("", "", "pantene_low.babylon", scene, function (newMeshes) { // Set the target of the camera to the first imported mesh if(i==4) { camera.target = newMeshes[0]; } newMeshes[0].position.x = i+10; }); } // Move the light with the camera scene.registerBeforeRender(function () { light.position = camera.position; }); return scene; } // call the createScene function var scene = createScene(); // run the render loop engine.runRenderLoop(function(){ scene.render(); }); // the canvas/window resize event handler window.addEventListener('resize', function(){ engine.resize(); }); }); </script> </body>