luisAmudiel Posted December 13, 2019 Share Posted December 13, 2019 this is my version on jump camp. Help for to get better jump <html> <style> html, body { overflow: hidden; width : 100%; height : 100%; margin : 0; padding : 0; } #renderCanvas { width : 100%; height : 100%; touch-action: none; } </style> <head> <meta http-equiv="Content-Type" content="text/html" charset="utf-8"/> <title>Babylon - Getting Started</title> <!-- Link to the last version of BabylonJS --> <script src="https://preview.babylonjs.com/babylon.js"></script> <!-- Link to the last version of BabylonJS loaders to enable loading filetypes such as .gltf --> <script src="https://preview.babylonjs.com/loaders/babylonjs.loaders.min.js"></script> <!-- Link to pep.js to ensure pointer events work consistently in all browsers --> <script src="https://code.jquery.com/pep/0.4.1/pep.js"></script> </head> <body> <canvas id="renderCanvas"></canvas> </body> <script> var obj = { cavas: null, engine: null, scene: null, camera: null, init: ()=>{ let { addScene } = obj; obj.canvas = document.getElementById('renderCanvas'); obj.engine = new BABYLON.Engine(obj.canvas, true); obj.scene = new BABYLON.Scene(obj.engine); addScene(); }, addScene: ()=>{ let { scene, canvas } = obj; scene.gravity = new BABYLON.Vector3(0, -0.9, 0); scene.collisionsEnabled = true; obj.camera = new BABYLON.FreeCamera("FreeCamera", new BABYLON.Vector3(0, 5, -20), scene); let { camera } = obj; camera.attachControl(canvas, true); camera.checkCollisions = true; camera.applyGravity = true; var light = new BABYLON.HemisphericLight('light1', new BABYLON.Vector3(0,1,0), scene); var sphere = BABYLON.Mesh.CreateSphere('sphere1', 5, 2, scene); sphere.wireframe = true; sphere.position.y = 1; var myBox = BABYLON.MeshBuilder.CreateBox("myBox", {height: 3, width: 2, depth: 0.5}, scene); myBox.position.y = 1.5; myBox.position.x = 3; var ground = BABYLON.Mesh.CreateGround('ground1', 100, 100, 2, scene); // return the created scene /*colicipon contra la camara (persona)*/ ground.checkCollisions = true; myBox.checkCollisions = true; }, onKeyUp: function (event) { switch (event.keyCode) { case 32: let { camera } = obj; camera.position.y += 6; break; } } }; window.addEventListener('DOMContentLoaded', function(){ obj.init(); // run the render loop obj.engine.runRenderLoop(function(){ obj.scene.render(); }); }); // the canvas/window resize event handler window.addEventListener('resize', function(){ obj.engine.resize(); }); window.addEventListener("keyup", obj.onKeyUp, false); </script> </html> 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.