Last active
May 27, 2018 20:19
-
-
Save sorskoot/46bbfeeb61b9d161949601ea9e559081 to your computer and use it in GitHub Desktop.
BabylonJS WebVR Hello World
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<canvas id="renderCanvas"></canvas> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import './style.css'; | |
import 'babylonjs'; | |
class VRApp { | |
constructor() { | |
} | |
run() { | |
} | |
} | |
new VRApp().run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VRApp { | |
private _engine: BABYLON.Engine; | |
private _scene: BABYLON.Scene; | |
constructor() { | |
const appDiv = <HTMLCanvasElement>document.getElementById('renderCanvas'); | |
this._engine = new BABYLON.Engine(appDiv, true); | |
this._scene = new BABYLON.Scene(this._engine); | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let light1 = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(1, 1, 0), this._scene); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let ground = BABYLON.Mesh.CreateGround("ground", 50, 50, 2, this._scene); | |
for (let i = 0; i < 25; i++) { | |
let box = BABYLON.Mesh.CreateBox(`box_${i}`, 2, this._scene); | |
box.position = new BABYLON.Vector3(Math.random() * 50.0 - 25.0, 1, Math.random() * 50.0 - 25.0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
run() { | |
this._engine.runRenderLoop(() => { | |
this._scene.render(); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this._scene.createDefaultVRExperience(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import './style.css'; | |
import 'babylonjs'; | |
class VRApp { | |
private _engine: BABYLON.Engine; | |
private _scene: BABYLON.Scene; | |
constructor() { | |
const appDiv = <HTMLCanvasElement>document.getElementById('renderCanvas'); | |
this._engine = new BABYLON.Engine(appDiv, true); | |
this._scene = new BABYLON.Scene(this._engine); | |
let light1 = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(1, 1, 0), this._scene); | |
let ground = BABYLON.Mesh.CreateGround("ground", 50, 50, 2, this._scene); | |
ground.translate(BABYLON.Vector3.Up(), -1); | |
for (let i = 0; i < 25; i++) { | |
let box = BABYLON.Mesh.CreateBox(`box_${i}`, 2, this._scene); | |
box.position = new BABYLON.Vector3(Math.random() * 50.0 - 25.0, 0, Math.random() * 50.0 - 25.0); | |
} | |
this._scene.createDefaultVRExperience(); | |
} | |
run() { | |
this._engine.runRenderLoop(() => { | |
this._scene.render(); | |
}); | |
} | |
} | |
new VRApp().run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html, body { | |
overflow: hidden; | |
width: 100%; | |
height: 100%; | |
margin: 0; | |
padding: 0; | |
} | |
#renderCanvas { | |
width: 100%; | |
height: 100%; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment