hart-estate-widget 0.0.21 → 0.0.24

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.
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -109,6 +109,8 @@ const ModelTab = (0, _mobxReactLite.observer)(_ref => {
109
109
  }, "View from above"), /*#__PURE__*/_react.default.createElement("li", {
110
110
  onClick: () => _modelStore.default.setCurrentControlsType('orbit')
111
111
  }, "Free camera"), /*#__PURE__*/_react.default.createElement("li", {
112
+ onClick: () => houseStore.setShadowsVisibility(!houseStore.isShadowsVisible)
113
+ }, "Shadows: ", houseStore.isShadowsVisible ? 'On' : 'Off'), /*#__PURE__*/_react.default.createElement("li", {
112
114
  onClick: () => houseStore.setPlanMode()
113
115
  }, "Plan"), /*#__PURE__*/_react.default.createElement("li", {
114
116
  onClick: () => houseStore.setFullBuildingVisibility(!houseStore.isFullBuildingVisible)
@@ -23,6 +23,8 @@ var _Loader = _interopRequireDefault(require("./Loader"));
23
23
 
24
24
  var _panoramaHelpers = require("../utils/panoramaHelpers");
25
25
 
26
+ var _geometric = require("geometric");
27
+
26
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
29
 
28
30
  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); }
@@ -63,21 +65,22 @@ const getPanoramas = (json, images, setLoadingState) => {
63
65
 
64
66
  const getPanoramaRooms = (json, panoramas) => {
65
67
  return panoramas.map((panorama, index) => {
66
- let currentRoom = {
67
- Type: "Room - ".concat(panorama['panorama_id'])
68
+ panorama['panorama_index'] = index;
69
+ const type = "Room - ".concat(panorama['panorama_id']);
70
+ if (!json) return {
71
+ type,
72
+ id: index,
73
+ panorama,
74
+ left: 0,
75
+ top: 0
68
76
  };
77
+ const currentRoom = json.Floors[0].Units[0].Rooms.find(room => room.ID === panorama['room_id']);
78
+ const [left, top] = (0, _geometric.polygonMean)((0, _panoramaHelpers.getRoomCoordinates)(currentRoom, json.Floors[0].Walls, json.Vertices));
69
79
 
70
- if (json) {
71
- currentRoom = json.Floors[0].Units[0].Rooms.find(room => room.ID === panorama['room_id']);
80
+ if (!panorama.linkedSpots.length) {
81
+ setPanoramaLinks(json, currentRoom, [left, top], panorama, panoramas);
72
82
  }
73
83
 
74
- const {
75
- left,
76
- top
77
- } = json ? (0, _panoramaHelpers.findRoomCenter)(currentRoom, json.Floors[0].Walls, json.Vertices) : {
78
- left: 0,
79
- top: 0
80
- };
81
84
  return {
82
85
  type: currentRoom.Type,
83
86
  id: index,
@@ -88,6 +91,39 @@ const getPanoramaRooms = (json, panoramas) => {
88
91
  }, []);
89
92
  };
90
93
 
94
+ const setPanoramaLinks = (json, currentRoom, center, panorama, panoramas) => {
95
+ json.Floors[0].Doors.forEach(_ref => {
96
+ let {
97
+ Location,
98
+ Walls
99
+ } = _ref;
100
+ if (!Walls.some(doorWallId => currentRoom.Walls.some(roomWallId => roomWallId === doorWallId))) return;
101
+ const connectedRoom = json.Floors[0].Units[0].Rooms.find(room => {
102
+ const roomHasSameWall = room.Walls.some(roomWallId => Walls.some(doorWallId => roomWallId === doorWallId));
103
+ const isSameRoom = room.ID === currentRoom.ID;
104
+ return roomHasSameWall && !isSameRoom;
105
+ });
106
+ if (!connectedRoom) return;
107
+ const connectedPanorama = panoramas.find(_ref2 => {
108
+ let {
109
+ room_id
110
+ } = _ref2;
111
+ return room_id === connectedRoom.ID;
112
+ });
113
+ if (!connectedPanorama) return;
114
+ const locationX = Location.X - center[0];
115
+ const locationY = -(Location.Y - center[1]);
116
+ const defaultScale = 20;
117
+ const maxScale = 50;
118
+ const defaultLength = 120;
119
+ const length = (0, _geometric.lineLength)([[0, 0], [locationX, locationY]]);
120
+ const scale = length / defaultLength * defaultScale;
121
+ const finalScale = scale > maxScale ? maxScale : scale;
122
+ const position = new THREE.Vector3(locationX, -10, locationY);
123
+ panorama.link(connectedPanorama, position, finalScale);
124
+ });
125
+ };
126
+
91
127
  const initPanorama = () => {
92
128
  let camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 1100);
93
129
  let controls = new _threeDeviceOrientation.default(camera);
@@ -113,12 +149,12 @@ const initPanorama = () => {
113
149
  };
114
150
  };
115
151
 
116
- const PanoramaTab = _ref => {
152
+ const PanoramaTab = _ref3 => {
117
153
  let {
118
154
  json,
119
155
  planImage,
120
156
  images
121
- } = _ref;
157
+ } = _ref3;
122
158
  const [menuState, setMenuState] = (0, _react.useState)(false);
123
159
  const [loadingState, setLoadingState] = (0, _react.useState)(true);
124
160
  const [isMapActive, setMapState] = (0, _react.useState)(false);
@@ -178,6 +214,12 @@ const PanoramaTab = _ref => {
178
214
  });
179
215
  panoramas.forEach(panorama => {
180
216
  if (!panorama.panorama_id) return;
217
+ panorama.addEventListener('enter', _ref4 => {
218
+ let {
219
+ target
220
+ } = _ref4;
221
+ return setCurrentRoomIndex(target['panorama_index']);
222
+ });
181
223
  newViewer.add(panorama);
182
224
  });
183
225
  setViewer(newViewer);
@@ -35,6 +35,8 @@ var _doorTexture = _interopRequireDefault(require("../assets/img/door-texture.jp
35
35
 
36
36
  var _exteriorWallTexture = _interopRequireDefault(require("../assets/img/exterior-wall-texture.jpeg"));
37
37
 
38
+ var _exteriorWallTextureRoughness = _interopRequireDefault(require("../assets/img/exterior-wall-texture-roughness.jpg"));
39
+
38
40
  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); }
39
41
 
40
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; }
@@ -57,7 +59,10 @@ const doorMaterialOptions = {
57
59
  };
58
60
  const modelLoader = new _FBXLoader.FBXLoader();
59
61
 
60
- const createDefaultMaterial = options => new THREE.MeshPhongMaterial(options);
62
+ const createDefaultMaterial = options => new THREE.MeshStandardMaterial(_objectSpread({
63
+ roughness: 1,
64
+ metalness: 0
65
+ }, options));
61
66
 
62
67
  class HouseStore {
63
68
  constructor(modelStore) {
@@ -77,6 +82,11 @@ class HouseStore {
77
82
 
78
83
  _defineProperty(this, "wallsColor", '#FFFFFF');
79
84
 
85
+ _defineProperty(this, "exteriorWallsMaps", {
86
+ map: null,
87
+ roughnessMap: null
88
+ });
89
+
80
90
  _defineProperty(this, "exteriorWallsMaterial", null);
81
91
 
82
92
  _defineProperty(this, "wallsTextures", []);
@@ -97,6 +107,8 @@ class HouseStore {
97
107
 
98
108
  _defineProperty(this, "loadedTextures", {});
99
109
 
110
+ _defineProperty(this, "isShadowsVisible", true);
111
+
100
112
  (0, _mobx.makeAutoObservable)(this);
101
113
  this.modelStore = modelStore;
102
114
  this.houseGroup.name = 'House-Group';
@@ -268,15 +280,28 @@ class HouseStore {
268
280
  side: THREE.DoubleSide
269
281
  });
270
282
  const mesh = new THREE.Mesh(geometry, material);
283
+ mesh.receiveShadow = true;
284
+ mesh.castShadow = false;
271
285
  mesh.name = 'FloorMesh';
272
- this.loadTexture(params.texture, [0.5, 0.5], texture => {
286
+
287
+ const callback = (texture, roughnessMap) => {
273
288
  const textureMaterial = createDefaultMaterial({
274
289
  color: params.color,
275
290
  side: THREE.DoubleSide,
276
291
  map: texture
277
292
  });
278
293
  mesh.material = textureMaterial;
294
+ if (roughnessMap) mesh.material.roughnessMap = roughnessMap;
279
295
  this.houseGroup.add(mesh);
296
+ };
297
+
298
+ this.loadTexture(params.texture, [0.5, 0.5], texture => {
299
+ if (!params.roughnessMap) {
300
+ callback(texture);
301
+ return;
302
+ }
303
+
304
+ this.loadTexture(params.roughnessMap, [0.5, 0.5], roughnessMap => callback(texture, roughnessMap));
280
305
  });
281
306
  });
282
307
  return this;
@@ -319,6 +344,8 @@ class HouseStore {
319
344
  const clippedMesh = new THREE.Mesh(clippedGeometry, clippedMaterial);
320
345
  const flatMesh = new THREE.Mesh(flatGeometry, material);
321
346
  const mesh = new THREE.Mesh(geometry, material);
347
+ flatMesh.receiveShadow = false;
348
+ flatMesh.castShadow = false;
322
349
  clippedMesh.position.z = -0.005;
323
350
  flatMesh.position.z = -0.005;
324
351
  mesh.position.z = -0.001;
@@ -328,6 +355,10 @@ class HouseStore {
328
355
  clippedMeshWithApertures.name = 'ClippedSpaceBetweenWalls';
329
356
  meshWithApertures.name = 'SpaceBetweenWalls';
330
357
  flatMesh.name = 'FlatSpaceBetweenWalls';
358
+ clippedMeshWithApertures.receiveShadow = false;
359
+ clippedMeshWithApertures.castShadow = false;
360
+ meshWithApertures.receiveShadow = false;
361
+ meshWithApertures.castShadow = false;
331
362
  this.houseGroup.add(flatMesh, clippedMeshWithApertures, meshWithApertures);
332
363
  return this;
333
364
  }
@@ -360,10 +391,18 @@ class HouseStore {
360
391
  const wallMesh = this.subtractApertures(new THREE.Mesh(wallGeometry, wallMaterial), apertures);
361
392
  const wallPadMesh = new THREE.Mesh(wallPadGeometry, wallPadMaterial);
362
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;
363
400
  wallPadMesh.position.z = this.wallsHeight;
364
401
  wallClippedPadMesh.position.z = (this.wallsHeight + 0.5) * clippedBuildingConstant + 0.001;
365
402
  const wallClippedPadMeshWithApertures = this.subtractApertures(wallClippedPadMesh, apertures);
366
403
  wallClippedPadMeshWithApertures.visible = false;
404
+ wallClippedPadMeshWithApertures.castShadow = false;
405
+ wallClippedPadMeshWithApertures.receiveShadow = false;
367
406
  const wallGroup = new THREE.Group();
368
407
  wallGroup.name = 'Wall';
369
408
  wallGroup.buildingId = wallId;
@@ -372,6 +411,11 @@ class HouseStore {
372
411
  this.wallsGroup.add(wallGroup);
373
412
  };
374
413
 
414
+ this.exteriorWallsMaterial = createDefaultMaterial(_objectSpread(_objectSpread({}, this.wallMaterialOptions), {}, {
415
+ map: this.exteriorWallsMaps.map,
416
+ roughnessMap: this.exteriorWallsMaps.roughnessMap,
417
+ color: '#FFFFFF'
418
+ }));
375
419
  this.rooms.forEach(_ref7 => {
376
420
  let {
377
421
  Walls
@@ -396,6 +440,8 @@ class HouseStore {
396
440
  mesh.position.y = Location.Y * this.sceneScale;
397
441
  mesh.position.z = this.doorsHeight / 2;
398
442
  mesh.rotation.z = THREE.Math.degToRad(Rotation.Yaw);
443
+ mesh.receiveShadow = true;
444
+ mesh.castShadow = true;
399
445
  this.doorsGroup.add(mesh);
400
446
  });
401
447
  this.houseGroup.add(this.doorsGroup);
@@ -444,7 +490,60 @@ class HouseStore {
444
490
  maxY,
445
491
  minY
446
492
  } = (0, _modelHelpers.getMinMaxCoordinates)(walls);
447
- this.houseGroup.position.set(-(maxX + minX) / 2, -(maxY + minY) / 2);
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
+ });
448
547
  return this;
449
548
  }
450
549
 
@@ -480,10 +579,17 @@ class HouseStore {
480
579
  image: _exteriorWallTexture.default,
481
580
  texture: texture
482
581
  });
483
- this.exteriorWallsMaterial = createDefaultMaterial(_objectSpread(_objectSpread({}, this.wallMaterialOptions), {}, {
484
- map: texture,
485
- color: '#FFFFFF'
486
- }));
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
591
+ });
592
+ this.exteriorWallsMaps.roughnessMap = texture;
487
593
  }
488
594
  }, {
489
595
  img: _doorTexture.default,
@@ -494,12 +600,12 @@ class HouseStore {
494
600
  }));
495
601
  }
496
602
  }];
497
- return Promise.all(assets.map(_ref10 => {
603
+ return Promise.all(assets.map(_ref11 => {
498
604
  let {
499
605
  img,
500
606
  repeat,
501
607
  callback
502
- } = _ref10;
608
+ } = _ref11;
503
609
  return new Promise(resolve => {
504
610
  this.loadTexture(img, repeat, texture => {
505
611
  callback(texture);
@@ -542,31 +648,31 @@ class HouseStore {
542
648
  });
543
649
 
544
650
  const onTexturesLoaded = (result, model) => {
545
- const materialsCount = result.reduce((acc, _ref11) => {
651
+ const materialsCount = result.reduce((acc, _ref12) => {
546
652
  let {
547
653
  image
548
- } = _ref11;
654
+ } = _ref12;
549
655
  if (!image.currentSrc.includes('_D.') && !image.currentSrc.includes('_DA.')) return acc;
550
656
  return acc += 1;
551
657
  }, 0);
552
658
 
553
659
  const createMaterial = num => {
554
- const map = result.find(_ref12 => {
660
+ const map = result.find(_ref13 => {
555
661
  let {
556
662
  image
557
- } = _ref12;
663
+ } = _ref13;
558
664
  return image.currentSrc.includes("".concat(num, "_D.")) || image.currentSrc.includes("".concat(num, "_DA."));
559
665
  });
560
- const envMap = result.find(_ref13 => {
666
+ const envMap = result.find(_ref14 => {
561
667
  let {
562
668
  image
563
- } = _ref13;
669
+ } = _ref14;
564
670
  return image.currentSrc.includes("".concat(num, "_RMO."));
565
671
  });
566
- const normalMap = result.find(_ref14 => {
672
+ const normalMap = result.find(_ref15 => {
567
673
  let {
568
674
  image
569
- } = _ref14;
675
+ } = _ref15;
570
676
  return image.currentSrc.includes("".concat(num, "_N."));
571
677
  });
572
678
  const material = new THREE.MeshStandardMaterial({
@@ -601,7 +707,11 @@ class HouseStore {
601
707
  }
602
708
 
603
709
  model.traverse(node => {
604
- if (node.isMesh) node.material = materials;
710
+ if (node.isMesh) {
711
+ node.material = materials;
712
+ node.receiveShadow = true;
713
+ node.castShadow = true;
714
+ }
605
715
  });
606
716
  this.houseGroup.add(model);
607
717
  this.loadFurniture(index + 1);
@@ -639,6 +749,16 @@ class HouseStore {
639
749
  } // Actions
640
750
 
641
751
 
752
+ setShadowsVisibility(value) {
753
+ this.isShadowsVisible = value;
754
+ this.houseGroup.children.forEach(node => {
755
+ const isLight = node instanceof THREE.DirectionalLight;
756
+ if (!isLight) return;
757
+ if (!node.shadowLight) return;
758
+ node.castShadow = value;
759
+ });
760
+ }
761
+
642
762
  setDoorsVisibility(value) {
643
763
  this.isDoorsVisible = value;
644
764
  this.doorsGroup.children.forEach(door => door.visible = value);
@@ -646,11 +766,11 @@ class HouseStore {
646
766
 
647
767
  setCurrentWallsMaterialType(value) {
648
768
  this.wallsMaterialType = value;
649
- this.wallsGroup.children.forEach(_ref15 => {
769
+ this.wallsGroup.children.forEach(_ref16 => {
650
770
  let {
651
771
  children,
652
772
  isExterior
653
- } = _ref15;
773
+ } = _ref16;
654
774
  const wall = children[0];
655
775
 
656
776
  if (value === 'texture') {
@@ -676,11 +796,11 @@ class HouseStore {
676
796
  setCurrentWallColor(color) {
677
797
  this.wallsColor = color;
678
798
  this.wallsMaterial.color.set(color);
679
- this.wallsGroup.children.forEach(_ref16 => {
799
+ this.wallsGroup.children.forEach(_ref17 => {
680
800
  let {
681
801
  children,
682
802
  isExterior
683
- } = _ref16;
803
+ } = _ref17;
684
804
  if (isExterior) return;
685
805
  const wall = children[0];
686
806
  wall.material.color.set(color);
@@ -707,10 +827,10 @@ class HouseStore {
707
827
  setFullBuildingVisibility(value) {
708
828
  this.isFullBuildingVisible = value;
709
829
  this.globalPlane.constant = this.isFullBuildingVisible ? 1 : clippedBuildingConstant;
710
- this.wallsGroup.children.forEach(_ref17 => {
830
+ this.wallsGroup.children.forEach(_ref18 => {
711
831
  let {
712
832
  children
713
- } = _ref17;
833
+ } = _ref18;
714
834
  return children[2].visible = !value;
715
835
  });
716
836
  }
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
 
8
+ require("core-js/modules/es.promise.js");
9
+
8
10
  require("core-js/modules/web.dom-collections.iterator.js");
9
11
 
10
12
  var _react = _interopRequireDefault(require("react"));
@@ -92,25 +94,30 @@ class ModelStore {
92
94
 
93
95
  _defineProperty(this, "createScene", () => {
94
96
  this.scene = new THREE.Scene();
95
- const light = new THREE.AmbientLight(0xffffff);
96
97
  this.scene.rotation.x = -Math.PI / 2;
97
98
  this.scene.scale.y = -1;
98
- this.scene.background = new THREE.Color('#FAFAFA');
99
- this.scene.add(light);
99
+ this.scene.background = new THREE.Color('#E7E7E7');
100
+ this.scene.fog = new THREE.Fog('#E7E7E7', 5, 200);
100
101
  this.createGround();
101
102
  return this;
102
103
  });
103
104
 
104
105
  _defineProperty(this, "createGround", () => {
105
- this.textureLoader.load(_grass.default, texture => {
106
- texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
107
- texture.repeat.set(70, 70);
108
- let groundMaterial = new THREE.MeshBasicMaterial({
109
- map: texture,
110
- color: 'rgb(255,255,255)'
106
+ const textures = {};
107
+ const assets = [new Promise(resolve => this.loadTexture(_grass.default, [75, 75], texture => {
108
+ textures.map = texture;
109
+ resolve();
110
+ }))];
111
+ Promise.all(assets).then(() => {
112
+ let groundMaterial = new THREE.MeshStandardMaterial({
113
+ map: textures.map,
114
+ normalMap: textures.normalMap,
115
+ envMap: textures.envMap,
116
+ color: 0xe7e7e7
111
117
  });
112
- let groundMesh = new THREE.Mesh(new THREE.PlaneBufferGeometry(300, 300), groundMaterial);
118
+ let groundMesh = new THREE.Mesh(new THREE.CircleGeometry(250, 100), groundMaterial);
113
119
  groundMesh.position.z = -0.01;
120
+ groundMesh.receiveShadow = true;
114
121
  this.scene.add(groundMesh);
115
122
  });
116
123
  return this;
@@ -121,6 +128,8 @@ class ModelStore {
121
128
  this.renderer.setPixelRatio(window.devicePixelRatio);
122
129
  this.updateRendererSize();
123
130
  this.renderer.localClippingEnabled = true;
131
+ this.renderer.shadowMap.enabled = true;
132
+ this.renderer.shadowMap.type = THREE.PCFSoftShadowMap;
124
133
  return this;
125
134
  });
126
135
 
@@ -253,6 +262,17 @@ class ModelStore {
253
262
  return ((_this$container2 = this.container) === null || _this$container2 === void 0 ? void 0 : _this$container2.offsetHeight) || window.innerHeight;
254
263
  }
255
264
 
265
+ loadTexture(img) {
266
+ let repeat = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [1, 1];
267
+ let callback = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : () => {};
268
+ this.textureLoader.load(img, texture => {
269
+ texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
270
+ texture.repeat.set(repeat[0], repeat[1]);
271
+ texture.flipY = false;
272
+ callback(texture);
273
+ });
274
+ }
275
+
256
276
  }
257
277
 
258
278
  var _default = new ModelStore();
@@ -28,18 +28,22 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
28
28
  const FloorParams = {
29
29
  'default': {
30
30
  texture: _floorDark.default,
31
+ roughnessMap: null,
31
32
  color: '#FFFFFF'
32
33
  },
33
34
  'Kitchen': {
34
35
  texture: _floorWhite.default,
36
+ roughnessMap: null,
35
37
  color: '#FFFFFF'
36
38
  },
37
39
  'Balcony': {
38
40
  texture: _floor.default,
41
+ roughnessMap: null,
39
42
  color: '#DADADA'
40
43
  },
41
44
  'Bathroom': {
42
45
  texture: _floorBathroom.default,
46
+ roughnessMap: null,
43
47
  color: '#FFFFFF'
44
48
  }
45
49
  };
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getVerticesLocations = exports.getScale = exports.findWallVertices = exports.findRoomCenter = exports.findMinMaxCoordinates = void 0;
6
+ exports.getScale = exports.getRoomCoordinates = exports.findWallVertices = void 0;
7
7
 
8
- require("core-js/modules/web.dom-collections.iterator.js");
8
+ require("core-js/modules/es.array.reduce.js");
9
9
 
10
10
  var _react = _interopRequireDefault(require("react"));
11
11
 
@@ -13,59 +13,24 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
13
13
 
14
14
  const findWallVertices = (walls, wall, vertices) => {
15
15
  const currentWall = walls.find(el => el.ID === wall);
16
- return currentWall.Vertices.map(vertex => vertices.find(el => el.ID === vertex));
17
- };
18
-
19
- exports.findWallVertices = findWallVertices;
20
-
21
- const getVerticesLocations = vertices => vertices.map(vertex => vertex.Location);
22
-
23
- exports.getVerticesLocations = getVerticesLocations;
24
-
25
- const findMinMaxCoordinates = (room, walls, vertices) => {
26
- let maxX = 0;
27
- let minX = Infinity;
28
- let maxY = 0;
29
- let minY = Infinity;
30
- room.Walls.forEach(wall => {
31
- const [coord1, coord2] = getVerticesLocations(findWallVertices(walls, wall, vertices)); // CALCULATE MAX COORDS
32
-
33
- if (coord1.X > maxX) maxX = coord1.X;
34
- if (coord1.X > maxX) maxX = coord1.X;
35
- if (coord2.Y > maxY) maxY = coord2.Y;
36
- if (coord2.Y > maxY) maxY = coord2.Y; // CALCULATE MIN COORDS
37
-
38
- if (coord1.X < minX) minX = coord1.X;
39
- if (coord1.X < minX) minX = coord1.X;
40
- if (coord2.Y < minY) minY = coord2.Y;
41
- if (coord2.Y < minY) minY = coord2.Y;
16
+ return currentWall.Vertices.map(vertexId => {
17
+ const vertex = vertices.find(el => el.ID === vertexId);
18
+ return [vertex.Location.X, vertex.Location.Y];
42
19
  });
43
- return {
44
- maxX,
45
- minX,
46
- maxY,
47
- minY
48
- };
49
20
  };
50
21
 
51
- exports.findMinMaxCoordinates = findMinMaxCoordinates;
22
+ exports.findWallVertices = findWallVertices;
52
23
 
53
- const findRoomCenter = (room, walls, vertices) => {
54
- const {
55
- maxX,
56
- minX,
57
- maxY,
58
- minY
59
- } = findMinMaxCoordinates(room, walls, vertices);
60
- const left = (maxX + minX) / 2;
61
- const top = (maxY + minY) / 2;
62
- return {
63
- left,
64
- top
65
- };
24
+ const getRoomCoordinates = (room, walls, vertices) => {
25
+ const points = room.Walls.reduce((acc, wallId) => {
26
+ const wall = walls.find(wallObject => wallObject.ID === wallId);
27
+ findWallVertices(walls, wall.ID, vertices).forEach(vertex => acc.push(vertex));
28
+ return acc;
29
+ }, []);
30
+ return points;
66
31
  };
67
32
 
68
- exports.findRoomCenter = findRoomCenter;
33
+ exports.getRoomCoordinates = getRoomCoordinates;
69
34
 
70
35
  const getScale = (image, json) => {
71
36
  if (!json) return {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "HART Estate widget",
4
4
  "author": "HART",
5
5
  "keywords": [],
6
- "version": "0.0.21",
6
+ "version": "0.0.24",
7
7
  "private": false,
8
8
  "main": "build/index.js",
9
9
  "module": "build/index.js",
@@ -20,6 +20,7 @@
20
20
  "dependencies": {
21
21
  "camera-controls": "^1.34.1",
22
22
  "core-js": "^3.21.0",
23
+ "geometric": "^2.2.10",
23
24
  "hold-event": "^0.1.0",
24
25
  "mobx": "^6.3.13",
25
26
  "mobx-react-lite": "^3.2.3",