kitchen-simulator 5.0.0-test.7 → 5.0.0-test.9

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.
Files changed (170) hide show
  1. package/package.json +12 -3
  2. package/src/components/export.js +16 -23
  3. package/src/components/catalog-view/catalog-breadcrumb.jsx +0 -53
  4. package/src/components/catalog-view/catalog-item.jsx +0 -229
  5. package/src/components/catalog-view/catalog-list.jsx +0 -173
  6. package/src/components/catalog-view/catalog-page-item.jsx +0 -110
  7. package/src/components/catalog-view/catalog-turn-back-page-item.jsx +0 -80
  8. package/src/components/configurator/custom-configurator.jsx +0 -77
  9. package/src/components/configurator/project-configurator.jsx +0 -120
  10. package/src/components/firstsetting/button/styles.js +0 -223
  11. package/src/components/firstsetting/export.js +0 -9
  12. package/src/components/firstsetting/firstsetting-content-button.jsx +0 -198
  13. package/src/components/firstsetting/firstsetting-toggle-button.jsx +0 -101
  14. package/src/components/firstsetting/firstsetting.jsx +0 -814
  15. package/src/components/footerbar/button/ControlButton.jsx +0 -43
  16. package/src/components/footerbar/button/DirectionButton.jsx +0 -54
  17. package/src/components/footerbar/button/DirectionPanSpinButton.jsx +0 -36
  18. package/src/components/footerbar/button/ToggleButton.jsx +0 -58
  19. package/src/components/footerbar/button/ToggleConvertButton.jsx +0 -48
  20. package/src/components/footerbar/button/ToggleMeasureButton.jsx +0 -33
  21. package/src/components/footerbar/button/styles.js +0 -217
  22. package/src/components/footerbar/export.js +0 -9
  23. package/src/components/footerbar/footer-content-button.jsx +0 -198
  24. package/src/components/footerbar/footer-toggle-button.jsx +0 -101
  25. package/src/components/footerbar/footerbar.jsx +0 -1103
  26. package/src/components/footerbar/styles.js +0 -263
  27. package/src/components/header/button/MenuButton.jsx +0 -46
  28. package/src/components/header/button/SaveButton.jsx +0 -54
  29. package/src/components/header/button/styles.js +0 -181
  30. package/src/components/header/export.js +0 -5
  31. package/src/components/header/header.jsx +0 -631
  32. package/src/components/header/header.style.css +0 -47
  33. package/src/components/header/styles.js +0 -320
  34. package/src/components/login/Login.js +0 -77
  35. package/src/components/login/LoginForm/index.js +0 -108
  36. package/src/components/login/Register.js +0 -83
  37. package/src/components/login/RegisterForm/index.js +0 -171
  38. package/src/components/login/jwtService.js +0 -201
  39. package/src/components/login/style.css +0 -158
  40. package/src/components/login/style.scss +0 -260
  41. package/src/components/myprojects/export.js +0 -5
  42. package/src/components/myprojects/index.jsx +0 -445
  43. package/src/components/myprojects/styles.js +0 -241
  44. package/src/components/sidebar/custom-accordion.jsx +0 -48
  45. package/src/components/sidebar/export.js +0 -15
  46. package/src/components/sidebar/panel-element-editor/attributes-editor/attributes-editor.jsx +0 -73
  47. package/src/components/sidebar/panel-element-editor/attributes-editor/confirm-popup.jsx +0 -101
  48. package/src/components/sidebar/panel-element-editor/attributes-editor/hole-attributes-editor.jsx +0 -149
  49. package/src/components/sidebar/panel-element-editor/attributes-editor/item-attributes-editor.jsx +0 -316
  50. package/src/components/sidebar/panel-element-editor/attributes-editor/line-attributes-editor.jsx +0 -108
  51. package/src/components/sidebar/panel-element-editor/element-editor.jsx +0 -1070
  52. package/src/components/sidebar/panel-element-editor/multi-elements-editor.jsx +0 -0
  53. package/src/components/sidebar/panel-element-editor/panel-element-editor.jsx +0 -104
  54. package/src/components/sidebar/panel-element-editor/panel-multi-elements-editor.jsx +0 -155
  55. package/src/components/sidebar/panel-group-editor.jsx +0 -272
  56. package/src/components/sidebar/panel-groups.jsx +0 -310
  57. package/src/components/sidebar/panel-guides.jsx +0 -192
  58. package/src/components/sidebar/panel-layer-elements.jsx +0 -298
  59. package/src/components/sidebar/panel-layers.jsx +0 -381
  60. package/src/components/sidebar/panel.jsx +0 -71
  61. package/src/components/sidebar/sidebar.jsx +0 -106
  62. package/src/components/sidebar/toolbar-panel.jsx +0 -139
  63. package/src/components/sign/export.js +0 -7
  64. package/src/components/sign/main/index.jsx +0 -523
  65. package/src/components/sign/main/styles.js +0 -163
  66. package/src/components/toolbar/button/ControlButton.jsx +0 -41
  67. package/src/components/toolbar/button/DirectionButton.jsx +0 -34
  68. package/src/components/toolbar/button/RightButton.jsx +0 -103
  69. package/src/components/toolbar/button/ToggleButton.jsx +0 -41
  70. package/src/components/toolbar/button/index.jsx +0 -55
  71. package/src/components/toolbar/button/styles.js +0 -127
  72. package/src/components/toolbar/components/DoorStyleMenu.jsx +0 -103
  73. package/src/components/toolbar/components/Pricing.jsx +0 -126
  74. package/src/components/toolbar/components/ReviewForQuote.jsx +0 -635
  75. package/src/components/toolbar/export.js +0 -21
  76. package/src/components/toolbar/main/Alert.js +0 -122
  77. package/src/components/toolbar/main/TakePictureModal.jsx +0 -104
  78. package/src/components/toolbar/main/confirm-popup.jsx +0 -99
  79. package/src/components/toolbar/main/index.jsx +0 -5627
  80. package/src/components/toolbar/main/lShaped.json +0 -311
  81. package/src/components/toolbar/main/longNarrow.json +0 -238
  82. package/src/components/toolbar/main/myComponents.js +0 -123
  83. package/src/components/toolbar/main/oRectangle.json +0 -220
  84. package/src/components/toolbar/main/rectangle.json +0 -238
  85. package/src/components/toolbar/main/style.css +0 -107
  86. package/src/components/toolbar/main/styles.js +0 -696
  87. package/src/components/toolbar/plugin-item.jsx +0 -123
  88. package/src/components/toolbar/popup/appliance/appliance-category/index.jsx +0 -73
  89. package/src/components/toolbar/popup/appliance/choose-appliance/index.jsx +0 -102
  90. package/src/components/toolbar/popup/appliance/index.jsx +0 -83
  91. package/src/components/toolbar/popup/autosaveprompt/index.jsx +0 -150
  92. package/src/components/toolbar/popup/autosaveprompt/styles.css +0 -64
  93. package/src/components/toolbar/popup/autosaveprompt/styles.js +0 -40
  94. package/src/components/toolbar/popup/cabinet/cabinet-category/index.jsx +0 -73
  95. package/src/components/toolbar/popup/cabinet/choose-product/index.jsx +0 -119
  96. package/src/components/toolbar/popup/cabinet/index.jsx +0 -85
  97. package/src/components/toolbar/popup/doorStyle/choose-style/index.jsx +0 -63
  98. package/src/components/toolbar/popup/doorStyle/index.jsx +0 -71
  99. package/src/components/toolbar/popup/doorStyle/style-category/index.jsx +0 -139
  100. package/src/components/toolbar/popup/downloadsummary/downloadSummaryContext.js +0 -2
  101. package/src/components/toolbar/popup/downloadsummary/downloadSummaryTemp.jsx +0 -157
  102. package/src/components/toolbar/popup/downloadsummary/index.jsx +0 -643
  103. package/src/components/toolbar/popup/downloadsummary/show2D/show2DView.jsx +0 -51
  104. package/src/components/toolbar/popup/downloadsummary/show2D/viewer2DDownLoad.jsx +0 -175
  105. package/src/components/toolbar/popup/downloadsummary/show3D/show3DView.jsx +0 -283
  106. package/src/components/toolbar/popup/downloadsummary/show3D/viewer3DDownLoad.jsx +0 -2257
  107. package/src/components/toolbar/popup/downloadsummary/showCabinetInfo.js +0 -93
  108. package/src/components/toolbar/popup/downloadsummary/showElevation/showElevationView.jsx +0 -132
  109. package/src/components/toolbar/popup/downloadsummary/showElevation/viewer3DElevationDownload.jsx +0 -2198
  110. package/src/components/toolbar/popup/downloadsummary/showElevation/viewerElevationDownload.jsx +0 -152
  111. package/src/components/toolbar/popup/downloadsummary/showWarranty.jsx +0 -149
  112. package/src/components/toolbar/popup/downloadsummary/styles.css +0 -177
  113. package/src/components/toolbar/popup/downloadsummary/styles.js +0 -453
  114. package/src/components/toolbar/popup/finishingtouch/category/index.jsx +0 -34
  115. package/src/components/toolbar/popup/finishingtouch/index.jsx +0 -58
  116. package/src/components/toolbar/popup/finishingtouch/material-edit.jsx +0 -112
  117. package/src/components/toolbar/popup/finishingtouch/product/index.jsx +0 -116
  118. package/src/components/toolbar/popup/floorplan/choose-floor/confirm-popup.jsx +0 -101
  119. package/src/components/toolbar/popup/floorplan/choose-floor/index.jsx +0 -254
  120. package/src/components/toolbar/popup/floorplan/choose-floor/lShaped.json +0 -311
  121. package/src/components/toolbar/popup/floorplan/choose-floor/longNarrow.json +0 -238
  122. package/src/components/toolbar/popup/floorplan/choose-floor/oRectangle.json +0 -220
  123. package/src/components/toolbar/popup/floorplan/choose-floor/rectangle.json +0 -238
  124. package/src/components/toolbar/popup/floorplan/choose-floor/styles.js +0 -86
  125. package/src/components/toolbar/popup/floorplan/floor-category/index.jsx +0 -109
  126. package/src/components/toolbar/popup/floorplan/index.jsx +0 -60
  127. package/src/components/toolbar/popup/index.jsx +0 -241
  128. package/src/components/toolbar/popup/newproject/index.jsx +0 -59
  129. package/src/components/toolbar/popup/newproject/styles.css +0 -64
  130. package/src/components/toolbar/popup/newproject/styles.js +0 -41
  131. package/src/components/toolbar/popup/product/appliance.jsx +0 -54
  132. package/src/components/toolbar/popup/product/cabinetproduct.jsx +0 -15
  133. package/src/components/toolbar/popup/product/doorstyle.jsx +0 -58
  134. package/src/components/toolbar/popup/product/doorstyleproduct.jsx +0 -47
  135. package/src/components/toolbar/popup/product/floor.jsx +0 -36
  136. package/src/components/toolbar/popup/product/floorproduct.jsx +0 -42
  137. package/src/components/toolbar/popup/product/index.jsx +0 -36
  138. package/src/components/toolbar/popup/product/primary.jsx +0 -77
  139. package/src/components/toolbar/popup/product/productline.jsx +0 -93
  140. package/src/components/toolbar/popup/product/reviewItem.jsx +0 -427
  141. package/src/components/toolbar/popup/product/reviewMolding.jsx +0 -310
  142. package/src/components/toolbar/popup/product/style.css +0 -54
  143. package/src/components/toolbar/popup/product/styles.js +0 -260
  144. package/src/components/toolbar/popup/savedesign/FullPictureForm.jsx +0 -146
  145. package/src/components/toolbar/popup/savedesign/index.jsx +0 -495
  146. package/src/components/toolbar/popup/savedesign/savedesign.style.css +0 -16
  147. package/src/components/toolbar/popup/savedesign/styles.js +0 -151
  148. package/src/components/toolbar/popup/setDoorStyleOption/index.jsx +0 -87
  149. package/src/components/toolbar/popup/styles.js +0 -909
  150. package/src/components/toolbar/popup/submitforquote/AddToCartOptions.jsx +0 -192
  151. package/src/components/toolbar/popup/submitforquote/CustomerRequestsForm.jsx +0 -96
  152. package/src/components/toolbar/popup/submitforquote/SkipDesignerReview.jsx +0 -54
  153. package/src/components/toolbar/popup/submitforquote/StepDots.jsx +0 -25
  154. package/src/components/toolbar/popup/submitforquote/cart-choice.jsx +0 -116
  155. package/src/components/toolbar/popup/submitforquote/doorstyle-menus.js +0 -38
  156. package/src/components/toolbar/popup/submitforquote/index.jsx +0 -698
  157. package/src/components/toolbar/popup/submitforquote/styles.css +0 -105
  158. package/src/components/toolbar/popup/submitforquote/styles.js +0 -294
  159. package/src/components/toolbar/popup/submitprompt/index.jsx +0 -89
  160. package/src/components/toolbar/popup/submitprompt/styles.css +0 -64
  161. package/src/components/toolbar/popup/submitprompt/styles.js +0 -42
  162. package/src/components/toolbar/toolbar-button.jsx +0 -90
  163. package/src/components/toolbar/toolbar-load-button.jsx +0 -36
  164. package/src/components/toolbar/toolbar-save-button.jsx +0 -32
  165. package/src/components/wizardstep/button/styles.js +0 -677
  166. package/src/components/wizardstep/export.js +0 -5
  167. package/src/components/wizardstep/index.jsx +0 -1372
  168. package/src/components/wizardstep/styles.js +0 -688
  169. package/src/components/wizardstep/wizardstep-content-button.jsx +0 -198
  170. package/src/components/wizardstep/wizardstep-toggle-button.jsx +0 -101
@@ -1,2198 +0,0 @@
1
- 'use strict';
2
-
3
- import React from 'react';
4
- import PropTypes from 'prop-types';
5
- import ReactDOM from 'react-dom';
6
- import * as Three from 'three';
7
- import {
8
- parseData,
9
- updateScene,
10
- deleteSpecifiedMeshObjects,
11
- createBacksplash,
12
- checkCabinetOverlap
13
- } from '../../../../viewer3d/scene-creator';
14
- import { disposeScene } from '../../../../viewer3d/three-memory-cleaner';
15
- import { disposeObject } from '../../../../viewer3d/three-memory-cleaner';
16
- import diff from 'immutablediff';
17
- import * as SharedStyle from '../../../../../shared-style';
18
- import {
19
- MODE_DRAWING_ITEM_3D,
20
- UNIT_CENTIMETER,
21
- SECONDARY_PURPLE_COLOR,
22
- ARRAY_ELEVATION_VIEW_MODES,
23
- MODE_FRONT_ELEVATION_VIEW,
24
- MODE_RIGHT_ELEVATION_VIEW,
25
- MODE_LEFT_ELEVATION_VIEW,
26
- MODE_BACK_ELEVATION_VIEW,
27
- BASE_CABINET_LAYOUTPOS,
28
- WALL_CABINET_LAYOUTPOS,
29
- TALL_CABINET_LAYOUTPOS
30
- } from '../../../../../constants';
31
- import { isUndefined } from 'util';
32
- import { verticesDistance } from '../../../../../utils/geometry';
33
- import convert from 'convert-units';
34
- import { GeometryUtils } from '../../../../../utils/export';
35
- import { RGBELoader } from 'three/examples/jsm/loaders/RGBELoader';
36
- import CameraControls from 'camera-controls';
37
- CameraControls.install({ THREE: Three });
38
- import { returnReplaceableDeepSearchType } from '../../../../viewer2d/utils';
39
- import { vectorIntersectWithMesh } from '../../../../../utils/objects-utils';
40
- import { almostEqual } from '../../../../../utils/geometry';
41
-
42
- export default class Viewer3DElevationDownload extends React.Component {
43
- constructor(props) {
44
- super(props);
45
- this.state = {
46
- isLoading: false,
47
- showflag: true,
48
- toolObj: null,
49
- angleObj: null,
50
- waitForRender: 0
51
- };
52
- this.lastMousePosition = {};
53
- this.width = props.width;
54
- this.height = props.height;
55
- this.renderingID = 0;
56
-
57
- let { mode } = props.state;
58
-
59
- if (!window.__elevationRendererDownload) {
60
- window.__elevationRendererDownload = {};
61
- }
62
-
63
- this.renderer =
64
- window.__threeRendererDownload ||
65
- window.__elevationRendererDownload[mode] ||
66
- new Three.WebGLRenderer({
67
- preserveDrawingBuffer: true,
68
- alpha: true,
69
- antialias: true
70
- });
71
-
72
- this.renderer.shadowMap.enabled = true;
73
- this.renderer.shadowMapSoft = true;
74
- if (mode == 'MODE_3D_VIEW') {
75
- window.__threeRendererDownload = this.renderer;
76
- } else {
77
- window.__elevationRendererDownload[mode] = this.renderer;
78
- }
79
-
80
- this.renderer.domElement.style.display = 'none';
81
- }
82
-
83
- componentDidMount(nextProps) {
84
- let scene3D, camera, pivot, cameraControls, clock;
85
-
86
- const actions = {
87
- areaActions: this.context.areaActions,
88
- holesActions: this.context.holesActions,
89
- itemsActions: this.context.itemsActions,
90
- sceneActions: this.context.sceneActions,
91
- linesActions: this.context.linesActions,
92
- projectActions: this.context.projectActions,
93
- catalog: this.context.catalog
94
- };
95
-
96
- const self = this;
97
- const { state } = this.props;
98
- const { mode, scene } = state;
99
-
100
- function setupLight(scene, inbBox) {
101
- if (ARRAY_ELEVATION_VIEW_MODES.includes(mode)) {
102
- const ambilight = new Three.AmbientLight('0xffffff', 3);
103
- scene.add(ambilight);
104
- } else {
105
- const shadowMapSize = 2048;
106
- const shadowCameraSize =
107
- Math.max(
108
- Math.abs(inbBox.min.x - inbBox.max.x),
109
- Math.abs(inbBox.min.y - inbBox.max.y),
110
- Math.abs(inbBox.min.z - inbBox.max.z)
111
- ) / 2;
112
- const shadowCameraFar = shadowCameraSize * 10;
113
- const bboxCenter = new Three.Vector3(
114
- (inbBox.min.x + inbBox.max.x) / 2,
115
- inbBox.min.y,
116
- (inbBox.min.z + inbBox.max.z) / 2
117
- );
118
-
119
- function addDirLight(inColor, inIntensity, inPosition) {
120
- const dirLight = new Three.DirectionalLight(inColor, inIntensity);
121
- dirLight.castShadow = true;
122
- dirLight.shadow.mapSize.x = shadowMapSize;
123
- dirLight.shadow.mapSize.y = shadowMapSize;
124
- dirLight.shadow.camera.near = 0;
125
- dirLight.shadow.camera.far = shadowCameraFar;
126
-
127
- dirLight.shadow.camera.top = shadowCameraSize * 1.5;
128
- dirLight.shadow.camera.bottom = -shadowCameraSize * 1.5;
129
- dirLight.shadow.camera.left = -shadowCameraSize * 1.5;
130
- dirLight.shadow.camera.right = shadowCameraSize * 1.5;
131
- dirLight.position.copy(inPosition);
132
-
133
- const targetObject = new Three.Object3D();
134
- targetObject.position.copy(bboxCenter);
135
- scene.add(targetObject);
136
-
137
- dirLight.target = targetObject;
138
- dirLight.target.updateMatrixWorld();
139
-
140
- scene.add(dirLight);
141
- }
142
-
143
- function addSpotLight(
144
- inColor,
145
- inIntensity,
146
- inPosition,
147
- inTarget,
148
- inDistance
149
- ) {
150
- const spotLight = new Three.SpotLight();
151
- spotLight.intensity = inIntensity;
152
- spotLight.color.setHex(inColor);
153
- spotLight.position.copy(inPosition);
154
- spotLight.angle = 1.3;
155
- spotLight.distance = inDistance;
156
- spotLight.penumbra = 1.8;
157
- spotLight.decay = 0.01;
158
-
159
- spotLight.castShadow = true;
160
- spotLight.shadow.intensity = 2;
161
- spotLight.shadow.mapSize.width = 4096;
162
- spotLight.shadow.mapSize.height = 4096;
163
-
164
- const targetObject = new Three.Object3D();
165
- targetObject.position.copy(
166
- new Three.Vector3(inTarget.x, 0, inTarget.z)
167
- );
168
- scene.add(targetObject);
169
-
170
- spotLight.target = targetObject;
171
- spotLight.target.updateMatrixWorld();
172
- scene.add(spotLight);
173
- }
174
-
175
- const dirLightPos = new Three.Vector3(
176
- inbBox.max.x,
177
- inbBox.max.y + 1.8 * Math.abs(inbBox.max.y - inbBox.min.y),
178
- inbBox.min.z - 0.5 * Math.abs(inbBox.max.z - inbBox.min.z)
179
- );
180
-
181
- addDirLight('white', 1.5, dirLightPos);
182
-
183
- const ceiling = scene3D.getObjectByName('ceil');
184
- if (ceiling) {
185
- const ceilBBox = new Three.Box3().setFromObject(ceiling);
186
-
187
- const spot1 = new Three.Vector3(
188
- ceilBBox.min.x + Math.abs(ceilBBox.min.x - ceilBBox.max.x) / 4,
189
- ceilBBox.max.y - 0.5,
190
- ceilBBox.min.z + Math.abs(ceilBBox.min.z - inbBox.max.z) / 4
191
- );
192
- const spot2 = new Three.Vector3(
193
- ceilBBox.min.x + Math.abs(ceilBBox.min.x - ceilBBox.max.x) / 4,
194
- ceilBBox.max.y - 0.5,
195
- ceilBBox.max.z - Math.abs(ceilBBox.min.z - ceilBBox.max.z) / 4
196
- );
197
-
198
- const spot3 = new Three.Vector3(
199
- ceilBBox.max.x - Math.abs(ceilBBox.min.x - ceilBBox.max.x) / 4,
200
- ceilBBox.max.y - 0.5,
201
- ceilBBox.min.z + Math.abs(ceilBBox.min.z - ceilBBox.max.z) / 4
202
- );
203
- const spot4 = new Three.Vector3(
204
- ceilBBox.max.x - Math.abs(ceilBBox.min.x - ceilBBox.max.x) / 4,
205
- ceilBBox.max.y - 0.5,
206
- ceilBBox.max.z - Math.abs(ceilBBox.min.z - ceilBBox.max.z) / 4
207
- );
208
-
209
- const spotlightDis = 1.5 * Math.abs(inbBox.min.y - inbBox.max.y);
210
-
211
- // check if spotlight is inside the room
212
- vectorIntersectWithMesh(spot1, scene3D.getObjectByName('floor')) &&
213
- addSpotLight('0xffffff', 0.8, spot1, spot1, spotlightDis);
214
- vectorIntersectWithMesh(spot2, scene3D.getObjectByName('floor')) &&
215
- addSpotLight('0xffffff', 0.8, spot2, spot2, spotlightDis);
216
- vectorIntersectWithMesh(spot3, scene3D.getObjectByName('floor')) &&
217
- addSpotLight('0xffffff', 0.8, spot3, spot3, spotlightDis);
218
- vectorIntersectWithMesh(spot4, scene3D.getObjectByName('floor')) &&
219
- addSpotLight('0xffffff', 0.8, spot4, spot4, spotlightDis);
220
- }
221
- }
222
- }
223
-
224
- // Load data
225
- this.setState({ isLoading: true, waitForRender: 0 });
226
- this.props.setIsLoading3D(true);
227
- const { promise, planData } = parseData(
228
- scene,
229
- actions,
230
- this.context.catalog,
231
- camera,
232
- this.renderer,
233
- state.mode
234
- );
235
-
236
- promise.then(() => {
237
- let objToRemove = [];
238
- planData.plan.traverse(obj => {
239
- if (obj.geometry === null) {
240
- objToRemove.push(obj);
241
- }
242
- });
243
- objToRemove.forEach(obj => {
244
- obj.removeFromParent();
245
- });
246
- const bbox = new Three.Box3().setFromObject(planData.plan);
247
- if (!ARRAY_ELEVATION_VIEW_MODES.includes(state.mode)) {
248
- //cameraControls.fitToBox(bbox, true);
249
- if (cameraControls) {
250
- const radius = 400; // Distance from target
251
- const angleInDegrees = 5;
252
- const angleInRadians = (angleInDegrees * Math.PI) / 180;
253
-
254
- // Calculate a position angleInDegrees to the right on the horizontal circle
255
- const eyeX = Math.sin(angleInRadians) * radius;
256
- const eyeZ = Math.cos(angleInRadians) * radius;
257
-
258
- cameraControls.setLookAt(eyeX, 0, eyeZ, 0, 0, 0); // Set camera with Y elevation
259
- }
260
- }
261
- setupLight(scene3D, planData.boundingBox);
262
-
263
- self.setState({ waitForRender: 1 });
264
- });
265
-
266
- const area = scene.getIn(['layers', scene.selectedLayer, 'areas']);
267
- const layer = scene.getIn(['layers', scene.selectedLayer]);
268
- const areas = [],
269
- lights = [];
270
-
271
- let snapBox = null;
272
-
273
- // Check for data
274
- let msg = '';
275
- scene.layers.forEach(layer => {
276
- if (layer.id === scene.selectedLayer || layer.visible) {
277
- layer.items.forEach(item => {
278
- if (item.doorStyle === null) {
279
- if (!msg.includes(item.name + "'s doorStyle is null."))
280
- msg += item.name + "'s doorStyle is null.\n";
281
- }
282
- });
283
- }
284
- });
285
- if (msg !== '') {
286
- confirm(msg);
287
- }
288
-
289
- init();
290
- render();
291
-
292
- area.forEach(data => {
293
- areas.push(data);
294
- });
295
- for (let i = 0; i < areas.length; i++) {
296
- let aVertices = [];
297
- let lines = [];
298
- let height = 100;
299
- areas[i].vertices.forEach(data => {
300
- aVertices.push(data);
301
- });
302
- layer.lines.forEach(data => {
303
- lines.push(data);
304
- });
305
- for (let i = 0; i < lines.length; i++) {
306
- let data = lines[i];
307
- let realVec = [];
308
- data.vertices.forEach(vec => {
309
- realVec.push(vec);
310
- });
311
- if (aVertices.includes(realVec[0]) && aVertices.includes(realVec[1])) {
312
- height = convert(layer.ceilHeight)
313
- .from(layer.unit)
314
- .to(UNIT_CENTIMETER);
315
- // height = data.properties.getIn(['height', 'length']);
316
- break;
317
- }
318
- }
319
- let vertices = [];
320
- areas[i].vertices.forEach(datas => {
321
- let vertex = scene.getIn([
322
- 'layers',
323
- scene.selectedLayer,
324
- 'vertices',
325
- datas
326
- ]);
327
- vertices.push(vertex);
328
- });
329
- vertices.push(vertices[0]);
330
- let fLen = vertices.length - 1;
331
- for (let i = 0; i < fLen; i++) {
332
- let sX = vertices[i].x;
333
- let sY = vertices[i].y;
334
- let eX = vertices[i + 1].x;
335
- let eY = vertices[i + 1].y;
336
- let len = Math.sqrt((eX - sX) * (eX - sX) + (eY - sY) * (eY - sY));
337
- for (let cLen = 200; cLen < len; cLen += 200) {
338
- let cX = sX + ((eX - sX) * cLen) / len;
339
- let cY = sY + ((eY - sY) * cLen) / len;
340
- let endLen = Math.sqrt((eX - cX) * (eX - cX) + (eY - cY) * (eY - cY));
341
- if (endLen <= 100) continue;
342
- let vec2 = new Three.Vector2(cX - sX, cY - sY);
343
- let angle = vec2.angle() + Math.PI / 2;
344
- cX = Math.cos(angle) * 30 + cX;
345
- cY = Math.sin(angle) * 30 + cY;
346
- let spotLight = new Three.SpotLight(0xeeeeee, 1.7);
347
- spotLight.angle = 0.76;
348
- spotLight.castShadow = true;
349
- spotLight.penumbra = 1;
350
- spotLight.decay = 1.7;
351
- spotLight.distance = height - 20;
352
- let target = new Three.Object3D();
353
- spotLight.target = target;
354
- lights.push({
355
- light: spotLight,
356
- target: target,
357
- x: cX,
358
- y: cY,
359
- height: height
360
- });
361
- }
362
- }
363
- }
364
- // //////////////////////////
365
-
366
- // OBJECT PICKING
367
- let toIntersect = [planData.plan];
368
- let mouse = new Three.Vector2();
369
- let gridPlane = planData.grid;
370
- let raycaster = new Three.Raycaster();
371
- let selectedObject = {};
372
- let currentObject = null;
373
- let isSelected = false;
374
- let bRotate = false;
375
- let bMove = false;
376
- let bMoveUP = false;
377
- /** Transformation matrix of grid */
378
- const gridMatrix = new Three.Matrix4();
379
- let rayDirection = new Three.Vector3();
380
- /** World position of grid plane */
381
- let gridPlanOrigin = new Three.Vector3();
382
- let Point = new Three.Vector2();
383
- let sPoint = new Three.Vector2();
384
-
385
- // SNAP FUNCTION VARIABLE
386
- let snapFlag = false;
387
- let snapAnimI = 0;
388
- let snapDelta = 6;
389
- let t_i = 0;
390
- let targetPoint = new Three.Vector3();
391
- let targetRot = 0;
392
- let targetUVec = new Three.Vector3();
393
- let targetCRotation = 0;
394
- let targetObj = null;
395
- let targetNumber = 0;
396
-
397
- let allItemRect;
398
- let allItemSnap;
399
- let allLines;
400
- let allLineRects;
401
- let allLineSnap;
402
- let allRect;
403
- let allArea;
404
-
405
- // end snap function variable///////////////////////
406
- let backsplashVisible = false;
407
- let holeItems = GeometryUtils.getHoleItems(layer);
408
-
409
- let removeSnapBox = () => {
410
- if (snapBox != null) {
411
- planData.plan.remove(snapBox);
412
- disposeObject(snapBox);
413
- snapBox = null;
414
- targetObj = null;
415
- snapFlag = false;
416
- }
417
- };
418
-
419
- const camToGrid = new Three.Vector3();
420
- let camPos = camera.position;
421
-
422
- const mapCursorPosition = (e, altitude) => {
423
- camToGrid.subVectors(gridPlanOrigin, camPos);
424
-
425
- let camD = camToGrid.y + (altitude ? altitude : 0);
426
- let rayD = rayDirection.y;
427
-
428
- const intersectPt = rayDirection.multiplyScalar(camD / rayD).add(camPos);
429
- intersectPt.y = gridPlanOrigin.y;
430
- intersectPt.applyMatrix4(gridMatrix);
431
-
432
- return { x: intersectPt.x, y: -intersectPt.z };
433
- };
434
-
435
- /* for Snap Functions*/
436
-
437
- let pointLineDistance = function (point, line) {
438
- // return distance from point to line and directional point of line
439
- let pX = point.x;
440
- let pY = point.y;
441
- let l1x = line[0].x;
442
- let l1y = line[0].y;
443
- let l2x = line[1].x;
444
- let l2y = line[1].y;
445
- let pLine = new Three.Vector2(l1x - pX, l1y - pY);
446
- let Line = new Three.Vector2(l1x - l2x, l1y - l2y);
447
- let pAngle = pLine.angle();
448
- let lAngle = Line.angle();
449
- let pDistance = pLine.length();
450
- let oDistance = Line.length();
451
- let directDistance = Math.sin(pAngle - lAngle) * pDistance;
452
- let lineDistance = Math.cos(pAngle - lAngle) * pDistance;
453
- let dX = l1x + ((l2x - l1x) * lineDistance) / oDistance;
454
- let dY = l1y + ((l2y - l1y) * lineDistance) / oDistance;
455
- let dPoint = { x: dX, y: dY };
456
- return { distance: directDistance, point: dPoint };
457
- };
458
- let getInterSect = function (shape1, shape2) {
459
- // return result of intersect of two shape
460
- let count = 0;
461
- for (let i = 0; i < shape1.length - 1; i++) {
462
- let sl1 = { x: shape1[i].x, y: shape1[i].y };
463
- let sl2 = { x: shape1[i + 1].x, y: shape1[i + 1].y };
464
- for (let j = 0; j < shape2.length - 1; j++) {
465
- let el1 = { x: shape2[j].x, y: shape2[j].y };
466
- let el2 = { x: shape2[j + 1].x, y: shape2[j + 1].y };
467
- let flag = GeometryUtils.getLineInterSect(
468
- sl1.x,
469
- sl1.y,
470
- sl2.x,
471
- sl2.y,
472
- el1.x,
473
- el1.y,
474
- el2.x,
475
- el2.y
476
- );
477
- if (flag) {
478
- count++;
479
- if (count > 1) return true;
480
- }
481
- }
482
- }
483
- return false;
484
- };
485
-
486
- this.getRectPoints = function (width, height, pos, rot) {
487
- // return 4 points from it's position, width, height, and rotation info
488
- let rX = width / 2;
489
- let rY = height / 2;
490
- let vertices = [];
491
- let cRot = rot;
492
- let pX = pos.x + Math.cos(cRot) * rX + Math.cos(cRot + Math.PI / 2) * rY;
493
- let pY = pos.y + Math.sin(cRot) * rX + Math.sin(cRot + Math.PI / 2) * rY;
494
- vertices.push({ x: Math.floor(pX + 0.5), y: Math.floor(pY + 0.5) });
495
- rX = -rX;
496
- pX = pos.x + Math.cos(cRot) * rX + Math.cos(cRot + Math.PI / 2) * rY;
497
- pY = pos.y + Math.sin(cRot) * rX + Math.sin(cRot + Math.PI / 2) * rY;
498
- vertices.push({ x: Math.floor(pX + 0.5), y: Math.floor(pY + 0.5) });
499
- rY = -rY;
500
- pX = pos.x + Math.cos(cRot) * rX + Math.cos(cRot + Math.PI / 2) * rY;
501
- pY = pos.y + Math.sin(cRot) * rX + Math.sin(cRot + Math.PI / 2) * rY;
502
- vertices.push({ x: Math.floor(pX + 0.5), y: Math.floor(pY + 0.5) });
503
- rX = -rX;
504
- pX = pos.x + Math.cos(cRot) * rX + Math.cos(cRot + Math.PI / 2) * rY;
505
- pY = pos.y + Math.sin(cRot) * rX + Math.sin(cRot + Math.PI / 2) * rY;
506
- vertices.push({ x: Math.floor(pX + 0.5), y: Math.floor(pY + 0.5) });
507
- vertices.push(vertices[0]);
508
- vertices.push(vertices[2]);
509
- return vertices;
510
- };
511
-
512
- const prepareSnap = layer => {
513
- allLines = GeometryUtils.getAllLines(layer);
514
- allLineRects = GeometryUtils.buildRectFromLines(layer, allLines);
515
- allItemRect = GeometryUtils.getAllItems(
516
- this.props.state.scene,
517
- actions.catalog,
518
- allLineRects
519
- );
520
- allItemSnap = GeometryUtils.getAllItemSnap(allItemRect);
521
- allLineSnap = GeometryUtils.getAllLineSnap(allLineRects, allItemRect.cur);
522
- allRect = allItemRect.others.concat(allLineRects);
523
- allItemSnap = GeometryUtils.validateSnaps(allItemSnap, allRect);
524
- allLineSnap = GeometryUtils.validateSnaps(allLineSnap, allRect);
525
- allArea = GeometryUtils.getAllArea(layer);
526
- };
527
-
528
- // prepareSnapSpec(layer);
529
- let lineRect = layer => {
530
- let areainfo = [];
531
- layer.areas.forEach(area => {
532
- let sz = area.vertices.size;
533
- for (var i = 0; i < sz; i++) {
534
- areainfo.push(area.vertices.get(i));
535
- }
536
- });
537
- let rect = [];
538
- areainfo.forEach(area => {
539
- let vert = layer.vertices.get(area);
540
- rect.push(vert.x, vert.y);
541
- });
542
- return rect;
543
- };
544
-
545
- this.collisionCheck = function (obj, pos, rot, tObj, item = null, catalog) {
546
- //collision check from one object to every other object excpet target object
547
- let layer = this.props.state.scene.getIn([
548
- 'layers',
549
- obj.userData.layerId
550
- ]);
551
- let layoutpos = 'utype';
552
- if (item !== null) {
553
- let catid = item.type;
554
- let cat = catalog.elements[catid];
555
- layoutpos = cat.info.layoutpos;
556
- }
557
- let oPos = new Three.Vector2(pos.clone().x, pos.clone().y);
558
- let sBounding = obj.children[0].userData;
559
- let width = sBounding.max.x - sBounding.min.x;
560
- let depth = sBounding.max.z - sBounding.min.z;
561
- let oVertices = this.getRectPoints(
562
- width,
563
- depth,
564
- oPos.clone(),
565
- ((rot % 360) / 180) * Math.PI
566
- );
567
- let datas = [];
568
- layer.items.forEach(data => {
569
- datas.push(data);
570
- });
571
- for (let i = 0; i < datas.length; i++) {
572
- let data = datas[i];
573
- if (data.id == obj.userData.itemId || data.id == tObj.userData.itemId)
574
- continue;
575
- let target =
576
- planData.sceneGraph.layers[obj.userData.layerId].items[data.id];
577
- if (target === undefined) {
578
- console.log(
579
- data.id +
580
- ' does not exist in viewer3d/viewer3d.js collisionCheck function'
581
- );
582
- return false;
583
- }
584
- let item = layer.items.getIn([data.id]);
585
- let ocatid = item.type;
586
- let ocat = catalog.elements[ocatid];
587
- let olayoutpos = ocat.info.layoutpos;
588
- if (
589
- !(
590
- (layoutpos === BASE_CABINET_LAYOUTPOS &&
591
- olayoutpos === WALL_CABINET_LAYOUTPOS) ||
592
- (layoutpos === WALL_CABINET_LAYOUTPOS &&
593
- olayoutpos === BASE_CABINET_LAYOUTPOS)
594
- )
595
- ) {
596
- let tRot = item.rotation;
597
- let tPos = new Three.Vector2(item.x, item.y);
598
- let tBounding = target.children[0].userData;
599
- let twidth = tBounding.max.x - tBounding.min.x;
600
- let tdepth = tBounding.max.z - tBounding.min.z;
601
- let tVertices = this.getRectPoints(
602
- twidth,
603
- tdepth,
604
- tPos.clone(),
605
- ((tRot % 360) / 180) * Math.PI
606
- );
607
- if (getInterSect(oVertices, tVertices)) {
608
- return false;
609
- }
610
- }
611
- }
612
- datas = [];
613
- layer.lines.forEach(data => {
614
- datas.push(data);
615
- });
616
- for (let i = 0; i < datas.length; i++) {
617
- let data = datas[i];
618
- if (data.id == obj.userData.itemId || data.id == tObj.userData.itemId)
619
- continue;
620
- let item = layer.lines.getIn([data.id]);
621
- // let llayoutpos = catalog.elements[item.type].info.layoutpos;
622
- let vertices = [];
623
- item.vertices.forEach(data => {
624
- let vertex = layer.vertices.get(data);
625
- vertices.push({ x: vertex.x, y: vertex.y });
626
- });
627
- let vec = new Three.Vector2(
628
- vertices[1].x - vertices[0].x,
629
- vertices[1].y - vertices[0].y
630
- );
631
- let tRot = vec.angle();
632
- let tPos = new Three.Vector2(
633
- (vertices[0].x + vertices[1].x) / 2,
634
- (vertices[0].y + vertices[1].y) / 2
635
- );
636
- let tdepth = item.properties.getIn(['thickness', 'length']);
637
- let twidth = Math.sqrt(vec.x * vec.x + vec.y * vec.y);
638
- let tVertices = this.getRectPoints(twidth, tdepth, tPos.clone(), tRot);
639
- if (getInterSect(oVertices, tVertices)) {
640
- return false;
641
- }
642
- }
643
- return true;
644
- };
645
-
646
- this.collisionHoleCheck = function (
647
- obj,
648
- pos,
649
- rot,
650
- tObj,
651
- item = null,
652
- catalog
653
- ) {
654
- let layer = this.props.state.scene.getIn([
655
- 'layers',
656
- obj.userData.layerId
657
- ]);
658
- let currentItem;
659
- if (item !== null) {
660
- let catid = item.type;
661
- let cat = catalog.elements[catid];
662
- currentItem = {
663
- selectedItem: item,
664
- cat
665
- };
666
- }
667
- let oPos = new Three.Vector2(pos.clone().x, pos.clone().y);
668
- let sBounding = obj.children[0].userData;
669
- let width = sBounding.max.x - sBounding.min.x;
670
- let depth = sBounding.max.z - sBounding.min.z;
671
- let oVertices = this.getRectPoints(
672
- width,
673
- depth,
674
- oPos.clone(),
675
- ((rot % 360) / 180) * Math.PI
676
- );
677
-
678
- let datas = [];
679
- layer.items.forEach(data => {
680
- datas.push(data);
681
- });
682
- for (let i = 0; i < datas.length; i++) {
683
- let data = datas[i];
684
- if (data.id == obj.userData.itemId || data.id == tObj.userData.itemId)
685
- continue;
686
- let target =
687
- planData.sceneGraph.layers[obj.userData.layerId].items[data.id];
688
- if (target === undefined) {
689
- console.log(
690
- data.id +
691
- ' does not exist in viewer3d/viewer3d.js collisionCheck function'
692
- );
693
- return false;
694
- }
695
- let item = layer.items.getIn([data.id]);
696
- let ocatid = item.type;
697
- let ocat = catalog.elements[ocatid];
698
- if (!ocat)
699
- ocat = catalog.elements[returnReplaceableDeepSearchType(ocatid)];
700
- let otherItem = {
701
- item,
702
- cat: ocat
703
- };
704
-
705
- if (
706
- GeometryUtils.needSnap(currentItem, otherItem) &&
707
- otherItem.cat.type != 'cabinet'
708
- ) {
709
- let tRot = item.rotation;
710
- let tPos = new Three.Vector2(item.x, item.y);
711
- let tBounding = target.children[0].userData;
712
- let twidth = tBounding.max.x - tBounding.min.x;
713
- let tdepth = tBounding.max.z - tBounding.min.z;
714
- let tVertices = this.getRectPoints(
715
- twidth,
716
- tdepth,
717
- tPos.clone(),
718
- ((tRot % 360) / 180) * Math.PI
719
- );
720
- if (getInterSect(oVertices, tVertices)) {
721
- return false;
722
- }
723
- }
724
- }
725
-
726
- let holes = [];
727
- layer.lines.forEach(line => {
728
- line.holes.forEach(holeID => {
729
- let hole = layer.holes.get(holeID);
730
- holes.push(hole);
731
- });
732
- });
733
- let i = 0;
734
- for (; i < holes.length; i++) {
735
- let tPos = new Three.Vector2(holes[i].x, holes[i].y);
736
- let twidth = holes[i].properties.getIn(['width', 'length']);
737
- let theight = holes[i].properties.getIn(['thickness', 'length']);
738
- let trot = holes[i].rotation;
739
- let tVertices = this.getRectPoints(twidth, theight, tPos.clone(), trot);
740
- if (getInterSect(oVertices, tVertices)) {
741
- return false;
742
- }
743
- }
744
- return true;
745
- };
746
-
747
- this.collisionSlide = function (
748
- item3D,
749
- originPos,
750
- layer,
751
- sVertices,
752
- tPos,
753
- item
754
- ) {
755
- let items = [];
756
-
757
- let cur_category = '';
758
- let catalog = actions.catalog;
759
- if (layer.selected.items.size > 0) {
760
- let selectedItem = layer.getIn(['items', layer.selected.items.get(0)]);
761
- let catid = selectedItem.type;
762
- let cat = catalog.elements[catid];
763
- if (cat === undefined || cat === null)
764
- cat = catalog.getIn(['elements', catid]);
765
- cur_category = cat.obj.category;
766
- }
767
-
768
- layer.items.forEach(data => {
769
- if (data.id == selectedObject.itemID) {
770
- return;
771
- }
772
-
773
- items.push(data.toJS());
774
- });
775
- let oPos = new Three.Vector2(originPos.x, -originPos.z);
776
-
777
- // sort from distance
778
- for (let i = 0; i < items.length - 1; i++) {
779
- for (let j = i + 1; j < items.length; j++) {
780
- if (
781
- verticesDistance(oPos, new Three.Vector2(items[i].x, items[i].y)) >
782
- verticesDistance(oPos, new Three.Vector2(items[j].x, items[j].y))
783
- ) {
784
- let exchange = items[j];
785
- items[j] = items[i];
786
- items[i] = exchange;
787
- }
788
- }
789
- }
790
- let i = 0;
791
-
792
- for (; i < items.length; i++) {
793
- if (!items[i]) return;
794
- let target =
795
- planData.sceneGraph.layers[selectedObject.layerID].items[items[i].id];
796
- if (target === undefined) {
797
- return false;
798
- }
799
- let targetData = layer.items.getIn([items[i].id]);
800
- let tRot = targetData.rotation;
801
- let tPos = new Three.Vector2(targetData.x, targetData.y);
802
- let tBounding = target.children[0].userData;
803
- let twidth = tBounding.max.x - tBounding.min.x;
804
- let tdepth = tBounding.max.z - tBounding.min.z;
805
- let tVertices = this.getRectPoints(
806
- twidth,
807
- tdepth,
808
- tPos.clone(),
809
- ((tRot % 360) / 180) * Math.PI
810
- );
811
- if (getInterSect(sVertices, tVertices)) {
812
- break;
813
- }
814
- }
815
- if (items.length == 0 || !items[i]) return;
816
- let target =
817
- planData.sceneGraph.layers[selectedObject.layerID].items[items[i].id];
818
- let targetData = layer.items.getIn([items[i].id]);
819
- let targetPos = new Three.Vector2(targetData.x, targetData.y);
820
- let tRot = targetData.rotation;
821
- let tBounding = target.children[0].userData;
822
- let twidth = tBounding.max.x - tBounding.min.x;
823
- let tdepth = tBounding.max.z - tBounding.min.z;
824
- let tVertices = this.getRectPoints(
825
- twidth,
826
- tdepth,
827
- targetPos.clone(),
828
- ((tRot % 360) / 180) * Math.PI
829
- );
830
- // ////////////////////////
831
- let vArray = [];
832
- let dteArray = [];
833
- let lineArray = [];
834
- let vdistanceArray = [];
835
- let cVecArray = [];
836
- let inFlag = false;
837
- for (let i = 0; i < 4; i++) {
838
- let v1 = tVertices[i];
839
- let v2 = tVertices[i + 1];
840
- let data = pointLineDistance({ x: tPos.x, y: tPos.y }, [
841
- { x: v1.x, y: v1.y },
842
- { x: v2.x, y: v2.y }
843
- ]);
844
- dteArray.push(data.distance);
845
- vArray.push(data.point);
846
- lineArray.push([v1, v2]);
847
- }
848
- // if tPos in target object
849
- let tPosDistance =
850
- Math.abs(pointLineDistance(tPos, lineArray[0]).distance) +
851
- Math.abs(pointLineDistance(tPos, lineArray[2]).distance);
852
- let realDistance = new Three.Vector2(
853
- lineArray[1][0].x - lineArray[1][1].x,
854
- lineArray[1][0].y - lineArray[1][1].y
855
- ).length();
856
- let tPosDistance1 =
857
- Math.abs(pointLineDistance(tPos, lineArray[1]).distance) +
858
- Math.abs(pointLineDistance(tPos, lineArray[3]).distance);
859
- let realDistance1 = new Three.Vector2(
860
- lineArray[0][0].x - lineArray[0][1].x,
861
- lineArray[0][0].y - lineArray[0][1].y
862
- ).length();
863
- if (
864
- Math.abs(Math.abs(tPosDistance) - Math.abs(realDistance)) < 0.01 &&
865
- Math.abs(Math.abs(tPosDistance1) - Math.abs(realDistance1)) < 0.01
866
- )
867
- inFlag = true;
868
- // ////////////////////
869
- let key = 0;
870
- // sort distance from origin point
871
- for (let j = 0; j < dteArray.length - 1; j++) {
872
- for (let k = j + 1; k < dteArray.length; k++) {
873
- if (Math.abs(dteArray[j]) > Math.abs(dteArray[k])) {
874
- let temp = dteArray[k];
875
- dteArray[j] = dteArray[k];
876
- dteArray[k] = temp;
877
- let temp1 = vArray[k];
878
- vArray[j] = vArray[k];
879
- vArray[k] = temp1;
880
- let temp2 = lineArray[k];
881
- lineArray[j] = lineArray[k];
882
- lineArray[k] = temp2;
883
- }
884
- }
885
- }
886
- // //////////////////////////////
887
- for (let i = 0; i < 4; i++) {
888
- let data = pointLineDistance(sVertices[i], lineArray[key]);
889
- vdistanceArray.push(data.distance);
890
- cVecArray.push({
891
- x: data.point.x - sVertices[i].x,
892
- y: data.point.y - sVertices[i].y
893
- });
894
- }
895
-
896
- for (let j = 0; j < vdistanceArray.length; j++) {
897
- let tX = tPos.x + cVecArray[j].x;
898
- let tY = tPos.y + cVecArray[j].y;
899
- if (
900
- this.collisionCheck(
901
- item3D,
902
- new Three.Vector2(tX, tY),
903
- item.rotation,
904
- {
905
- userData: { itemId: null }
906
- },
907
- item,
908
- this.context.catalog
909
- )
910
- ) {
911
- item3D.position.set(tX, originPos.y, -tY);
912
- sPoint.set(tX, tY);
913
- break;
914
- }
915
- }
916
- };
917
-
918
- this.snap = function (obj, layer) {
919
- // snap operation
920
- let target = obj.userData.target;
921
- for (; target.parent != null; ) {
922
- if (target.name == 'pivot') break;
923
- target = target.parent;
924
- }
925
- let source = obj.parent.parent.parent;
926
- if (target.userData.type == 'item') {
927
- let sRot = layer.getIn(['items', source.userData.itemId]).rotation;
928
- let tRot = layer.getIn(['items', target.userData.itemId])
929
- ? layer.getIn(['items', target.userData.itemId]).rotation
930
- : 0;
931
- let item = layer.getIn(['items', source.userData.itemId]);
932
- let layoutType = item.layoutpos;
933
- let altitudeLength = convert(
934
- item.properties.getIn(['altitude', '_length'])
935
- )
936
- .from('in')
937
- .to('cm');
938
- let sBounding = source.children[0].userData;
939
- let tBounding = target.children[0].userData;
940
- let tPos = target.position.clone();
941
- let width = sBounding.max.x - sBounding.min.x;
942
- let height = sBounding.max.y - sBounding.min.y;
943
- let depth = sBounding.max.z - sBounding.min.z;
944
- let snapBoxGeom = new Three.BoxGeometry(width, height, depth);
945
- let snapBoxObj = new Three.Mesh(
946
- snapBoxGeom,
947
- new Three.MeshBasicMaterial({
948
- // color: 0x2cde6b,
949
- // opacity: 0.7,
950
- transparent: true,
951
- blending: Three.MultiplyBlending
952
- })
953
- );
954
- let removeSnapBoxObj = () => {
955
- if (snapBoxObj) {
956
- planData.plan.remove(snapBoxObj);
957
- disposeObject(snapBoxObj);
958
- }
959
- snapFlag = false;
960
- };
961
- let box = new Three.BoxHelper(snapBoxObj, 0xffffff);
962
- box.material.linewidth = 2;
963
- box.material.depthTest = false;
964
- box.renderOrder = 200;
965
- snapBoxObj.add(box);
966
- snapBoxObj.position.set(
967
- source.position.x,
968
- layoutType === WALL_CABINET_LAYOUTPOS
969
- ? altitudeLength + source.position.y + height / 2
970
- : source.position.y + height / 2,
971
- source.position.z
972
- );
973
- snapBoxObj.rotation.set(
974
- source.rotation.x,
975
- source.rotation.y,
976
- source.rotation.z
977
- );
978
- snapBoxObj.name = 'TransformBox';
979
- planData.plan.add(snapBoxObj);
980
- let deltaX =
981
- (tBounding.max.x - tBounding.min.x) / 2 +
982
- (sBounding.max.x - sBounding.min.x) / 2;
983
- let deltaZ =
984
- (tBounding.max.z - tBounding.min.z) / 2 -
985
- (sBounding.max.z - sBounding.min.z) / 2;
986
- let sPos = snapBoxObj.position.clone();
987
- // avaliable snap place///////////////
988
- let tPoses = [];
989
- let pX =
990
- tPos.x +
991
- deltaX * Math.cos((tRot / 180) * Math.PI) +
992
- deltaZ * Math.sin((tRot / 180) * Math.PI);
993
- let pZ =
994
- tPos.z -
995
- deltaX * Math.sin((tRot / 180) * Math.PI) +
996
- deltaZ * Math.cos((tRot / 180) * Math.PI);
997
- tPoses.push(new Three.Vector3(pX, 0, pZ));
998
- deltaX = -deltaX;
999
- pX =
1000
- tPos.x +
1001
- deltaX * Math.cos((tRot / 180) * Math.PI) +
1002
- deltaZ * Math.sin((tRot / 180) * Math.PI);
1003
- pZ =
1004
- tPos.z -
1005
- deltaX * Math.sin((tRot / 180) * Math.PI) +
1006
- deltaZ * Math.cos((tRot / 180) * Math.PI);
1007
- tPoses.push(new Three.Vector3(pX, 0, pZ));
1008
- deltaX =
1009
- (tBounding.max.x - tBounding.min.x) / 2 -
1010
- (sBounding.max.x - sBounding.min.x) / 2;
1011
- deltaZ =
1012
- -(tBounding.max.z - tBounding.min.z) / 2 -
1013
- (sBounding.max.z - sBounding.min.z) / 2;
1014
- pX =
1015
- tPos.x +
1016
- deltaX * Math.cos((tRot / 180) * Math.PI) +
1017
- deltaZ * Math.sin((tRot / 180) * Math.PI);
1018
- pZ =
1019
- tPos.z -
1020
- deltaX * Math.sin((tRot / 180) * Math.PI) +
1021
- deltaZ * Math.cos((tRot / 180) * Math.PI);
1022
- tPoses.push(new Three.Vector3(pX, 0, pZ));
1023
- deltaX = -deltaX;
1024
- pX =
1025
- tPos.x +
1026
- deltaX * Math.cos((tRot / 180) * Math.PI) +
1027
- deltaZ * Math.sin((tRot / 180) * Math.PI);
1028
- pZ =
1029
- tPos.z -
1030
- deltaX * Math.sin((tRot / 180) * Math.PI) +
1031
- deltaZ * Math.cos((tRot / 180) * Math.PI);
1032
- tPoses.push(new Three.Vector3(pX, 0, pZ));
1033
- let distance = Math.sqrt(
1034
- (sPos.x - tPoses[0].x) * (sPos.x - tPoses[0].x) +
1035
- (sPos.z - tPoses[0].z) * (sPos.z - tPoses[0].z)
1036
- );
1037
- let tNum = 1;
1038
- tPos = tPoses[0].clone();
1039
- for (let i = 1; i < tPoses.length; i++) {
1040
- let curDis = Math.sqrt(
1041
- (sPos.x - tPoses[i].x) * (sPos.x - tPoses[i].x) +
1042
- (sPos.z - tPoses[i].z) * (sPos.z - tPoses[i].z)
1043
- );
1044
- if (curDis < distance) {
1045
- distance = curDis;
1046
- tNum = i + 1;
1047
- tPos = tPoses[i].clone();
1048
- }
1049
- }
1050
- // //////////////////////////////////
1051
- if (
1052
- targetObj != null &&
1053
- targetObj.userData.itemId == target.userData.itemId &&
1054
- tNum == targetNumber
1055
- ) {
1056
- removeSnapBoxObj();
1057
- return;
1058
- } else {
1059
- removeSnapBox();
1060
- }
1061
- // //////////////////////////////////
1062
- if (tNum >= 3) tRot += 180;
1063
-
1064
- snapAnimI = 0;
1065
- t_i = 0;
1066
- targetObj = target;
1067
- targetNumber = tNum;
1068
- targetRot = tRot;
1069
- targetPoint = tPos;
1070
- snapBox = snapBoxObj;
1071
- let cx = sPos.x - tPos.x;
1072
- let cz = sPos.z - tPos.z;
1073
- targetUVec = new Three.Vector3(cx, 0, cz);
1074
- targetCRotation = (((tRot - sRot) % 360) / 180) * Math.PI;
1075
- } else {
1076
- let item = layer.getIn(['items', source.userData.itemId]);
1077
- if (holeItems.length) {
1078
- let i;
1079
- for (i = 0; i < holeItems.length; i++) {
1080
- let hole = holeItems[i];
1081
- if (Math.abs(Math.sin(selectedObj.rotRad)) === 1) {
1082
- if (
1083
- item.y + selectedObj.size.width / 2 >=
1084
- hole.y - hole.width / 2 &&
1085
- item.y - selectedObj.size.width / 2 <=
1086
- hole.y + hole.width / 2 &&
1087
- (selectedObj.rotRad == 0 || selectedObj.rotRad == -Math.PI / 2
1088
- ? item.x <= hole.x &&
1089
- item.x + selectedObj.size.height >= hole.x
1090
- : item.x >= hole.x &&
1091
- item.x - selectedObj.size.height <= hole.x)
1092
- )
1093
- break;
1094
- } else {
1095
- if (
1096
- item.x + selectedObj.size.width / 2 >=
1097
- hole.x - hole.width / 2 &&
1098
- item.x - selectedObj.size.width / 2 <=
1099
- hole.x + hole.width / 2 &&
1100
- (selectedObj.rotRad == 0 || selectedObj.rotRad == -Math.PI / 2
1101
- ? item.y <= hole.y &&
1102
- item.y + selectedObj.size.height >= hole.y
1103
- : item.y >= hole.y &&
1104
- item.y - selectedObj.size.height <= hole.y)
1105
- )
1106
- break;
1107
- }
1108
- }
1109
- if (i != holeItems.length) return;
1110
- }
1111
- if (target.userData.type == 'hole') {
1112
- snapFlag = false;
1113
- return;
1114
- } else {
1115
- let layoutType = item.layoutpos;
1116
- let altitudeLength = convert(
1117
- item.properties.getIn(['altitude', '_length'])
1118
- )
1119
- .from('in')
1120
- .to('cm');
1121
- let sBounding = source.children[0].userData;
1122
- let width = sBounding.max.x - sBounding.min.x;
1123
- let height = sBounding.max.y - sBounding.min.y;
1124
- let depth = sBounding.max.z - sBounding.min.z;
1125
- let snapBoxGeom = new Three.BoxGeometry(width, height, depth);
1126
- let snapBoxObj = new Three.Mesh(
1127
- snapBoxGeom,
1128
- new Three.MeshBasicMaterial({
1129
- // color: 0x2cde6b,
1130
- // opacity: 0.7,
1131
- transparent: true,
1132
- blending: Three.MultiplyBlending
1133
- })
1134
- );
1135
- let removeSnapBoxObj = () => {
1136
- if (snapBoxObj) {
1137
- planData.plan.remove(snapBoxObj);
1138
- disposeObject(snapBoxObj);
1139
- }
1140
- snapFlag = false;
1141
- };
1142
- let box = new Three.BoxHelper(snapBoxObj, 0xffffff);
1143
- box.material.linewidth = 2;
1144
- box.material.depthTest = false;
1145
- box.renderOrder = 100;
1146
- snapBoxObj.add(box);
1147
-
1148
- snapBoxObj.position.set(
1149
- source.position.x,
1150
- layoutType === WALL_CABINET_LAYOUTPOS
1151
- ? altitudeLength + source.position.y + height / 2
1152
- : source.position.y + height / 2,
1153
- source.position.z
1154
- );
1155
- snapBoxObj.rotation.set(
1156
- source.rotation.x,
1157
- source.rotation.y,
1158
- source.rotation.z
1159
- );
1160
- snapBoxObj.name = 'TransformBox';
1161
- planData.plan.add(snapBoxObj);
1162
-
1163
- let snapLine = layer.getIn(['lines', target.userData.lineId]);
1164
- // let snapLineThickness = snapLine.properties.getIn([
1165
- // 'thickness',
1166
- // 'length'
1167
- // ]);
1168
- let snapLineThickness = 10.64;
1169
- let vertices = [];
1170
- if (snapLine === undefined) return;
1171
- snapLine.vertices.forEach(data => {
1172
- let vec = layer.getIn(['vertices', data]);
1173
- vertices.push(vec);
1174
- });
1175
- let iX = source.position.clone().x;
1176
- let iY = -source.position.clone().z;
1177
- let lineVec = new Three.Vector2(
1178
- vertices[1].x - vertices[0].x,
1179
- vertices[1].y - vertices[0].y
1180
- );
1181
- let oLength = Math.sqrt(
1182
- lineVec.x * lineVec.x + lineVec.y * lineVec.y
1183
- );
1184
- lineVec.normalize();
1185
- let vec2 = new Three.Vector2(iX - vertices[0].x, iY - vertices[0].y);
1186
- let vec2Legnth = Math.sqrt(vec2.x * vec2.x + vec2.y * vec2.y);
1187
- let angle = Math.abs(lineVec.angle() - vec2.angle());
1188
- angle = angle > Math.PI ? 2 * Math.PI - angle : angle;
1189
- let lineLength = Math.cos(angle) * vec2Legnth;
1190
- let transLength = 0;
1191
- if (lineLength < 100) {
1192
- transLength = -lineLength + (snapLineThickness + width) / 2;
1193
- }
1194
- if (lineLength > oLength - 100) {
1195
- transLength =
1196
- -lineLength - (snapLineThickness + width) / 2 + oLength;
1197
- }
1198
- let directPoint = new Three.Vector2(
1199
- lineVec.x * lineLength + vertices[0].x,
1200
- lineVec.y * lineLength + vertices[0].y
1201
- );
1202
- let directLine = new Three.Vector2(
1203
- directPoint.x - iX,
1204
- directPoint.y - iY
1205
- );
1206
- let dLength = Math.sqrt(
1207
- (iX - directPoint.x) * (iX - directPoint.x) +
1208
- (iY - directPoint.y) * (iY - directPoint.y)
1209
- );
1210
- let reduceLen = (snapLineThickness + depth) / 2;
1211
- let scale = (dLength - reduceLen) / dLength;
1212
- let tPos = new Three.Vector2(
1213
- iX + (directPoint.x - iX) * scale + lineVec.x * transLength,
1214
- iY + (directPoint.y - iY) * scale + lineVec.y * transLength
1215
- );
1216
- let realAngle = directLine.angle() - Math.PI / 2;
1217
- let tRot = (realAngle * 180) / Math.PI;
1218
- let sPos = new Three.Vector2(iX, iY);
1219
- let sRot = item.rotation;
1220
- let tNum = 0;
1221
- // //////////////////////////////////////
1222
- // check part////
1223
- let result = this.collisionCheck(
1224
- source,
1225
- tPos,
1226
- tRot,
1227
- target,
1228
- item,
1229
- this.context.catalog
1230
- );
1231
- // console.log('result', result);
1232
- if (result == false) {
1233
- removeSnapBoxObj();
1234
- removeSnapBox();
1235
- return;
1236
- }
1237
- // ////////////////
1238
- if (targetObj === target && snapBox !== null) {
1239
- removeSnapBoxObj();
1240
- snapAnimI = 20;
1241
- targetPoint = new Three.Vector3(tPos.x, 0, -tPos.y);
1242
- let sourcePos = snapBox.position.clone();
1243
- let cx = sourcePos.x - targetPoint.x;
1244
- let cz = sourcePos.z - targetPoint.z;
1245
- targetUVec = new Three.Vector3(cx, 0, cz);
1246
- targetRot = tRot;
1247
- targetCRotation = (((tRot - sRot) % 360) / 180) * Math.PI;
1248
- snapFlag = false;
1249
- return;
1250
- } else {
1251
- removeSnapBox();
1252
- }
1253
- // //////////////////////////////////////
1254
- snapAnimI = 0;
1255
- t_i = 0;
1256
- targetObj = target;
1257
- targetNumber = tNum;
1258
- targetRot = tRot;
1259
- targetPoint = new Three.Vector3(tPos.x, 0, -tPos.y);
1260
- snapBox = snapBoxObj;
1261
- let sourcePos = snapBox.position.clone();
1262
- let cx = sourcePos.x - targetPoint.x;
1263
- let cz = sourcePos.z - targetPoint.z;
1264
- targetUVec = new Three.Vector3(cx, 0, cz);
1265
- targetRot = tRot;
1266
- targetCRotation = (((tRot - sRot) % 360) / 180) * Math.PI;
1267
- }
1268
- }
1269
- };
1270
-
1271
- /*end of snap functions*/
1272
- let selectedObj = null;
1273
- let firstMove = false;
1274
- let prevX, prevY;
1275
-
1276
- let selObj = null;
1277
-
1278
- let createToolObject = () => {
1279
- const canvas = document.createElement('canvas');
1280
- canvas.width = 100;
1281
- canvas.height = 200;
1282
- canvas.style.width = 50 + 'px';
1283
- canvas.style.height = 100 + 'px';
1284
- const ctx = canvas.getContext('2d');
1285
- ctx.fillStyle = '#FFFFFF';
1286
- ctx.strokeStyle = '#000000';
1287
- ctx.beginPath();
1288
- ctx.arc(50, 50, 40, 0, 4 * Math.PI);
1289
- ctx.fill();
1290
- ctx.stroke();
1291
- let img1 = new Image();
1292
- img1.crossOrigin = 'anonymous';
1293
- img1.src = '/assets/img/svg/3d_item_rotation.svg';
1294
- img1.onload = function () {
1295
- ctx.drawImage(img1, 16, 16, 68, 68);
1296
- };
1297
-
1298
- ctx.beginPath();
1299
- ctx.arc(50, 150, 40, 0, 4 * Math.PI);
1300
- ctx.fill();
1301
- ctx.stroke();
1302
- let img2 = new Image();
1303
- img2.crossOrigin = 'anonymous';
1304
- img2.src = '/assets/img/svg/3d_item_move.svg';
1305
- img2.onload = function () {
1306
- ctx.drawImage(img2, 16, 116, 68, 68);
1307
- };
1308
-
1309
- return canvas;
1310
- };
1311
-
1312
- let clockWise = true;
1313
- let lastAngle = 0;
1314
-
1315
- let createAngleObject = rotate => {
1316
- const canvas = document.createElement('canvas');
1317
- canvas.width = 100;
1318
- canvas.height = 100;
1319
- canvas.style.width = 100 + 'px';
1320
- canvas.style.height = 100 + 'px';
1321
- const ctx = canvas.getContext('2d');
1322
- ctx.strokeStyle = '#FFFFFF';
1323
- ctx.lineWidth = 10;
1324
- ctx.beginPath();
1325
- ctx.arc(50, 50, 45, 0, 2 * Math.PI);
1326
- ctx.stroke();
1327
-
1328
- ctx.strokeStyle = SECONDARY_PURPLE_COLOR;
1329
- ctx.lineWidth = 6;
1330
- ctx.beginPath();
1331
- if (lastAngle < 15 && lastAngle > -15) {
1332
- if (rotate >= 0) {
1333
- clockWise = false;
1334
- } else {
1335
- clockWise = true;
1336
- }
1337
- if (lastAngle === 0) {
1338
- if (rotate > -180) {
1339
- clockWise = true;
1340
- } else {
1341
- clockWise = false;
1342
- }
1343
- }
1344
- }
1345
-
1346
- ctx.arc(50, 50, 45, 0, (rotate / 180.0) * Math.PI, clockWise);
1347
- ctx.stroke();
1348
-
1349
- lastAngle = rotate;
1350
-
1351
- return canvas;
1352
- };
1353
-
1354
- let toolTexture = new Three.Texture(createToolObject());
1355
- toolTexture.needsUpdate = true;
1356
-
1357
- let toolObj = new Three.Sprite(
1358
- new Three.SpriteMaterial({ map: toolTexture, sizeAttenuation: true })
1359
- );
1360
- toolObj.material.transparent = true;
1361
- toolObj.material.depthTest = false;
1362
- toolObj.scale.set(20, 40, 20);
1363
- toolObj.renderOrder = 3;
1364
- toolObj.name = 'toolObj';
1365
-
1366
- let angleTexture = new Three.Texture(createAngleObject(0));
1367
- angleTexture.needsUpdate = true;
1368
-
1369
- let angleObj = new Three.Sprite(
1370
- new Three.SpriteMaterial({ map: angleTexture, sizeAttenuation: false })
1371
- );
1372
-
1373
- angleObj.scale.set(0.075, 0.075, 0.075);
1374
- angleObj.material.transparent = true;
1375
- angleObj.material.depthTest = false;
1376
- angleObj.renderOrder = 3;
1377
- angleObj.name = 'angleObj';
1378
-
1379
- /**
1380
- * Calculate plane point of mouse with `event` & `altitude`
1381
- * * Calculate mouse.x & mouse.y
1382
- * * Set raycaster from camera & Set raycaster direction
1383
- * * Calculate Point & dispatch an action
1384
- */
1385
- const getPoint = (e, alti) => {
1386
- mouse.x = (e.offsetX / this.width) * 2 - 1;
1387
- mouse.y = (-e.offsetY / this.height) * 2 + 1;
1388
-
1389
- raycaster.setFromCamera(mouse, camera);
1390
- rayDirection = raycaster.ray.direction;
1391
-
1392
- Point = mapCursorPosition(e, alti);
1393
- this.context.projectActions.updateMouseCoord(Point);
1394
- };
1395
-
1396
- const getIntersectWallPoint = e => {
1397
- mouse.x = (e.offsetX / this.width) * 2 - 1;
1398
- mouse.y = (-e.offsetY / this.height) * 2 + 1;
1399
-
1400
- raycaster.setFromCamera(mouse, camera);
1401
- rayDirection = raycaster.ray.direction;
1402
-
1403
- let lines = planData.sceneGraph.layers[scene.selectedLayer].lines;
1404
- let keys = Object.keys(lines);
1405
- let arrMesh = [];
1406
- keys.forEach(key => {
1407
- lines[key].children[0].children.forEach(mesh => {
1408
- if (mesh.name == 'soul' && mesh.visible) arrMesh.push(mesh);
1409
- });
1410
- });
1411
- if (arrMesh.length > 0) {
1412
- const intersects = raycaster.intersectObjects(arrMesh);
1413
- if (intersects.length > 0) {
1414
- let intersectPt = intersects[0].point;
1415
- intersectPt.applyMatrix4(gridMatrix);
1416
-
1417
- Point = { x: intersectPt.x, y: -intersectPt.z };
1418
- this.context.projectActions.updateMouseCoord(Point);
1419
- return true;
1420
- }
1421
- }
1422
-
1423
- return false;
1424
- };
1425
-
1426
- this.mouseDownEvent = event => {
1427
- gridPlanOrigin = gridPlane.position;
1428
- gridMatrix.copy(gridPlane.matrixWorld).invert();
1429
- let altitude = 0;
1430
- if (
1431
- allItemRect &&
1432
- allItemRect.cur &&
1433
- allItemRect.cur.itemInfo !== undefined
1434
- ) {
1435
- let properties = allItemRect.cur.itemInfo.properties;
1436
- altitude = properties.getIn(['altitude', '_length']);
1437
- let unit = properties.getIn(['altitude', '_unit']) || 'in';
1438
- altitude = convert(altitude).from(unit).to(this.props.state.scene.unit);
1439
- }
1440
- getPoint(event, altitude);
1441
-
1442
- const state = this.props.state;
1443
-
1444
- this.lastMousePosition.x = mouse.x;
1445
- this.lastMousePosition.y = mouse.y;
1446
-
1447
- const layer = state.scene.getIn(['layers', state.scene.selectedLayer]);
1448
- const sCount =
1449
- layer.selected.areas.size +
1450
- layer.selected.holes.size +
1451
- layer.selected.items.size +
1452
- layer.selected.lines.size;
1453
-
1454
- if (sCount <= 0) {
1455
- isSelected = false;
1456
- } else if (sCount >= 0 && selectedObject && 'holeID' in selectedObject) {
1457
- isSelected = true;
1458
- }
1459
-
1460
- prevX = Point.x;
1461
- prevY = Point.y;
1462
-
1463
- /**
1464
- * 0 - rotate
1465
- * 1 - move up/down
1466
- * 2 - move x/y
1467
- * 3 - camera rotate
1468
- */
1469
- let transflag = 3;
1470
- raycaster.setFromCamera(mouse, camera);
1471
- const meshes = [];
1472
- toIntersect.forEach(object => {
1473
- if (!object) return;
1474
- object.traverse(o => {
1475
- if (o.isMesh) meshes.push(o);
1476
- });
1477
- });
1478
- let intersects = raycaster.intersectObjects(meshes, true);
1479
-
1480
- let toolIntersects = raycaster.intersectObjects([toolObj], true);
1481
-
1482
- if (toolIntersects.length > 0) {
1483
- let distance = Math.sqrt(
1484
- Math.pow((toolIntersects[0].uv.x - 0.5) * 50, 2) +
1485
- Math.pow((toolIntersects[0].uv.y - 0.25) * 100, 2)
1486
- );
1487
- if (distance <= 20) {
1488
- transflag = 2;
1489
- } else {
1490
- distance = Math.sqrt(
1491
- Math.pow((toolIntersects[0].uv.x - 0.5) * 50, 2) +
1492
- Math.pow((toolIntersects[0].uv.y - 0.75) * 100, 2)
1493
- );
1494
- if (distance <= 20) {
1495
- transflag = 0;
1496
- }
1497
- }
1498
- }
1499
-
1500
- if (intersects.length > 0) {
1501
- let i = 0,
1502
- length = intersects.length;
1503
- for (i = 0; i < length; i++) {
1504
- if (
1505
- intersects[i].object.type !== 'BoxHelper' &&
1506
- // intersects[i].object.type === OBJTYPE_MESH &&
1507
- intersects[i].object.name !== 'lineText' &&
1508
- intersects[i].object.name !== 'soul' &&
1509
- !intersects[i].object.name.includes('WarningBox')
1510
- )
1511
- break;
1512
- }
1513
-
1514
- if (intersects[i] !== undefined) {
1515
- if (intersects[i].object.name.indexOf('transUp') != -1) transflag = 1;
1516
- if (intersects[i].object.name.indexOf('transHole') != -1)
1517
- transflag = 2;
1518
- } else {
1519
- console.log('intersects[i] is undefined in viewer3d/viewer3d.js');
1520
- }
1521
- }
1522
-
1523
- if (this.props.state.mode == MODE_DRAWING_ITEM_3D) return;
1524
-
1525
- if (isSelected) {
1526
- if (intersects.length > 0 && !isNaN(intersects[0].distance)) {
1527
- let i;
1528
- for (i = 0; i < intersects.length; i++) {
1529
- if (
1530
- intersects[i].object instanceof Three.Mesh &&
1531
- intersects[i].object.name != 'TransformBox' &&
1532
- intersects[i].object.type != 'Line' &&
1533
- intersects[i].object.name != 'lineText' &&
1534
- intersects[i].object.name != 'countertops' &&
1535
- intersects[i].object.type != 'BoxHelper' &&
1536
- intersects[i].object.name != 'floor' &&
1537
- intersects[i].object.name != 'backFace' &&
1538
- intersects[i].object.name != 'soul' &&
1539
- !intersects[i].object.name.includes('backsplash') &&
1540
- !intersects[i].object.name.includes('WarningBox')
1541
- )
1542
- break;
1543
- }
1544
- if (intersects[i] === undefined) {
1545
- if (transflag !== 0 && transflag !== 2) {
1546
- isSelected = false;
1547
- this.context.projectActions.unselectAll();
1548
- scene3D.remove(toolObj);
1549
- this.context.itemsActions.removeReplacingSupport();
1550
- // orbitController.enableRotate = true;
1551
- return;
1552
- }
1553
- }
1554
- if (selectedObject !== undefined) {
1555
- sPoint.set(Point.x, Point.y);
1556
- if (transflag == 0) {
1557
- scene3D.remove(toolObj);
1558
- let alti = 0;
1559
- if (
1560
- allItemRect &&
1561
- allItemRect.cur &&
1562
- allItemRect.cur.itemInfo !== undefined
1563
- ) {
1564
- let properties = allItemRect.cur.itemInfo.properties;
1565
- alti = properties.getIn(['altitude', '_length']);
1566
- let unit = properties.getIn(['altitude', '_unit']) || 'in';
1567
- alti = convert(alti).from(unit).to(this.props.state.scene.unit);
1568
- }
1569
- getPoint(
1570
- { offsetX: event.offsetX - 50, offsetY: event.offsetY },
1571
- alti
1572
- );
1573
- let selectedItem =
1574
- planData.sceneGraph.layers[selectedObject.layerID].items[
1575
- selectedObject.itemID
1576
- ];
1577
- if (isUndefined(selectedItem)) return;
1578
- const selItem = this.props.state.scene.layers
1579
- .get(selectedObject.layerID)
1580
- .items.get(selectedObject.itemID);
1581
-
1582
- lastAngle = 0;
1583
-
1584
- angleObj.position.set(
1585
- planData.plan.position.x + Point.x,
1586
- selItem.category === 'lighting'
1587
- ? -planData.plan.position.y -
1588
- selItem.properties.get('height').get('length')
1589
- : selItem.properties.get('altitude').get('length') +
1590
- planData.plan.position.y,
1591
- planData.plan.position.z - Point.y
1592
- );
1593
-
1594
- angleTexture.image = createAngleObject(0);
1595
- angleTexture.needsUpdate = true;
1596
-
1597
- scene3D.add(angleObj);
1598
- this.setState({ angleObj: angleObj });
1599
- let centerPos = Point;
1600
- getPoint(event, alti);
1601
-
1602
- this.context.itemsActions.beginRotatingItem3D(
1603
- selectedObject.layerID,
1604
- selectedObject.itemID,
1605
- Point.x,
1606
- Point.y,
1607
- centerPos.x,
1608
- centerPos.y
1609
- );
1610
- bRotate = true;
1611
- } else if (transflag == 1) {
1612
- bMoveUP = true;
1613
- } else if (transflag == 2) {
1614
- switch (true) {
1615
- case 'holeID' in selectedObject:
1616
- this.context.holesActions.beginDraggingHole3D(
1617
- selectedObject.layerID,
1618
- selectedObject.holeID,
1619
- Point.x,
1620
- Point.y
1621
- );
1622
- break;
1623
- default:
1624
- this.context.itemsActions.beginDraggingItem3D(
1625
- selectedObject.layerID,
1626
- selectedObject.itemID,
1627
- Point.x,
1628
- Point.y
1629
- );
1630
- break;
1631
- }
1632
- bMove = true;
1633
- scene3D.remove(toolObj);
1634
- }
1635
- if (!ARRAY_ELEVATION_VIEW_MODES.includes(mode))
1636
- cameraControls.mouseButtons.left = CameraControls.ACTION.NONE;
1637
- }
1638
- } else {
1639
- isSelected = false;
1640
- this.context.projectActions.unselectAll();
1641
- scene3D.remove(toolObj);
1642
- this.context.itemsActions.removeReplacingSupport();
1643
- // orbitController.enableRotate = true;
1644
- return;
1645
- }
1646
- }
1647
- };
1648
-
1649
- this.renderer.setClearColor(new Three.Color(SharedStyle.COLORS.white)); // 3D background color
1650
- this.renderer.setSize(this.width, this.height);
1651
-
1652
- // Add the output of the renderer to the html element
1653
- const canvasWrapper = ReactDOM.findDOMNode(this.refs.canvasWrapper);
1654
- canvasWrapper.appendChild(this.renderer.domElement);
1655
-
1656
- //
1657
-
1658
- if (
1659
- scene.getIn(['layers', scene.selectedLayer, 'selected', 'items']).size !=
1660
- 0
1661
- ) {
1662
- // if selected Object
1663
- isSelected = true;
1664
- selectedObject.layerID = scene.selectedLayer;
1665
- selectedObject.itemID = scene
1666
- .getIn(['layers', scene.selectedLayer, 'selected', 'items'])
1667
- .toJS()[0];
1668
- setTimeout(() => {
1669
- try {
1670
- currentObject =
1671
- planData.sceneGraph.layers[selectedObject.layerID].items[
1672
- selectedObject.itemID
1673
- ];
1674
- if (isUndefined(currentObject)) return;
1675
- const selItem = this.props.state.scene.layers
1676
- .get(selectedObject.layerID)
1677
- .items.get(selectedObject.itemID);
1678
- let itemPos = currentObject.position.clone();
1679
- toolObj.position.set(
1680
- planData.plan.position.x + itemPos.x,
1681
- selItem.category === 'lighting'
1682
- ? -planData.plan.position.y -
1683
- selItem.properties.get('height').get('length')
1684
- : planData.plan.position.y + currentObject.children[0].position.y,
1685
- planData.plan.position.z + itemPos.z
1686
- );
1687
-
1688
- scene3D.add(toolObj);
1689
- this.setState({ toolObj: toolObj });
1690
- } catch (err) {
1691
- console.log(
1692
- 'selectedObject : ' +
1693
- JSON.stringify(selectedObject) +
1694
- '\nError: ' +
1695
- err
1696
- );
1697
- }
1698
- }, 2000);
1699
- }
1700
-
1701
- // Scene functions
1702
-
1703
- function init() {
1704
- clock = new Three.Clock();
1705
- scene3D = new Three.Scene();
1706
- scene3D.background = new Three.Color(0xc3cadc); // change color about v1: 0x8791AB, v2: 0xC2C2C2, v3: 0xC3CADC
1707
- // scene3D.fog = new Three.Fog(0xC3CADC, 2000, 3500);
1708
- window.scene3D = scene3D;
1709
- // Camera
1710
- if (ARRAY_ELEVATION_VIEW_MODES.includes(state.mode)) {
1711
- let { layers } = scene;
1712
- let selectedLayer = layers.get(scene.selectedLayer);
1713
- let ceilHeight = convert(selectedLayer.ceilHeight)
1714
- .from(scene.rulerUnit)
1715
- .to(scene.unit);
1716
- let vertices = selectedLayer.vertices.toJS();
1717
- let maxX = 0,
1718
- maxY = 0,
1719
- minX = 0,
1720
- minY = 0;
1721
- let lines = [];
1722
- selectedLayer.lines.toArray().forEach(line => {
1723
- let vertex0 = selectedLayer.vertices.get(line.vertices.get(0));
1724
- let vertex1 = selectedLayer.vertices.get(line.vertices.get(1));
1725
- let { x: x1, y: y1 } = vertex0;
1726
- let { x: x2, y: y2 } = vertex1;
1727
- let data = line.toJS();
1728
- data = { ...data, l0: { x: x1, y: y1 }, l1: { x: x2, y: y2 } };
1729
- switch (mode) {
1730
- case MODE_FRONT_ELEVATION_VIEW:
1731
- if (almostEqual(y1, y2) && x1 < x2) {
1732
- lines.push(data);
1733
- }
1734
- break;
1735
- case MODE_BACK_ELEVATION_VIEW:
1736
- if (almostEqual(y1, y2) && x1 > x2) {
1737
- lines.push(data);
1738
- }
1739
- break;
1740
- case MODE_LEFT_ELEVATION_VIEW:
1741
- if (almostEqual(x1, x2) && y1 < y2) {
1742
- lines.push(data);
1743
- }
1744
- break;
1745
- case MODE_RIGHT_ELEVATION_VIEW:
1746
- if (almostEqual(x1, x2) && y1 > y2) {
1747
- lines.push(data);
1748
- }
1749
- break;
1750
- default:
1751
- break;
1752
- }
1753
- });
1754
- vertices.toArray().forEach(vertex => {
1755
- if (lines.filter(line => line.vertices.includes(vertex.id)).length) {
1756
- maxX = Math.max(vertex.x, maxX);
1757
- maxY = Math.max(vertex.y, maxY);
1758
- if (minX === 0) minX = vertex.x;
1759
- if (minY === 0) minY = vertex.y;
1760
- minX = Math.min(vertex.x, minX);
1761
- minY = Math.min(vertex.y, minY);
1762
- }
1763
- });
1764
- let line_length, angle, posX, posY;
1765
- switch (state.mode) {
1766
- case MODE_FRONT_ELEVATION_VIEW:
1767
- line_length = maxX - minX;
1768
- posY = minY - 100;
1769
- posX = (minX + maxX) / 2;
1770
- angle = 0;
1771
- break;
1772
- case MODE_RIGHT_ELEVATION_VIEW:
1773
- line_length = maxY - minY;
1774
- posX = minX - 100;
1775
- posY = (minY + maxY) / 2;
1776
- angle = -Math.PI / 2;
1777
- break;
1778
- case MODE_LEFT_ELEVATION_VIEW:
1779
- line_length = maxY - minY;
1780
- posX = maxX + 100;
1781
- posY = (minY + maxY) / 2;
1782
- angle = Math.PI / 2;
1783
- break;
1784
- case MODE_BACK_ELEVATION_VIEW:
1785
- line_length = maxX - minX;
1786
- posY = maxY + 100;
1787
- posX = (minX + maxX) / 2;
1788
- angle = Math.PI;
1789
- break;
1790
- }
1791
- let scale = Math.min(
1792
- (self.width * 0.85) / line_length,
1793
- (self.height * 0.85) / ceilHeight
1794
- );
1795
- // let frontRect = {width: line_length * scale, height: ceilHeight * scale};
1796
- let cameraRect = {
1797
- width: self.width / scale,
1798
- height: self.height / scale
1799
- };
1800
- camera = new Three.OrthographicCamera(
1801
- -cameraRect.width / 2,
1802
- cameraRect.width / 2,
1803
- cameraRect.height / 2,
1804
- -cameraRect.height / 2,
1805
- 1,
1806
- 10000
1807
- );
1808
- camera.position.set(posX, ceilHeight / 2, -posY);
1809
- camera.rotation.set(0, angle, 0);
1810
- } else {
1811
- const aspectRatio = self.width / self.height;
1812
- camera = new Three.PerspectiveCamera(45, aspectRatio, 1, 300000);
1813
- camera.position.set(0, 0, 1);
1814
- }
1815
- camera.layers.enable(1);
1816
-
1817
- function loadENV() {
1818
- new RGBELoader().load(
1819
- '/assets/brown_photostudio_02_1k.hdr',
1820
- function (texture) {
1821
- texture.mapping = Three.EquirectangularReflectionMapping;
1822
- scene3D.environment = texture;
1823
- texture.dispose();
1824
- }
1825
- );
1826
- }
1827
-
1828
- // Camera Controls
1829
- if (!ARRAY_ELEVATION_VIEW_MODES.includes(state.mode)) {
1830
- cameraControls = new CameraControls(camera, self.renderer.domElement);
1831
- cameraControls.dollyToCursor = true;
1832
- cameraControls.infinityDolly = true;
1833
- cameraControls.minDistance = 50;
1834
- cameraControls.maxDistance = Infinity;
1835
- cameraControls.zoomSpeed = 1;
1836
-
1837
- loadENV();
1838
- }
1839
-
1840
- scene3D.add(planData.plan);
1841
- scene3D.add(planData.grid);
1842
- scene3D.add(camera);
1843
- if (ARRAY_ELEVATION_VIEW_MODES.includes(state.mode)) {
1844
- planData.cam.add(camera);
1845
- scene3D.add(planData.cam);
1846
- } else {
1847
- pivot = new Three.Object3D();
1848
- pivot.add(camera);
1849
- scene3D.add(pivot);
1850
- }
1851
-
1852
- // LIGHT
1853
-
1854
- let light = new Three.AmbientLight(0xbfbfbf, 0.9); // soft white light
1855
- }
1856
-
1857
- function render() {
1858
- const delta = clock.getDelta(); // Get time delta for smooth updates
1859
- if (!ARRAY_ELEVATION_VIEW_MODES.includes(state.mode))
1860
- cameraControls.update(delta);
1861
- for (let i = 0; i < lights.length; i++) {
1862
- lights[i].light.position.set(
1863
- planData.plan.position.x + lights[i].x,
1864
- planData.plan.position.y + lights[i].height - 10,
1865
- planData.plan.position.z - lights[i].y
1866
- );
1867
- lights[i].target.position.set(
1868
- planData.plan.position.x + lights[i].x,
1869
- planData.plan.position.y,
1870
- planData.plan.position.z - lights[i].y
1871
- );
1872
- }
1873
-
1874
- camera.updateMatrix();
1875
- camera.updateMatrixWorld();
1876
-
1877
- for (let elemID in planData.sceneGraph.LODs) {
1878
- planData.sceneGraph.LODs[elemID].update(camera);
1879
- }
1880
- if (snapBox !== null) {
1881
- if (snapAnimI >= 15) {
1882
- if ('x' in targetPoint)
1883
- snapBox.position.set(
1884
- targetPoint.x,
1885
- snapBox.position.y,
1886
- targetPoint.z
1887
- );
1888
- snapFlag = false;
1889
- t_i++;
1890
- } else {
1891
- if (snapAnimI == 0) {
1892
- targetCRotation =
1893
- ((((targetRot / 180) * Math.PI - snapBox.rotation.y + Math.PI) *
1894
- 180) /
1895
- Math.PI) %
1896
- 360;
1897
- if (targetCRotation > 180) targetCRotation -= 360;
1898
- if (targetCRotation < -180) targetCRotation += 360;
1899
- targetCRotation = (targetCRotation / 180) * Math.PI;
1900
- }
1901
- if (snapAnimI < 10) {
1902
- snapBox.rotateY(targetCRotation / 10);
1903
- } else {
1904
- snapBox.position.set(
1905
- snapBox.position.clone().x - targetUVec.x / 10,
1906
- snapBox.position.clone().y - targetUVec.y / 10,
1907
- snapBox.position.clone().z - targetUVec.z / 10
1908
- );
1909
- }
1910
- snapAnimI++;
1911
- }
1912
- }
1913
-
1914
- if (t_i === 20) {
1915
- //stop snap after 5s
1916
- removeSnapBox();
1917
- }
1918
-
1919
- // hide hole if wall is not visible
1920
- let layerID = self.props.state.scene.selectedLayer;
1921
- let layer = self.props.state.scene.layers.get(layerID);
1922
- layer.holes.forEach(data => {
1923
- let line = planData.sceneGraph.layers[layerID].lines[data.line];
1924
- let hole = planData.sceneGraph.layers[layerID].holes[data.id];
1925
- if (line instanceof Three.Object3D && !line.isMesh) {
1926
- line = line.children[0].children[0];
1927
- // index(faces) of the line
1928
- const indexAttribute = line.geometry.getIndex();
1929
- const firstFaceIndices = [
1930
- indexAttribute.getX(0),
1931
- indexAttribute.getX(1),
1932
- indexAttribute.getX(2)
1933
- ];
1934
-
1935
- if (firstFaceIndices == undefined) return;
1936
- // normal vector of the line
1937
- const normalAttribute = line.geometry.attributes.normal;
1938
- let normal = new Three.Vector3()
1939
- .fromBufferAttribute(normalAttribute, 0)
1940
- .clone();
1941
- normal = normal
1942
- .applyMatrix4(line.matrixWorld)
1943
- .sub(new Three.Vector3(0, 0, 0).applyMatrix4(line.matrixWorld))
1944
- .normalize();
1945
- let vertices = layer.lines.get(data.line).vertices.toJS();
1946
- let vertex1 = layer.vertices.get(vertices[0]);
1947
- let vertex2 = layer.vertices.get(vertices[1]);
1948
- let cX = (vertex1.x + vertex2.x) / 2;
1949
- let cY = (vertex1.y + vertex2.y) / 2;
1950
- let posVec = new Three.Vector3(cX, 150, -cY);
1951
- posVec = posVec.add(planData.plan.position.clone());
1952
- let cameraLine = camera.position.clone().sub(posVec);
1953
- if (hole) {
1954
- hole.traverse(child => {
1955
- if (child.isMesh) {
1956
- child.material.opacity = cameraLine.dot(normal) > 0 ? 1 : 0;
1957
- child.material.transparent =
1958
- cameraLine.dot(normal) > 0 ? false : true;
1959
- child.material.needsUpdate = true;
1960
- }
1961
- });
1962
- }
1963
- }
1964
- // /////////////////////////////////////
1965
- });
1966
-
1967
- self.renderer.render(scene3D, camera);
1968
- self.renderingID = requestAnimationFrame(render);
1969
-
1970
- if (self.state.waitForRender > 0) {
1971
- self.state.waitForRender++;
1972
- if (self.state.waitForRender > 2) {
1973
- self.setState({ isLoading: false, waitForRender: 0 });
1974
- setTimeout(() => self.props.setIsLoading3D(false), 100);
1975
- console.log('257 line: false');
1976
- self.renderer.domElement.style.display = 'block';
1977
- }
1978
- }
1979
- }
1980
-
1981
- //
1982
-
1983
- window.planData = planData;
1984
- this.planData = planData;
1985
- this.camera = camera;
1986
- this.cameraControls = cameraControls;
1987
- this.scene3D = scene3D;
1988
-
1989
- //
1990
-
1991
- prepareSnap(layer);
1992
- }
1993
-
1994
- componentWillUnmount() {
1995
- cancelAnimationFrame(this.renderingID);
1996
-
1997
- if (!ARRAY_ELEVATION_VIEW_MODES.includes(this.props.state.mode)) {
1998
- if (this.cameraControls !== undefined) this.cameraControls.dispose();
1999
- }
2000
-
2001
- disposeScene(this.scene3D);
2002
- this.scene3D.remove(this.planData.plan);
2003
- this.scene3D.remove(this.planData.grid);
2004
-
2005
- this.scene3D = null;
2006
- this.planData = null;
2007
- this.camera = null;
2008
- this.cameraControls = null;
2009
- this.renderer.renderLists.dispose();
2010
- }
2011
-
2012
- componentWillReceiveProps(nextProps) {
2013
- let { width, height } = nextProps;
2014
- let actions = {
2015
- areaActions: this.context.areaActions,
2016
- holesActions: this.context.holesActions,
2017
- itemsActions: this.context.itemsActions,
2018
- sceneActions: this.context.sceneActions,
2019
- linesActions: this.context.linesActions,
2020
- projectActions: this.context.projectActions,
2021
- catalog: this.context.catalog
2022
- };
2023
-
2024
- this.width = width;
2025
- this.height = height;
2026
-
2027
- this.renderer.setSize(width, height);
2028
-
2029
- let allLines;
2030
- let allLineRects;
2031
- let allItemRect;
2032
-
2033
- this.camera.aspect = width / height;
2034
- this.camera.updateProjectionMatrix();
2035
-
2036
- let data = nextProps.state.scene;
2037
- let layer = data.getIn(['layers', data.selectedLayer]);
2038
- const self = this;
2039
-
2040
- function implementBacksplash() {
2041
- let allItems = GeometryUtils.getAllItemSpecified(
2042
- nextProps.state.scene,
2043
- actions.catalog,
2044
- BASE_CABINET_LAYOUTPOS
2045
- );
2046
- let i,
2047
- items = [];
2048
- for (i = 0; i < allItems.others.length; i++)
2049
- items.push(allItems.others[i]);
2050
- if (allItems.cur) items.push(allItems.cur);
2051
-
2052
- for (i = 0; i < items.length; i++) {
2053
- let calcRect = GeometryUtils.getCalcRectFromItem3D(items[i]);
2054
- let visible = GeometryUtils.isSnappedLine(calcRect, allLineRects);
2055
- actions.itemsActions.setBacksplashVisible(
2056
- items[i].itemInfo.id,
2057
- visible
2058
- );
2059
-
2060
- createBacksplash(
2061
- items[i],
2062
- nextProps.state.scene.getIn([
2063
- 'layers',
2064
- nextProps.state.scene.selectedLayer
2065
- ]),
2066
- planData,
2067
- nextProps.state.scene
2068
- );
2069
- }
2070
- }
2071
-
2072
- function implementWarningBox() {
2073
- let holeItems = GeometryUtils.getHoleItems(layer);
2074
- let i,
2075
- items = [];
2076
- for (i = 0; i < allItemRect.others.length; i++)
2077
- items.push(allItemRect.others[i]);
2078
- if (allItemRect.cur) items.push(allItemRect.cur);
2079
-
2080
- for (i = 0; i < items.length; i++)
2081
- checkCabinetOverlap(
2082
- { x: items[i].pos.x, y: items[i].pos.y },
2083
- items[i],
2084
- holeItems,
2085
- planData
2086
- );
2087
- }
2088
-
2089
- let prepareSnapSpec = layer => {
2090
- allLines = GeometryUtils.getAllLines(layer);
2091
- allLineRects = GeometryUtils.buildRectFromLines(layer, allLines);
2092
- allItemRect = GeometryUtils.getAllItemSpecified(
2093
- this.props.state.scene,
2094
- actions.catalog,
2095
- [WALL_CABINET_LAYOUTPOS, TALL_CABINET_LAYOUTPOS]
2096
- );
2097
- };
2098
-
2099
- let layer1 = this.props.state.scene.getIn(['layers', data.selectedLayer]);
2100
-
2101
- if (this.state.showflag) {
2102
- prepareSnapSpec(layer);
2103
- implementBacksplash();
2104
- implementWarningBox();
2105
- this.setState({ showflag: false });
2106
- }
2107
- if (
2108
- nextProps.state.scene !== this.props.state.scene ||
2109
- (nextProps.state.doorStyle &&
2110
- nextProps.state.doorStyle.get('name') !==
2111
- this.props.state.doorStyle.get('name'))
2112
- ) {
2113
- let changedValues = diff(this.props.state.scene, nextProps.state.scene);
2114
- prepareSnapSpec(layer);
2115
- if (
2116
- nextProps.state.doorStyle &&
2117
- nextProps.state.doorStyle.get('name') ===
2118
- this.props.state.doorStyle.get('name')
2119
- ) {
2120
- self.setState({ isLoading: true, waitForRender: 0 });
2121
- this.props.setIsLoading3D(true);
2122
- self.renderer.domElement.style.display = 'none';
2123
- }
2124
- if (nextProps.state.scene.showfg == true) {
2125
- implementBacksplash();
2126
- implementWarningBox();
2127
- } else {
2128
- deleteSpecifiedMeshObjects('TransformBox');
2129
- }
2130
- let { toolObj, angleObj } = this.state;
2131
- var { promise } = updateScene(
2132
- this.planData,
2133
- nextProps.state.scene,
2134
- this.props.state.scene,
2135
- changedValues.toJS(),
2136
- actions,
2137
- this.context.catalog,
2138
- nextProps.state.mode,
2139
- toolObj,
2140
- angleObj
2141
- );
2142
- promise.then(p1Value => {
2143
- self.setState({ waitForRender: 1 });
2144
- });
2145
- }
2146
- }
2147
-
2148
- render() {
2149
- const { isLoading } = this.state;
2150
- if (isLoading) {
2151
- // document.getElementById('elevation') && (document.getElementById('elevation').style.display = 'none');
2152
- this.renderer.domElement.style.display = 'none';
2153
- return (
2154
- <div
2155
- style={{
2156
- alignItems: ' center',
2157
- width: this.props.width,
2158
- height: this.props.height,
2159
- display: 'inline-flex',
2160
- justifyContent: 'center'
2161
- }}
2162
- >
2163
- <img
2164
- style={{
2165
- width: '70px',
2166
- height: '70px',
2167
- animation: 'spin 2s linear infinite'
2168
- }}
2169
- src={'/assets/img/loading_large.gif'}
2170
- alt="img"
2171
- />
2172
- </div>
2173
- );
2174
- } else {
2175
- this.renderer.domElement.style.pointerEvents = 'auto';
2176
- this.renderer.domElement.style.opacity = '1';
2177
- // document.getElementById('elevation') && (document.getElementById('elevation').style.display = 'block');
2178
- return React.createElement('div', { ref: 'canvasWrapper' });
2179
- }
2180
- }
2181
- }
2182
-
2183
- Viewer3DElevationDownload.propTypes = {
2184
- state: PropTypes.object.isRequired,
2185
- width: PropTypes.number.isRequired,
2186
- height: PropTypes.number.isRequired,
2187
- replaceCabinet: PropTypes.func.isRequired
2188
- };
2189
-
2190
- Viewer3DElevationDownload.contextTypes = {
2191
- areaActions: PropTypes.object.isRequired,
2192
- holesActions: PropTypes.object.isRequired,
2193
- itemsActions: PropTypes.object.isRequired,
2194
- linesActions: PropTypes.object.isRequired,
2195
- sceneActions: PropTypes.object.isRequired,
2196
- projectActions: PropTypes.object.isRequired,
2197
- catalog: PropTypes.object
2198
- };