hart-estate-widget 0.0.10 → 0.0.11

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.
@@ -0,0 +1,675 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ require("core-js/modules/web.dom-collections.iterator.js");
9
+
10
+ require("core-js/modules/es.array.reduce.js");
11
+
12
+ require("core-js/modules/es.promise.js");
13
+
14
+ var _react = _interopRequireDefault(require("react"));
15
+
16
+ var _mobx = require("mobx");
17
+
18
+ var _api = require("../api");
19
+
20
+ var THREE = _interopRequireWildcard(require("three"));
21
+
22
+ var _FBXLoader = require("three/examples/jsm/loaders/FBXLoader");
23
+
24
+ var _modelHelpers = require("../utils/modelHelpers");
25
+
26
+ var _threeCsg = _interopRequireDefault(require("../utils/csg/three-csg"));
27
+
28
+ var _wallTexture = _interopRequireDefault(require("../assets/img/wall-texture.jpg"));
29
+
30
+ var _doorTexture = _interopRequireDefault(require("../assets/img/door-texture.jpeg"));
31
+
32
+ var _exteriorWallTexture = _interopRequireDefault(require("../assets/img/exterior-wall-texture.jpeg"));
33
+
34
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
35
+
36
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
37
+
38
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
+
40
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
41
+
42
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
43
+
44
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
45
+
46
+ (0, _mobx.configure)({
47
+ useProxies: 'never'
48
+ });
49
+ const clippedBuildingConstant = 0.4;
50
+ const doorMaterialOptions = {
51
+ color: '#DADADA',
52
+ side: THREE.DoubleSide
53
+ };
54
+ const modelLoader = new _FBXLoader.FBXLoader();
55
+
56
+ class HouseStore {
57
+ constructor(modelStore) {
58
+ _defineProperty(this, "modelStore", null);
59
+
60
+ _defineProperty(this, "houseGroup", new THREE.Group());
61
+
62
+ _defineProperty(this, "wallsGroup", new THREE.Group());
63
+
64
+ _defineProperty(this, "doorsGroup", new THREE.Group());
65
+
66
+ _defineProperty(this, "doorMaterial", null);
67
+
68
+ _defineProperty(this, "wallsMaterial", null);
69
+
70
+ _defineProperty(this, "wallsColor", '#FFFFFF');
71
+
72
+ _defineProperty(this, "exteriorWallsMaterial", null);
73
+
74
+ _defineProperty(this, "wallsTextures", []);
75
+
76
+ _defineProperty(this, "isDoorsVisible", true);
77
+
78
+ _defineProperty(this, "isFullBuildingVisible", true);
79
+
80
+ _defineProperty(this, "wallsMaterialType", 'texture');
81
+
82
+ _defineProperty(this, "globalPlane", null);
83
+
84
+ _defineProperty(this, "clippingPlanes", []);
85
+
86
+ _defineProperty(this, "furnitureData", {});
87
+
88
+ _defineProperty(this, "loadedModels", {});
89
+
90
+ _defineProperty(this, "loadedTextures", {});
91
+
92
+ (0, _mobx.makeAutoObservable)(this);
93
+ this.modelStore = modelStore;
94
+ this.globalPlane = new THREE.Plane(new THREE.Vector3(0, -this.wallsHeight - 0.5, 0), 1);
95
+ this.clippingPlanes = [this.globalPlane];
96
+ this.setCenterPosition().loadTextures().then(() => {
97
+ this.createFloors().createSpaceBetweenWalls().createWalls().createDoors();
98
+ });
99
+ (0, _api.loadFurnitureData)(this.furniture).then(resp => {
100
+ this.furnitureData = resp;
101
+ this.loadFurniture(0);
102
+ });
103
+ }
104
+
105
+ get textureLoader() {
106
+ return this.modelStore.textureLoader;
107
+ }
108
+
109
+ get sceneScale() {
110
+ return this.modelStore.sceneScale;
111
+ }
112
+
113
+ get wallsHeight() {
114
+ return this.modelStore.wallsHeight;
115
+ }
116
+
117
+ get json() {
118
+ return this.modelStore.json;
119
+ }
120
+
121
+ get vertices() {
122
+ return this.json.Vertices;
123
+ }
124
+
125
+ get rooms() {
126
+ return this.json.Floors[0].Units[0].Rooms;
127
+ }
128
+
129
+ get walls() {
130
+ return this.json.Floors[0].Walls;
131
+ }
132
+
133
+ get exteriorWalls() {
134
+ return this.json.Floors[0].ExteriorWalls;
135
+ }
136
+
137
+ get doors() {
138
+ return this.json.Floors[0].Doors.map(door => this.getParsedAperture(door, 'Door'));
139
+ }
140
+
141
+ get windows() {
142
+ return this.json.Floors[0].Windows.map(window => this.getParsedAperture(window, 'Window'));
143
+ }
144
+
145
+ get apertures() {
146
+ return [...this.doors, ...this.windows];
147
+ }
148
+
149
+ get doorsHeight() {
150
+ return this.wallsHeight / 2 + this.wallsHeight / 4;
151
+ }
152
+
153
+ get wallMaterialOptions() {
154
+ return {
155
+ clippingPlanes: this.clippingPlanes,
156
+ color: this.wallsColor,
157
+ side: THREE.DoubleSide
158
+ };
159
+ }
160
+
161
+ get furniture() {
162
+ return this.rooms.reduce((acc, _ref) => {
163
+ let {
164
+ Furniture
165
+ } = _ref;
166
+ if (!Furniture || !Furniture.length) return acc;
167
+ return [...acc, ...Furniture];
168
+ }, []);
169
+ }
170
+
171
+ getVertexById(vertexId) {
172
+ return this.vertices.find(_ref2 => {
173
+ let {
174
+ ID
175
+ } = _ref2;
176
+ return ID === vertexId;
177
+ });
178
+ }
179
+
180
+ getWallById(wallId) {
181
+ return this.walls.find(_ref3 => {
182
+ let {
183
+ ID
184
+ } = _ref3;
185
+ return ID === wallId;
186
+ });
187
+ }
188
+
189
+ getParsedAperture(aperture, type) {
190
+ const {
191
+ Location,
192
+ Walls
193
+ } = aperture;
194
+ const position = new THREE.Vector3(Location.X, Location.Y, Location.Z);
195
+ const secondWall = this.getParsedWallById(Walls[1], 1);
196
+ const line = new THREE.Line3(secondWall.start, secondWall.end);
197
+ const positionOnFirstWall = new THREE.Vector3();
198
+ line.closestPointToPoint(position, true, positionOnFirstWall);
199
+ const lineBetweenWalls = new THREE.Line3(position, positionOnFirstWall);
200
+ const distanceBetweenWalls = lineBetweenWalls.distance();
201
+ const positionBetweenWalls = lineBetweenWalls.getCenter(positionOnFirstWall);
202
+
203
+ const parsedAperture = _objectSpread(_objectSpread({}, aperture), {}, {
204
+ Type: type,
205
+ Depth: distanceBetweenWalls,
206
+ Location: {
207
+ X: positionBetweenWalls.x,
208
+ Y: positionBetweenWalls.y,
209
+ Z: positionBetweenWalls.z
210
+ }
211
+ });
212
+
213
+ return parsedAperture;
214
+ }
215
+
216
+ getParsedWallById(wallId) {
217
+ let scale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.sceneScale;
218
+ const currentWall = this.getWallById(wallId);
219
+ const [coord1, coord2] = currentWall.Vertices.map(vertexId => this.getVertexById(vertexId).Location);
220
+ return {
221
+ id: wallId,
222
+ start: {
223
+ x: coord1.X * scale,
224
+ y: coord1.Y * scale,
225
+ z: 0
226
+ },
227
+ end: {
228
+ x: coord2.X * scale,
229
+ y: coord2.Y * scale,
230
+ z: 0
231
+ }
232
+ };
233
+ }
234
+
235
+ getVerticesFromParsedWalls(walls) {
236
+ return walls.reduce((acc, _ref4) => {
237
+ let {
238
+ start,
239
+ end
240
+ } = _ref4;
241
+ acc.push(new THREE.Vector2(start.x, start.y), new THREE.Vector2(end.x, end.y));
242
+ return acc;
243
+ }, []);
244
+ }
245
+
246
+ createFloors() {
247
+ this.rooms.forEach(_ref5 => {
248
+ let {
249
+ Walls,
250
+ Type
251
+ } = _ref5;
252
+ const walls = Walls.map(wallId => this.getParsedWallById(wallId));
253
+ const params = (0, _modelHelpers.getFloorParams)(Type);
254
+ const vertices = this.getVerticesFromParsedWalls(walls);
255
+ const shape = new THREE.Shape(vertices);
256
+ const geometry = new THREE.ShapeGeometry(shape);
257
+ const material = new THREE.MeshBasicMaterial({
258
+ color: params.color,
259
+ side: THREE.DoubleSide
260
+ });
261
+ const mesh = new THREE.Mesh(geometry, material);
262
+ mesh.name = 'FloorMesh';
263
+ this.loadTexture(params.texture, [0.5, 0.5], texture => {
264
+ const textureMaterial = new THREE.MeshBasicMaterial({
265
+ color: params.color,
266
+ side: THREE.DoubleSide,
267
+ map: texture
268
+ });
269
+ mesh.material = textureMaterial;
270
+ this.houseGroup.add(mesh);
271
+ });
272
+ });
273
+ return this;
274
+ }
275
+
276
+ createSpaceBetweenWalls() {
277
+ const walls = this.exteriorWalls.map(wallId => this.getParsedWallById(wallId));
278
+ const vertices = this.getVerticesFromParsedWalls(walls);
279
+ const clippedDepth = (this.wallsHeight + 0.5) * clippedBuildingConstant + 0.006;
280
+ const depth = this.wallsHeight + 0.002;
281
+ const shapeWithHoles = new THREE.Shape(vertices);
282
+ const shape = new THREE.Shape(vertices);
283
+ this.rooms.forEach(_ref6 => {
284
+ let {
285
+ Walls
286
+ } = _ref6;
287
+ const roomWalls = Walls.map(wallId => this.getParsedWallById(wallId));
288
+ const roomVertices = this.getVerticesFromParsedWalls(roomWalls);
289
+ shapeWithHoles.holes.push(new THREE.Shape(roomVertices));
290
+ });
291
+ const clippedGeometry = new THREE.ExtrudeGeometry(shapeWithHoles, {
292
+ depth: clippedDepth,
293
+ bevelEnabled: false
294
+ });
295
+ const flatGeometry = new THREE.ExtrudeGeometry(shape, {
296
+ depth: 0.001,
297
+ bevelEnabled: false
298
+ });
299
+ const geometry = new THREE.ExtrudeGeometry(shapeWithHoles, {
300
+ depth,
301
+ bevelEnabled: false
302
+ });
303
+ const clippedMaterial = new THREE.MeshBasicMaterial({
304
+ side: THREE.DoubleSide,
305
+ color: '#5C5C5C'
306
+ });
307
+ const material = new THREE.MeshBasicMaterial(_objectSpread(_objectSpread({}, this.wallMaterialOptions), {}, {
308
+ color: '#5C5C5C'
309
+ }));
310
+ const clippedMesh = new THREE.Mesh(clippedGeometry, clippedMaterial);
311
+ const flatMesh = new THREE.Mesh(flatGeometry, material);
312
+ const mesh = new THREE.Mesh(geometry, material);
313
+ clippedMesh.position.z = -0.005;
314
+ flatMesh.position.z = -0.005;
315
+ mesh.position.z = -0.001;
316
+ const additionalApertureWidth = 0.25;
317
+ const clippedMeshWithApertures = this.subtractApertures(clippedMesh, this.apertures, additionalApertureWidth);
318
+ const meshWithApertures = this.subtractApertures(mesh, this.apertures, additionalApertureWidth);
319
+ clippedMeshWithApertures.name = 'ClippedSpaceBetweenWalls';
320
+ meshWithApertures.name = 'SpaceBetweenWalls';
321
+ flatMesh.name = 'FlatSpaceBetweenWalls';
322
+ this.houseGroup.add(flatMesh, clippedMeshWithApertures, meshWithApertures);
323
+ return this;
324
+ }
325
+
326
+ createWalls() {
327
+ const createWall = (wallId, isExterior) => {
328
+ const {
329
+ start,
330
+ end
331
+ } = this.getParsedWallById(wallId);
332
+ const wallHalfWidth = 0.005;
333
+ const wallShape = new THREE.Shape([new THREE.Vector2(start.x + wallHalfWidth, start.y - wallHalfWidth), new THREE.Vector2(end.x + wallHalfWidth, end.y - wallHalfWidth), new THREE.Vector2(end.x - wallHalfWidth, end.y + wallHalfWidth), new THREE.Vector2(start.x - wallHalfWidth, start.y + wallHalfWidth)]);
334
+ const wallGeometry = new THREE.ExtrudeGeometry(wallShape, {
335
+ depth: this.wallsHeight,
336
+ bevelEnabled: false
337
+ });
338
+ const wallPadGeometry = new THREE.ExtrudeGeometry(wallShape, {
339
+ depth: 0.001,
340
+ bevelEnabled: false
341
+ });
342
+ const wallMaterial = isExterior ? this.exteriorWallsMaterial : this.wallsMaterial;
343
+ const wallPadMaterial = new THREE.MeshBasicMaterial(_objectSpread(_objectSpread({}, this.wallMaterialOptions), {}, {
344
+ color: '#5C5C5C'
345
+ }));
346
+ const wallClippedPadMaterial = new THREE.MeshBasicMaterial({
347
+ side: THREE.DoubleSide,
348
+ color: '#5C5C5C'
349
+ });
350
+ const apertures = this.apertures.filter(aperture => aperture.Walls.some(id => wallId === id));
351
+ const wallMesh = this.subtractApertures(new THREE.Mesh(wallGeometry, wallMaterial), apertures);
352
+ const wallPadMesh = new THREE.Mesh(wallPadGeometry, wallPadMaterial);
353
+ const wallClippedPadMesh = new THREE.Mesh(wallPadGeometry, wallClippedPadMaterial);
354
+ wallPadMesh.position.z = this.wallsHeight;
355
+ wallClippedPadMesh.position.z = (this.wallsHeight + 0.5) * clippedBuildingConstant + 0.001;
356
+ const wallClippedPadMeshWithApertures = this.subtractApertures(wallClippedPadMesh, apertures);
357
+ wallClippedPadMeshWithApertures.visible = false;
358
+ const wallGroup = new THREE.Group();
359
+ wallGroup.name = 'Wall';
360
+ wallGroup.buildingId = wallId;
361
+ wallGroup.isExterior = isExterior;
362
+ wallGroup.add(wallMesh, wallPadMesh, wallClippedPadMeshWithApertures);
363
+ this.wallsGroup.add(wallGroup);
364
+ };
365
+
366
+ this.rooms.forEach(_ref7 => {
367
+ let {
368
+ Walls
369
+ } = _ref7;
370
+ return Walls.forEach(wallId => createWall(wallId, false));
371
+ });
372
+ this.exteriorWalls.forEach(wallId => createWall(wallId, true));
373
+ this.houseGroup.add(this.wallsGroup);
374
+ return this;
375
+ }
376
+
377
+ createDoors() {
378
+ this.doors.forEach(_ref8 => {
379
+ let {
380
+ Width,
381
+ Location,
382
+ Rotation
383
+ } = _ref8;
384
+ const geometry = new THREE.BoxGeometry(Width * this.sceneScale, 0.1, this.doorsHeight);
385
+ let mesh = new THREE.Mesh(geometry, this.doorMaterial);
386
+ mesh.position.x = Location.X * this.sceneScale;
387
+ mesh.position.y = Location.Y * this.sceneScale;
388
+ mesh.position.z = this.doorsHeight / 2;
389
+ mesh.rotation.z = THREE.Math.degToRad(Rotation.Yaw);
390
+ this.doorsGroup.add(mesh);
391
+ });
392
+ this.houseGroup.add(this.doorsGroup);
393
+ return this;
394
+ }
395
+
396
+ subtractApertures(mesh, apertures) {
397
+ let additionalWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
398
+ let resultMesh = mesh;
399
+ apertures.forEach(_ref9 => {
400
+ let {
401
+ Width,
402
+ Depth,
403
+ Location,
404
+ Rotation,
405
+ Type
406
+ } = _ref9;
407
+ const isDoor = Type === 'Door';
408
+ const apertureGeometry = new THREE.BoxGeometry((Width + additionalWidth) * this.sceneScale, Depth * this.sceneScale + 1, (isDoor ? this.doorsHeight : this.wallsHeight / 2) + additionalWidth * this.sceneScale);
409
+ const apertureMaterial = new THREE.MeshBasicMaterial({
410
+ color: '#00B4F7'
411
+ });
412
+ const apertureMesh = new THREE.Mesh(apertureGeometry, apertureMaterial);
413
+ apertureMesh.rotation.z = THREE.Math.degToRad(Rotation.Yaw);
414
+ apertureMesh.position.x = Location.X * this.sceneScale;
415
+ apertureMesh.position.y = Location.Y * this.sceneScale;
416
+ apertureMesh.position.z = isDoor ? this.doorsHeight / 2 : this.wallsHeight / 2;
417
+ apertureMesh.updateMatrix();
418
+ resultMesh.updateMatrix();
419
+
420
+ const apertureBSP = _threeCsg.default.fromMesh(apertureMesh);
421
+
422
+ const wallBSP = _threeCsg.default.fromMesh(resultMesh);
423
+
424
+ const resultBSP = wallBSP.subtract(apertureBSP);
425
+ resultMesh = _threeCsg.default.toMesh(resultBSP, mesh.matrix, resultMesh.material);
426
+ });
427
+ return resultMesh;
428
+ }
429
+
430
+ setCenterPosition() {
431
+ const walls = this.exteriorWalls.map(wallId => this.getParsedWallById(wallId));
432
+ const {
433
+ maxX,
434
+ minX,
435
+ maxY,
436
+ minY
437
+ } = (0, _modelHelpers.getMinMaxCoordinates)(walls);
438
+ this.houseGroup.position.set(-(maxX + minX) / 2, -(maxY + minY) / 2);
439
+ return this;
440
+ }
441
+
442
+ loadTexture(img) {
443
+ let repeat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [1, 1];
444
+ let callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => {};
445
+ this.textureLoader.load(img, texture => {
446
+ texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
447
+ texture.repeat.set(repeat[0], repeat[1]);
448
+ texture.flipY = false;
449
+ callback(texture);
450
+ });
451
+ }
452
+
453
+ loadTextures() {
454
+ const assets = [{
455
+ img: _wallTexture.default,
456
+ repeat: [0.5, 0.5],
457
+ callback: texture => {
458
+ this.wallsTextures.push({
459
+ image: _wallTexture.default,
460
+ texture: texture
461
+ });
462
+ this.wallsMaterial = new THREE.MeshBasicMaterial(_objectSpread(_objectSpread({}, this.wallMaterialOptions), {}, {
463
+ map: texture
464
+ }));
465
+ }
466
+ }, {
467
+ img: _exteriorWallTexture.default,
468
+ repeat: [1, 1],
469
+ callback: texture => {
470
+ this.wallsTextures.push({
471
+ image: _exteriorWallTexture.default,
472
+ texture: texture
473
+ });
474
+ this.exteriorWallsMaterial = new THREE.MeshBasicMaterial(_objectSpread(_objectSpread({}, this.wallMaterialOptions), {}, {
475
+ map: texture,
476
+ color: '#FFFFFF'
477
+ }));
478
+ }
479
+ }, {
480
+ img: _doorTexture.default,
481
+ repeat: [1, 1],
482
+ callback: texture => {
483
+ this.doorMaterial = new THREE.MeshBasicMaterial(_objectSpread(_objectSpread({}, doorMaterialOptions), {}, {
484
+ map: texture
485
+ }));
486
+ }
487
+ }];
488
+ return Promise.all(assets.map(_ref10 => {
489
+ let {
490
+ img,
491
+ repeat,
492
+ callback
493
+ } = _ref10;
494
+ return new Promise(resolve => {
495
+ this.loadTexture(img, repeat, texture => {
496
+ callback(texture);
497
+ resolve();
498
+ });
499
+ });
500
+ }));
501
+ }
502
+
503
+ loadFurniture(index) {
504
+ const furniture = this.furniture[index];
505
+ if (!furniture) return;
506
+ const furnitureData = this.furnitureData[furniture.Model];
507
+
508
+ if (!furnitureData) {
509
+ this.loadFurniture(index + 1);
510
+ return;
511
+ }
512
+
513
+ const {
514
+ mesh,
515
+ textures
516
+ } = furnitureData;
517
+ const modelPath = "".concat(_api.API_URL, "/storage/furniture/").concat(mesh);
518
+ const {
519
+ Location,
520
+ Rotation,
521
+ Model: ModelName
522
+ } = furniture;
523
+ const {
524
+ X,
525
+ Y,
526
+ Z
527
+ } = Location;
528
+ const promises = textures.map(url => {
529
+ const texturePath = "".concat(_api.API_URL, "/storage/furniture/").concat(url);
530
+ return new Promise(resolve => {
531
+ this.textureLoader.load(texturePath, texture => resolve(texture));
532
+ });
533
+ });
534
+
535
+ const onTexturesLoaded = (result, model) => {
536
+ const materials = result.map(texture => new THREE.MeshBasicMaterial({
537
+ map: texture,
538
+ opacity: 0,
539
+ transparent: true
540
+ }));
541
+ model.traverse(node => {
542
+ if (node.isMesh) node.material = materials;
543
+ });
544
+ this.houseGroup.add(model);
545
+ this.loadFurniture(index + 1);
546
+ const opacityInterval = setInterval(() => {
547
+ model.children[0].material.forEach(material => {
548
+ material.opacity += 0.01;
549
+
550
+ if (material.opacity >= 1) {
551
+ clearInterval(opacityInterval);
552
+ material.opacity = 1;
553
+ }
554
+ });
555
+ }, 1);
556
+ };
557
+
558
+ const onModelLoaded = originalModel => {
559
+ const model = originalModel.clone();
560
+ model.scale.set(this.sceneScale, this.sceneScale, this.sceneScale);
561
+ model.position.set(X * this.sceneScale, Y * this.sceneScale, Z * this.sceneScale);
562
+ model.rotation.set(Math.PI / 2, THREE.Math.degToRad(Rotation.Yaw), 0);
563
+ const loadedTextures = this.loadedTextures[ModelName];
564
+
565
+ if (loadedTextures) {
566
+ onTexturesLoaded(loadedTextures, model);
567
+ return;
568
+ }
569
+
570
+ Promise.all(promises).then(result => {
571
+ onTexturesLoaded(result, model);
572
+ this.loadedTextures[ModelName] = result;
573
+ });
574
+ };
575
+
576
+ const loadedModel = this.loadedModels[ModelName];
577
+
578
+ if (loadedModel) {
579
+ onModelLoaded(loadedModel);
580
+ return;
581
+ }
582
+
583
+ modelLoader.load(modelPath, model => {
584
+ this.loadedModels[ModelName] = model;
585
+ onModelLoaded(model);
586
+ });
587
+ } // Actions
588
+
589
+
590
+ setDoorsVisibility(value) {
591
+ this.isDoorsVisible = value;
592
+ this.doorsGroup.children.forEach(door => door.visible = value);
593
+ }
594
+
595
+ setCurrentWallsMaterialType(value) {
596
+ this.wallsMaterialType = value;
597
+ this.wallsGroup.children.forEach(_ref11 => {
598
+ let {
599
+ children,
600
+ isExterior
601
+ } = _ref11;
602
+ const wall = children[0];
603
+
604
+ if (value === 'texture') {
605
+ wall.material = isExterior ? this.exteriorWallsMaterial : this.wallsMaterial;
606
+ return;
607
+ }
608
+
609
+ const color = isExterior ? '#FFFFFF' : this.wallsColor;
610
+ wall.material = new THREE.MeshBasicMaterial(_objectSpread(_objectSpread({}, this.wallMaterialOptions), {}, {
611
+ color
612
+ }));
613
+ });
614
+ this.doorsGroup.children.forEach(door => {
615
+ if (value === 'texture') {
616
+ door.material = this.doorMaterial;
617
+ return;
618
+ }
619
+
620
+ door.material = new THREE.MeshBasicMaterial(doorMaterialOptions);
621
+ });
622
+ }
623
+
624
+ setCurrentWallColor(color) {
625
+ this.wallsColor = color;
626
+ this.wallsMaterial.color.set(color);
627
+ this.wallsGroup.children.forEach(_ref12 => {
628
+ let {
629
+ children,
630
+ isExterior
631
+ } = _ref12;
632
+ if (isExterior) return;
633
+ const wall = children[0];
634
+ wall.material.color.set(color);
635
+ });
636
+ }
637
+
638
+ setCurrentWallTexture(texture) {
639
+ this.wallsMaterial = new THREE.MeshBasicMaterial(_objectSpread(_objectSpread({}, this.wallMaterialOptions), {}, {
640
+ map: texture
641
+ }));
642
+ this.setCurrentWallsMaterialType('texture');
643
+ }
644
+
645
+ addWallTexture(image) {
646
+ this.loadTexture(image, [0.5, 0.5], texture => {
647
+ this.wallsTextures.push({
648
+ image,
649
+ texture
650
+ });
651
+ this.setCurrentWallTexture(texture);
652
+ });
653
+ }
654
+
655
+ setFullBuildingVisibility(value) {
656
+ this.isFullBuildingVisible = value;
657
+ this.globalPlane.constant = this.isFullBuildingVisible ? 1 : clippedBuildingConstant;
658
+ this.wallsGroup.children.forEach(_ref13 => {
659
+ let {
660
+ children
661
+ } = _ref13;
662
+ return children[2].visible = !value;
663
+ });
664
+ }
665
+
666
+ setPlanMode() {
667
+ this.setDoorsVisibility(false);
668
+ this.setFullBuildingVisibility(false);
669
+ this.setCurrentWallsMaterialType('color');
670
+ }
671
+
672
+ }
673
+
674
+ var _default = HouseStore;
675
+ exports.default = _default;