basic scene.js 1.1 KB

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