phil1234 Posted October 5, 2015 Share Posted October 5, 2015 Hi everyone, I just cant see why my code does not work It seems the task I defined does not seem to be runningno 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 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 5, 2015 Share Posted October 5, 2015 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)); Quote Link to comment Share on other sites More sharing options...
iiceman Posted October 5, 2015 Share Posted October 5, 2015 Hmm, might be a stupid question, but are you calling "assetsManager.load()" somewhere? I think that is needed to make it start processing the defined tasks. Since that line is a bit hidden in the documentation, I thought I better ask GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Temechon Posted October 5, 2015 Share Posted October 5, 2015 Yes, the load method is missing assetManager.load(); Quote Link to comment Share on other sites More sharing options...
phil1234 Posted October 6, 2015 Author Share Posted October 6, 2015 yep, figured it out, actualy in the tutorial, it was a bit "hidden" as I read it too fastthanks everyone :-) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.