Commit 785195d46700273590e723166ffa578825f64513

Authored by Gustav Johansen
1 parent 0acb52fd

Noe fiks på veggfeste, gjort det mulig å velge veggfeste ved å trykke på veggen

js/Glass.js
... ... @@ -84,6 +84,10 @@ class Glass {
84 84 }
85 85 }
86 86  
  87 + isMesh(mesh) {
  88 + return mesh === this.glass || mesh === this.handrail;
  89 + }
  90 +
87 91 getYRotation() {
88 92 return this.mesh.rotationQuaternion.toEulerAngles().y;
89 93 }
... ... @@ -252,7 +256,7 @@ class Glass {
252 256 }
253 257  
254 258 placeGlassOnPole(pole) {
255   - if(pole.getChildren().length === 1) {
  259 + if(pole.containerClass.type === POLE_END || pole.containerClass.type === WALL_MOUNT) {
256 260 this.attachGlassToHolder(pole.getChildren()[0]);
257 261 }
258 262 else {
... ... @@ -326,7 +330,6 @@ class Glass {
326 330 this.mesh.position = holder.absolutePosition.clone();
327 331 var rotation = holder.rotationQuaternion.multiply(holder.parent.rotationQuaternion)
328 332 .multiply(closestEnd.rotationQuaternion);
329   - // TODO: Finn riktig offset på holdere.
330 333 if(holder.name === "pole135.holder1") {
331 334 rotation.multiplyInPlace(new BABYLON.Quaternion(0, -0.9238795325112866, 0, 0.3826834323650897));
332 335 }
... ...
js/MeshControls.js
... ... @@ -104,15 +104,8 @@ class MeshControls {
104 104  
105 105 onPointerDown() {
106 106 var pickInfo = scene.pick(scene.pointerX, scene.pointerY, (mesh) => {
107   - if (this.meshClass instanceof Glass) {
108   - if (mesh === this.meshClass.glass || mesh === this.meshClass.handrail) {
109   - return true;
110   - }
111   - }
112   - else {
113   - if (mesh === this.meshClass.mesh || mesh === this.meshClass.mesh.getChildren()[1]) {
114   - return true;
115   - }
  107 + if(this.meshClass.isMesh(mesh)) {
  108 + return true;
116 109 }
117 110 });
118 111  
... ...
js/app.js
... ... @@ -306,11 +306,13 @@ function addGlass(glass) {
306 306  
307 307 function placeGlass(meshClass) {
308 308 meshControls.show(meshClass);
  309 + meshClass.mesh.markAsDirty();
309 310 meshClass.collect();
310 311 }
311 312  
312 313 function placePole(meshClass) {
313 314 meshControls.show(meshClass);
  315 + meshClass.mesh.markAsDirty();
314 316 meshClass.collect();
315 317 }
316 318  
... ...
js/pole/Pole.js
... ... @@ -60,7 +60,27 @@ class Pole {
60 60 camera.setPerspectiveCameraTarget(this.mesh.position.clone(), 500);
61 61 }
62 62 )
63   - )
  63 + );
  64 +
  65 + if(this.type === WALL_MOUNT) {
  66 + var wall = this.mesh.getChildren()[1];
  67 + wall.actionManager = new BABYLON.ActionManager(scene);
  68 + wall.actionManager.registerAction(
  69 + new BABYLON.ExecuteCodeAction(
  70 + BABYLON.ActionManager.OnPickTrigger, () => {
  71 + if(meshControls.meshClass !== this) {
  72 + meshControls.show(this);
  73 + }
  74 +
  75 + camera.setPerspectiveCameraTarget(this.mesh.position.clone(), 500);
  76 + }
  77 + )
  78 + );
  79 + }
  80 + }
  81 +
  82 + isMesh(mesh) {
  83 + return mesh === this.mesh || (this.type === WALL_MOUNT && mesh === this.mesh.getChildren()[1]);
64 84 }
65 85  
66 86 getYRotation() {
... ... @@ -86,6 +106,9 @@ class Pole {
86 106  
87 107 updateHoverCursor(cursor) {
88 108 this.mesh.actionManager.hoverCursor = cursor;
  109 + if(this.type === WALL_MOUNT) {
  110 + this.mesh.getChildren()[1].actionManager.hoverCursor = cursor;
  111 + }
89 112 }
90 113  
91 114 rotate(amount) {
... ... @@ -321,6 +344,7 @@ class Pole {
321 344 addConnection(holder, glassEnd);
322 345  
323 346 this.mesh.markAsDirty();
  347 + this.onTerrace = true;
324 348  
325 349 setTimeout(() => {
326 350 this.checkForSegment(holder, glassEnd.parent);
... ...
js/pole/PoleProvider.js
... ... @@ -257,7 +257,7 @@ class PoleProvider {
257 257  
258 258 let holder1 = BABYLON.MeshBuilder.CreateBox("holder1", {size: 10}, scene);
259 259 holder1.position.x -= 34.69;
260   - holder1.position.y -= 6;
  260 + holder1.position.y = 0;
261 261 holder1.isVisible = false;
262 262 this.wallMount.addChild(holder1);
263 263  
... ... @@ -347,7 +347,7 @@ class PoleProvider {
347 347 wallMount.addLODLevel(this.lodDistance, poleLod);
348 348 }
349 349  
350   - wallMount.getChildren()[0].isVisible = true; // Holder
  350 + //wallMount.getChildren()[0].isVisible = true; // Holder
351 351 wallMount.getChildren()[1].isVisible = true; // Wall
352 352  
353 353 wallMount.position.y = 0;
... ...