Commit 2411273e9abf7d329aa6c3d281db9e52565aa6e2

Authored by Gustav
1 parent a0dd0047

Støtte for internet explorer

js/GUI.js
... ... @@ -357,7 +357,7 @@ function cancelAutoGen() {
357 357 meshControls.disposeArrows();
358 358 if(autoGenEndPole) {
359 359 meshControls.hide();
360   - autoGenEndPole.containerClass.delete();
  360 + autoGenEndPole.containerClass.dispose();
361 361 }
362 362 }
363 363  
... ... @@ -736,6 +736,6 @@ function getPrice(type) {
736 736 return POLE_45.price;
737 737 }
738 738 else {
739   - return Glass.getType(parseInt(document.getElementById("glassTypeSelect").value), type).price + Glass.getRailing(type).price;
  739 + return Glass.GetType(parseInt(document.getElementById("glassTypeSelect").value), type).price + Glass.GetRailing(type).price;
740 740 }
741 741 }
742 742 \ No newline at end of file
... ...
js/MeshControls.js
1   -class MeshControls {
2   - constructor() {
  1 +var MeshControls = (function() {
  2 +
  3 + function MeshControls() {
3 4 this.visible = false;
4 5  
5 6 this.meshClass = undefined;
... ... @@ -16,18 +17,20 @@ class MeshControls {
16 17 this.textPlanesNeedUpdate = false;
17 18 }
18 19  
19   - show(meshClass) {
  20 + MeshControls.prototype.show = function(meshClass) {
20 21 if (meshClass === this.meshClass) {
21 22 return;
22 23 }
23 24  
  25 + var _this = this;
  26 +
24 27 this.visible = true;
25 28  
26 29 if (meshClass instanceof Pole) {
27 30 if(this.meshClass) {
28 31 this.hideMeshMenu();
29   - setTimeout(() => {
30   - this.showPoleMenu();
  32 + setTimeout(function() {
  33 + _this.showPoleMenu();
31 34 }, 300);
32 35 }
33 36 else {
... ... @@ -37,8 +40,8 @@ class MeshControls {
37 40 else if (meshClass instanceof Glass) {
38 41 if(this.meshClass) {
39 42 this.hideMeshMenu();
40   - setTimeout(() => {
41   - this.showGlassMenu(meshClass.glassType);
  43 + setTimeout(function() {
  44 + _this.showGlassMenu(meshClass.glassType);
42 45 }, 300);
43 46 }
44 47 else {
... ... @@ -65,9 +68,9 @@ class MeshControls {
65 68 }
66 69  
67 70 this.prevMeshClass = meshClass;
68   - }
  71 + };
69 72  
70   - hide() {
  73 + MeshControls.prototype.hide = function() {
71 74 this.visible = false;
72 75 this.startingPoint = null;
73 76 this.textPlanesNeedUpdate = false;
... ... @@ -85,9 +88,9 @@ class MeshControls {
85 88 }
86 89  
87 90 this.hideMeshMenu();
88   - }
  91 + };
89 92  
90   - disposeDistancePlanes() {
  93 + MeshControls.prototype.disposeDistancePlanes = function() {
91 94 if (this.meshClass && this.meshClass.xPlane && this.meshClass.zPlane) {
92 95 this.meshClass.xPlane.material.diffuseTexture.dispose();
93 96 this.meshClass.xPlane.material.dispose();
... ... @@ -98,9 +101,9 @@ class MeshControls {
98 101 this.meshClass.zPlane.dispose();
99 102 this.meshClass.zPlane = undefined;
100 103 }
101   - }
  104 + };
102 105  
103   - disposeOldPlanes() {
  106 + MeshControls.prototype.disposeOldPlanes = function() {
104 107 if (this.prevMeshClass && this.prevMeshClass.xPlane && this.prevMeshClass.zPlane) {
105 108 this.prevMeshClass.xPlane.material.diffuseTexture.dispose();
106 109 this.prevMeshClass.xPlane.material.dispose();
... ... @@ -111,17 +114,18 @@ class MeshControls {
111 114 this.prevMeshClass.zPlane.dispose();
112 115 this.prevMeshClass.zPlane = undefined;
113 116 }
114   - }
  117 + };
115 118  
116   - showDistancePlanes() {
  119 + MeshControls.prototype.showDistancePlanes = function() {
117 120 if (terrace.showMeasurements && this.meshClass && this.meshClass instanceof Pole) {
118 121 TextProvider.updateXZ(this.meshClass);
119 122 }
120   - }
  123 + };
121 124  
122   - onPointerDown() {
123   - var pickInfo = scene.pick(scene.pointerX, scene.pointerY, (mesh) => {
124   - if(this.meshClass.isMesh(mesh)) {
  125 + MeshControls.prototype.onPointerDown = function() {
  126 + var _this = this;
  127 + var pickInfo = scene.pick(scene.pointerX, scene.pointerY, function(mesh) {
  128 + if(_this.meshClass.isMesh(mesh)) {
125 129 return true;
126 130 }
127 131 });
... ... @@ -133,9 +137,9 @@ class MeshControls {
133 137 camera.perspectiveCamera.detachControl(canvas);
134 138 }
135 139 }
136   - }
  140 + };
137 141  
138   - onPointerMove() {
  142 + MeshControls.prototype.onPointerMove = function() {
139 143 if (this.startingPoint) {
140 144 var current = terrace.buildingPlane.getPickInfo();
141 145 if (!current)
... ... @@ -167,9 +171,9 @@ class MeshControls {
167 171  
168 172 this.startingPoint = current;
169 173 }
170   - }
  174 + };
171 175  
172   - onPointerUp() {
  176 + MeshControls.prototype.onPointerUp = function() {
173 177 if (this.startingPoint) {
174 178 if (scene.activeCamera === camera.perspectiveCamera) {
175 179 camera.perspectiveCamera.attachControl(canvas, true);
... ... @@ -177,43 +181,43 @@ class MeshControls {
177 181 this.startingPoint = null;
178 182 camera.setPerspectiveCameraTarget(this.meshClass.mesh.position.clone(), 500);
179 183 }
180   - }
  184 + };
181 185  
182   - rotate(amount) {
  186 + MeshControls.prototype.rotate = function(amount) {
183 187 this.meshClass.rotate(amount);
184 188 if(terrace.showMeasurements && this.meshClass instanceof Pole)
185 189 TextProvider.updateXZ(this.meshClass);
186   - }
  190 + };
187 191  
188   - delete() {
  192 + MeshControls.prototype.delete = function() {
189 193 if (this.meshClass instanceof Pole) {
190 194 this.disposeDistancePlanes();
191 195 }
192 196  
193   - this.meshClass.delete();
  197 + this.meshClass.dispose();
194 198 this.meshClass = undefined;
195 199 this.hide();
196   - }
  200 + };
197 201  
198   - showPoleMenu() {
  202 + MeshControls.prototype.showPoleMenu = function() {
199 203 document.getElementById("poleMenu").style.bottom = "0";
200   - }
  204 + };
201 205  
202   - showGlassMenu(glassType) {
  206 + MeshControls.prototype.showGlassMenu = function(glassType) {
203 207 document.getElementById("glassMenuTypeSelect").value = glassType;
204 208 document.getElementById("glassMenu").style.bottom = "0";
205   - }
  209 + };
206 210  
207   - hideMeshMenu() {
  211 + MeshControls.prototype.hideMeshMenu = function() {
208 212 document.getElementById("poleMenu").style.bottom = "-55px";
209 213 document.getElementById("glassMenu").style.bottom = "-55px";
210 214 document.getElementById("autoGenPoleSelect").style.display = "none";
211 215 document.getElementById("moduleMenu").style.pointerEvents = "auto";
212   - }
  216 + };
213 217  
214 218 //****************** Auto-gen **********************************//
215 219  
216   - createDirectionArrows() {
  220 + MeshControls.prototype.createDirectionArrows = function() {
217 221 if (this.meshClass instanceof Pole && !this.arrows) {
218 222 var pole = this.meshClass;
219 223  
... ... @@ -230,9 +234,9 @@ class MeshControls {
230 234 }
231 235  
232 236 return true;
233   - }
  237 + };
234 238  
235   - selectedDirection(holder) {
  239 + MeshControls.prototype.selectedDirection = function(holder) {
236 240 if(this.meshClass.type === POLE_45) {
237 241 if(holder.name === "pole45.holder1")
238 242 this.direction = this.meshClass.getHolderRotation(this.meshClass.holder2) / 180 * Math.PI;
... ... @@ -254,9 +258,9 @@ class MeshControls {
254 258 } else {
255 259 // TODO: Create popup msg
256 260 }
257   - }
  261 + };
258 262  
259   - disposeArrows() {
  263 + MeshControls.prototype.disposeArrows = function() {
260 264 if (this.arrow1) {
261 265 this.arrow1.dispose();
262 266 this.arrow1 = undefined;
... ... @@ -268,15 +272,15 @@ class MeshControls {
268 272 }
269 273  
270 274 this.arrows = false;
271   - }
  275 + };
272 276  
273   - edgeTooClose(position) {
  277 + MeshControls.prototype.edgeTooClose = function(position) {
274 278 var ray = new BABYLON.Ray(position, this.getDirVec());
275 279 var dist = ray.intersectsMesh(terrace.terraceBorder).distance - POLE_BASE_WIDTH / 2;
276 280 return dist <= MIN_AUTO_DIST;
277   - }
  281 + };
278 282  
279   - getDirVec() {
  283 + MeshControls.prototype.getDirVec = function() {
280 284 switch (this.direction) {
281 285 case 0:
282 286 return new BABYLON.Vector3(1, 0, 0);
... ... @@ -296,9 +300,9 @@ class MeshControls {
296 300 case -Math.PI / 4 * 3:
297 301 return new BABYLON.Vector3(-1, 0, -1);
298 302 }
299   - }
  303 + };
300 304  
301   - getArrow(name, meshClass, holder) {
  305 + MeshControls.prototype.getArrow = function(name, meshClass, holder) {
302 306 var path = [
303 307 new BABYLON.Vector3(-25, 0, -25),
304 308 new BABYLON.Vector3(300, 0, -25),
... ... @@ -334,11 +338,14 @@ class MeshControls {
334 338  
335 339 arrow.actionManager = new BABYLON.ActionManager(scene);
336 340 arrow.actionManager.registerAction( new BABYLON.ExecuteCodeAction(
337   - BABYLON.ActionManager.OnPickTrigger, () => {
  341 + BABYLON.ActionManager.OnPickTrigger, function() {
338 342 meshControls.selectedDirection(holder)
339 343 })
340 344 );
341 345  
342 346 return arrow;
343   - }
344   -}
345 347 \ No newline at end of file
  348 + };
  349 +
  350 + return MeshControls;
  351 +
  352 +}());
346 353 \ No newline at end of file
... ...
js/Setup.js
1   -class Setup {
  1 +var Setup = (function() {
2 2  
3   - constructor() {
  3 + function Setup() {
4 4 this.initElements();
5 5 }
6 6  
7   - initElements() {
  7 + Setup.prototype.initElements = function() {
8 8 this.selectedLayout = "";
9 9 this.setupView = document.getElementById("setup");
10 10 this.mainView = document.getElementById("main");
... ... @@ -14,29 +14,44 @@ class Setup {
14 14 this.previewImg = document.getElementById("layoutPreview");
15 15 this.customTerrace = document.getElementById("custom-terrace-gui");
16 16  
  17 + var _this = this;
17 18 this.btDraw = document.getElementById("btDraw");
18   - this.btDraw.onclick = () => this.draw();
  19 + this.btDraw.onclick = function() {
  20 + _this.draw();
  21 + };
19 22  
20 23 this.btPrevious = document.getElementById("btPrevious");
21   - this.btPrevious.onclick = () => this.previous();
  24 + this.btPrevious.onclick = function() {
  25 + _this.previous();
  26 + };
22 27  
23 28 this.btNext = document.getElementById("btNext");
24   - this.btNext.onclick = () => this.next();
  29 + this.btNext.onclick = function() {
  30 + _this.next();
  31 + };
25 32  
26 33 this.layout1 = document.getElementById("btLayout1");
27   - this.layout1.onclick = () => this.initLayoutMeasurements("terraceSquare", "img/layouts/terrace_square_labeled.png");
  34 + this.layout1.onclick = function() {
  35 + _this.initLayoutMeasurements("terraceSquare", "img/layouts/terrace_square_labeled.png");
  36 + };
28 37  
29 38 this.layout2 = document.getElementById("btLayout2");
30   - this.layout2.onclick = () => this.initLayoutMeasurements("terraceLShape", "img/layouts/terrace_l_shape_labeled.png");
  39 + this.layout2.onclick = function() {
  40 + _this.initLayoutMeasurements("terraceLShape", "img/layouts/terrace_l_shape_labeled.png");
  41 + };
31 42  
32 43 this.layout3 = document.getElementById("btLayout3");
33   - this.layout3.onclick = () => this.initLayoutMeasurements("terraceDiamond", "img/layouts/terrace_diamond_labeled.png");
  44 + this.layout3.onclick = function() {
  45 + _this.initLayoutMeasurements("terraceDiamond", "img/layouts/terrace_diamond_labeled.png");
  46 + };
34 47  
35 48 this.layout4 = document.getElementById("btLayout4");
36   - this.layout4.onclick = () => this.initLayoutMeasurements("terraceTriangle", "img/layouts/terrace_triangle_labeled.png");
37   - }
  49 + this.layout4.onclick = function() {
  50 + _this.initLayoutMeasurements("terraceTriangle", "img/layouts/terrace_triangle_labeled.png");
  51 + };
  52 + };
38 53  
39   - initLayoutMeasurements(layout, img) {
  54 + Setup.prototype.initLayoutMeasurements = function(layout, img) {
40 55 this.selectedLayout = layout;
41 56 this.previewImg.src = img;
42 57 this.layout.style.display = "none";
... ... @@ -46,27 +61,27 @@ class Setup {
46 61 document.getElementById("formC").style.display = "inline";
47 62 document.getElementById("formD").style.display = "inline";
48 63 }
49   - }
  64 + };
50 65  
51   - next() {
52   - Setup.resetErrorMsg();
  66 + Setup.prototype.next = function() {
  67 + Setup.ResetErrorMessage();
53 68 this.buildTerrace();
54   - }
  69 + };
55 70  
56   - previous() {
  71 + Setup.prototype.previous = function() {
57 72 document.getElementById("formC").style.display = "none";
58 73 document.getElementById("formD").style.display = "none";
59   - Setup.resetErrorMsg();
60   - Setup.clearInputs();
  74 + Setup.ResetErrorMessage();
  75 + Setup.ClearInputs();
61 76 this.showLayouts();
62   - }
  77 + };
63 78  
64   - showLayouts() {
  79 + Setup.prototype.showLayouts = function() {
65 80 this.measurements.style.display = "none";
66 81 this.layout.style.display = "inline";
67   - }
  82 + };
68 83  
69   - draw() {
  84 + Setup.prototype.draw = function() {
70 85 document.getElementById("setup").style.display = "none";
71 86 document.getElementById("custom-terrace-gui").style.display = "inline";
72 87 document.getElementById("renderCanvas").style.display = "inline";
... ... @@ -74,9 +89,9 @@ class Setup {
74 89  
75 90 initCanvas();
76 91 createCustomTerrace();
77   - }
  92 + };
78 93  
79   - buildTerrace() {
  94 + Setup.prototype.buildTerrace = function() {
80 95 var inputs = [];
81 96 inputs.push(document.getElementById("sideA").value); // A
82 97 inputs.push(document.getElementById("sideB").value); // B
... ... @@ -99,9 +114,9 @@ class Setup {
99 114 document.getElementById("info").style.display = "inline";
100 115 resize();
101 116 }
102   - }
  117 + };
103 118  
104   - verifyInputs(inputs) {
  119 + Setup.prototype.verifyInputs = function(inputs) {
105 120 for (let i = 0; i < inputs.length; i++) {
106 121 if (isNaN(inputs[i]) || parseInt(inputs[i]) <= 0 || inputs[i] === "") {
107 122 document.getElementById("triggerModal").click();
... ... @@ -125,25 +140,27 @@ class Setup {
125 140 }
126 141  
127 142 return true;
128   - }
  143 + };
129 144  
130   - hideSetup() {
  145 + Setup.prototype.hideSetup = function() {
131 146 this.measurements.style.display = "none";
132 147 this.setupView.style.display = "none";
133 148 this.mainView.style.display = "inline";
134 149 canvas.style.display = "inline";
135   - }
  150 + };
136 151  
137   - static resetErrorMsg() {
  152 + Setup.ResetErrorMessage = function() {
138 153 document.getElementById("errorC").style.display = "none";
139 154 document.getElementById("errorD").style.display = "none";
140   - }
  155 + };
141 156  
142   - static clearInputs() {
  157 + Setup.ClearInputs = function() {
143 158 document.getElementById("sideA").value = "";
144 159 document.getElementById("sideB").value = "";
145 160 document.getElementById("sideC").value = "";
146 161 document.getElementById("sideD").value = "";
147   - }
  162 + };
  163 +
  164 + return Setup;
148 165  
149   -}
150 166 \ No newline at end of file
  167 +}());
151 168 \ No newline at end of file
... ...
js/app.js
... ... @@ -215,6 +215,11 @@ function onPointerUp() {
215 215 if(meshControls.visible) {
216 216 meshControls.onPointerUp();
217 217 }
  218 +
  219 + if(scene.activeCamera === camera.orthographicCamera.oCamera) {
  220 + camera.orthographicCamera.prevX = undefined;
  221 + camera.orthographicCamera.prevY = undefined;
  222 + }
218 223 }
219 224  
220 225 function onMouseWheel(event) {
... ...
js/camera/CameraController.js
1   -class CameraController {
  1 +var CameraController = (function() {
2 2  
3   - constructor() {
  3 + function CameraController() {
4 4 this.orthographicCamera = new OrthographicCamera();
5 5 this.perspectiveCamera = new BABYLON.ArcRotateCamera("perspectiveCamera",
6 6 Math.PI / 4, Math.PI / 4, 1000, BABYLON.Vector3.Zero(), scene);
... ... @@ -11,26 +11,26 @@ class CameraController {
11 11 this.perspectiveCamera.wheelPrecision = 0.1;
12 12 }
13 13  
14   - setUpCameras() {
  14 + CameraController.prototype.setUpCameras = function() {
15 15 this.focusPerspectiveCamera();
16 16 this.orthographicCamera.setDefaultZoom(terrace.width > terrace.depth ? terrace.width : terrace.depth);
17 17 this.orthographicCamera.setDefaultTarget(terrace.width / 2, terrace.depth + 10);
18 18  
19 19 this.perspectiveMode();
20   - }
  20 + };
21 21  
22   - focusPerspectiveCamera() {
  22 + CameraController.prototype.focusPerspectiveCamera = function() {
23 23 let sum = terrace.width + terrace.depth;
24 24 this.perspectiveCamera.radius = sum;
25 25 this.perspectiveCamera.setPosition(new BABYLON.Vector3(0, sum / 2, 0));
26 26 this.perspectiveCamera.target = new BABYLON.Vector3(terrace.width / 2, 0, terrace.depth / 2);
27   - }
  27 + };
28 28  
29   - setPerspectiveCameraTarget(targetVector, yOffset) {
  29 + CameraController.prototype.setPerspectiveCameraTarget = function(targetVector, yOffset) {
30 30 this.animatePerspectiveCamera(targetVector, yOffset);
31   - }
  31 + };
32 32  
33   - animatePerspectiveCamera(targetVector, yOffset) {
  33 + CameraController.prototype.animatePerspectiveCamera = function(targetVector, yOffset) {
34 34 var cameraFocusAnimation = new BABYLON.Animation("cameraFocusAnimation", "target", 30,
35 35 BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE);
36 36  
... ... @@ -45,29 +45,31 @@ class CameraController {
45 45  
46 46 this.perspectiveCamera.animations.push(cameraFocusAnimation);
47 47 scene.beginAnimation(this.perspectiveCamera, 0, 16, false);
48   - }
  48 + };
49 49  
50   - perspectiveMode() {
  50 + CameraController.prototype.perspectiveMode = function() {
51 51 this.perspectiveCamera.attachControl(canvas, true);
52 52 scene.activeCamera = this.perspectiveCamera;
53   - }
  53 + };
54 54  
55   - orthographicMode() {
  55 + CameraController.prototype.orthographicMode = function() {
56 56 this.perspectiveCamera.detachControl(canvas);
57 57 scene.activeCamera = this.orthographicCamera.oCamera;
58   - }
  58 + };
59 59  
60   - onPointerMove(event) {
  60 + CameraController.prototype.onPointerMove = function(event) {
61 61 let buttons = (event.buttons === undefined ? event.which : event.buttons);
62 62 if(scene.activeCamera === this.orthographicCamera.oCamera && buttons === 1) {
63 63 this.orthographicCamera.onPointerMove(event);
64 64 }
65   - }
  65 + };
66 66  
67   - onMouseWheel(event) {
  67 + CameraController.prototype.onMouseWheel = function(event) {
68 68 if(scene.activeCamera === this.orthographicCamera.oCamera) {
69 69 this.orthographicCamera.zoomCamera(event.deltaY);
70 70 }
71   - }
  71 + };
  72 +
  73 + return CameraController;
72 74  
73   -}
74 75 \ No newline at end of file
  76 +}());
75 77 \ No newline at end of file
... ...
js/camera/OrthographicCamera.js
1   -class OrthographicCamera {
2   - constructor() {
  1 +var OrthographicCamera = (function() {
  2 +
  3 + function OrthographicCamera() {
3 4 this.defaultZoom = 4000;
4 5 this.zoom = 4000;
5 6 this.zoomDelta = 500;
... ... @@ -15,6 +16,9 @@ class OrthographicCamera {
15 16 this.widthFactor = window.innerWidth / 1920;
16 17 this.heightFactor = window.innerHeight / 1920;
17 18  
  19 + this.prevX = undefined;
  20 + this.prevY = undefined;
  21 +
18 22 this.oCamera = new BABYLON.FreeCamera("OrthographicCamera",
19 23 new BABYLON.Vector3(0, 10000, 0), scene);
20 24 this.oCamera.setTarget(new BABYLON.Vector3(0, 0, 0));
... ... @@ -25,44 +29,50 @@ class OrthographicCamera {
25 29 this.update();
26 30 }
27 31  
28   - setDefaultTarget(x, z) {
  32 + OrthographicCamera.prototype.setDefaultTarget = function(x, z) {
29 33 this.defaultOffsetX = x;
30 34 this.defaultOffsetZ = z;
31 35 this.offsetX = x;
32 36 this.offsetZ = z;
33 37  
34 38 this.update();
35   - }
  39 + };
36 40  
37   - setDefaultZoom(zoom) {
  41 + OrthographicCamera.prototype.setDefaultZoom = function(zoom) {
38 42 this.defaultZoom = zoom;
39 43 this.zoom = zoom;
40 44  
41 45 this.updateSensibility();
42 46 this.update();
43   - }
  47 + };
44 48  
45   - update() {
  49 + OrthographicCamera.prototype.update = function() {
46 50 this.oCamera.orthoTop = (this.zoom + this.offsetZ) * this.heightFactor;
47 51 this.oCamera.orthoBottom = (-this.zoom + this.offsetZ) * this.heightFactor;
48 52 this.oCamera.orthoLeft = (-this.zoom + this.offsetX) * this.widthFactor;
49 53 this.oCamera.orthoRight = (this.zoom + this.offsetX) * this.widthFactor;
50   - }
  54 + };
51 55  
52   - resize() {
  56 + OrthographicCamera.prototype.resize = function() {
53 57 this.widthFactor = window.innerWidth / 1920;
54 58 this.heightFactor = window.innerHeight / 1920;
55 59  
56 60 this.update();
57   - }
  61 + };
  62 +
  63 + OrthographicCamera.prototype.onPointerMove = function(event) {
  64 + //this.offsetX -= (event.movementX || event.mozMovementX || event.webkitMovementX || 0) * this.sensibility;
  65 + //this.offsetZ += (event.movementY || event.mozMovementY || event.webkitMovementY || 0) * this.sensibility;
  66 + this.offsetX -= (this.prevX ? event.screenX - this.prevX : 0) * this.sensibility;
  67 + this.offsetZ += (this.prevY ? event.screenY - this.prevY : 0) * this.sensibility;
  68 +
  69 + this.prevX = event.screenX;
  70 + this.prevY = event.screenY;
58 71  
59   - onPointerMove(event) {
60   - this.offsetX -= (event.movementX || event.mozMovementX || event.webkitMovementX || 0) * this.sensibility;
61   - this.offsetZ += (event.movementY || event.mozMovementY || event.webkitMovementY || 0) * this.sensibility;
62 72 this.update();
63   - }
  73 + };
64 74  
65   - zoomCamera(deltaY) {
  75 + OrthographicCamera.prototype.zoomCamera = function(deltaY) {
66 76 if(deltaY > 0)
67 77 this.zoom += this.zoomDelta;
68 78 else if(deltaY < 0 && this.zoom >= 1000)
... ... @@ -70,30 +80,33 @@ class OrthographicCamera {
70 80  
71 81 this.updateSensibility();
72 82 this.update();
73   - }
  83 + };
74 84  
75   - zoomCameraManually(deltaY) {
  85 + OrthographicCamera.prototype.zoomCameraManually = function(deltaY) {
76 86 if (deltaY > 0 || this.zoom >= 1000) {
77 87 this.zoom += deltaY;
78 88 this.updateSensibility();
79 89 this.update();
80 90 }
81   - }
  91 + };
82 92  
83   - updateSensibility() {
  93 + OrthographicCamera.prototype.updateSensibility = function() {
84 94 this.sensibility = ((this.zoom / 1000) / 4) * this.baseSensibility;
85   - }
  95 + };
86 96  
87   - resetPosition() {
  97 + OrthographicCamera.prototype.resetPosition = function() {
88 98 this.offsetX = this.defaultOffsetX;
89 99 this.offsetZ = this.defaultOffsetZ;
90 100  
91 101 this.update();
92   - }
  102 + };
93 103  
94   - resetZoom() {
  104 + OrthographicCamera.prototype.resetZoom = function() {
95 105 this.zoom = this.defaultZoom;
96 106  
97 107 this.update();
98   - }
99   -}
100 108 \ No newline at end of file
  109 + };
  110 +
  111 + return OrthographicCamera;
  112 +
  113 +}());
101 114 \ No newline at end of file
... ...
js/modules/Glass.js
1   -class Glass {
  1 +var Glass = (function() {
2 2  
3   - constructor(mesh, width, glassType) {
  3 + function Glass(mesh, width, glassType) {
4 4 this.mesh = mesh;
5 5 this.mesh.containerClass = this;
6 6 this.mesh.segmentId = undefined;
7 7  
8 8 this.width = width;
9 9 this.glassType = glassType;
10   - this.type = Glass.getType(glassType, width);
  10 + this.type = Glass.GetType(glassType, width);
11 11  
12 12 this.inCart = false;
13 13 this.textPositioned = false;
... ... @@ -44,15 +44,16 @@ class Glass {
44 44 glassEnds.push(this.end1);
45 45 glassEnds.push(this.end2);
46 46  
  47 + var _this = this;
47 48 this.glass.actionManager = new BABYLON.ActionManager(scene);
48 49 this.glass.actionManager.registerAction(
49 50 new BABYLON.ExecuteCodeAction(
50   - BABYLON.ActionManager.OnPickTrigger, () => {
  51 + BABYLON.ActionManager.OnPickTrigger, function() {
51 52 if(isAutoGen) return;
52 53  
53   - meshControls.show(this);
  54 + meshControls.show(_this);
54 55  
55   - camera.setPerspectiveCameraTarget(this.mesh.position.clone(), 500);
  56 + camera.setPerspectiveCameraTarget(_this.mesh.position.clone(), 500);
56 57 }
57 58 )
58 59 );
... ... @@ -60,58 +61,53 @@ class Glass {
60 61 this.handrail.actionManager = new BABYLON.ActionManager(scene);
61 62 this.handrail.actionManager.registerAction(
62 63 new BABYLON.ExecuteCodeAction(
63   - BABYLON.ActionManager.OnPickTrigger, () => {
  64 + BABYLON.ActionManager.OnPickTrigger, function() {
64 65 if(isAutoGen) return;
65 66  
66   - meshControls.show(this);
  67 + meshControls.show(_this);
67 68  
68   - camera.setPerspectiveCameraTarget(this.mesh.position.clone(), 500);
  69 + camera.setPerspectiveCameraTarget(_this.mesh.position.clone(), 500);
69 70 }
70 71 )
71 72 );
72 73 }
73 74  
74   - changeMaterial(glassType) {
  75 + Glass.prototype.changeMaterial = function(glassType) {
75 76 this.glassType = glassType;
76   - this.type = Glass.getType(glassType, this.width);
  77 + this.type = Glass.GetType(glassType, this.width);
77 78  
78 79 this.glass.material.dispose();
79 80 this.glass.material = materialProvider.getGlassMaterialByType(glassType);
80   - }
  81 + };
81 82  
82   - isMesh(mesh) {
  83 + Glass.prototype.isMesh = function(mesh) {
83 84 return mesh === this.glass || mesh === this.handrail;
84   - }
  85 + };
85 86  
86   - getYRotation() {
  87 + Glass.prototype.getYRotation = function() {
87 88 return this.mesh.rotationQuaternion.toEulerAngles().y;
88   - }
  89 + };
89 90  
90   - useHighlight() {
  91 + Glass.prototype.useHighlight = function() {
91 92 this.handrail.material = materialProvider.getHighlightMetalMaterial();
92   - }
  93 + };
93 94  
94   - removeHighlight() {
  95 + Glass.prototype.removeHighlight = function() {
95 96 this.handrail.material = materialProvider.getMetalMaterial();
96   - }
  97 + };
97 98  
98   - updateHoverCursor(cursor) {
  99 + Glass.prototype.updateHoverCursor = function(cursor) {
99 100 this.glass.actionManager.hoverCursor = cursor;
100 101 this.handrail.actionManager.hoverCursor = cursor;
101   - }
  102 + };
102 103  
103   - rotate(amount) {
  104 + Glass.prototype.rotate = function(amount) {
104 105 if(!this.end1.connectedMesh && !this.end2.connectedMesh) {
105 106 this.mesh.rotate(BABYLON.Axis.Y, amount);
106 107 }
107   - }
  108 + };
108 109  
109   - delete() {
110   - this.removeSegment();
111   - this.dispose();
112   - }
113   -
114   - translate(x, z) {
  110 + Glass.prototype.translate = function(x, z) {
115 111 if(this.mesh.position.y !== 0) this.mesh.position.y = 0;
116 112 if((x === 0 && z === 0) || this.end1.connectedMesh || this.end2.connectedMesh) {
117 113 return;
... ... @@ -206,9 +202,9 @@ class Glass {
206 202 }
207 203  
208 204 this.updateWorldMatrix();
209   - }
  205 + };
210 206  
211   - placeGlassOnPole(pole) {
  207 + Glass.prototype.placeGlassOnPole = function(pole) {
212 208 if(pole.containerClass.type === POLE_END || pole.containerClass.type === WALL_MOUNT) {
213 209 this.attachGlassToHolder(pole.getChildren()[0], true);
214 210 }
... ... @@ -233,9 +229,9 @@ class Glass {
233 229 }
234 230 }
235 231 }
236   - }
  232 + };
237 233  
238   - attachGlassToHolder(holder, checkOtherEnd) {
  234 + Glass.prototype.attachGlassToHolder = function(holder, checkOtherEnd) {
239 235 var glassOffset = this.width / 2;
240 236 var closestEnd = this.findClosestEnd(holder);
241 237 addConnection(holder, closestEnd);
... ... @@ -285,18 +281,18 @@ class Glass {
285 281 }
286 282 this.positionText();
287 283 }
288   - }
  284 + };
289 285  
290   - updateWorldMatrix() {
  286 + Glass.prototype.updateWorldMatrix = function() {
291 287 this.mesh.computeWorldMatrix(true);
292 288 this.glass.computeWorldMatrix(true);
293 289 this.handrail.computeWorldMatrix(true);
294 290 this.end1.computeWorldMatrix(true);
295 291 this.end2.computeWorldMatrix(true);
296 292 this.widthText.computeWorldMatrix(true);
297   - }
  293 + };
298 294  
299   - checkForHolderOnOtherEnd(end) {
  295 + Glass.prototype.checkForHolderOnOtherEnd = function(end) {
300 296 for(let i = 0; i < poles.length; i++) {
301 297 if(!poles[i].containerClass.holder1.connectedMesh
302 298 && absolutePositionXAndZEquals(poles[i].containerClass.holder1, end)) {
... ... @@ -312,9 +308,9 @@ class Glass {
312 308 }
313 309 }
314 310 return false;
315   - }
  311 + };
316 312  
317   - findClosestEnd(holder) {
  313 + Glass.prototype.findClosestEnd = function(holder) {
318 314 if(BABYLON.Vector3.Distance(this.end1.absolutePosition, holder.absolutePosition) <
319 315 BABYLON.Vector3.Distance(this.end2.absolutePosition, holder.absolutePosition)) {
320 316 return this.end1;
... ... @@ -322,36 +318,32 @@ class Glass {
322 318 else {
323 319 return this.end2;
324 320 }
325   - }
  321 + };
326 322  
327   - checkForSegment(holder) {
328   - if(holder.parent.containerClass.type === POLE_180) {
329   - if(holder.segmentId) {
330   - segments[holder.segmentId].addElement(this.mesh, holder.parent);
331   - this.mesh.segmentId = holder.segmentId;
332   - }
333   - else {
334   - newSegment(holder, this.mesh);
335   - }
  323 + Glass.prototype.checkForSegment = function(holder) {
  324 + if(holder.parent.containerClass.type === POLE_180 && holder.segmentId) {
  325 + segments[holder.segmentId].addElement(this.mesh, holder.parent);
  326 + this.mesh.segmentId = holder.segmentId;
336 327 }
337 328 else {
338 329 newSegment(holder, this.mesh);
339 330 }
340   - }
  331 + };
341 332  
342   - removeSegment() {
  333 + Glass.prototype.removeSegment = function() {
343 334 if(this.mesh.segmentId) {
344 335 segments[this.mesh.segmentId].removeElement(this.mesh);
  336 + this.mesh.segmentId = undefined;
345 337 }
346   - }
  338 + };
347 339  
348   - updateSegmentId(oldId, newId) {
  340 + Glass.prototype.updateSegmentId = function(oldId, newId) {
349 341 if(this.mesh.segmentId === oldId) {
350 342 this.mesh.segmentId = newId;
351 343 }
352   - }
  344 + };
353 345  
354   - positionText() {
  346 + Glass.prototype.positionText = function() {
355 347 if(!this.mesh.segmentId || this.textPositioned)
356 348 return;
357 349  
... ... @@ -391,41 +383,44 @@ class Glass {
391 383 this.widthText.position.z = textOffsetZ;
392 384  
393 385 this.textPositioned = true;
394   - }
  386 + };
  387 +
  388 + Glass.prototype.collect = function() {
  389 + addToCart(this.type);
  390 + addToCart(Glass.GetRailing(this.width));
  391 + this.inCart = true;
  392 + updateTotalCost();
  393 + };
  394 +
  395 + Glass.prototype.discard = function() {
  396 + if (this.inCart) {
  397 + removeFromCart(this.type);
  398 + removeFromCart(Glass.GetRailing(this.width));
  399 + updateTotalCost();
  400 + }
  401 + };
395 402  
396   - dispose() {
  403 + Glass.prototype.dispose = function() {
397 404 camera.setPerspectiveCameraTarget(
398 405 new BABYLON.Vector3(terrace.width / 2, 0, terrace.depth / 2), 0);
399 406  
  407 + this.removeSegment();
  408 +
400 409 if(this.end1.connectedMesh) {
401 410 removeConnection(this.end1.connectedMesh, this.end1);
402 411 }
403 412 if(this.end2.connectedMesh) {
404 413 removeConnection(this.end2.connectedMesh, this.end2);
405 414 }
  415 +
406 416 removeGlassEndFromArray(this.end1);
407 417 removeGlassEndFromArray(this.end2);
408 418  
409 419 this.mesh.dispose();
410 420 this.discard();
411   - }
  421 + };
412 422  
413   - collect() {
414   - addToCart(this.type);
415   - addToCart(Glass.getRailing(this.width));
416   - this.inCart = true;
417   - updateTotalCost();
418   - }
419   -
420   - discard() {
421   - if (this.inCart) {
422   - removeFromCart(this.type);
423   - removeFromCart(Glass.getRailing(this.width));
424   - updateTotalCost();
425   - }
426   - }
427   -
428   - static getType(glassType, width) {
  423 + Glass.GetType = function(glassType, width) {
429 424 switch(glassType) {
430 425 case glassProvider.Types.CLEAR: {
431 426 switch (width) {
... ... @@ -510,9 +505,9 @@ class Glass {
510 505 }
511 506 }
512 507 }
513   - }
  508 + };
514 509  
515   - static getRailing(width) {
  510 + Glass.GetRailing = function(width) {
516 511 switch(width) {
517 512 case 1120:
518 513 return RAILING_1120;
... ... @@ -537,6 +532,8 @@ class Glass {
537 532 case 120:
538 533 return RAILING_120;
539 534 }
540   - }
  535 + };
  536 +
  537 + return Glass;
541 538  
542   -}
543 539 \ No newline at end of file
  540 +}());
544 541 \ No newline at end of file
... ...
js/modules/GlassProvider.js
1   -class GlassProvider {
2   - constructor() {
  1 +var GlassProvider = (function() {
  2 +
  3 + function GlassProvider() {
3 4 this.Types = {
4 5 CLEAR: 0,
5 6 FROSTED: 1,
... ... @@ -34,21 +35,22 @@ class GlassProvider {
34 35  
35 36 this.handrail100 = undefined;
36 37