hart-estate-widget 0.0.64 → 0.0.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/package.json +17 -5
- package/build/assets/css/app.css +0 -1
- package/build/assets/css/app.css.map +0 -1
- package/build/assets/fonts/RobotoMono/RobotoMono-Bold.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Bold.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Bold.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-BoldItalic.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-BoldItalic.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-BoldItalic.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Italic.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Italic.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Italic.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Light.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Light.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Light.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-LightItalic.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-LightItalic.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-LightItalic.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Medium.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Medium.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Medium.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-MediumItalic.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-MediumItalic.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-MediumItalic.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Regular.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Regular.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Regular.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Thin.ttf +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Thin.woff +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono-Thin.woff2 +0 -0
- package/build/assets/fonts/RobotoMono/RobotoMono.css +0 -98
- package/build/assets/icons/1x.svg +0 -4
- package/build/assets/icons/2x.svg +0 -4
- package/build/assets/icons/bullet.png +0 -0
- package/build/assets/icons/close.svg +0 -4
- package/build/assets/icons/enter-fullscreen.svg +0 -6
- package/build/assets/icons/hand-move.svg +0 -15
- package/build/assets/icons/hand-research.svg +0 -12
- package/build/assets/icons/rotation-close.svg +0 -6
- package/build/assets/icons/rotation.svg +0 -4
- package/build/assets/img/3D.jpg +0 -0
- package/build/assets/img/door-icon.png +0 -0
- package/build/assets/img/door-texture.jpeg +0 -0
- package/build/assets/img/exterior-wall-texture-roughness.jpg +0 -0
- package/build/assets/img/exterior-wall-texture.jpeg +0 -0
- package/build/assets/img/floor-bathroom.jpg +0 -0
- package/build/assets/img/floor-dark.png +0 -0
- package/build/assets/img/floor-white.png +0 -0
- package/build/assets/img/floor.jpg +0 -0
- package/build/assets/img/grass.png +0 -0
- package/build/assets/img/logo.svg +0 -11
- package/build/assets/img/refresh-icon.svg +0 -6
- package/build/assets/img/spot-icon.png +0 -0
- package/build/assets/img/wall-texture.jpg +0 -0
- package/build/assets/sass/components/instructions.sass +0 -94
- package/build/assets/sass/components/loader.sass +0 -54
- package/build/assets/sass/components/model.sass +0 -27
- package/build/assets/sass/components/panorama.sass +0 -174
- package/build/assets/sass/components/rotation.sass +0 -106
- package/build/assets/sass/components/tabs.sass +0 -121
- package/build/assets/sass/index.sass +0 -65
- package/build/assets/sass/mixin.sass +0 -48
- package/build/assets/sass/vars.sass +0 -28
- package/build/components/Application.js +0 -132
- package/build/components/Buttons/FullScreenButton.js +0 -50
- package/build/components/Buttons/TabButton.js +0 -24
- package/build/components/Instructions.js +0 -54
- package/build/components/Loader.js +0 -22
- package/build/components/ModelTab.js +0 -213
- package/build/components/PanoramaTab.js +0 -620
- package/build/components/RotationTab.js +0 -152
- package/build/components/Widget.js +0 -130
- package/build/config/defaultConfig.js +0 -30
- package/build/enums/deviceOrientationStatuses.js +0 -11
- package/build/enums/deviceWidth.js +0 -21
- package/build/enums/imageExtentions.js +0 -16
- package/build/index.css +0 -2
- package/build/index.js +0 -67
- package/build/locale/en/data.json +0 -25
- package/build/locale/index.js +0 -71
- package/build/locale/ru/data.json +0 -25
- package/build/store/apiStore.js +0 -231
- package/build/store/deviceStore.js +0 -60
- package/build/store/fullScreenStore.js +0 -159
- package/build/store/houseStore.js +0 -952
- package/build/store/index.js +0 -124
- package/build/store/modelStore.js +0 -338
- package/build/threesixty/events.js +0 -220
- package/build/threesixty/index.js +0 -264
- package/build/utils/csg/csg-lib.js +0 -472
- package/build/utils/csg/csg-worker.js +0 -84
- package/build/utils/csg/three-csg.js +0 -277
- package/build/utils/helpers.js +0 -12
- package/build/utils/modelHelpers.js +0 -161
- package/build/utils/panoramaHelpers.js +0 -117
@@ -1,952 +0,0 @@
|
|
1
|
-
"use strict";
|
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
|
-
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
6
|
-
value: true
|
7
|
-
});
|
8
|
-
exports.default = void 0;
|
9
|
-
|
10
|
-
var _react = _interopRequireDefault(require("react"));
|
11
|
-
|
12
|
-
var _mobx = require("mobx");
|
13
|
-
|
14
|
-
var _apiStore = _interopRequireDefault(require("../store/apiStore"));
|
15
|
-
|
16
|
-
var _store = _interopRequireDefault(require("../store"));
|
17
|
-
|
18
|
-
var THREE = _interopRequireWildcard(require("three"));
|
19
|
-
|
20
|
-
var _FBXLoader = require("three/examples/jsm/loaders/FBXLoader");
|
21
|
-
|
22
|
-
var _modelHelpers = require("../utils/modelHelpers");
|
23
|
-
|
24
|
-
var _threeCsg = _interopRequireDefault(require("../utils/csg/three-csg"));
|
25
|
-
|
26
|
-
var _wallTexture = _interopRequireDefault(require("../assets/img/wall-texture.jpg"));
|
27
|
-
|
28
|
-
var _doorTexture = _interopRequireDefault(require("../assets/img/door-texture.jpeg"));
|
29
|
-
|
30
|
-
var _exteriorWallTexture = _interopRequireDefault(require("../assets/img/exterior-wall-texture.jpeg"));
|
31
|
-
|
32
|
-
var _exteriorWallTextureRoughness = _interopRequireDefault(require("../assets/img/exterior-wall-texture-roughness.jpg"));
|
33
|
-
|
34
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
35
|
-
|
36
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
37
|
-
|
38
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
39
|
-
|
40
|
-
function _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
|
-
|
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; }
|
67
|
-
|
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; }
|
69
|
-
|
70
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
71
|
-
|
72
|
-
(0, _mobx.configure)({
|
73
|
-
useProxies: 'never'
|
74
|
-
});
|
75
|
-
var clippedBuildingConstant = 0.4;
|
76
|
-
var doorMaterialOptions = {
|
77
|
-
color: '#DADADA',
|
78
|
-
side: THREE.DoubleSide
|
79
|
-
};
|
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;
|
92
|
-
|
93
|
-
_classCallCheck(this, HouseStore);
|
94
|
-
|
95
|
-
_defineProperty(this, "modelStore", null);
|
96
|
-
|
97
|
-
_defineProperty(this, "apiStore", new _apiStore.default(_store.default.config.API_URL));
|
98
|
-
|
99
|
-
_defineProperty(this, "houseGroup", new THREE.Group());
|
100
|
-
|
101
|
-
_defineProperty(this, "wallsGroup", new THREE.Group());
|
102
|
-
|
103
|
-
_defineProperty(this, "doorsGroup", new THREE.Group());
|
104
|
-
|
105
|
-
_defineProperty(this, "doorMaterial", null);
|
106
|
-
|
107
|
-
_defineProperty(this, "wallsMaterial", null);
|
108
|
-
|
109
|
-
_defineProperty(this, "wallsColor", '#FFFFFF');
|
110
|
-
|
111
|
-
_defineProperty(this, "exteriorWallsMaps", {
|
112
|
-
map: null,
|
113
|
-
roughnessMap: null
|
114
|
-
});
|
115
|
-
|
116
|
-
_defineProperty(this, "exteriorWallsMaterial", null);
|
117
|
-
|
118
|
-
_defineProperty(this, "wallsTextures", []);
|
119
|
-
|
120
|
-
_defineProperty(this, "isDoorsVisible", true);
|
121
|
-
|
122
|
-
_defineProperty(this, "isFullBuildingVisible", true);
|
123
|
-
|
124
|
-
_defineProperty(this, "wallsMaterialType", 'texture');
|
125
|
-
|
126
|
-
_defineProperty(this, "globalPlane", null);
|
127
|
-
|
128
|
-
_defineProperty(this, "clippingPlanes", []);
|
129
|
-
|
130
|
-
_defineProperty(this, "furnitureData", []);
|
131
|
-
|
132
|
-
_defineProperty(this, "loadedModels", {});
|
133
|
-
|
134
|
-
_defineProperty(this, "loadedTextures", {});
|
135
|
-
|
136
|
-
_defineProperty(this, "isShadowsVisible", true);
|
137
|
-
|
138
|
-
(0, _mobx.makeAutoObservable)(this);
|
139
|
-
this.modelStore = modelStore;
|
140
|
-
this.houseGroup.name = 'House-Group';
|
141
|
-
this.globalPlane = new THREE.Plane(new THREE.Vector3(0, -this.wallsHeight - 0.5, 0), 1);
|
142
|
-
this.clippingPlanes = [this.globalPlane];
|
143
|
-
this.setCenterPosition().loadTextures().then(function () {
|
144
|
-
_this.createFloors().createSpaceBetweenWalls().createWalls().createDoors();
|
145
|
-
});
|
146
|
-
this.apiStore.loadFurnitureData().then(function (resp) {
|
147
|
-
_this.furnitureData = resp;
|
148
|
-
|
149
|
-
_this.loadFurniture(0);
|
150
|
-
});
|
151
|
-
}
|
152
|
-
|
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;
|
197
|
-
|
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;
|
206
|
-
|
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,
|
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
|
-
}
|
277
|
-
});
|
278
|
-
|
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
|
-
}
|
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);
|
332
|
-
|
333
|
-
var vertices = _this5.getVerticesFromParsedWalls(walls);
|
334
|
-
|
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
|
-
});
|
368
|
-
});
|
369
|
-
return this;
|
370
|
-
}
|
371
|
-
}, {
|
372
|
-
key: "createSpaceBetweenWalls",
|
373
|
-
value: function createSpaceBetweenWalls() {
|
374
|
-
var _this6 = this;
|
375
|
-
|
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);
|
391
|
-
|
392
|
-
shapeWithHoles.holes.push(new THREE.Shape(roomVertices));
|
393
|
-
});
|
394
|
-
var clippedGeometry = new THREE.ExtrudeGeometry(shapeWithHoles, {
|
395
|
-
depth: clippedDepth,
|
396
|
-
bevelEnabled: false
|
397
|
-
});
|
398
|
-
var flatGeometry = new THREE.ExtrudeGeometry(shape, {
|
399
|
-
depth: 0.001,
|
400
|
-
bevelEnabled: false
|
401
|
-
});
|
402
|
-
var geometry = new THREE.ExtrudeGeometry(shapeWithHoles, {
|
403
|
-
depth: depth,
|
404
|
-
bevelEnabled: false
|
405
|
-
});
|
406
|
-
var clippedMaterial = createDefaultMaterial({
|
407
|
-
side: THREE.DoubleSide,
|
408
|
-
color: '#5C5C5C'
|
409
|
-
});
|
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
|
449
|
-
});
|
450
|
-
var wallPadGeometry = new THREE.ExtrudeGeometry(wallShape, {
|
451
|
-
depth: 0.001,
|
452
|
-
bevelEnabled: false
|
453
|
-
});
|
454
|
-
var wallMaterial = isExterior ? _this7.exteriorWallsMaterial : _this7.wallsMaterial;
|
455
|
-
var wallPadMaterial = createDefaultMaterial(_objectSpread(_objectSpread({}, _this7.wallMaterialOptions), {}, {
|
456
|
-
color: '#5C5C5C'
|
457
|
-
}));
|
458
|
-
var wallClippedPadMaterial = createDefaultMaterial({
|
459
|
-
side: THREE.DoubleSide,
|
460
|
-
color: '#5C5C5C'
|
461
|
-
});
|
462
|
-
|
463
|
-
var apertures = _this7.apertures.filter(function (aperture) {
|
464
|
-
return aperture.Walls.some(function (id) {
|
465
|
-
return wallId === id;
|
466
|
-
});
|
467
|
-
});
|
468
|
-
|
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
|
-
};
|
495
|
-
|
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);
|
505
|
-
});
|
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'
|
553
|
-
});
|
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();
|
561
|
-
|
562
|
-
var apertureBSP = _threeCsg.default.fromMesh(apertureMesh);
|
563
|
-
|
564
|
-
var wallBSP = _threeCsg.default.fromMesh(resultMesh);
|
565
|
-
|
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;
|
575
|
-
|
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;
|
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;
|
725
|
-
});
|
726
|
-
|
727
|
-
if (!furnitureData) {
|
728
|
-
this.loadFurniture(index + 1);
|
729
|
-
return;
|
730
|
-
}
|
731
|
-
|
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
|
-
});
|
748
|
-
});
|
749
|
-
|
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
|
-
});
|
788
|
-
|
789
|
-
if (materialsCount === 1) {
|
790
|
-
materials = createMaterial('');
|
791
|
-
}
|
792
|
-
|
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
|
-
}
|
800
|
-
|
801
|
-
model.traverse(function (node) {
|
802
|
-
if (node.isMesh) {
|
803
|
-
node.material = materials;
|
804
|
-
node.receiveShadow = true;
|
805
|
-
node.castShadow = true;
|
806
|
-
}
|
807
|
-
});
|
808
|
-
|
809
|
-
_this12.houseGroup.add(model);
|
810
|
-
|
811
|
-
_this12.loadFurniture(index + 1);
|
812
|
-
};
|
813
|
-
|
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];
|
820
|
-
|
821
|
-
if (loadedTextures) {
|
822
|
-
onTexturesLoaded(loadedTextures, model);
|
823
|
-
return;
|
824
|
-
}
|
825
|
-
|
826
|
-
Promise.all(promises).then(function (result) {
|
827
|
-
onTexturesLoaded(result, model);
|
828
|
-
_this12.loadedTextures[ModelName] = result;
|
829
|
-
});
|
830
|
-
};
|
831
|
-
|
832
|
-
var loadedModel = this.loadedModels[ModelName];
|
833
|
-
|
834
|
-
if (loadedModel) {
|
835
|
-
onModelLoaded(loadedModel);
|
836
|
-
return;
|
837
|
-
}
|
838
|
-
|
839
|
-
modelLoader.load(modelPath, function (model) {
|
840
|
-
_this12.loadedModels[ModelName] = model;
|
841
|
-
onModelLoaded(model);
|
842
|
-
});
|
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
|
-
}
|
879
|
-
|
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
|
-
}
|
890
|
-
|
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
|
-
}]);
|
947
|
-
|
948
|
-
return HouseStore;
|
949
|
-
}();
|
950
|
-
|
951
|
-
var _default = HouseStore;
|
952
|
-
exports.default = _default;
|