Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var createScene = function () {
- // This creates a basic Babylon Scene object (non-mesh)
- var scene = new BABYLON.Scene(engine);
- // This creates and positions a free camera (non-mesh)
- var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene);
- // This targets the camera to scene origin
- camera.setTarget(BABYLON.Vector3.Zero());
- // This attaches the camera to the canvas
- camera.attachControl(canvas, true);
- scene.gravity = new BABYLON.Vector3(0, -1, 0);
- // This creates a light, aiming 0,1,0 - to the sky (non-mesh)
- var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene);
- // Default intensity is 1. Let's dim the light a small amount
- light.intensity = 1;
- // Box
- /*var box = BABYLON.Mesh.CreateBox("box",5,scene, false);
- //box.position.y = 10;
- box.position.x = 10;
- box.position.z = 10;
- box.checkCollisions = true;
- box.applyGravity = true;*/
- // Our built-in 'sphere' shape. Params: name, subdivs, size, scene
- //var box = BABYLON.Mesh.CreateBox("box", 100, scene);
- var skybox = BABYLON.Mesh.CreateBox("skyBox", 1000.0, scene);
- var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", scene);
- skyboxMaterial.backFaceCulling = false;
- skybox.material = skyboxMaterial;
- skybox.infiniteDistance = true;
- skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
- skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
- skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("textures/skybox", scene);
- skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
- // Ground
- var ground = BABYLON.Mesh.CreateGround("ground", 100, 100, 100,scene);
- var groundMaterial = new BABYLON.StandardMaterial("ground", scene);
- groundMaterial.diffuseTexture = new BABYLON.Texture("textures/ground.jpg", scene);
- groundMaterial.diffuseTexture.uScale = 6;
- groundMaterial.diffuseTexture.vScale = 6;
- groundMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
- ground.position.y = -2.0;
- ground.material = groundMaterial;
- //var roof = BABYLON.Mesh.CreateGround("roof", 1000, 1500, 1000, scene);
- // Move the sphere upward 1/2 its height
- //skybox.position.y = 1;
- scene.collisionsEnabled = true;
- camera.checkCollisions = true;
- ground.checkCollisions = true;
- camera.keysDown = [83];
- camera.keysLeft = [65];
- camera.keysRight = [68];
- camera.keysUp = [87];
- camera.speed = 1;
- camera.applyGravity = true;
- window.onclick = function(e){
- var rotx = camera.rotation[x];
- var roty = camera.rotation[y];
- var bullet = BABYLON.Mesh.CreateBox('bullet', .2, scene);
- }
- return scene;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement