Commit c1caa6a18b49da99b40559737a927dcde02acbc3

Authored by Gustav Johansen
1 parent 785195d4

Fjernet muligheten til å dra moduler ut når de allerede er festet

Showing 3 changed files with 14 additions and 54 deletions   Show diff stats
js/Glass.js
... ... @@ -123,7 +123,6 @@ class Glass {
123 123 }
124 124  
125 125 delete() {
126   - // TODO: Hva skjer med segment på stolpe?
127 126 this.removeSegment();
128 127 this.dispose();
129 128 }
... ... @@ -132,28 +131,7 @@ class Glass {
132 131 if(x === 0 && z === 0) {
133 132 return false;
134 133 }
135   - if(this.end1.connectedMesh && this.end2.connectedMesh) {
136   - return false;
137   - }
138   - else if(this.end1.connectedMesh) {
139   - if(Math.abs(x) > 70 || Math.abs(z) > 70) {
140   - removeConnection(this.end1.connectedMesh, this.end1);
141   - this.removeSegment();
142   - }
143   - else {
144   - return false;
145   - }
146   - }
147   - else if(this.end2.connectedMesh) {
148   - if(Math.abs(x) > 70 || Math.abs(z) > 70) {
149   - removeConnection(this.end2.connectedMesh, this.end2);
150   - this.removeSegment();
151   - }
152   - else {
153   - return false;
154   - }
155   - }
156   - return true;
  134 + return !(this.end1.connectedMesh || this.end2.connectedMesh);
157 135 }
158 136  
159 137 translate(x, z) {
... ...
js/Segment.js
... ... @@ -279,13 +279,19 @@ class Segment {
279 279 }
280 280  
281 281 addElement(mesh, connectedMesh) {
282   - if(connectedMesh === this.elements[0]) {
283   - this.elements.unshift(mesh);
  282 + try {
  283 + if(connectedMesh === this.elements[0]) {
  284 + this.elements.unshift(mesh);
  285 + }
  286 + else if(connectedMesh === this.elements[this.elements.length - 1]) {
  287 + this.elements.push(mesh);
  288 + }
  289 + this.drawLength();
284 290 }
285   - else if(connectedMesh === this.elements[this.elements.length - 1]) {
286   - this.elements.push(mesh);
  291 + catch(e) {
  292 + console.log("Noe gikk galt");
  293 + console.log(e);
287 294 }
288   - this.drawLength();
289 295 }
290 296  
291 297 removeElement(meshId) {
... ...
js/pole/Pole.js
... ... @@ -206,37 +206,13 @@ class Pole {
206 206 }
207 207 if(this.type === POLE_END || this.type === WALL_MOUNT) {
208 208 if(this.holder1.connectedMesh) {
209   - if(Math.abs(x) < 70 && Math.abs(z) < 70) {
210   - return false;
211   - }
212   - else {
213   - removeConnection(this.holder1, this.holder1.connectedMesh);
214   - this.removeSegment(this.holder1);
215   - }
  209 + return false;
216 210 }
217 211 }
218 212 else {
219   - if(this.holder1.connectedMesh && this.holder2.connectedMesh) {
  213 + if(this.holder1.connectedMesh || this.holder2.connectedMesh) {
220 214 return false;
221 215 }
222   - else if(this.holder1.connectedMesh) {
223   - if(Math.abs(x) > 70 || Math.abs(z) > 70) {
224   - removeConnection(this.holder1, this.holder1.connectedMesh);
225   - this.removeSegment(this.holder1);
226   - }
227   - else {
228   - return false;
229   - }
230   - }
231   - else if(this.holder2.connectedMesh) {
232   - if(Math.abs(x) > 70 || Math.abs(z) > 70) {
233   - removeConnection(this.holder2, this.holder2.connectedMesh);
234   - this.removeSegment(this.holder2);
235   - }
236   - else {
237   - return false;
238   - }
239   - }
240 216 }
241 217 return true;
242 218 }
... ...