adobeSlash

Members
  • Content Count

    13
  • Joined

  • Last visited

About adobeSlash

  • Rank
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Understood ! this two lines : this.body.body.setQuaternion(this.rotationQuaternion); this.body.body.sleeping = false; was working good before switching from 2.3 to 2.4 now I have the following errors : Uncaught TypeError: Cannot read property 'setQuaternion' of undefined So I supposed it's came from the new physics rules... My body is instantiated like that : this.body = this.setPhysicsState(BABYLON.PhysicsEngine.BoxImpostor, {mass:1, friction:0.9});
  2. Everything is ok excepted this : Player.prototype._rotateTo = function(s) { // get mesh quaternion var mq = this.rotationQuaternion; var q = BABYLON.Quaternion.RotationAxis(BABYLON.Axis.Y, s); this.rotationQuaternion = q.multiply(mq); this.body.body.setQuaternion(this.rotationQuaternion); this.body.body.sleeping = false; }; was working before.. I'm loading my body like this : this.body = this.setPhysicsState(BABYLON.PhysicsEngine.BoxImpostor, {mass:1, friction:0.9}); If needed this is the complet code of this class : var Player = function (game) { GameObject.call(this, "player", game); var vertexData = BABYLON.VertexData.CreateSphere(16, 0.75, BABYLON.Mesh.DEFAULTSIDE); // Create the player box //var vertexData = BABYLON.VertexData.CreateBox(0.5, BABYLON.Mesh.DEFAULTSIDE); vertexData.applyToMesh(this); this.position.y = Player.START_HEIGHT; this.body = this.setPhysicsState(BABYLON.PhysicsEngine.BoxImpostor, {mass:1, friction:0.9}); var _this = this; this.getScene().registerBeforeRender(function() { if (_this.position.y < -10) { _this.game.reset(); } }); // Two boolean giving the direction (forward/backward) this.directions = [0,0]; // Two boolean giving the rotation (right/left) this.rotations = [0,0]; this.rotationQuaternion = new BABYLON.Quaternion(); var _this = this; this.getScene().registerBeforeRender(function() { // Move the player is possible _this.move(); //... // Reset the game if the player position is below 10 if (_this.position.y < -10) { _this.game.reset(); } }); window.addEventListener("keydown", function(e) { switch (e.keyCode) { case 39: // right _this.rotations[0] = 1; break; case 37: // left _this.rotations[1] = 1; break; case 38://bot: _this.directions[0] = 1; break; case 40://top: _this.directions[1] = 1; break; } }); window.addEventListener("keyup", function(e) { switch (e.keyCode) { case 39: // right case 37: // left _this.rotations = [0,0]; break; case 38://bot: case 40://top: _this.directions = [0,0]; break; } }); }; Player.START_HEIGHT = 5; // Our object is a GameObject Player.prototype = Object.create(GameObject.prototype); Player.prototype.constructor = Player; Player.prototype.move = function() { if (this.directions[0] != 0) { this._moveTo(-1); } if (this.directions[1] != 0) { this._moveTo(1); } if (this.rotations[0] != 0) { this._rotateTo(0.05); } if (this.rotations[1] != 0) { this._rotateTo(-0.05); } }; Player.prototype._moveTo = function(s) { // Compute the world matrix of the player this.computeWorldMatrix(); // Moving forward along the global z-axis var v = new BABYLON.Vector3(0,0,s); // Get the world matrix var m = this.getWorldMatrix(); // Transform the global vector into local vector var v2 = BABYLON.Vector3.TransformCoordinates(v, m); v2.subtractInPlace(this.position); v2.normalize().scaleInPlace(0.5); this.applyImpulse(v2, this.position); // Add this new vector to the player position //this.position.addInPlace(v2); }; Player.prototype._rotateTo = function(s) { // get mesh quaternion var mq = this.rotationQuaternion; var q = BABYLON.Quaternion.RotationAxis(BABYLON.Axis.Y, s); this.rotationQuaternion = q.multiply(mq); this.body.body.setQuaternion(this.rotationQuaternion); this.body.body.sleeping = false; }; Player.prototype.reset = function (pos) { //this.position = pos; //this.position.y = Player.START_HEIGHT; this.body.resetPosition(pos.x, Player.START_HEIGHT, pos.z); this.body.resetRotation(0,0,0); //this.body.body.linear this.rotations = [0,0]; this.directions = [0,0]; } The physics is initialized like that : scene.enablePhysics(new BABYLON.Vector3(0, -10, 0), new BABYLON.OimoJSPlugin());
  3. !!!!!!!!!! It works !! To help people understand which part of my code require PBMMaterial ? It's look like 2.4 use cannon.js for physics : BJS - [10:19:15]: CannonJS is not available. Please make sure you included the js file.
  4. If the url doesn't work here is a zip file with the source code and assets datageneration.zip
  5. You can check this out at : http://datageneration.apps.eu01.cf.canopy-cloud.com/ How can I check if the scene file is correctly loaded ?
  6. No nothing is loaded ... To be sure I use the scene debugger and my mesh doesn't appear in the MESHES TREE
  7. I need you experience. But I suppose that it's impossible to call console.log into a callback isn't ? So it can explain why i can't see my debug message...
  8. Thanks for your help ! Unfortunately i got the following error if I delete the manifest : babylon.2.3.js:2 GET http://datageneration.apps.eu01.cf.canopy-cloud.com/assets/scene/scene.babylon.manifest?1460015970229 404 (Not Found) I tried to use the Loader : // All models to load var toLoad = [ { name:"ground", folder:"assets/scene/", filename:"scene.babylon", anims : [] } ]; // Creates a loader var loader = new BABYLON.AssetsManager(this.scene); loader.loadingUIBackgroundColor = "#2c2b29"; var _this = this; // For each object to load toLoad.forEach(function(tl) { var task = loader.addMeshTask(tl.name, "", tl.folder, tl.filename); task.onSuccess = function(t) { // Set all mesh invisible t.loadedMeshes.forEach(function(mesh) { mesh.isVisible = false; }); // Save it in the asset array _this.assets[t.name] = {meshes:t.loadedMeshes, anims:tl.anims}; }; task.onTaskError = function (task) { console.error("error while loading " + task.name); } }); loader.onFinish = function () { console.log(_this.assets); // Init the game _this._initGame(); _this.engine.runRenderLoop(function () { _this.scene.render(); }); }; loader.load(); }; But if I print the content of _this.assets it still empty ...
  9. Sorry about that.. But... var Ground = function(x, z, game, scene) { console.log("Adding the ground"); BABYLON.SceneLoader.ImportMesh("", "assets/", "scene.babylon", scene, function (newMeshes) { console.log("I'm in"); this.mesh = newMeshes[0]; this.mesh.isVisible = true; this.mesh.shadows.getShadowMap().renderList.push(this.mesh); this.mesh.position = new BABYLON.Vector3(x, 0.75, z); this.mesh.receiveShadows = true; console.log("Ground added : " + this.mesh); }); console.log("scene info : " + scene); }; It's never printed : " I'm in ".... No error, nothing... so still not working
  10. Love you dude ! That's works now. My scene was undefined for some obscure reason.... but now it's ok ! Thank a lot for you time.
  11. It's not the same post. This one has been edited once more and I've made some changes in some code you'r pointing in your solution. But I don't know why there is two post.. better to close the other one I think. SO ! I made changes in my code and using yours : var Ground = function(x, z, game, scene) { console.log("Adding the ground"); BABYLON.SceneLoader.ImportMesh("", "assets/", "scene.babylon", scene, function (newMeshes) { this.mesh = newMeshes[0]; this.mesh.isVisible = true; this.mesh.shadows.getShadowMap().renderList.push(this.mesh); this.mesh.position = new BABYLON.Vector3(x, 0.75, z); this.mesh.receiveShadows = true; console.log("Ground added"); }); }; //console.log("number of meshes : " + game.assets['ground'].meshes.length); //var ground = game.assets['ground'].meshes; // Our object is a GameObject Ground.prototype = Object.create(GameObject.prototype); // And its constructor is the Ground function described above. Ground.prototype.constructor = Ground; But i'm still having the same error : babylon.2.3.js:13 Uncaught TypeError: Cannot read property '_addPendingData' of undefined As said you can watch it working directly at : http://datageneration.apps.eu01.cf.canopy-cloud.com/ . Maybe that can help... Thanks a lot for your consideration ! EDIT : I tried my file into the babylon sandbox and it can load it.. so the file is correct..
  12. Hello everyone ! This is my first post here and i'm not used to so apologies if I do some begginers mistakes. I look for it in internet but nothing about this error : TypeError: undefined is not an object (evaluating 's._addPendingData') I'm just trying to import a mesh into my scene. This is my code : var Ground = function(x, z, game, scene) { // Call the super class BABYLON.Mesh GameObject.call(this, "ground", game); console.log("Adding the ground"); BABYLON.SceneLoader.ImportMesh("", "assets/", "scene.babylon", scene, function (newMeshes, particleSystems) { this = newMeshes[0]; this.isVisible = true; this.parent = this; this.shadows.getShadowMap().renderList.push(ground); this.position = new BABYLON.Vector3(x, 0.75, z); this.receiveShadows = true; }); console.log("Ground added"); //console.log("number of meshes : " + game.assets['ground'].meshes.length); //var ground = game.assets['ground'].meshes; }; // Our object is a GameObject Ground.prototype = Object.create(GameObject.prototype); // And its constructor is the Ground function described above. Ground.prototype.constructor = Ground; and my file architecture : Main Folder -- Ground -- assets -- scene/babylon Does someone have information for me ? Thank you in advance, enjoy your day UPDATE : I've made some changes to my code and i put all my files on a server (cloud foundry, so you guys can see my code : http://datageneration.apps.eu01.cf.canopy-cloud.com/) var Ground = function(x, z, game, scene) { // Call the super class BABYLON.Mesh GameObject.call(this, "ground", game); console.log("Adding the ground"); BABYLON.SceneLoader.ImportMesh("", "assets/", "scene.babylon", scene, function (newMeshes, particleSystems) { this.meshes = newMeshes[0]; this.meshes.isVisible = true; this.meshes.parent = this; this.meshes.shadows.getShadowMap().renderList.push(ground); this.meshes.position = new BABYLON.Vector3(x, 0.75, z); this.meshes.receiveShadows = true; }); console.log("Ground added"); //console.log("number of meshes : " + game.assets['ground'].meshes.length); //var ground = game.assets['ground'].meshes; }; // Our object is a GameObject Ground.prototype = Object.create(GameObject.prototype); // And its constructor is the Ground function described above. Ground.prototype.constructor = Ground; The error is the same but without the 's.' : Uncaught TypeError: Cannot read property '_addPendingData' of undefined Thank you for you consideration EDIT : If you need it this is the complet file system : Block.js 636B Game.js 3.5K GameObject.js 356B Ground.js 927B Level.js 1.2K Player.js 4.2K assets/ - index.html 704B js/ - levels.js 771B old/ - cd assets/ key.babylon 47.7K key.babylon.manifest 78B scene.babylon 163.5K scene.babylon.manifest 79B skybox/ - cd ../js Oimo.js 302.5K babylon.2.3.js 948.4K cannon.js 384.2K hand-1.3.7.js 29.6K