|
@@ -58,29 +58,29 @@ To add a module install the respected package. A list of extra packages and thei
|
|
## Usage
|
|
## Usage
|
|
See [Getting Started](http://doc.babylonjs.com/#getting-started)
|
|
See [Getting Started](http://doc.babylonjs.com/#getting-started)
|
|
```javascript
|
|
```javascript
|
|
-// get the canvas DOM element
|
|
|
|
|
|
+// Get the canvas DOM element
|
|
var canvas = document.getElementById('renderCanvas');
|
|
var canvas = document.getElementById('renderCanvas');
|
|
-// load the 3D engine
|
|
|
|
-var engine = new BABYLON.Engine(canvas, true);
|
|
|
|
-// createScene function that creates and return the scene
|
|
|
|
|
|
+// Load the 3D engine
|
|
|
|
+var engine = new BABYLON.Engine(canvas, true, {preserveDrawingBuffer: true, stencil: true});
|
|
|
|
+// CreateScene function that creates and return the scene
|
|
var createScene = function(){
|
|
var createScene = function(){
|
|
- // create a basic BJS Scene object
|
|
|
|
|
|
+ // Create a basic BJS Scene object
|
|
var scene = new BABYLON.Scene(engine);
|
|
var scene = new BABYLON.Scene(engine);
|
|
- // create a FreeCamera, and set its position to (x:0, y:5, z:-10)
|
|
|
|
- var camera = new BABYLON.FreeCamera('camera1', new BABYLON.Vector3(0, 5,-10), scene);
|
|
|
|
- // target the camera to scene origin
|
|
|
|
|
|
+ // Create a FreeCamera, and set its position to {x: 0, y: 5, z: -10}
|
|
|
|
+ var camera = new BABYLON.FreeCamera('camera1', new BABYLON.Vector3(0, 5, -10), scene);
|
|
|
|
+ // Target the camera to scene origin
|
|
camera.setTarget(BABYLON.Vector3.Zero());
|
|
camera.setTarget(BABYLON.Vector3.Zero());
|
|
- // attach the camera to the canvas
|
|
|
|
|
|
+ // Attach the camera to the canvas
|
|
camera.attachControl(canvas, false);
|
|
camera.attachControl(canvas, false);
|
|
- // create a basic light, aiming 0,1,0 - meaning, to the sky
|
|
|
|
- var light = new BABYLON.HemisphericLight('light1', new BABYLON.Vector3(0,1,0), scene);
|
|
|
|
- // create a built-in "sphere" shape; its constructor takes 6 params: name, segment, diameter, scene, updatable, sideOrientation
|
|
|
|
- var sphere = BABYLON.Mesh.CreateSphere('sphere1', 16, 2, scene);
|
|
|
|
- // move the sphere upward 1/2 of its height
|
|
|
|
|
|
+ // Create a basic light, aiming 0, 1, 0 - meaning, to the sky
|
|
|
|
+ var light = new BABYLON.HemisphericLight('light1', new BABYLON.Vector3(0, 1, 0), scene);
|
|
|
|
+ // Create a built-in "sphere" shape; its constructor takes 6 params: name, segment, diameter, scene, updatable, sideOrientation
|
|
|
|
+ var sphere = BABYLON.Mesh.CreateSphere('sphere1', 16, 2, scene, false, BABYLON.Mesh.FRONTSIDE);
|
|
|
|
+ // Move the sphere upward 1/2 of its height
|
|
sphere.position.y = 1;
|
|
sphere.position.y = 1;
|
|
- // create a built-in "ground" shape; its constructor takes the same 6 params : name, width, height, subdivision, scene, updatable
|
|
|
|
- var ground = BABYLON.Mesh.CreateGround('ground1', 6, 6, 2, scene);
|
|
|
|
- // return the created scene
|
|
|
|
|
|
+ // Create a built-in "ground" shape; its constructor takes 6 params : name, width, height, subdivision, scene, updatable
|
|
|
|
+ var ground = BABYLON.Mesh.CreateGround('ground1', 6, 6, 2, scene, false);
|
|
|
|
+ // Return the created scene
|
|
return scene;
|
|
return scene;
|
|
}
|
|
}
|
|
// call the createScene function
|
|
// call the createScene function
|