-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTH.js
More file actions
73 lines (67 loc) · 2.53 KB
/
TH.js
File metadata and controls
73 lines (67 loc) · 2.53 KB
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
var TH = {
materials : {
pinkLineMat : null,
whiteLineMat : null,
blackBasicMat : null,
debugBasicMat : null,
none : null
},
threediv : null,
width : null,
height : null,
scene : null,
camera : null,
raycaster: null,
mouseVec : null,
renderer : null,
floorY : -30,
clock : null,
animators : [],
lines: [],
levelTriggers: [],
fadeOut : false,
fadeOutDone : null,
fadeIn : false,
fadeSpeed : 0.02,
delta : 0,
originalRGB: {r: 0, g: 0, b: 0},
screens: [],
init : function () {
TH.threediv = document.getElementById('game'),
TH.width = TH.threediv.clientWidth;
TH.height = TH.threediv.clientHeight;
TH.scene = new THREE.Scene();
//TH.scene.background = new THREE.Color(0x0c1013);
TH.camera = new THREE.PerspectiveCamera(45, TH.width / TH.height, 0.1, 8000);
TH.scene.add(TH.camera);
TH.camera.rotateY(-3.14 / 2);
TH.renderer = new THREE.WebGLRenderer({antialias: true});
TH.renderer.setSize(TH.width, TH.height);
TH.threediv.appendChild(TH.renderer.domElement);
TH.raycaster = new THREE.Raycaster();
TH.mouseVec = new THREE.Vector2();
TH.clock = new THREE.Clock();
this.materials.pinkLineMat = new THREE.LineBasicMaterial({color: 0xf442d4});
this.originalRGB.r = this.materials.pinkLineMat.color.r;
this.originalRGB.g = this.materials.pinkLineMat.color.g;
this.originalRGB.b = this.materials.pinkLineMat.color.b;
// Start black to fade in.
this.materials.pinkLineMat.color.r = 0;
this.materials.pinkLineMat.color.g = 0;
this.materials.pinkLineMat.color.b = 0;
this.materials.whiteLineMat = new THREE.LineBasicMaterial({color: 0xf260d8});
this.materials.blackBasicMat = new THREE.MeshBasicMaterial({color: 0x000000, side: THREE.DoubleSide});
this.materials.debugBasicMat = new THREE.MeshBasicMaterial({color: 0x0c1013, side: THREE.DoubleSide});
this.materials.none = new THREE.MeshBasicMaterial({color: 0x000000, transparent: true, opacity: 0});
},
run : function(update) {
requestAnimationFrame( function(){TH.run(update)} );
this.delta = this.clock.getDelta();
update(this.delta);
TH.renderer.render( TH.scene, TH.camera );
},
resize : function(width, height) {
TH.renderer.setSize(width, height);
TH.camera = new THREE.PerspectiveCamera(45, width / height, 0.1, 4000);
},
}