-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstructions.js
74 lines (53 loc) · 1.97 KB
/
instructions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/******* Add the create scene function ******/
class Instructions {
constructor() {
this.scene;
this.video;
}
createScene() {
var scene = new BABYLON.Scene(engine);
// Setup environment
var light = new BABYLON.HemisphericLight("ambientLight", new BABYLON.Vector3(-10, -10, -10), scene);
//var light2 = new BABYLON.PointLight("Omni", new BABYLON.Vector3(10, 10, -20), scene);
var camera = new BABYLON.ArcRotateCamera("Camera", -Math.PI / 2, Math.PI / 2, 15, new BABYLON.Vector3(0,0,0), scene);
camera.attachControl(canvas);
this.createVideo(scene);
let fireworkHelper = new FireworkHelper();
fireworkHelper.createParticles(scene, {x: 0, y: 0, z: 2}, true);
fireworkHelper.createParticles(scene, {x: 5, y: 0, z: 2}, true);
fireworkHelper.createParticles(scene, {x: -5, y: 0, z: 2}, true);
this.scene = scene;
this.scene.executeOnceBeforeRender(
() => {
this.video.play();
}
);
}
createVideo(scene) {
// Video plane
var videoPlane = BABYLON.MeshBuilder.CreatePlane("Screen", {width: 16, height: 9}, scene);
videoPlane.position.y = 0;
videoPlane.position.z = 0;
// Video material
var videoMat = new BABYLON.StandardMaterial("textVid", scene);
videoMat.diffuseTexture = new BABYLON.VideoTexture("video", ["assets/videos/All the Moves of HeadBangZ_720p.mp4"], scene, false);
videoMat.backFaceCulling = false;
//Applying materials
videoPlane.material = videoMat;
let htmlVideo = videoMat.diffuseTexture.video; // reflections
var playing = false;
this.video = htmlVideo;
}
isReady() {
return (this.scene && this.scene.isReady());
}
onLoad() {
this.video.currentTime = 0;
}
render() {
this.scene.render();
}
dispose() {
this.scene.dispose();
}
}