-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroom.ts
79 lines (67 loc) · 3.35 KB
/
room.ts
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
75
76
77
78
79
export class Room {
ROOM_X;
ROOM_Y;
ROOM_Z;
constructor(scene) {
this.ROOM_X = 150;
this.ROOM_Y = 40;
this.ROOM_Z = 150;
// Our built-in 'ground' shape. Params: name, width, depth, subdivs, scene
/* Boundaries */
var ground = BABYLON.MeshBuilder.CreateGround("ground",
{width: this.ROOM_Z, height: this.ROOM_X}, scene);
ground.checkCollisions = true;
var wall_N = BABYLON.MeshBuilder.CreateBox("myPlane",
{width: this.ROOM_Z, height: this.ROOM_Y, sideOrientation: BABYLON.Mesh.DOUBLESIDE}, scene);
wall_N.position.y = this.ROOM_Y / 2;
wall_N.position.z = this.ROOM_X / 2;
wall_N.checkCollisions = true;
var wall_S = BABYLON.MeshBuilder.CreateBox("myPlane",
{width: this.ROOM_Z, height: this.ROOM_Y, sideOrientation: BABYLON.Mesh.DOUBLESIDE}, scene);
wall_S.position.y = this.ROOM_Y / 2;
wall_S.position.z = -this.ROOM_X / 2;
wall_S.checkCollisions = true;
wall_S.rotate(BABYLON.Axis.Z, Math.PI, BABYLON.Space.WORLD);
var wall_W = BABYLON.MeshBuilder.CreateBox("myPlane",
{width: this.ROOM_X, height: this.ROOM_Y, sideOrientation: BABYLON.Mesh.DOUBLESIDE}, scene);
wall_W.position.y = this.ROOM_Y / 2;
wall_W.position.x = -this.ROOM_Z / 2;
wall_W.rotate(BABYLON.Axis.Y, Math.PI/2, BABYLON.Space.WORLD);
wall_W.rotate(BABYLON.Axis.X, Math.PI, BABYLON.Space.WORLD);
wall_W.checkCollisions = true;
var wall_E = BABYLON.MeshBuilder.CreateBox("myPlane",
{width: this.ROOM_X, height: this.ROOM_Y, sideOrientation: BABYLON.Mesh.DOUBLESIDE}, scene);
wall_E.position.y = this.ROOM_Y / 2;
wall_E.position.x = this.ROOM_Z / 2;
wall_E.rotate(BABYLON.Axis.Y, Math.PI/2, BABYLON.Space.WORLD);
wall_E.checkCollisions = true;
var ceiling = BABYLON.MeshBuilder.CreateBox("myPlane",
{width: this.ROOM_Z, height: this.ROOM_X, sideOrientation: BABYLON.Mesh.DOUBLESIDE}, scene);
ceiling.position.y = this.ROOM_Y;
ceiling.rotate(BABYLON.Axis.X, Math.PI/2, BABYLON.Space.WORLD);
ceiling.checkCollisions = true;
/* Textures */
var ground_mat = new BABYLON.StandardMaterial("wood floor", scene);
ground_mat.diffuseTexture = new BABYLON.Texture(
"https://i.imgur.com/wUGRD2s.png", scene);
var window_mat = new BABYLON.StandardMaterial("window wall", scene);
window_mat.diffuseTexture = new BABYLON.Texture(
"https://i.imgur.com/oqodmI9.jpeg", scene);
var wall_mat = new BABYLON.StandardMaterial("chair wall", scene);
wall_mat.diffuseTexture = new BABYLON.Texture(
"https://i.imgur.com/MO034Uh.png", scene);
var door_mat = new BABYLON.StandardMaterial("door wall", scene);
door_mat.diffuseTexture = new BABYLON.Texture(
"https://i.imgur.com/m6WMVCi.jpg", scene);
var ceiling_mat = new BABYLON.StandardMaterial("ceiling", scene);
ceiling_mat.diffuseTexture = new BABYLON.Texture(
"https://i.imgur.com/zVW0Lmk.png", scene);
/* Boundary Texture Selection */
ground.material = ground_mat;
wall_N.material = window_mat;
wall_S.material = window_mat;
wall_W.material = wall_mat;
wall_E.material = door_mat;
ceiling.material = ceiling_mat;
}
}