hart-estate-widget 0.0.49 → 0.0.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/build/assets/css/app.css +1 -1
  2. package/build/assets/css/app.css.map +1 -1
  3. package/build/assets/sass/components/panorama.sass +38 -33
  4. package/build/assets/sass/components/tabs.sass +7 -6
  5. package/build/assets/sass/index.sass +2 -2
  6. package/build/components/Application.js +42 -25
  7. package/build/components/Buttons/FullScreenButton.js +7 -3
  8. package/build/components/Buttons/TabButton.js +4 -6
  9. package/build/components/ImageTab.js +3 -5
  10. package/build/components/Instructions.js +15 -13
  11. package/build/components/Loader.js +4 -5
  12. package/build/components/ModelTab.js +89 -54
  13. package/build/components/PanoramaTab.js +332 -207
  14. package/build/components/RotationTab.js +75 -33
  15. package/build/components/Widget.js +44 -28
  16. package/build/config/defaultConfig.js +2 -4
  17. package/build/enums/deviceOrientationStatuses.js +11 -0
  18. package/build/enums/deviceWidth.js +11 -0
  19. package/build/enums/imageExtentions.js +6 -11
  20. package/build/index.js +0 -2
  21. package/build/store/apiStore.js +177 -40
  22. package/build/store/fullScreenStore.js +90 -20
  23. package/build/store/houseStore.js +792 -693
  24. package/build/store/index.js +70 -44
  25. package/build/store/modelStore.js +194 -141
  26. package/build/threesixty/events.js +94 -71
  27. package/build/threesixty/index.js +138 -112
  28. package/build/utils/csg/csg-lib.js +383 -298
  29. package/build/utils/csg/csg-worker.js +23 -33
  30. package/build/utils/csg/three-csg.js +103 -106
  31. package/build/utils/helpers.js +12 -0
  32. package/build/utils/modelHelpers.js +46 -40
  33. package/build/utils/panoramaHelpers.js +48 -32
  34. package/package.json +7 -14
  35. package/build/enums/deviceOrientationStatus.js +0 -11
@@ -5,306 +5,374 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.Vertex = exports.Vector = exports.Polygon = exports.Plane = exports.CSG = void 0;
7
7
 
8
- require("core-js/modules/es.array.reverse.js");
9
-
10
8
  var _react = _interopRequireDefault(require("react"));
11
9
 
12
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
11
 
14
- class CSG {
15
- constructor() {
16
- this.polygons = [];
17
- }
12
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
18
13
 
19
- clone() {
20
- let csg = new CSG();
21
- csg.polygons = this.polygons.map(p => p.clone());
22
- return csg;
23
- }
14
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
24
15
 
25
- toPolygons() {
26
- return this.polygons;
27
- }
16
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
28
17
 
29
- union(csg) {
30
- let a = new Node(this.clone().polygons);
31
- let b = new Node(csg.clone().polygons);
32
- a.clipTo(b);
33
- b.clipTo(a);
34
- b.invert();
35
- b.clipTo(a);
36
- b.invert();
37
- a.build(b.allPolygons());
38
- return CSG.fromPolygons(a.allPolygons());
39
- }
18
+ var CSG = /*#__PURE__*/function () {
19
+ function CSG() {
20
+ _classCallCheck(this, CSG);
40
21
 
41
- subtract(csg) {
42
- let a = new Node(this.clone().polygons);
43
- let b = new Node(csg.clone().polygons);
44
- a.invert();
45
- a.clipTo(b);
46
- b.clipTo(a);
47
- b.invert();
48
- b.clipTo(a);
49
- b.invert();
50
- a.build(b.allPolygons());
51
- a.invert();
52
- return CSG.fromPolygons(a.allPolygons());
22
+ this.polygons = [];
53
23
  }
54
24
 
55
- intersect(csg) {
56
- let a = new Node(this.clone().polygons);
57
- let b = new Node(csg.clone().polygons);
58
- a.invert();
59
- b.clipTo(a);
60
- b.invert();
61
- a.clipTo(b);
62
- b.clipTo(a);
63
- a.build(b.allPolygons());
64
- a.invert();
65
- return CSG.fromPolygons(a.allPolygons());
66
- } // Return a new CSG solid with solid and empty space switched. This solid is
67
- // not modified.
68
-
69
-
70
- inverse() {
71
- let csg = this.clone();
72
- csg.polygons.forEach(p => p.flip());
73
- return csg;
74
- }
25
+ _createClass(CSG, [{
26
+ key: "clone",
27
+ value: function clone() {
28
+ var csg = new CSG();
29
+ csg.polygons = this.polygons.map(function (p) {
30
+ return p.clone();
31
+ });
32
+ return csg;
33
+ }
34
+ }, {
35
+ key: "toPolygons",
36
+ value: function toPolygons() {
37
+ return this.polygons;
38
+ }
39
+ }, {
40
+ key: "union",
41
+ value: function union(csg) {
42
+ var a = new Node(this.clone().polygons);
43
+ var b = new Node(csg.clone().polygons);
44
+ a.clipTo(b);
45
+ b.clipTo(a);
46
+ b.invert();
47
+ b.clipTo(a);
48
+ b.invert();
49
+ a.build(b.allPolygons());
50
+ return CSG.fromPolygons(a.allPolygons());
51
+ }
52
+ }, {
53
+ key: "subtract",
54
+ value: function subtract(csg) {
55
+ var a = new Node(this.clone().polygons);
56
+ var b = new Node(csg.clone().polygons);
57
+ a.invert();
58
+ a.clipTo(b);
59
+ b.clipTo(a);
60
+ b.invert();
61
+ b.clipTo(a);
62
+ b.invert();
63
+ a.build(b.allPolygons());
64
+ a.invert();
65
+ return CSG.fromPolygons(a.allPolygons());
66
+ }
67
+ }, {
68
+ key: "intersect",
69
+ value: function intersect(csg) {
70
+ var a = new Node(this.clone().polygons);
71
+ var b = new Node(csg.clone().polygons);
72
+ a.invert();
73
+ b.clipTo(a);
74
+ b.invert();
75
+ a.clipTo(b);
76
+ b.clipTo(a);
77
+ a.build(b.allPolygons());
78
+ a.invert();
79
+ return CSG.fromPolygons(a.allPolygons());
80
+ } // Return a new CSG solid with solid and empty space switched. This solid is
81
+ // not modified.
82
+
83
+ }, {
84
+ key: "inverse",
85
+ value: function inverse() {
86
+ var csg = this.clone();
87
+ csg.polygons.forEach(function (p) {
88
+ return p.flip();
89
+ });
90
+ return csg;
91
+ }
92
+ }]);
75
93
 
76
- }
94
+ return CSG;
95
+ }();
77
96
 
78
97
  exports.CSG = CSG;
79
98
 
80
99
  CSG.fromPolygons = function (polygons) {
81
- let csg = new CSG();
100
+ var csg = new CSG();
82
101
  csg.polygons = polygons;
83
102
  return csg;
84
103
  };
85
104
 
86
- class Vector {
87
- constructor() {
88
- let x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
89
- let y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
90
- let z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
105
+ var Vector = /*#__PURE__*/function () {
106
+ function Vector() {
107
+ var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
108
+ var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
109
+ var z = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
110
+
111
+ _classCallCheck(this, Vector);
112
+
91
113
  this.x = x;
92
114
  this.y = y;
93
115
  this.z = z;
94
116
  }
95
117
 
96
- copy(v) {
97
- this.x = v.x;
98
- this.y = v.y;
99
- this.z = v.z;
100
- return this;
101
- }
102
-
103
- clone() {
104
- return new Vector(this.x, this.y, this.z);
105
- }
106
-
107
- negate() {
108
- this.x *= -1;
109
- this.y *= -1;
110
- this.z *= -1;
111
- return this;
112
- }
113
-
114
- add(a) {
115
- this.x += a.x;
116
- this.y += a.y;
117
- this.z += a.z;
118
- return this;
119
- }
120
-
121
- sub(a) {
122
- this.x -= a.x;
123
- this.y -= a.y;
124
- this.z -= a.z;
125
- return this;
126
- }
127
-
128
- times(a) {
129
- this.x *= a;
130
- this.y *= a;
131
- this.z *= a;
132
- return this;
133
- }
134
-
135
- dividedBy(a) {
136
- this.x /= a;
137
- this.y /= a;
138
- this.z /= a;
139
- return this;
140
- }
141
-
142
- lerp(a, t) {
143
- return this.add(tv0.copy(a).sub(this).times(t));
144
- }
145
-
146
- unit() {
147
- return this.dividedBy(this.length());
148
- }
149
-
150
- length() {
151
- return Math.sqrt(this.x ** 2 + this.y ** 2 + this.z ** 2);
152
- }
153
-
154
- normalize() {
155
- return this.unit();
156
- }
157
-
158
- cross(b) {
159
- let a = this;
160
- const ax = a.x,
118
+ _createClass(Vector, [{
119
+ key: "copy",
120
+ value: function copy(v) {
121
+ this.x = v.x;
122
+ this.y = v.y;
123
+ this.z = v.z;
124
+ return this;
125
+ }
126
+ }, {
127
+ key: "clone",
128
+ value: function clone() {
129
+ return new Vector(this.x, this.y, this.z);
130
+ }
131
+ }, {
132
+ key: "negate",
133
+ value: function negate() {
134
+ this.x *= -1;
135
+ this.y *= -1;
136
+ this.z *= -1;
137
+ return this;
138
+ }
139
+ }, {
140
+ key: "add",
141
+ value: function add(a) {
142
+ this.x += a.x;
143
+ this.y += a.y;
144
+ this.z += a.z;
145
+ return this;
146
+ }
147
+ }, {
148
+ key: "sub",
149
+ value: function sub(a) {
150
+ this.x -= a.x;
151
+ this.y -= a.y;
152
+ this.z -= a.z;
153
+ return this;
154
+ }
155
+ }, {
156
+ key: "times",
157
+ value: function times(a) {
158
+ this.x *= a;
159
+ this.y *= a;
160
+ this.z *= a;
161
+ return this;
162
+ }
163
+ }, {
164
+ key: "dividedBy",
165
+ value: function dividedBy(a) {
166
+ this.x /= a;
167
+ this.y /= a;
168
+ this.z /= a;
169
+ return this;
170
+ }
171
+ }, {
172
+ key: "lerp",
173
+ value: function lerp(a, t) {
174
+ return this.add(tv0.copy(a).sub(this).times(t));
175
+ }
176
+ }, {
177
+ key: "unit",
178
+ value: function unit() {
179
+ return this.dividedBy(this.length());
180
+ }
181
+ }, {
182
+ key: "length",
183
+ value: function length() {
184
+ return Math.sqrt(Math.pow(this.x, 2) + Math.pow(this.y, 2) + Math.pow(this.z, 2));
185
+ }
186
+ }, {
187
+ key: "normalize",
188
+ value: function normalize() {
189
+ return this.unit();
190
+ }
191
+ }, {
192
+ key: "cross",
193
+ value: function cross(b) {
194
+ var a = this;
195
+ var ax = a.x,
161
196
  ay = a.y,
162
197
  az = a.z;
163
- const bx = b.x,
198
+ var bx = b.x,
164
199
  by = b.y,
165
200
  bz = b.z;
166
- this.x = ay * bz - az * by;
167
- this.y = az * bx - ax * bz;
168
- this.z = ax * by - ay * bx;
169
- return this;
170
- }
171
-
172
- dot(b) {
173
- return this.x * b.x + this.y * b.y + this.z * b.z;
174
- }
201
+ this.x = ay * bz - az * by;
202
+ this.y = az * bx - ax * bz;
203
+ this.z = ax * by - ay * bx;
204
+ return this;
205
+ }
206
+ }, {
207
+ key: "dot",
208
+ value: function dot(b) {
209
+ return this.x * b.x + this.y * b.y + this.z * b.z;
210
+ }
211
+ }]);
175
212
 
176
- }
213
+ return Vector;
214
+ }();
177
215
 
178
216
  exports.Vector = Vector;
179
- let tv0 = new Vector();
180
- let tv1 = new Vector();
217
+ var tv0 = new Vector();
218
+ var tv1 = new Vector();
219
+
220
+ var Vertex = /*#__PURE__*/function () {
221
+ function Vertex(pos, normal, uv, color) {
222
+ _classCallCheck(this, Vertex);
181
223
 
182
- class Vertex {
183
- constructor(pos, normal, uv, color) {
184
224
  this.pos = new Vector().copy(pos);
185
225
  this.normal = new Vector().copy(normal);
186
226
  uv && (this.uv = new Vector().copy(uv)) && (this.uv.z = 0);
187
227
  color && (this.color = new Vector().copy(color));
188
228
  }
189
229
 
190
- clone() {
191
- return new Vertex(this.pos, this.normal, this.uv, this.color);
192
- }
193
-
194
- flip() {
195
- this.normal.negate();
196
- }
197
-
198
- interpolate(other, t) {
199
- return new Vertex(this.pos.clone().lerp(other.pos, t), this.normal.clone().lerp(other.normal, t), this.uv && other.uv && this.uv.clone().lerp(other.uv, t), this.color && other.color && this.color.clone().lerp(other.color, t));
200
- }
230
+ _createClass(Vertex, [{
231
+ key: "clone",
232
+ value: function clone() {
233
+ return new Vertex(this.pos, this.normal, this.uv, this.color);
234
+ }
235
+ }, {
236
+ key: "flip",
237
+ value: function flip() {
238
+ this.normal.negate();
239
+ }
240
+ }, {
241
+ key: "interpolate",
242
+ value: function interpolate(other, t) {
243
+ return new Vertex(this.pos.clone().lerp(other.pos, t), this.normal.clone().lerp(other.normal, t), this.uv && other.uv && this.uv.clone().lerp(other.uv, t), this.color && other.color && this.color.clone().lerp(other.color, t));
244
+ }
245
+ }]);
201
246
 
202
- }
247
+ return Vertex;
248
+ }();
203
249
 
204
250
  exports.Vertex = Vertex;
205
251
 
206
- class Plane {
207
- constructor(normal, w) {
252
+ var Plane = /*#__PURE__*/function () {
253
+ function Plane(normal, w) {
254
+ _classCallCheck(this, Plane);
255
+
208
256
  this.normal = normal;
209
257
  this.w = w;
210
258
  }
211
259
 
212
- clone() {
213
- return new Plane(this.normal.clone(), this.w);
214
- }
215
-
216
- flip() {
217
- this.normal.negate();
218
- this.w = -this.w;
219
- }
220
-
221
- splitPolygon(polygon, coplanarFront, coplanarBack, front, back) {
222
- const COPLANAR = 0;
223
- const FRONT = 1;
224
- const BACK = 2;
225
- const SPANNING = 3;
226
- let polygonType = 0;
227
- let types = [];
228
-
229
- for (let i = 0; i < polygon.vertices.length; i++) {
230
- let t = this.normal.dot(polygon.vertices[i].pos) - this.w;
231
- let type = t < -Plane.EPSILON ? BACK : t > Plane.EPSILON ? FRONT : COPLANAR;
232
- polygonType |= type;
233
- types.push(type);
234
- }
235
-
236
- switch (polygonType) {
237
- case COPLANAR:
238
- (this.normal.dot(polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
239
- break;
240
-
241
- case FRONT:
242
- front.push(polygon);
243
- break;
244
-
245
- case BACK:
246
- back.push(polygon);
247
- break;
248
-
249
- case SPANNING:
250
- let f = [];
251
- let b = [];
252
-
253
- for (let i = 0; i < polygon.vertices.length; i++) {
254
- let j = (i + 1) % polygon.vertices.length;
255
- let ti = types[i],
256
- tj = types[j];
257
- let vi = polygon.vertices[i],
258
- vj = polygon.vertices[j];
259
- if (ti != BACK) f.push(vi);
260
- if (ti != FRONT) b.push(ti != BACK ? vi.clone() : vi);
261
-
262
- if ((ti | tj) == SPANNING) {
263
- let t = (this.w - this.normal.dot(vi.pos)) / this.normal.dot(tv0.copy(vj.pos).sub(vi.pos));
264
- let v = vi.interpolate(vj, t);
265
- f.push(v);
266
- b.push(v.clone());
260
+ _createClass(Plane, [{
261
+ key: "clone",
262
+ value: function clone() {
263
+ return new Plane(this.normal.clone(), this.w);
264
+ }
265
+ }, {
266
+ key: "flip",
267
+ value: function flip() {
268
+ this.normal.negate();
269
+ this.w = -this.w;
270
+ }
271
+ }, {
272
+ key: "splitPolygon",
273
+ value: function splitPolygon(polygon, coplanarFront, coplanarBack, front, back) {
274
+ var COPLANAR = 0;
275
+ var FRONT = 1;
276
+ var BACK = 2;
277
+ var SPANNING = 3;
278
+ var polygonType = 0;
279
+ var types = [];
280
+
281
+ for (var i = 0; i < polygon.vertices.length; i++) {
282
+ var t = this.normal.dot(polygon.vertices[i].pos) - this.w;
283
+ var type = t < -Plane.EPSILON ? BACK : t > Plane.EPSILON ? FRONT : COPLANAR;
284
+ polygonType |= type;
285
+ types.push(type);
286
+ }
287
+
288
+ switch (polygonType) {
289
+ case COPLANAR:
290
+ (this.normal.dot(polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
291
+ break;
292
+
293
+ case FRONT:
294
+ front.push(polygon);
295
+ break;
296
+
297
+ case BACK:
298
+ back.push(polygon);
299
+ break;
300
+
301
+ case SPANNING:
302
+ var f = [];
303
+ var b = [];
304
+
305
+ for (var _i = 0; _i < polygon.vertices.length; _i++) {
306
+ var j = (_i + 1) % polygon.vertices.length;
307
+ var ti = types[_i],
308
+ tj = types[j];
309
+ var vi = polygon.vertices[_i],
310
+ vj = polygon.vertices[j];
311
+ if (ti != BACK) f.push(vi);
312
+ if (ti != FRONT) b.push(ti != BACK ? vi.clone() : vi);
313
+
314
+ if ((ti | tj) == SPANNING) {
315
+ var _t = (this.w - this.normal.dot(vi.pos)) / this.normal.dot(tv0.copy(vj.pos).sub(vi.pos));
316
+
317
+ var v = vi.interpolate(vj, _t);
318
+ f.push(v);
319
+ b.push(v.clone());
320
+ }
267
321
  }
268
- }
269
322
 
270
- if (f.length >= 3) front.push(new Polygon(f, polygon.shared));
271
- if (b.length >= 3) back.push(new Polygon(b, polygon.shared));
272
- break;
323
+ if (f.length >= 3) front.push(new Polygon(f, polygon.shared));
324
+ if (b.length >= 3) back.push(new Polygon(b, polygon.shared));
325
+ break;
326
+ }
273
327
  }
274
- }
328
+ }]);
275
329
 
276
- }
330
+ return Plane;
331
+ }();
277
332
 
278
333
  exports.Plane = Plane;
279
334
  Plane.EPSILON = 1e-5;
280
335
 
281
336
  Plane.fromPoints = function (a, b, c) {
282
- let n = tv0.copy(b).sub(a).cross(tv1.copy(c).sub(a)).normalize();
337
+ var n = tv0.copy(b).sub(a).cross(tv1.copy(c).sub(a)).normalize();
283
338
  return new Plane(n.clone(), n.dot(a));
284
339
  };
285
340
 
286
- class Polygon {
287
- constructor(vertices, shared) {
341
+ var Polygon = /*#__PURE__*/function () {
342
+ function Polygon(vertices, shared) {
343
+ _classCallCheck(this, Polygon);
344
+
288
345
  this.vertices = vertices;
289
346
  this.shared = shared;
290
347
  this.plane = Plane.fromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
291
348
  }
292
349
 
293
- clone() {
294
- return new Polygon(this.vertices.map(v => v.clone()), this.shared);
295
- }
296
-
297
- flip() {
298
- this.vertices.reverse().forEach(v => v.flip());
299
- this.plane.flip();
300
- }
350
+ _createClass(Polygon, [{
351
+ key: "clone",
352
+ value: function clone() {
353
+ return new Polygon(this.vertices.map(function (v) {
354
+ return v.clone();
355
+ }), this.shared);
356
+ }
357
+ }, {
358
+ key: "flip",
359
+ value: function flip() {
360
+ this.vertices.reverse().forEach(function (v) {
361
+ return v.flip();
362
+ });
363
+ this.plane.flip();
364
+ }
365
+ }]);
301
366
 
302
- }
367
+ return Polygon;
368
+ }();
303
369
 
304
370
  exports.Polygon = Polygon;
305
371
 
306
- class Node {
307
- constructor(polygons) {
372
+ var Node = /*#__PURE__*/function () {
373
+ function Node(polygons) {
374
+ _classCallCheck(this, Node);
375
+
308
376
  this.plane = null;
309
377
  this.front = null;
310
378
  this.back = null;
@@ -312,76 +380,93 @@ class Node {
312
380
  if (polygons) this.build(polygons);
313
381
  }
314
382
 
315
- clone() {
316
- let node = new Node();
317
- node.plane = this.plane && this.plane.clone();
318
- node.front = this.front && this.front.clone();
319
- node.back = this.back && this.back.clone();
320
- node.polygons = this.polygons.map(p => p.clone());
321
- return node;
322
- }
323
-
324
- invert() {
325
- for (let i = 0; i < this.polygons.length; i++) this.polygons[i].flip();
326
-
327
- this.plane && this.plane.flip();
328
- this.front && this.front.invert();
329
- this.back && this.back.invert();
330
- let temp = this.front;
331
- this.front = this.back;
332
- this.back = temp;
333
- }
334
-
335
- clipPolygons(polygons) {
336
- if (!this.plane) return polygons.slice();
337
- let front = [],
338
- back = [];
339
-
340
- for (let i = 0; i < polygons.length; i++) {
341
- this.plane.splitPolygon(polygons[i], front, back, front, back);
383
+ _createClass(Node, [{
384
+ key: "clone",
385
+ value: function clone() {
386
+ var node = new Node();
387
+ node.plane = this.plane && this.plane.clone();
388
+ node.front = this.front && this.front.clone();
389
+ node.back = this.back && this.back.clone();
390
+ node.polygons = this.polygons.map(function (p) {
391
+ return p.clone();
392
+ });
393
+ return node;
342
394
  }
343
-
344
- if (this.front) front = this.front.clipPolygons(front);
345
- if (this.back) back = this.back.clipPolygons(back);else back = [];
346
- return front.concat(back);
347
- }
348
-
349
- clipTo(bsp) {
350
- this.polygons = bsp.clipPolygons(this.polygons);
351
- if (this.front) this.front.clipTo(bsp);
352
- if (this.back) this.back.clipTo(bsp);
353
- }
354
-
355
- allPolygons() {
356
- let polygons = this.polygons.slice();
357
- if (this.front) polygons = polygons.concat(this.front.allPolygons());
358
- if (this.back) polygons = polygons.concat(this.back.allPolygons());
359
- return polygons;
360
- }
361
-
362
- build(polygons) {
363
- if (!polygons.length) return;
364
- if (!this.plane) this.plane = polygons[0].plane.clone();
365
- let front = [],
366
- back = [];
367
-
368
- for (let i = 0; i < polygons.length; i++) {
369
- this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
395
+ }, {
396
+ key: "invert",
397
+ value: function invert() {
398
+ for (var i = 0; i < this.polygons.length; i++) {
399
+ this.polygons[i].flip();
400
+ }
401
+
402
+ this.plane && this.plane.flip();
403
+ this.front && this.front.invert();
404
+ this.back && this.back.invert();
405
+ var temp = this.front;
406
+ this.front = this.back;
407
+ this.back = temp;
370
408
  }
371
-
372
- if (front.length) {
373
- if (!this.front) this.front = new Node();
374
- this.front.build(front);
409
+ }, {
410
+ key: "clipPolygons",
411
+ value: function clipPolygons(polygons) {
412
+ if (!this.plane) return polygons.slice();
413
+ var front = [],
414
+ back = [];
415
+
416
+ for (var i = 0; i < polygons.length; i++) {
417
+ this.plane.splitPolygon(polygons[i], front, back, front, back);
418
+ }
419
+
420
+ if (this.front) front = this.front.clipPolygons(front);
421
+ if (this.back) back = this.back.clipPolygons(back);else back = [];
422
+ return front.concat(back);
375
423
  }
376
-
377
- if (back.length) {
378
- if (!this.back) this.back = new Node();
379
- this.back.build(back);
424
+ }, {
425
+ key: "clipTo",
426
+ value: function clipTo(bsp) {
427
+ this.polygons = bsp.clipPolygons(this.polygons);
428
+ if (this.front) this.front.clipTo(bsp);
429
+ if (this.back) this.back.clipTo(bsp);
380
430
  }
381
- }
431
+ }, {
432
+ key: "allPolygons",
433
+ value: function allPolygons() {
434
+ var polygons = this.polygons.slice();
435
+ if (this.front) polygons = polygons.concat(this.front.allPolygons());
436
+ if (this.back) polygons = polygons.concat(this.back.allPolygons());
437
+ return polygons;
438
+ }
439
+ }, {
440
+ key: "build",
441
+ value: function build(polygons) {
442
+ if (!polygons.length) return;
443
+ if (!this.plane) this.plane = polygons[0].plane.clone();
444
+ var front = [],
445
+ back = [];
446
+
447
+ for (var i = 0; i < polygons.length; i++) {
448
+ this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
449
+ }
450
+
451
+ if (front.length) {
452
+ if (!this.front) this.front = new Node();
453
+ this.front.build(front);
454
+ }
455
+
456
+ if (back.length) {
457
+ if (!this.back) this.back = new Node();
458
+ this.back.build(back);
459
+ }
460
+ }
461
+ }]);
382
462
 
383
- }
463
+ return Node;
464
+ }();
384
465
 
385
466
  CSG.fromJSON = function (json) {
386
- return CSG.fromPolygons(json.polygons.map(p => new Polygon(p.vertices.map(v => new Vertex(v.pos, v.normal, v.uv)), p.shared)));
467
+ return CSG.fromPolygons(json.polygons.map(function (p) {
468
+ return new Polygon(p.vertices.map(function (v) {
469
+ return new Vertex(v.pos, v.normal, v.uv);
470
+ }), p.shared);
471
+ }));
387
472
  };