hart-estate-widget 0.0.64 → 0.0.67
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.
- package/README.md +7 -3
- package/package.json +17 -5
- package/build/assets/css/app.css +0 -1
- package/build/assets/css/app.css.map +0 -1
- package/build/assets/fonts/RobotoMono/RobotoMono-Bold.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Bold.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Bold.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-BoldItalic.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-BoldItalic.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-BoldItalic.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Italic.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Italic.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Italic.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Light.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Light.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Light.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-LightItalic.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-LightItalic.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-LightItalic.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Medium.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Medium.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Medium.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-MediumItalic.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-MediumItalic.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-MediumItalic.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Regular.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Regular.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Regular.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Thin.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Thin.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Thin.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono.css +0 -98
- package/build/assets/icons/1x.svg +0 -4
- package/build/assets/icons/2x.svg +0 -4
- package/build/assets/icons/bullet.png +0 -0
- package/build/assets/icons/close.svg +0 -4
- package/build/assets/icons/enter-fullscreen.svg +0 -6
- package/build/assets/icons/hand-move.svg +0 -15
- package/build/assets/icons/hand-research.svg +0 -12
- package/build/assets/icons/rotation-close.svg +0 -6
- package/build/assets/icons/rotation.svg +0 -4
- package/build/assets/img/3D.jpg +0 -0
- package/build/assets/img/door-icon.png +0 -0
- package/build/assets/img/door-texture.jpeg +0 -0
- package/build/assets/img/exterior-wall-texture-roughness.jpg +0 -0
- package/build/assets/img/exterior-wall-texture.jpeg +0 -0
- package/build/assets/img/floor-bathroom.jpg +0 -0
- package/build/assets/img/floor-dark.png +0 -0
- package/build/assets/img/floor-white.png +0 -0
- package/build/assets/img/floor.jpg +0 -0
- package/build/assets/img/grass.png +0 -0
- package/build/assets/img/logo.svg +0 -11
- package/build/assets/img/refresh-icon.svg +0 -6
- package/build/assets/img/spot-icon.png +0 -0
- package/build/assets/img/wall-texture.jpg +0 -0
- package/build/assets/sass/components/instructions.sass +0 -94
- package/build/assets/sass/components/loader.sass +0 -54
- package/build/assets/sass/components/model.sass +0 -27
- package/build/assets/sass/components/panorama.sass +0 -174
- package/build/assets/sass/components/rotation.sass +0 -106
- package/build/assets/sass/components/tabs.sass +0 -121
- package/build/assets/sass/index.sass +0 -65
- package/build/assets/sass/mixin.sass +0 -48
- package/build/assets/sass/vars.sass +0 -28
- package/build/components/Application.js +0 -132
- package/build/components/Buttons/FullScreenButton.js +0 -50
- package/build/components/Buttons/TabButton.js +0 -24
- package/build/components/Instructions.js +0 -54
- package/build/components/Loader.js +0 -22
- package/build/components/ModelTab.js +0 -213
- package/build/components/PanoramaTab.js +0 -620
- package/build/components/RotationTab.js +0 -152
- package/build/components/Widget.js +0 -130
- package/build/config/defaultConfig.js +0 -30
- package/build/enums/deviceOrientationStatuses.js +0 -11
- package/build/enums/deviceWidth.js +0 -21
- package/build/enums/imageExtentions.js +0 -16
- package/build/index.css +0 -2
- package/build/index.js +0 -67
- package/build/locale/en/data.json +0 -25
- package/build/locale/index.js +0 -71
- package/build/locale/ru/data.json +0 -25
- package/build/store/apiStore.js +0 -231
- package/build/store/deviceStore.js +0 -60
- package/build/store/fullScreenStore.js +0 -159
- package/build/store/houseStore.js +0 -952
- package/build/store/index.js +0 -124
- package/build/store/modelStore.js +0 -338
- package/build/threesixty/events.js +0 -220
- package/build/threesixty/index.js +0 -264
- package/build/utils/csg/csg-lib.js +0 -472
- package/build/utils/csg/csg-worker.js +0 -84
- package/build/utils/csg/three-csg.js +0 -277
- package/build/utils/helpers.js +0 -12
- package/build/utils/modelHelpers.js +0 -161
- package/build/utils/panoramaHelpers.js +0 -117
@@ -1,472 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.Vertex = exports.Vector = exports.Polygon = exports.Plane = exports.CSG = void 0;
|
7
|
-
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
9
|
-
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
-
|
12
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
13
|
-
|
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); } }
|
15
|
-
|
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; }
|
17
|
-
|
18
|
-
var CSG = /*#__PURE__*/function () {
|
19
|
-
function CSG() {
|
20
|
-
_classCallCheck(this, CSG);
|
21
|
-
|
22
|
-
this.polygons = [];
|
23
|
-
}
|
24
|
-
|
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
|
-
}]);
|
93
|
-
|
94
|
-
return CSG;
|
95
|
-
}();
|
96
|
-
|
97
|
-
exports.CSG = CSG;
|
98
|
-
|
99
|
-
CSG.fromPolygons = function (polygons) {
|
100
|
-
var csg = new CSG();
|
101
|
-
csg.polygons = polygons;
|
102
|
-
return csg;
|
103
|
-
};
|
104
|
-
|
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
|
-
|
113
|
-
this.x = x;
|
114
|
-
this.y = y;
|
115
|
-
this.z = z;
|
116
|
-
}
|
117
|
-
|
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,
|
196
|
-
ay = a.y,
|
197
|
-
az = a.z;
|
198
|
-
var bx = b.x,
|
199
|
-
by = b.y,
|
200
|
-
bz = b.z;
|
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
|
-
}]);
|
212
|
-
|
213
|
-
return Vector;
|
214
|
-
}();
|
215
|
-
|
216
|
-
exports.Vector = 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);
|
223
|
-
|
224
|
-
this.pos = new Vector().copy(pos);
|
225
|
-
this.normal = new Vector().copy(normal);
|
226
|
-
uv && (this.uv = new Vector().copy(uv)) && (this.uv.z = 0);
|
227
|
-
color && (this.color = new Vector().copy(color));
|
228
|
-
}
|
229
|
-
|
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
|
-
}]);
|
246
|
-
|
247
|
-
return Vertex;
|
248
|
-
}();
|
249
|
-
|
250
|
-
exports.Vertex = Vertex;
|
251
|
-
|
252
|
-
var Plane = /*#__PURE__*/function () {
|
253
|
-
function Plane(normal, w) {
|
254
|
-
_classCallCheck(this, Plane);
|
255
|
-
|
256
|
-
this.normal = normal;
|
257
|
-
this.w = w;
|
258
|
-
}
|
259
|
-
|
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
|
-
}
|
321
|
-
}
|
322
|
-
|
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
|
-
}
|
327
|
-
}
|
328
|
-
}]);
|
329
|
-
|
330
|
-
return Plane;
|
331
|
-
}();
|
332
|
-
|
333
|
-
exports.Plane = Plane;
|
334
|
-
Plane.EPSILON = 1e-5;
|
335
|
-
|
336
|
-
Plane.fromPoints = function (a, b, c) {
|
337
|
-
var n = tv0.copy(b).sub(a).cross(tv1.copy(c).sub(a)).normalize();
|
338
|
-
return new Plane(n.clone(), n.dot(a));
|
339
|
-
};
|
340
|
-
|
341
|
-
var Polygon = /*#__PURE__*/function () {
|
342
|
-
function Polygon(vertices, shared) {
|
343
|
-
_classCallCheck(this, Polygon);
|
344
|
-
|
345
|
-
this.vertices = vertices;
|
346
|
-
this.shared = shared;
|
347
|
-
this.plane = Plane.fromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
|
348
|
-
}
|
349
|
-
|
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
|
-
}]);
|
366
|
-
|
367
|
-
return Polygon;
|
368
|
-
}();
|
369
|
-
|
370
|
-
exports.Polygon = Polygon;
|
371
|
-
|
372
|
-
var Node = /*#__PURE__*/function () {
|
373
|
-
function Node(polygons) {
|
374
|
-
_classCallCheck(this, Node);
|
375
|
-
|
376
|
-
this.plane = null;
|
377
|
-
this.front = null;
|
378
|
-
this.back = null;
|
379
|
-
this.polygons = [];
|
380
|
-
if (polygons) this.build(polygons);
|
381
|
-
}
|
382
|
-
|
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;
|
394
|
-
}
|
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;
|
408
|
-
}
|
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);
|
423
|
-
}
|
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);
|
430
|
-
}
|
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
|
-
}]);
|
462
|
-
|
463
|
-
return Node;
|
464
|
-
}();
|
465
|
-
|
466
|
-
CSG.fromJSON = function (json) {
|
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
|
-
}));
|
472
|
-
};
|
@@ -1,84 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _react = _interopRequireDefault(require("react"));
|
4
|
-
|
5
|
-
var _csgLib = require("./csg-lib.js");
|
6
|
-
|
7
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
8
|
-
|
9
|
-
var gWorkersStarted = false;
|
10
|
-
var gWorker;
|
11
|
-
var gWorkerUrl;
|
12
|
-
var taskId = 0;
|
13
|
-
var tasks = {};
|
14
|
-
|
15
|
-
var spawnWorker = function spawnWorker() {
|
16
|
-
var worker = new Worker(gWorkerUrl);
|
17
|
-
|
18
|
-
worker.onmessage = function (e) {
|
19
|
-
var rslt = JSON.parse(e.data);
|
20
|
-
var task = tasks[rslt.taskId];
|
21
|
-
delete tasks[rslt.taskId];
|
22
|
-
task.resolve(_csgLib.CSG.fromJSON(rslt.result)); //console.log('Message received from worker');
|
23
|
-
|
24
|
-
gWorker.busy = false;
|
25
|
-
};
|
26
|
-
|
27
|
-
return gWorker = {
|
28
|
-
worker: worker,
|
29
|
-
busy: false
|
30
|
-
};
|
31
|
-
};
|
32
|
-
|
33
|
-
var getWorker = function getWorker() {
|
34
|
-
if (!gWorkersStarted) {
|
35
|
-
gWorkersStarted = true;
|
36
|
-
return fetch('../csg-lib.js').then(function (response) {
|
37
|
-
return response.text().then(function (text) {
|
38
|
-
text = text.slice(0, text.lastIndexOf('export'));
|
39
|
-
var code = text + "\n self.onmessage=(message)=>{\n let task = JSON.parse(message.data)\n //console.log(\"Got task:\"+task.op+' '+task.taskId)\n postMessage(JSON.stringify({\n taskId:task.taskId,\n result : CSG.fromJSON(task.a)[task.op](CSG.fromJSON(task.b))\n }))\n }\n console.log('CSG worker started!')";
|
40
|
-
var blob = new Blob([code], {
|
41
|
-
type: 'application/javascript'
|
42
|
-
});
|
43
|
-
gWorkerUrl = URL.createObjectURL(blob);
|
44
|
-
}).then(function () {
|
45
|
-
return spawnWorker();
|
46
|
-
});
|
47
|
-
});
|
48
|
-
}
|
49
|
-
|
50
|
-
if (gWorker && !gWorker.busy) {
|
51
|
-
gWorker.busy = true;
|
52
|
-
return {
|
53
|
-
then: function then(fn) {
|
54
|
-
return fn(gWorker);
|
55
|
-
}
|
56
|
-
};
|
57
|
-
}
|
58
|
-
|
59
|
-
return {
|
60
|
-
then: function then() {
|
61
|
-
return this;
|
62
|
-
}
|
63
|
-
};
|
64
|
-
};
|
65
|
-
|
66
|
-
_csgLib.CSG.doAsync = function (a, op, b) {
|
67
|
-
return getWorker().then(function (worker) {
|
68
|
-
var task = {
|
69
|
-
a: a,
|
70
|
-
op: op,
|
71
|
-
b: b,
|
72
|
-
taskId: taskId
|
73
|
-
};
|
74
|
-
tasks[taskId] = task;
|
75
|
-
taskId++;
|
76
|
-
task.result = new Promise(function (resolve, reject) {
|
77
|
-
task.resolve = resolve; //console.log("posting to worker:")
|
78
|
-
|
79
|
-
worker.busy = true;
|
80
|
-
worker.worker.postMessage(JSON.stringify(task));
|
81
|
-
});
|
82
|
-
return task.result;
|
83
|
-
});
|
84
|
-
};
|