Jump to content

noob cant make it work - assetmanager


phil1234
 Share

Recommended Posts

Hi everyone,

 

I just cant see why my code does not work

 

It seems the task I defined does not seem to be running

no error, nothing

 

   this.canvas = document.getElementById('renderCanvas');    this.engine = new BABYLON.Engine(this.canvas, true);    this.scene = this.CreateScene();        this.engine.runRenderLoop((function(){        this.scene.render();    }).bind(this));        $(window).on('resize',(function(){        this.engine.resize();    }).bind(this));

 

System.prototype.CreateScene = function(){    // create a basic BJS Scene object    var scene = new BABYLON.Scene(this.engine);    // create a FreeCamera, and set its position to (x:0, y:5, z:-10)    var camera = new BABYLON.FreeCamera('camera1', new BABYLON.Vector3(0, 5,-10), scene);    // target the camera to scene origin    camera.setTarget(BABYLON.Vector3.Zero());    // attach the camera to the canvas    camera.attachControl(this.canvas, false);    // create a basic light, aiming 0,1,0 - meaning, to the sky    var light = new BABYLON.HemisphericLight('light1', new BABYLON.Vector3(0,1,0), scene);     var assetsManager = new BABYLON.AssetsManager(scene);    var meshTask = assetsManager.addMeshTask("loading task1", "", "./data/", "blender.babylon");    meshTask.onSuccess = function (task) {        task.loadedMeshes[0].position = new BABYLON.Vector3(0, 0, 0);    };     assetsManager.onFinish = function (tasks) {        this.engine.runRenderLoop(function () {            scene.render();        });    };   return scene;}; 

 

any idea what I could be doing wrong

 

thanks

Link to comment
Share on other sites

Hello,

 

it seems to me that you should not render the scene returned by your function as you also ask to render it when the mesh is loaded:

  this.canvas = document.getElementById('renderCanvas');    this.engine = new BABYLON.Engine(this.canvas, true);    this.CreateScene();            $(window).on('resize',(function(){        this.engine.resize();    }).bind(this));
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...