webvr.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. var createScene = function () {
  2. // This creates a basic Babylon Scene object (non-mesh)
  3. var scene = new BABYLON.Scene(engine);
  4. scene.createDefaultVRExperience();
  5. // This creates a light, aiming 0,1,0 - to the sky (non-mesh)
  6. var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene);
  7. // Default intensity is 1. Let's dim the light a small amount
  8. light.intensity = 0.7;
  9. // Create some spheres at the default eye level (2m)
  10. createSphereBox(scene, 2, 2);
  11. createSphereBox(scene, 3, 2);
  12. // Our built-in 'ground' shape. Params: name, width, depth, subdivs, scene
  13. var ground = BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, scene);
  14. return scene;
  15. };
  16. function createSphereBox(scene, distance, height) {
  17. createSphere(scene, distance, height, distance);
  18. createSphere(scene, distance, height, -distance);
  19. createSphere(scene, -distance, height, distance);
  20. createSphere(scene, -distance, height, -distance);
  21. }
  22. function createSphere(scene, x, y, z) {
  23. // Our built-in 'sphere' shape. Params: name, subdivs, size, scene
  24. var sphere = BABYLON.Mesh.CreateSphere("sphere1", 4, 0.4, scene);
  25. sphere.position.x = x;
  26. sphere.position.y = y;
  27. sphere.position.z = z;
  28. }