hart-estate-widget 0.0.48 → 0.0.51

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.
@@ -1,18 +1,12 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.default = void 0;
7
9
 
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
- require("core-js/modules/es.string.includes.js");
15
-
16
10
  var _react = _interopRequireDefault(require("react"));
17
11
 
18
12
  var _mobx = require("mobx");
@@ -39,10 +33,36 @@ var _exteriorWallTextureRoughness = _interopRequireDefault(require("../assets/im
39
33
 
40
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); }
41
35
 
42
- 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; }
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; }
43
37
 
44
38
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
45
39
 
40
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
41
+
42
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
43
+
44
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
45
+
46
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
47
+
48
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
49
+
50
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
51
+
52
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
53
+
54
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
55
+
56
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
57
+
58
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
59
+
60
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
61
+
62
+ 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); } }
63
+
64
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
65
+
46
66
  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; }
47
67
 
48
68
  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; }
@@ -52,20 +72,26 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
52
72
  (0, _mobx.configure)({
53
73
  useProxies: 'never'
54
74
  });
55
- const clippedBuildingConstant = 0.4;
56
- const doorMaterialOptions = {
75
+ var clippedBuildingConstant = 0.4;
76
+ var doorMaterialOptions = {
57
77
  color: '#DADADA',
58
78
  side: THREE.DoubleSide
59
79
  };
60
- const modelLoader = new _FBXLoader.FBXLoader();
80
+ var modelLoader = new _FBXLoader.FBXLoader();
81
+
82
+ var createDefaultMaterial = function createDefaultMaterial(options) {
83
+ return new THREE.MeshStandardMaterial(_objectSpread({
84
+ roughness: 1,
85
+ metalness: 0
86
+ }, options));
87
+ };
88
+
89
+ var HouseStore = /*#__PURE__*/function () {
90
+ function HouseStore(modelStore) {
91
+ var _this = this;
61
92
 
62
- const createDefaultMaterial = options => new THREE.MeshStandardMaterial(_objectSpread({
63
- roughness: 1,
64
- metalness: 0
65
- }, options));
93
+ _classCallCheck(this, HouseStore);
66
94
 
67
- class HouseStore {
68
- constructor(modelStore) {
69
95
  _defineProperty(this, "modelStore", null);
70
96
 
71
97
  _defineProperty(this, "apiStore", new _apiStore.default(_store.default.config.API_URL));
@@ -114,740 +140,813 @@ class HouseStore {
114
140
  this.houseGroup.name = 'House-Group';
115
141
  this.globalPlane = new THREE.Plane(new THREE.Vector3(0, -this.wallsHeight - 0.5, 0), 1);
116
142
  this.clippingPlanes = [this.globalPlane];
117
- this.setCenterPosition().loadTextures().then(() => {
118
- this.createFloors().createSpaceBetweenWalls().createWalls().createDoors();
119
- });
120
- this.apiStore.loadFurnitureData().then(resp => {
121
- this.furnitureData = resp;
122
- this.loadFurniture(0);
123
- });
124
- }
125
-
126
- get textureLoader() {
127
- return this.modelStore.textureLoader;
128
- }
129
-
130
- get sceneScale() {
131
- return this.modelStore.sceneScale;
132
- }
133
-
134
- get wallsHeight() {
135
- return this.modelStore.wallsHeight;
136
- }
137
-
138
- get json() {
139
- return this.modelStore.json;
140
- }
141
-
142
- get vertices() {
143
- return this.json.Vertices;
144
- }
145
-
146
- get rooms() {
147
- return this.json.Floors[0].Units[0].Rooms;
148
- }
149
-
150
- get walls() {
151
- return this.json.Floors[0].Walls;
152
- }
153
-
154
- get exteriorWalls() {
155
- return this.json.Floors[0].ExteriorWalls;
156
- }
157
-
158
- get doors() {
159
- return this.json.Floors[0].Doors.map(door => this.getParsedAperture(door, 'Door'));
160
- }
161
-
162
- get windows() {
163
- return this.json.Floors[0].Windows.map(window => this.getParsedAperture(window, 'Window'));
164
- }
165
-
166
- get apertures() {
167
- return [...this.doors, ...this.windows];
168
- }
169
-
170
- get doorsHeight() {
171
- return this.wallsHeight / 2 + this.wallsHeight / 4;
172
- }
173
-
174
- get wallMaterialOptions() {
175
- return {
176
- clippingPlanes: this.clippingPlanes,
177
- color: this.wallsColor,
178
- side: THREE.DoubleSide
179
- };
180
- }
181
-
182
- get furniture() {
183
- return this.rooms.reduce((acc, _ref) => {
184
- let {
185
- Furniture
186
- } = _ref;
187
- if (!Furniture || !Furniture.length) return acc;
188
- return [...acc, ...Furniture];
189
- }, []);
190
- }
191
-
192
- getVertexById(vertexId) {
193
- return this.vertices.find(_ref2 => {
194
- let {
195
- ID
196
- } = _ref2;
197
- return ID === vertexId;
143
+ this.setCenterPosition().loadTextures().then(function () {
144
+ _this.createFloors().createSpaceBetweenWalls().createWalls().createDoors();
198
145
  });
199
- }
146
+ this.apiStore.loadFurnitureData().then(function (resp) {
147
+ _this.furnitureData = resp;
200
148
 
201
- getWallById(wallId) {
202
- return this.walls.find(_ref3 => {
203
- let {
204
- ID
205
- } = _ref3;
206
- return ID === wallId;
149
+ _this.loadFurniture(0);
207
150
  });
208
151
  }
209
152
 
210
- getParsedAperture(aperture, type) {
211
- const {
212
- Location,
213
- Walls
214
- } = aperture;
215
- const position = new THREE.Vector3(Location.X, Location.Y, Location.Z);
216
- const secondWall = this.getParsedWallById(Walls[1], 1);
217
- const line = new THREE.Line3(secondWall.start, secondWall.end);
218
- const positionOnFirstWall = new THREE.Vector3();
219
- line.closestPointToPoint(position, true, positionOnFirstWall);
220
- const lineBetweenWalls = new THREE.Line3(position, positionOnFirstWall);
221
- const distanceBetweenWalls = lineBetweenWalls.distance();
222
- const positionBetweenWalls = lineBetweenWalls.getCenter(positionOnFirstWall);
223
-
224
- const parsedAperture = _objectSpread(_objectSpread({}, aperture), {}, {
225
- Type: type,
226
- Depth: distanceBetweenWalls,
227
- Location: {
228
- X: positionBetweenWalls.x,
229
- Y: positionBetweenWalls.y,
230
- Z: positionBetweenWalls.z
231
- }
232
- });
233
-
234
- return parsedAperture;
235
- }
236
-
237
- getParsedWallById(wallId) {
238
- let scale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.sceneScale;
239
- const currentWall = this.getWallById(wallId);
240
- const [coord1, coord2] = currentWall.Vertices.map(vertexId => this.getVertexById(vertexId).Location);
241
- return {
242
- id: wallId,
243
- start: {
244
- x: coord1.X * scale,
245
- y: coord1.Y * scale,
246
- z: 0
247
- },
248
- end: {
249
- x: coord2.X * scale,
250
- y: coord2.Y * scale,
251
- z: 0
252
- }
253
- };
254
- }
153
+ _createClass(HouseStore, [{
154
+ key: "textureLoader",
155
+ get: function get() {
156
+ return this.modelStore.textureLoader;
157
+ }
158
+ }, {
159
+ key: "sceneScale",
160
+ get: function get() {
161
+ return this.modelStore.sceneScale;
162
+ }
163
+ }, {
164
+ key: "wallsHeight",
165
+ get: function get() {
166
+ return this.modelStore.wallsHeight;
167
+ }
168
+ }, {
169
+ key: "json",
170
+ get: function get() {
171
+ return this.modelStore.json;
172
+ }
173
+ }, {
174
+ key: "vertices",
175
+ get: function get() {
176
+ return this.json.Vertices;
177
+ }
178
+ }, {
179
+ key: "rooms",
180
+ get: function get() {
181
+ return this.json.Floors[0].Units[0].Rooms;
182
+ }
183
+ }, {
184
+ key: "walls",
185
+ get: function get() {
186
+ return this.json.Floors[0].Walls;
187
+ }
188
+ }, {
189
+ key: "exteriorWalls",
190
+ get: function get() {
191
+ return this.json.Floors[0].ExteriorWalls;
192
+ }
193
+ }, {
194
+ key: "doors",
195
+ get: function get() {
196
+ var _this2 = this;
255
197
 
256
- getVerticesFromParsedWalls(walls) {
257
- return walls.reduce((acc, _ref4) => {
258
- let {
259
- start,
260
- end
261
- } = _ref4;
262
- acc.push(new THREE.Vector2(start.x, start.y), new THREE.Vector2(end.x, end.y));
263
- return acc;
264
- }, []);
265
- }
198
+ return this.json.Floors[0].Doors.map(function (door) {
199
+ return _this2.getParsedAperture(door, 'Door');
200
+ });
201
+ }
202
+ }, {
203
+ key: "windows",
204
+ get: function get() {
205
+ var _this3 = this;
266
206
 
267
- createFloors() {
268
- this.rooms.forEach(_ref5 => {
269
- let {
270
- Walls,
271
- Type
272
- } = _ref5;
273
- const walls = Walls.map(wallId => this.getParsedWallById(wallId));
274
- const params = (0, _modelHelpers.getFloorParams)(Type);
275
- const vertices = this.getVerticesFromParsedWalls(walls);
276
- const shape = new THREE.Shape(vertices);
277
- const geometry = new THREE.ShapeGeometry(shape);
278
- const material = createDefaultMaterial({
279
- color: params.color,
207
+ return this.json.Floors[0].Windows.map(function (window) {
208
+ return _this3.getParsedAperture(window, 'Window');
209
+ });
210
+ }
211
+ }, {
212
+ key: "apertures",
213
+ get: function get() {
214
+ return [].concat(_toConsumableArray(this.doors), _toConsumableArray(this.windows));
215
+ }
216
+ }, {
217
+ key: "doorsHeight",
218
+ get: function get() {
219
+ return this.wallsHeight / 2 + this.wallsHeight / 4;
220
+ }
221
+ }, {
222
+ key: "wallMaterialOptions",
223
+ get: function get() {
224
+ return {
225
+ clippingPlanes: this.clippingPlanes,
226
+ color: this.wallsColor,
280
227
  side: THREE.DoubleSide
228
+ };
229
+ }
230
+ }, {
231
+ key: "furniture",
232
+ get: function get() {
233
+ return this.rooms.reduce(function (acc, _ref) {
234
+ var Furniture = _ref.Furniture;
235
+ if (!Furniture || !Furniture.length) return acc;
236
+ return [].concat(_toConsumableArray(acc), _toConsumableArray(Furniture));
237
+ }, []);
238
+ }
239
+ }, {
240
+ key: "getVertexById",
241
+ value: function getVertexById(vertexId) {
242
+ return this.vertices.find(function (_ref2) {
243
+ var ID = _ref2.ID;
244
+ return ID === vertexId;
245
+ });
246
+ }
247
+ }, {
248
+ key: "getWallById",
249
+ value: function getWallById(wallId) {
250
+ return this.walls.find(function (_ref3) {
251
+ var ID = _ref3.ID;
252
+ return ID === wallId;
253
+ });
254
+ }
255
+ }, {
256
+ key: "getParsedAperture",
257
+ value: function getParsedAperture(aperture, type) {
258
+ var Location = aperture.Location,
259
+ Walls = aperture.Walls;
260
+ var position = new THREE.Vector3(Location.X, Location.Y, Location.Z);
261
+ var secondWall = this.getParsedWallById(Walls[1], 1);
262
+ var line = new THREE.Line3(secondWall.start, secondWall.end);
263
+ var positionOnFirstWall = new THREE.Vector3();
264
+ line.closestPointToPoint(position, true, positionOnFirstWall);
265
+ var lineBetweenWalls = new THREE.Line3(position, positionOnFirstWall);
266
+ var distanceBetweenWalls = lineBetweenWalls.distance();
267
+ var positionBetweenWalls = lineBetweenWalls.getCenter(positionOnFirstWall);
268
+
269
+ var parsedAperture = _objectSpread(_objectSpread({}, aperture), {}, {
270
+ Type: type,
271
+ Depth: distanceBetweenWalls,
272
+ Location: {
273
+ X: positionBetweenWalls.x,
274
+ Y: positionBetweenWalls.y,
275
+ Z: positionBetweenWalls.z
276
+ }
281
277
  });
282
- const mesh = new THREE.Mesh(geometry, material);
283
- mesh.receiveShadow = true;
284
- mesh.castShadow = false;
285
- mesh.name = 'FloorMesh';
286
278
 
287
- const callback = (texture, roughnessMap) => {
288
- const textureMaterial = createDefaultMaterial({
289
- color: params.color,
290
- side: THREE.DoubleSide,
291
- map: texture
292
- });
293
- mesh.material = textureMaterial;
294
- if (roughnessMap) mesh.material.roughnessMap = roughnessMap;
295
- this.houseGroup.add(mesh);
279
+ return parsedAperture;
280
+ }
281
+ }, {
282
+ key: "getParsedWallById",
283
+ value: function getParsedWallById(wallId) {
284
+ var _this4 = this;
285
+
286
+ var scale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.sceneScale;
287
+ var currentWall = this.getWallById(wallId);
288
+
289
+ var _currentWall$Vertices = currentWall.Vertices.map(function (vertexId) {
290
+ return _this4.getVertexById(vertexId).Location;
291
+ }),
292
+ _currentWall$Vertices2 = _slicedToArray(_currentWall$Vertices, 2),
293
+ coord1 = _currentWall$Vertices2[0],
294
+ coord2 = _currentWall$Vertices2[1];
295
+
296
+ return {
297
+ id: wallId,
298
+ start: {
299
+ x: coord1.X * scale,
300
+ y: coord1.Y * scale,
301
+ z: 0
302
+ },
303
+ end: {
304
+ x: coord2.X * scale,
305
+ y: coord2.Y * scale,
306
+ z: 0
307
+ }
296
308
  };
309
+ }
310
+ }, {
311
+ key: "getVerticesFromParsedWalls",
312
+ value: function getVerticesFromParsedWalls(walls) {
313
+ return walls.reduce(function (acc, _ref4) {
314
+ var start = _ref4.start,
315
+ end = _ref4.end;
316
+ acc.push(new THREE.Vector2(start.x, start.y), new THREE.Vector2(end.x, end.y));
317
+ return acc;
318
+ }, []);
319
+ }
320
+ }, {
321
+ key: "createFloors",
322
+ value: function createFloors() {
323
+ var _this5 = this;
324
+
325
+ this.rooms.forEach(function (_ref5) {
326
+ var Walls = _ref5.Walls,
327
+ Type = _ref5.Type;
328
+ var walls = Walls.map(function (wallId) {
329
+ return _this5.getParsedWallById(wallId);
330
+ });
331
+ var params = (0, _modelHelpers.getFloorParams)(Type);
297
332
 
298
- this.loadTexture(params.texture, [0.5, 0.5], texture => {
299
- if (!params.roughnessMap) {
300
- callback(texture);
301
- return;
302
- }
333
+ var vertices = _this5.getVerticesFromParsedWalls(walls);
303
334
 
304
- this.loadTexture(params.roughnessMap, [0.5, 0.5], roughnessMap => callback(texture, roughnessMap));
335
+ var shape = new THREE.Shape(vertices);
336
+ var geometry = new THREE.ShapeGeometry(shape);
337
+ var material = createDefaultMaterial({
338
+ color: params.color,
339
+ side: THREE.DoubleSide
340
+ });
341
+ var mesh = new THREE.Mesh(geometry, material);
342
+ mesh.receiveShadow = true;
343
+ mesh.castShadow = false;
344
+ mesh.name = 'FloorMesh';
345
+
346
+ var callback = function callback(texture, roughnessMap) {
347
+ var textureMaterial = createDefaultMaterial({
348
+ color: params.color,
349
+ side: THREE.DoubleSide,
350
+ map: texture
351
+ });
352
+ mesh.material = textureMaterial;
353
+ if (roughnessMap) mesh.material.roughnessMap = roughnessMap;
354
+
355
+ _this5.houseGroup.add(mesh);
356
+ };
357
+
358
+ _this5.loadTexture(params.texture, [0.5, 0.5], function (texture) {
359
+ if (!params.roughnessMap) {
360
+ callback(texture);
361
+ return;
362
+ }
363
+
364
+ _this5.loadTexture(params.roughnessMap, [0.5, 0.5], function (roughnessMap) {
365
+ return callback(texture, roughnessMap);
366
+ });
367
+ });
305
368
  });
306
- });
307
- return this;
308
- }
369
+ return this;
370
+ }
371
+ }, {
372
+ key: "createSpaceBetweenWalls",
373
+ value: function createSpaceBetweenWalls() {
374
+ var _this6 = this;
309
375
 
310
- createSpaceBetweenWalls() {
311
- const walls = this.exteriorWalls.map(wallId => this.getParsedWallById(wallId));
312
- const vertices = this.getVerticesFromParsedWalls(walls);
313
- const clippedDepth = (this.wallsHeight + 0.5) * clippedBuildingConstant + 0.006;
314
- const depth = this.wallsHeight + 0.002;
315
- const shapeWithHoles = new THREE.Shape(vertices);
316
- const shape = new THREE.Shape(vertices);
317
- this.rooms.forEach(_ref6 => {
318
- let {
319
- Walls
320
- } = _ref6;
321
- const roomWalls = Walls.map(wallId => this.getParsedWallById(wallId));
322
- const roomVertices = this.getVerticesFromParsedWalls(roomWalls);
323
- shapeWithHoles.holes.push(new THREE.Shape(roomVertices));
324
- });
325
- const clippedGeometry = new THREE.ExtrudeGeometry(shapeWithHoles, {
326
- depth: clippedDepth,
327
- bevelEnabled: false
328
- });
329
- const flatGeometry = new THREE.ExtrudeGeometry(shape, {
330
- depth: 0.001,
331
- bevelEnabled: false
332
- });
333
- const geometry = new THREE.ExtrudeGeometry(shapeWithHoles, {
334
- depth,
335
- bevelEnabled: false
336
- });
337
- const clippedMaterial = createDefaultMaterial({
338
- side: THREE.DoubleSide,
339
- color: '#5C5C5C'
340
- });
341
- const material = createDefaultMaterial(_objectSpread(_objectSpread({}, this.wallMaterialOptions), {}, {
342
- color: '#5C5C5C'
343
- }));
344
- const clippedMesh = new THREE.Mesh(clippedGeometry, clippedMaterial);
345
- const flatMesh = new THREE.Mesh(flatGeometry, material);
346
- const mesh = new THREE.Mesh(geometry, material);
347
- flatMesh.receiveShadow = false;
348
- flatMesh.castShadow = false;
349
- clippedMesh.position.z = -0.005;
350
- flatMesh.position.z = -0.005;
351
- mesh.position.z = -0.001;
352
- const additionalApertureWidth = 0.25;
353
- const clippedMeshWithApertures = this.subtractApertures(clippedMesh, this.apertures, additionalApertureWidth);
354
- const meshWithApertures = this.subtractApertures(mesh, this.apertures, additionalApertureWidth);
355
- clippedMeshWithApertures.name = 'ClippedSpaceBetweenWalls';
356
- meshWithApertures.name = 'SpaceBetweenWalls';
357
- flatMesh.name = 'FlatSpaceBetweenWalls';
358
- clippedMeshWithApertures.receiveShadow = false;
359
- clippedMeshWithApertures.castShadow = false;
360
- meshWithApertures.receiveShadow = false;
361
- meshWithApertures.castShadow = false;
362
- this.houseGroup.add(flatMesh, clippedMeshWithApertures, meshWithApertures);
363
- return this;
364
- }
376
+ var walls = this.exteriorWalls.map(function (wallId) {
377
+ return _this6.getParsedWallById(wallId);
378
+ });
379
+ var vertices = this.getVerticesFromParsedWalls(walls);
380
+ var clippedDepth = (this.wallsHeight + 0.5) * clippedBuildingConstant + 0.006;
381
+ var depth = this.wallsHeight + 0.002;
382
+ var shapeWithHoles = new THREE.Shape(vertices);
383
+ var shape = new THREE.Shape(vertices);
384
+ this.rooms.forEach(function (_ref6) {
385
+ var Walls = _ref6.Walls;
386
+ var roomWalls = Walls.map(function (wallId) {
387
+ return _this6.getParsedWallById(wallId);
388
+ });
389
+
390
+ var roomVertices = _this6.getVerticesFromParsedWalls(roomWalls);
365
391
 
366
- createWalls() {
367
- const createWall = (wallId, isExterior) => {
368
- const {
369
- start,
370
- end
371
- } = this.getParsedWallById(wallId);
372
- const wallHalfWidth = 0.005;
373
- 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)]);
374
- const wallGeometry = new THREE.ExtrudeGeometry(wallShape, {
375
- depth: this.wallsHeight,
392
+ shapeWithHoles.holes.push(new THREE.Shape(roomVertices));
393
+ });
394
+ var clippedGeometry = new THREE.ExtrudeGeometry(shapeWithHoles, {
395
+ depth: clippedDepth,
376
396
  bevelEnabled: false
377
397
  });
378
- const wallPadGeometry = new THREE.ExtrudeGeometry(wallShape, {
398
+ var flatGeometry = new THREE.ExtrudeGeometry(shape, {
379
399
  depth: 0.001,
380
400
  bevelEnabled: false
381
401
  });
382
- const wallMaterial = isExterior ? this.exteriorWallsMaterial : this.wallsMaterial;
383
- const wallPadMaterial = createDefaultMaterial(_objectSpread(_objectSpread({}, this.wallMaterialOptions), {}, {
384
- color: '#5C5C5C'
385
- }));
386
- const wallClippedPadMaterial = createDefaultMaterial({
402
+ var geometry = new THREE.ExtrudeGeometry(shapeWithHoles, {
403
+ depth: depth,
404
+ bevelEnabled: false
405
+ });
406
+ var clippedMaterial = createDefaultMaterial({
387
407
  side: THREE.DoubleSide,
388
408
  color: '#5C5C5C'
389
409
  });
390
- const apertures = this.apertures.filter(aperture => aperture.Walls.some(id => wallId === id));
391
- const wallMesh = this.subtractApertures(new THREE.Mesh(wallGeometry, wallMaterial), apertures);
392
- const wallPadMesh = new THREE.Mesh(wallPadGeometry, wallPadMaterial);
393
- const wallClippedPadMesh = new THREE.Mesh(wallPadGeometry, wallClippedPadMaterial);
394
- wallMesh.castShadow = true;
395
- wallMesh.receiveShadow = !isExterior;
396
- wallPadMesh.castShadow = false;
397
- wallPadMesh.receiveShadow = false;
398
- wallClippedPadMesh.castShadow = false;
399
- wallClippedPadMesh.receiveShadow = false;
400
- wallPadMesh.position.z = this.wallsHeight;
401
- wallClippedPadMesh.position.z = (this.wallsHeight + 0.5) * clippedBuildingConstant + 0.001;
402
- const wallClippedPadMeshWithApertures = this.subtractApertures(wallClippedPadMesh, apertures);
403
- wallClippedPadMeshWithApertures.visible = false;
404
- wallClippedPadMeshWithApertures.castShadow = false;
405
- wallClippedPadMeshWithApertures.receiveShadow = false;
406
- const wallGroup = new THREE.Group();
407
- wallGroup.name = 'Wall';
408
- wallGroup.buildingId = wallId;
409
- wallGroup.isExterior = isExterior;
410
- wallGroup.add(wallMesh, wallPadMesh, wallClippedPadMeshWithApertures);
411
- this.wallsGroup.add(wallGroup);
412
- };
413
-
414
- this.exteriorWallsMaterial = createDefaultMaterial(_objectSpread(_objectSpread({}, this.wallMaterialOptions), {}, {
415
- map: this.exteriorWallsMaps.map,
416
- roughnessMap: this.exteriorWallsMaps.roughnessMap,
417
- color: '#FFFFFF'
418
- }));
419
- this.rooms.forEach(_ref7 => {
420
- let {
421
- Walls
422
- } = _ref7;
423
- return Walls.forEach(wallId => createWall(wallId, false));
424
- });
425
- this.exteriorWalls.forEach(wallId => createWall(wallId, true));
426
- this.houseGroup.add(this.wallsGroup);
427
- return this;
428
- }
429
-
430
- createDoors() {
431
- this.doors.forEach(_ref8 => {
432
- let {
433
- Width,
434
- Location,
435
- Rotation
436
- } = _ref8;
437
- const geometry = new THREE.BoxGeometry(Width * this.sceneScale, 0.1, this.doorsHeight);
438
- let mesh = new THREE.Mesh(geometry, this.doorMaterial);
439
- mesh.position.x = Location.X * this.sceneScale;
440
- mesh.position.y = Location.Y * this.sceneScale;
441
- mesh.position.z = this.doorsHeight / 2;
442
- mesh.rotation.z = THREE.Math.degToRad(Rotation.Yaw);
443
- mesh.receiveShadow = true;
444
- mesh.castShadow = true;
445
- this.doorsGroup.add(mesh);
446
- });
447
- this.houseGroup.add(this.doorsGroup);
448
- return this;
449
- }
450
-
451
- subtractApertures(mesh, apertures) {
452
- let additionalWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
453
- let resultMesh = mesh;
454
- apertures.forEach(_ref9 => {
455
- let {
456
- Width,
457
- Depth,
458
- Location,
459
- Rotation,
460
- Type
461
- } = _ref9;
462
- const isDoor = Type === 'Door';
463
- const apertureGeometry = new THREE.BoxGeometry((Width + additionalWidth) * this.sceneScale, Depth * this.sceneScale + 1, (isDoor ? this.doorsHeight : this.wallsHeight / 2) + additionalWidth * this.sceneScale);
464
- const apertureMaterial = createDefaultMaterial({
465
- color: '#00B4F7'
466
- });
467
- const apertureMesh = new THREE.Mesh(apertureGeometry, apertureMaterial);
468
- apertureMesh.rotation.z = THREE.Math.degToRad(Rotation.Yaw);
469
- apertureMesh.position.x = Location.X * this.sceneScale;
470
- apertureMesh.position.y = Location.Y * this.sceneScale;
471
- apertureMesh.position.z = isDoor ? this.doorsHeight / 2 : this.wallsHeight / 2;
472
- apertureMesh.updateMatrix();
473
- resultMesh.updateMatrix();
474
-
475
- const apertureBSP = _threeCsg.default.fromMesh(apertureMesh);
476
-
477
- const wallBSP = _threeCsg.default.fromMesh(resultMesh);
478
-
479
- const resultBSP = wallBSP.subtract(apertureBSP);
480
- resultMesh = _threeCsg.default.toMesh(resultBSP, mesh.matrix, resultMesh.material);
481
- });
482
- return resultMesh;
483
- }
484
-
485
- setCenterPosition() {
486
- const walls = this.exteriorWalls.map(wallId => this.getParsedWallById(wallId));
487
- const {
488
- maxX,
489
- minX,
490
- maxY,
491
- minY
492
- } = (0, _modelHelpers.getMinMaxCoordinates)(walls);
493
- const centerX = (maxX + minX) / 2;
494
- const centerY = (maxY + minY) / 2;
495
- const lightsOffset = 25;
496
- this.houseGroup.position.set(-centerX, -centerY);
497
- const lights = [{
498
- x: centerX - lightsOffset,
499
- y: centerY - lightsOffset,
500
- z: this.wallsHeight * 3,
501
- power: 0.4,
502
- castShadow: true
503
- }, {
504
- x: centerX - lightsOffset,
505
- y: centerY - lightsOffset,
506
- z: this.wallsHeight * 2,
507
- power: 1,
508
- castShadow: false
509
- }, {
510
- x: centerX + lightsOffset,
511
- y: centerY + lightsOffset,
512
- z: this.wallsHeight * 2,
513
- power: 1.1,
514
- castShadow: false
515
- }, {
516
- x: centerX,
517
- y: centerY,
518
- z: this.wallsHeight * 5,
519
- power: 0.1,
520
- castShadow: false
521
- }];
522
- const targetObject = new THREE.Object3D();
523
- targetObject.position.set(centerX, centerY, 0);
524
- this.houseGroup.add(targetObject);
525
- lights.forEach(_ref10 => {
526
- let {
527
- x,
528
- y,
529
- z,
530
- power,
531
- castShadow
532
- } = _ref10;
533
- const light = new THREE.DirectionalLight(0xffffff, power);
534
- light.position.set(x, y, z);
535
- light.shadowLight = castShadow;
536
- light.castShadow = castShadow;
537
- light.shadow.camera.left = -centerX * 2;
538
- light.shadow.camera.right = centerX * 2;
539
- light.shadow.camera.top = centerY * 2;
540
- light.shadow.camera.bottom = -centerY * 2;
541
- light.shadow.camera.zoom = 1;
542
- light.shadow.mapSize = new THREE.Vector2(2048, 2048);
543
- light.shadow.normalBias = 1;
544
- light.target = targetObject;
545
- this.houseGroup.add(light);
546
- });
547
- return this;
548
- }
549
-
550
- loadTexture(img) {
551
- let repeat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [1, 1];
552
- let callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => {};
553
- this.textureLoader.load(img, texture => {
554
- texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
555
- texture.repeat.set(repeat[0], repeat[1]);
556
- texture.flipY = false;
557
- callback(texture);
558
- });
559
- }
560
-
561
- loadTextures() {
562
- const assets = [{
563
- img: _wallTexture.default,
564
- repeat: [0.5, 0.5],
565
- callback: texture => {
566
- this.wallsTextures.push({
567
- image: _wallTexture.default,
568
- texture: texture
569
- });
570
- this.wallsMaterial = createDefaultMaterial(_objectSpread(_objectSpread({}, this.wallMaterialOptions), {}, {
571
- map: texture
572
- }));
573
- }
574
- }, {
575
- img: _exteriorWallTexture.default,
576
- repeat: [1, 1],
577
- callback: texture => {
578
- this.wallsTextures.push({
579
- image: _exteriorWallTexture.default,
580
- texture: texture
410
+ var material = createDefaultMaterial(_objectSpread(_objectSpread({}, this.wallMaterialOptions), {}, {
411
+ color: '#5C5C5C'
412
+ }));
413
+ var clippedMesh = new THREE.Mesh(clippedGeometry, clippedMaterial);
414
+ var flatMesh = new THREE.Mesh(flatGeometry, material);
415
+ var mesh = new THREE.Mesh(geometry, material);
416
+ flatMesh.receiveShadow = false;
417
+ flatMesh.castShadow = false;
418
+ clippedMesh.position.z = -0.005;
419
+ flatMesh.position.z = -0.005;
420
+ mesh.position.z = -0.001;
421
+ var additionalApertureWidth = 0.25;
422
+ var clippedMeshWithApertures = this.subtractApertures(clippedMesh, this.apertures, additionalApertureWidth);
423
+ var meshWithApertures = this.subtractApertures(mesh, this.apertures, additionalApertureWidth);
424
+ clippedMeshWithApertures.name = 'ClippedSpaceBetweenWalls';
425
+ meshWithApertures.name = 'SpaceBetweenWalls';
426
+ flatMesh.name = 'FlatSpaceBetweenWalls';
427
+ clippedMeshWithApertures.receiveShadow = false;
428
+ clippedMeshWithApertures.castShadow = false;
429
+ meshWithApertures.receiveShadow = false;
430
+ meshWithApertures.castShadow = false;
431
+ this.houseGroup.add(flatMesh, clippedMeshWithApertures, meshWithApertures);
432
+ return this;
433
+ }
434
+ }, {
435
+ key: "createWalls",
436
+ value: function createWalls() {
437
+ var _this7 = this;
438
+
439
+ var createWall = function createWall(wallId, isExterior) {
440
+ var _this7$getParsedWallB = _this7.getParsedWallById(wallId),
441
+ start = _this7$getParsedWallB.start,
442
+ end = _this7$getParsedWallB.end;
443
+
444
+ var wallHalfWidth = 0.005;
445
+ var 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)]);
446
+ var wallGeometry = new THREE.ExtrudeGeometry(wallShape, {
447
+ depth: _this7.wallsHeight,
448
+ bevelEnabled: false
581
449
  });
582
- this.exteriorWallsMaps.map = texture;
583
- }
584
- }, {
585
- img: _exteriorWallTextureRoughness.default,
586
- repeat: [1, 1],
587
- callback: texture => {
588
- this.wallsTextures.push({
589
- image: _exteriorWallTextureRoughness.default,
590
- texture: texture
450
+ var wallPadGeometry = new THREE.ExtrudeGeometry(wallShape, {
451
+ depth: 0.001,
452
+ bevelEnabled: false
591
453
  });
592
- this.exteriorWallsMaps.roughnessMap = texture;
593
- }
594
- }, {
595
- img: _doorTexture.default,
596
- repeat: [1, 1],
597
- callback: texture => {
598
- this.doorMaterial = createDefaultMaterial(_objectSpread(_objectSpread({}, doorMaterialOptions), {}, {
599
- map: texture
454
+ var wallMaterial = isExterior ? _this7.exteriorWallsMaterial : _this7.wallsMaterial;
455
+ var wallPadMaterial = createDefaultMaterial(_objectSpread(_objectSpread({}, _this7.wallMaterialOptions), {}, {
456
+ color: '#5C5C5C'
600
457
  }));
601
- }
602
- }];
603
- return Promise.all(assets.map(_ref11 => {
604
- let {
605
- img,
606
- repeat,
607
- callback
608
- } = _ref11;
609
- return new Promise(resolve => {
610
- this.loadTexture(img, repeat, texture => {
611
- callback(texture);
612
- resolve();
458
+ var wallClippedPadMaterial = createDefaultMaterial({
459
+ side: THREE.DoubleSide,
460
+ color: '#5C5C5C'
613
461
  });
614
- });
615
- }));
616
- }
617
462
 
618
- loadFurniture(index) {
619
- const furniture = this.furniture[index];
620
- if (!furniture) return;
621
- const furnitureData = this.furnitureData.find(_ref12 => {
622
- let {
623
- name,
624
- type
625
- } = _ref12;
626
- return name === furniture.Model && type === furniture.Type;
627
- });
463
+ var apertures = _this7.apertures.filter(function (aperture) {
464
+ return aperture.Walls.some(function (id) {
465
+ return wallId === id;
466
+ });
467
+ });
628
468
 
629
- if (!furnitureData) {
630
- this.loadFurniture(index + 1);
631
- return;
632
- }
633
-
634
- const {
635
- mesh,
636
- textures
637
- } = furnitureData;
638
- const modelPath = "".concat(this.apiStore.API_URL, "/storage/furniture/").concat(mesh);
639
- const {
640
- Location,
641
- Rotation,
642
- Model: ModelName
643
- } = furniture;
644
- const {
645
- X,
646
- Y,
647
- Z
648
- } = Location;
649
- const promises = textures.map(url => {
650
- const texturePath = "".concat(this.apiStore.API_URL, "/storage/furniture/").concat(url);
651
- return new Promise(resolve => {
652
- this.textureLoader.load(texturePath, texture => resolve(texture));
653
- });
654
- });
469
+ var wallMesh = _this7.subtractApertures(new THREE.Mesh(wallGeometry, wallMaterial), apertures);
470
+
471
+ var wallPadMesh = new THREE.Mesh(wallPadGeometry, wallPadMaterial);
472
+ var wallClippedPadMesh = new THREE.Mesh(wallPadGeometry, wallClippedPadMaterial);
473
+ wallMesh.castShadow = true;
474
+ wallMesh.receiveShadow = !isExterior;
475
+ wallPadMesh.castShadow = false;
476
+ wallPadMesh.receiveShadow = false;
477
+ wallClippedPadMesh.castShadow = false;
478
+ wallClippedPadMesh.receiveShadow = false;
479
+ wallPadMesh.position.z = _this7.wallsHeight;
480
+ wallClippedPadMesh.position.z = (_this7.wallsHeight + 0.5) * clippedBuildingConstant + 0.001;
481
+
482
+ var wallClippedPadMeshWithApertures = _this7.subtractApertures(wallClippedPadMesh, apertures);
483
+
484
+ wallClippedPadMeshWithApertures.visible = false;
485
+ wallClippedPadMeshWithApertures.castShadow = false;
486
+ wallClippedPadMeshWithApertures.receiveShadow = false;
487
+ var wallGroup = new THREE.Group();
488
+ wallGroup.name = 'Wall';
489
+ wallGroup.buildingId = wallId;
490
+ wallGroup.isExterior = isExterior;
491
+ wallGroup.add(wallMesh, wallPadMesh, wallClippedPadMeshWithApertures);
492
+
493
+ _this7.wallsGroup.add(wallGroup);
494
+ };
655
495
 
656
- const onTexturesLoaded = (result, model) => {
657
- const materialsCount = result.reduce((acc, _ref13) => {
658
- let {
659
- image
660
- } = _ref13;
661
- if (!image.currentSrc.includes('_D.') && !image.currentSrc.includes('_DA.')) return acc;
662
- return acc += 1;
663
- }, 0);
664
-
665
- const createMaterial = num => {
666
- const map = result.find(_ref14 => {
667
- let {
668
- image
669
- } = _ref14;
670
- return image.currentSrc.includes("".concat(num, "_D.")) || image.currentSrc.includes("".concat(num, "_DA."));
671
- });
672
- const envMap = result.find(_ref15 => {
673
- let {
674
- image
675
- } = _ref15;
676
- return image.currentSrc.includes("".concat(num, "_RMO."));
677
- });
678
- const normalMap = result.find(_ref16 => {
679
- let {
680
- image
681
- } = _ref16;
682
- return image.currentSrc.includes("".concat(num, "_N."));
496
+ this.exteriorWallsMaterial = createDefaultMaterial(_objectSpread(_objectSpread({}, this.wallMaterialOptions), {}, {
497
+ map: this.exteriorWallsMaps.map,
498
+ roughnessMap: this.exteriorWallsMaps.roughnessMap,
499
+ color: '#FFFFFF'
500
+ }));
501
+ this.rooms.forEach(function (_ref7) {
502
+ var Walls = _ref7.Walls;
503
+ return Walls.forEach(function (wallId) {
504
+ return createWall(wallId, false);
683
505
  });
684
- const material = new THREE.MeshStandardMaterial({
685
- roughness: 1,
686
- transparent: true
506
+ });
507
+ this.exteriorWalls.forEach(function (wallId) {
508
+ return createWall(wallId, true);
509
+ });
510
+ this.houseGroup.add(this.wallsGroup);
511
+ return this;
512
+ }
513
+ }, {
514
+ key: "createDoors",
515
+ value: function createDoors() {
516
+ var _this8 = this;
517
+
518
+ this.doors.forEach(function (_ref8) {
519
+ var Width = _ref8.Width,
520
+ Location = _ref8.Location,
521
+ Rotation = _ref8.Rotation;
522
+ var geometry = new THREE.BoxGeometry(Width * _this8.sceneScale, 0.1, _this8.doorsHeight);
523
+ var mesh = new THREE.Mesh(geometry, _this8.doorMaterial);
524
+ mesh.position.x = Location.X * _this8.sceneScale;
525
+ mesh.position.y = Location.Y * _this8.sceneScale;
526
+ mesh.position.z = _this8.doorsHeight / 2;
527
+ mesh.rotation.z = THREE.Math.degToRad(Rotation.Yaw);
528
+ mesh.receiveShadow = true;
529
+ mesh.castShadow = true;
530
+
531
+ _this8.doorsGroup.add(mesh);
532
+ });
533
+ this.houseGroup.add(this.doorsGroup);
534
+ return this;
535
+ }
536
+ }, {
537
+ key: "subtractApertures",
538
+ value: function subtractApertures(mesh, apertures) {
539
+ var _this9 = this;
540
+
541
+ var additionalWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
542
+ var resultMesh = mesh;
543
+ apertures.forEach(function (_ref9) {
544
+ var Width = _ref9.Width,
545
+ Depth = _ref9.Depth,
546
+ Location = _ref9.Location,
547
+ Rotation = _ref9.Rotation,
548
+ Type = _ref9.Type;
549
+ var isDoor = Type === 'Door';
550
+ var apertureGeometry = new THREE.BoxGeometry((Width + additionalWidth) * _this9.sceneScale, Depth * _this9.sceneScale + 1, (isDoor ? _this9.doorsHeight : _this9.wallsHeight / 2) + additionalWidth * _this9.sceneScale);
551
+ var apertureMaterial = createDefaultMaterial({
552
+ color: '#00B4F7'
687
553
  });
688
- material.depthWrite = !(ModelName === 'Flower' && num === '01');
689
- if (map) material.map = map;
690
- if (envMap) material.envMap = envMap;
691
- if (normalMap) material.normalMap = normalMap;
692
- return material;
693
- };
554
+ var apertureMesh = new THREE.Mesh(apertureGeometry, apertureMaterial);
555
+ apertureMesh.rotation.z = THREE.Math.degToRad(Rotation.Yaw);
556
+ apertureMesh.position.x = Location.X * _this9.sceneScale;
557
+ apertureMesh.position.y = Location.Y * _this9.sceneScale;
558
+ apertureMesh.position.z = isDoor ? _this9.doorsHeight / 2 : _this9.wallsHeight / 2;
559
+ apertureMesh.updateMatrix();
560
+ resultMesh.updateMatrix();
694
561
 
695
- let materials = new THREE.MeshPhysicalMaterial({
696
- roughness: 1,
697
- clearcoat: 1,
698
- clearcoatRoughness: 1,
699
- reflectivity: 0,
700
- fog: false
701
- });
562
+ var apertureBSP = _threeCsg.default.fromMesh(apertureMesh);
702
563
 
703
- if (materialsCount === 1) {
704
- materials = createMaterial('');
705
- }
564
+ var wallBSP = _threeCsg.default.fromMesh(resultMesh);
706
565
 
707
- if (materialsCount > 1) {
708
- materials = [...Array(materialsCount).keys()].map(i => {
709
- const num = i + 1;
710
- const realNum = num < 10 ? "0".concat(num) : num;
711
- return createMaterial(realNum);
712
- });
713
- }
566
+ var resultBSP = wallBSP.subtract(apertureBSP);
567
+ resultMesh = _threeCsg.default.toMesh(resultBSP, mesh.matrix, resultMesh.material);
568
+ });
569
+ return resultMesh;
570
+ }
571
+ }, {
572
+ key: "setCenterPosition",
573
+ value: function setCenterPosition() {
574
+ var _this10 = this;
714
575
 
715
- model.traverse(node => {
716
- if (node.isMesh) {
717
- node.material = materials;
718
- node.receiveShadow = true;
719
- node.castShadow = true;
576
+ var walls = this.exteriorWalls.map(function (wallId) {
577
+ return _this10.getParsedWallById(wallId);
578
+ });
579
+
580
+ var _getMinMaxCoordinates = (0, _modelHelpers.getMinMaxCoordinates)(walls),
581
+ maxX = _getMinMaxCoordinates.maxX,
582
+ minX = _getMinMaxCoordinates.minX,
583
+ maxY = _getMinMaxCoordinates.maxY,
584
+ minY = _getMinMaxCoordinates.minY;
585
+
586
+ var centerX = (maxX + minX) / 2;
587
+ var centerY = (maxY + minY) / 2;
588
+ var lightsOffset = 25;
589
+ this.houseGroup.position.set(-centerX, -centerY);
590
+ var lights = [{
591
+ x: centerX - lightsOffset,
592
+ y: centerY - lightsOffset,
593
+ z: this.wallsHeight * 3,
594
+ power: 0.4,
595
+ castShadow: true
596
+ }, {
597
+ x: centerX - lightsOffset,
598
+ y: centerY - lightsOffset,
599
+ z: this.wallsHeight * 2,
600
+ power: 1,
601
+ castShadow: false
602
+ }, {
603
+ x: centerX + lightsOffset,
604
+ y: centerY + lightsOffset,
605
+ z: this.wallsHeight * 2,
606
+ power: 1.1,
607
+ castShadow: false
608
+ }, {
609
+ x: centerX,
610
+ y: centerY,
611
+ z: this.wallsHeight * 5,
612
+ power: 0.1,
613
+ castShadow: false
614
+ }];
615
+ var targetObject = new THREE.Object3D();
616
+ targetObject.position.set(centerX, centerY, 0);
617
+ this.houseGroup.add(targetObject);
618
+ lights.forEach(function (_ref10) {
619
+ var x = _ref10.x,
620
+ y = _ref10.y,
621
+ z = _ref10.z,
622
+ power = _ref10.power,
623
+ castShadow = _ref10.castShadow;
624
+ var light = new THREE.DirectionalLight(0xffffff, power);
625
+ light.position.set(x, y, z);
626
+ light.shadowLight = castShadow;
627
+ light.castShadow = castShadow;
628
+ light.shadow.camera.left = -centerX * 2;
629
+ light.shadow.camera.right = centerX * 2;
630
+ light.shadow.camera.top = centerY * 2;
631
+ light.shadow.camera.bottom = -centerY * 2;
632
+ light.shadow.camera.zoom = 1;
633
+ light.shadow.mapSize = new THREE.Vector2(2048, 2048);
634
+ light.shadow.normalBias = 1;
635
+ light.target = targetObject;
636
+
637
+ _this10.houseGroup.add(light);
638
+ });
639
+ return this;
640
+ }
641
+ }, {
642
+ key: "loadTexture",
643
+ value: function loadTexture(img) {
644
+ var repeat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [1, 1];
645
+ var callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : function () {};
646
+ this.textureLoader.load(img, function (texture) {
647
+ texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
648
+ texture.repeat.set(repeat[0], repeat[1]);
649
+ texture.flipY = false;
650
+ callback(texture);
651
+ });
652
+ }
653
+ }, {
654
+ key: "loadTextures",
655
+ value: function loadTextures() {
656
+ var _this11 = this;
657
+
658
+ var assets = [{
659
+ img: _wallTexture.default,
660
+ repeat: [0.5, 0.5],
661
+ callback: function callback(texture) {
662
+ _this11.wallsTextures.push({
663
+ image: _wallTexture.default,
664
+ texture: texture
665
+ });
666
+
667
+ _this11.wallsMaterial = createDefaultMaterial(_objectSpread(_objectSpread({}, _this11.wallMaterialOptions), {}, {
668
+ map: texture
669
+ }));
670
+ }
671
+ }, {
672
+ img: _exteriorWallTexture.default,
673
+ repeat: [1, 1],
674
+ callback: function callback(texture) {
675
+ _this11.wallsTextures.push({
676
+ image: _exteriorWallTexture.default,
677
+ texture: texture
678
+ });
679
+
680
+ _this11.exteriorWallsMaps.map = texture;
681
+ }
682
+ }, {
683
+ img: _exteriorWallTextureRoughness.default,
684
+ repeat: [1, 1],
685
+ callback: function callback(texture) {
686
+ _this11.wallsTextures.push({
687
+ image: _exteriorWallTextureRoughness.default,
688
+ texture: texture
689
+ });
690
+
691
+ _this11.exteriorWallsMaps.roughnessMap = texture;
720
692
  }
693
+ }, {
694
+ img: _doorTexture.default,
695
+ repeat: [1, 1],
696
+ callback: function callback(texture) {
697
+ _this11.doorMaterial = createDefaultMaterial(_objectSpread(_objectSpread({}, doorMaterialOptions), {}, {
698
+ map: texture
699
+ }));
700
+ }
701
+ }];
702
+ return Promise.all(assets.map(function (_ref11) {
703
+ var img = _ref11.img,
704
+ repeat = _ref11.repeat,
705
+ callback = _ref11.callback;
706
+ return new Promise(function (resolve) {
707
+ _this11.loadTexture(img, repeat, function (texture) {
708
+ callback(texture);
709
+ resolve();
710
+ });
711
+ });
712
+ }));
713
+ }
714
+ }, {
715
+ key: "loadFurniture",
716
+ value: function loadFurniture(index) {
717
+ var _this12 = this;
718
+
719
+ var furniture = this.furniture[index];
720
+ if (!furniture) return;
721
+ var furnitureData = this.furnitureData.find(function (_ref12) {
722
+ var name = _ref12.name,
723
+ type = _ref12.type;
724
+ return name === furniture.Model && type === furniture.Type;
721
725
  });
722
- this.houseGroup.add(model);
723
- this.loadFurniture(index + 1);
724
- };
725
-
726
- const onModelLoaded = originalModel => {
727
- const model = originalModel.clone();
728
- model.scale.set(this.sceneScale, this.sceneScale, this.sceneScale);
729
- model.position.set(X * this.sceneScale, Y * this.sceneScale, Z * this.sceneScale);
730
- model.rotation.set(Math.PI / 2, THREE.Math.degToRad(Rotation.Yaw), 0);
731
- const loadedTextures = this.loadedTextures[ModelName];
732
-
733
- if (loadedTextures) {
734
- onTexturesLoaded(loadedTextures, model);
726
+
727
+ if (!furnitureData) {
728
+ this.loadFurniture(index + 1);
735
729
  return;
736
730
  }
737
731
 
738
- Promise.all(promises).then(result => {
739
- onTexturesLoaded(result, model);
740
- this.loadedTextures[ModelName] = result;
732
+ var mesh = furnitureData.mesh,
733
+ textures = furnitureData.textures;
734
+ var modelPath = "".concat(this.apiStore.API_URL, "/storage/furniture/").concat(mesh);
735
+ var Location = furniture.Location,
736
+ Rotation = furniture.Rotation,
737
+ ModelName = furniture.Model;
738
+ var X = Location.X,
739
+ Y = Location.Y,
740
+ Z = Location.Z;
741
+ var promises = textures.map(function (url) {
742
+ var texturePath = "".concat(_this12.apiStore.API_URL, "/storage/furniture/").concat(url);
743
+ return new Promise(function (resolve) {
744
+ _this12.textureLoader.load(texturePath, function (texture) {
745
+ return resolve(texture);
746
+ });
747
+ });
741
748
  });
742
- };
743
749
 
744
- const loadedModel = this.loadedModels[ModelName];
750
+ var onTexturesLoaded = function onTexturesLoaded(result, model) {
751
+ var materialsCount = result.reduce(function (acc, _ref13) {
752
+ var image = _ref13.image;
753
+ if (!image.currentSrc.includes('_D.') && !image.currentSrc.includes('_DA.')) return acc;
754
+ return acc += 1;
755
+ }, 0);
756
+
757
+ var createMaterial = function createMaterial(num) {
758
+ var map = result.find(function (_ref14) {
759
+ var image = _ref14.image;
760
+ return image.currentSrc.includes("".concat(num, "_D.")) || image.currentSrc.includes("".concat(num, "_DA."));
761
+ });
762
+ var envMap = result.find(function (_ref15) {
763
+ var image = _ref15.image;
764
+ return image.currentSrc.includes("".concat(num, "_RMO."));
765
+ });
766
+ var normalMap = result.find(function (_ref16) {
767
+ var image = _ref16.image;
768
+ return image.currentSrc.includes("".concat(num, "_N."));
769
+ });
770
+ var material = new THREE.MeshStandardMaterial({
771
+ roughness: 1,
772
+ transparent: true
773
+ });
774
+ material.depthWrite = !(ModelName === 'Flower' && num === '01');
775
+ if (map) material.map = map;
776
+ if (envMap) material.envMap = envMap;
777
+ if (normalMap) material.normalMap = normalMap;
778
+ return material;
779
+ };
780
+
781
+ var materials = new THREE.MeshPhysicalMaterial({
782
+ roughness: 1,
783
+ clearcoat: 1,
784
+ clearcoatRoughness: 1,
785
+ reflectivity: 0,
786
+ fog: false
787
+ });
745
788
 
746
- if (loadedModel) {
747
- onModelLoaded(loadedModel);
748
- return;
749
- }
789
+ if (materialsCount === 1) {
790
+ materials = createMaterial('');
791
+ }
750
792
 
751
- modelLoader.load(modelPath, model => {
752
- this.loadedModels[ModelName] = model;
753
- onModelLoaded(model);
754
- });
755
- } // Actions
793
+ if (materialsCount > 1) {
794
+ materials = _toConsumableArray(Array(materialsCount).keys()).map(function (i) {
795
+ var num = i + 1;
796
+ var realNum = num < 10 ? "0".concat(num) : num;
797
+ return createMaterial(realNum);
798
+ });
799
+ }
756
800
 
801
+ model.traverse(function (node) {
802
+ if (node.isMesh) {
803
+ node.material = materials;
804
+ node.receiveShadow = true;
805
+ node.castShadow = true;
806
+ }
807
+ });
757
808
 
758
- setShadowsVisibility(value) {
759
- this.isShadowsVisible = value;
760
- this.houseGroup.children.forEach(node => {
761
- const isLight = node instanceof THREE.DirectionalLight;
762
- if (!isLight) return;
763
- if (!node.shadowLight) return;
764
- node.castShadow = value;
765
- });
766
- }
809
+ _this12.houseGroup.add(model);
767
810
 
768
- setDoorsVisibility(value) {
769
- this.isDoorsVisible = value;
770
- this.doorsGroup.children.forEach(door => door.visible = value);
771
- }
811
+ _this12.loadFurniture(index + 1);
812
+ };
772
813
 
773
- setCurrentWallsMaterialType(value) {
774
- this.wallsMaterialType = value;
775
- this.wallsGroup.children.forEach(_ref17 => {
776
- let {
777
- children,
778
- isExterior
779
- } = _ref17;
780
- const wall = children[0];
781
-
782
- if (value === 'texture') {
783
- wall.material = isExterior ? this.exteriorWallsMaterial : this.wallsMaterial;
784
- return;
785
- }
814
+ var onModelLoaded = function onModelLoaded(originalModel) {
815
+ var model = originalModel.clone();
816
+ model.scale.set(_this12.sceneScale, _this12.sceneScale, _this12.sceneScale);
817
+ model.position.set(X * _this12.sceneScale, Y * _this12.sceneScale, Z * _this12.sceneScale);
818
+ model.rotation.set(Math.PI / 2, THREE.Math.degToRad(Rotation.Yaw), 0);
819
+ var loadedTextures = _this12.loadedTextures[ModelName];
786
820
 
787
- const color = isExterior ? '#FFFFFF' : this.wallsColor;
788
- wall.material = createDefaultMaterial(_objectSpread(_objectSpread({}, this.wallMaterialOptions), {}, {
789
- color
790
- }));
791
- });
792
- this.doorsGroup.children.forEach(door => {
793
- if (value === 'texture') {
794
- door.material = this.doorMaterial;
795
- return;
796
- }
821
+ if (loadedTextures) {
822
+ onTexturesLoaded(loadedTextures, model);
823
+ return;
824
+ }
797
825
 
798
- door.material = createDefaultMaterial(doorMaterialOptions);
799
- });
800
- }
826
+ Promise.all(promises).then(function (result) {
827
+ onTexturesLoaded(result, model);
828
+ _this12.loadedTextures[ModelName] = result;
829
+ });
830
+ };
801
831
 
802
- setCurrentWallColor(color) {
803
- this.wallsColor = color;
804
- this.wallsMaterial.color.set(color);
805
- this.wallsGroup.children.forEach(_ref18 => {
806
- let {
807
- children,
808
- isExterior
809
- } = _ref18;
810
- if (isExterior) return;
811
- const wall = children[0];
812
- wall.material.color.set(color);
813
- });
814
- }
832
+ var loadedModel = this.loadedModels[ModelName];
815
833
 
816
- setCurrentWallTexture(texture) {
817
- this.wallsMaterial = createDefaultMaterial(_objectSpread(_objectSpread({}, this.wallMaterialOptions), {}, {
818
- map: texture
819
- }));
820
- this.setCurrentWallsMaterialType('texture');
821
- }
834
+ if (loadedModel) {
835
+ onModelLoaded(loadedModel);
836
+ return;
837
+ }
822
838
 
823
- addWallTexture(image) {
824
- this.loadTexture(image, [0.5, 0.5], texture => {
825
- this.wallsTextures.push({
826
- image,
827
- texture
839
+ modelLoader.load(modelPath, function (model) {
840
+ _this12.loadedModels[ModelName] = model;
841
+ onModelLoaded(model);
828
842
  });
829
- this.setCurrentWallTexture(texture);
830
- });
831
- }
843
+ } // Actions
844
+
845
+ }, {
846
+ key: "setShadowsVisibility",
847
+ value: function setShadowsVisibility(value) {
848
+ this.isShadowsVisible = value;
849
+ this.houseGroup.children.forEach(function (node) {
850
+ var isLight = node instanceof THREE.DirectionalLight;
851
+ if (!isLight) return;
852
+ if (!node.shadowLight) return;
853
+ node.castShadow = value;
854
+ });
855
+ }
856
+ }, {
857
+ key: "setDoorsVisibility",
858
+ value: function setDoorsVisibility(value) {
859
+ this.isDoorsVisible = value;
860
+ this.doorsGroup.children.forEach(function (door) {
861
+ return door.visible = value;
862
+ });
863
+ }
864
+ }, {
865
+ key: "setCurrentWallsMaterialType",
866
+ value: function setCurrentWallsMaterialType(value) {
867
+ var _this13 = this;
868
+
869
+ this.wallsMaterialType = value;
870
+ this.wallsGroup.children.forEach(function (_ref17) {
871
+ var children = _ref17.children,
872
+ isExterior = _ref17.isExterior;
873
+ var wall = children[0];
874
+
875
+ if (value === 'texture') {
876
+ wall.material = isExterior ? _this13.exteriorWallsMaterial : _this13.wallsMaterial;
877
+ return;
878
+ }
832
879
 
833
- setFullBuildingVisibility(value) {
834
- this.isFullBuildingVisible = value;
835
- this.globalPlane.constant = this.isFullBuildingVisible ? 1 : clippedBuildingConstant;
836
- this.wallsGroup.children.forEach(_ref19 => {
837
- let {
838
- children
839
- } = _ref19;
840
- return children[2].visible = !value;
841
- });
842
- }
880
+ var color = isExterior ? '#FFFFFF' : _this13.wallsColor;
881
+ wall.material = createDefaultMaterial(_objectSpread(_objectSpread({}, _this13.wallMaterialOptions), {}, {
882
+ color: color
883
+ }));
884
+ });
885
+ this.doorsGroup.children.forEach(function (door) {
886
+ if (value === 'texture') {
887
+ door.material = _this13.doorMaterial;
888
+ return;
889
+ }
843
890
 
844
- setPlanMode() {
845
- this.setDoorsVisibility(false);
846
- this.setFullBuildingVisibility(false);
847
- this.setCurrentWallsMaterialType('color');
848
- }
891
+ door.material = createDefaultMaterial(doorMaterialOptions);
892
+ });
893
+ }
894
+ }, {
895
+ key: "setCurrentWallColor",
896
+ value: function setCurrentWallColor(color) {
897
+ this.wallsColor = color;
898
+ this.wallsMaterial.color.set(color);
899
+ this.wallsGroup.children.forEach(function (_ref18) {
900
+ var children = _ref18.children,
901
+ isExterior = _ref18.isExterior;
902
+ if (isExterior) return;
903
+ var wall = children[0];
904
+ wall.material.color.set(color);
905
+ });
906
+ }
907
+ }, {
908
+ key: "setCurrentWallTexture",
909
+ value: function setCurrentWallTexture(texture) {
910
+ this.wallsMaterial = createDefaultMaterial(_objectSpread(_objectSpread({}, this.wallMaterialOptions), {}, {
911
+ map: texture
912
+ }));
913
+ this.setCurrentWallsMaterialType('texture');
914
+ }
915
+ }, {
916
+ key: "addWallTexture",
917
+ value: function addWallTexture(image) {
918
+ var _this14 = this;
919
+
920
+ this.loadTexture(image, [0.5, 0.5], function (texture) {
921
+ _this14.wallsTextures.push({
922
+ image: image,
923
+ texture: texture
924
+ });
925
+
926
+ _this14.setCurrentWallTexture(texture);
927
+ });
928
+ }
929
+ }, {
930
+ key: "setFullBuildingVisibility",
931
+ value: function setFullBuildingVisibility(value) {
932
+ this.isFullBuildingVisible = value;
933
+ this.globalPlane.constant = this.isFullBuildingVisible ? 1 : clippedBuildingConstant;
934
+ this.wallsGroup.children.forEach(function (_ref19) {
935
+ var children = _ref19.children;
936
+ return children[2].visible = !value;
937
+ });
938
+ }
939
+ }, {
940
+ key: "setPlanMode",
941
+ value: function setPlanMode() {
942
+ this.setDoorsVisibility(false);
943
+ this.setFullBuildingVisibility(false);
944
+ this.setCurrentWallsMaterialType('color');
945
+ }
946
+ }]);
849
947
 
850
- }
948
+ return HouseStore;
949
+ }();
851
950
 
852
951
  var _default = HouseStore;
853
952
  exports.default = _default;