basic scene.txt 1.3 KB

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