hart-estate-widget 0.0.21 → 0.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/assets/img/exterior-wall-texture-roughness /320/272/320/276/320/277/320/270/321/217.jpg +0 -0
- package/build/assets/img/exterior-wall-texture-roughness.jpg +0 -0
- package/build/assets/img/exterior-wall-texture-roughness.psd +0 -0
- package/build/assets/img/floor-dark-roughness.jpg +0 -0
- package/build/components/ModelTab.js +2 -0
- package/build/store/houseStore.js +144 -24
- package/build/store/modelStore.js +7 -6
- package/build/utils/modelHelpers.js +4 -0
- package/package.json +1 -1
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)
|
@@ -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.
|
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
|
-
|
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
|
-
|
493
|
+
const centerX = (maxX + minX) / 2;
|
494
|
+
const centerY = (maxY + minY) / 2;
|
495
|
+
const longerValue = centerX > centerY ? centerX : centerY;
|
496
|
+
this.houseGroup.position.set(-centerX, -centerY);
|
497
|
+
const lights = [{
|
498
|
+
x: centerX - longerValue,
|
499
|
+
y: centerY - longerValue,
|
500
|
+
z: this.wallsHeight * 3,
|
501
|
+
power: 0.4,
|
502
|
+
castShadow: true
|
503
|
+
}, {
|
504
|
+
x: centerX - longerValue,
|
505
|
+
y: centerY - longerValue,
|
506
|
+
z: this.wallsHeight * 2,
|
507
|
+
power: 1,
|
508
|
+
castShadow: false
|
509
|
+
}, {
|
510
|
+
x: centerX + longerValue,
|
511
|
+
y: centerY + longerValue,
|
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.
|
484
|
-
|
485
|
-
|
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(
|
603
|
+
return Promise.all(assets.map(_ref11 => {
|
498
604
|
let {
|
499
605
|
img,
|
500
606
|
repeat,
|
501
607
|
callback
|
502
|
-
} =
|
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,
|
651
|
+
const materialsCount = result.reduce((acc, _ref12) => {
|
546
652
|
let {
|
547
653
|
image
|
548
|
-
} =
|
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(
|
660
|
+
const map = result.find(_ref13 => {
|
555
661
|
let {
|
556
662
|
image
|
557
|
-
} =
|
663
|
+
} = _ref13;
|
558
664
|
return image.currentSrc.includes("".concat(num, "_D.")) || image.currentSrc.includes("".concat(num, "_DA."));
|
559
665
|
});
|
560
|
-
const envMap = result.find(
|
666
|
+
const envMap = result.find(_ref14 => {
|
561
667
|
let {
|
562
668
|
image
|
563
|
-
} =
|
669
|
+
} = _ref14;
|
564
670
|
return image.currentSrc.includes("".concat(num, "_RMO."));
|
565
671
|
});
|
566
|
-
const normalMap = result.find(
|
672
|
+
const normalMap = result.find(_ref15 => {
|
567
673
|
let {
|
568
674
|
image
|
569
|
-
} =
|
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)
|
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(
|
769
|
+
this.wallsGroup.children.forEach(_ref16 => {
|
650
770
|
let {
|
651
771
|
children,
|
652
772
|
isExterior
|
653
|
-
} =
|
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(
|
799
|
+
this.wallsGroup.children.forEach(_ref17 => {
|
680
800
|
let {
|
681
801
|
children,
|
682
802
|
isExterior
|
683
|
-
} =
|
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(
|
830
|
+
this.wallsGroup.children.forEach(_ref18 => {
|
711
831
|
let {
|
712
832
|
children
|
713
|
-
} =
|
833
|
+
} = _ref18;
|
714
834
|
return children[2].visible = !value;
|
715
835
|
});
|
716
836
|
}
|
@@ -92,11 +92,9 @@ class ModelStore {
|
|
92
92
|
|
93
93
|
_defineProperty(this, "createScene", () => {
|
94
94
|
this.scene = new THREE.Scene();
|
95
|
-
const light = new THREE.AmbientLight(0xffffff);
|
96
95
|
this.scene.rotation.x = -Math.PI / 2;
|
97
96
|
this.scene.scale.y = -1;
|
98
97
|
this.scene.background = new THREE.Color('#FAFAFA');
|
99
|
-
this.scene.add(light);
|
100
98
|
this.createGround();
|
101
99
|
return this;
|
102
100
|
});
|
@@ -104,13 +102,14 @@ class ModelStore {
|
|
104
102
|
_defineProperty(this, "createGround", () => {
|
105
103
|
this.textureLoader.load(_grass.default, texture => {
|
106
104
|
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
|
107
|
-
texture.repeat.set(
|
108
|
-
let groundMaterial = new THREE.
|
105
|
+
texture.repeat.set(50, 50);
|
106
|
+
let groundMaterial = new THREE.MeshStandardMaterial({
|
109
107
|
map: texture,
|
110
|
-
color:
|
108
|
+
color: 0xffffff
|
111
109
|
});
|
112
|
-
let groundMesh = new THREE.Mesh(new THREE.
|
110
|
+
let groundMesh = new THREE.Mesh(new THREE.CircleGeometry(100, 100), groundMaterial);
|
113
111
|
groundMesh.position.z = -0.01;
|
112
|
+
groundMesh.receiveShadow = true;
|
114
113
|
this.scene.add(groundMesh);
|
115
114
|
});
|
116
115
|
return this;
|
@@ -121,6 +120,8 @@ class ModelStore {
|
|
121
120
|
this.renderer.setPixelRatio(window.devicePixelRatio);
|
122
121
|
this.updateRendererSize();
|
123
122
|
this.renderer.localClippingEnabled = true;
|
123
|
+
this.renderer.shadowMap.enabled = true;
|
124
|
+
this.renderer.shadowMap.type = THREE.PCFSoftShadowMap;
|
124
125
|
return this;
|
125
126
|
});
|
126
127
|
|
@@ -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
|
};
|