index.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. /// <reference path="../../dist/preview release/babylon.d.ts"/>
  2. // Playground like creation of the scene
  3. var createScene = function () {
  4. // This creates a basic Babylon Scene object (non-mesh)
  5. var scene = new BABYLON.Scene(engine);
  6. // This creates and positions a free camera (non-mesh)
  7. var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene);
  8. // This targets the camera to scene origin
  9. camera.setTarget(BABYLON.Vector3.Zero());
  10. // This attaches the camera to the canvas
  11. camera.attachControl(canvas, true);
  12. // This creates a light, aiming 0,1,0 - to the sky (non-mesh)
  13. var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene);
  14. // Default intensity is 1. Let's dim the light a small amount
  15. light.intensity = 0.7;
  16. // Our built-in 'sphere' shape. Params: name, subdivs, size, scene
  17. var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene);
  18. // Move the sphere upward 1/2 its height
  19. sphere.position.y = 1;
  20. // Our built-in 'ground' shape. Params: name, width, depth, subdivs, scene
  21. var ground = BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, scene);
  22. return scene;
  23. };