@eturnity/eturnity_3d 7.30.0 → 7.32.1

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 (45) hide show
  1. package/package.json +7 -5
  2. package/src/App.vue +12 -12
  3. package/src/Overlay/AirTeamOverlay.js +15 -15
  4. package/src/Overlay/ImageOverlay.js +10 -10
  5. package/src/Overlay/Overlay.js +8 -8
  6. package/src/Overlay/OverlayFactory.js +1 -1
  7. package/src/assets/theme.js +3 -3
  8. package/src/components/ThreeCanvasViewer.vue +289 -280
  9. package/src/config.js +48 -48
  10. package/src/helper/UpdateRoofModuleFieldRelations.js +5 -5
  11. package/src/helper/UpdateRoofObstacleRelations.js +1 -1
  12. package/src/helper/cameraMixin.js +34 -34
  13. package/src/helper/customProvider.js +0 -1
  14. package/src/helper/initializeThree.js +2 -2
  15. package/src/helper/materialMixin.js +17 -17
  16. package/src/helper/projectedMaterial.js +27 -25
  17. package/src/helper/render/base.js +4 -4
  18. package/src/helper/render/clear.js +9 -8
  19. package/src/helper/render/edge.js +2 -2
  20. package/src/helper/render/geometryHandler.js +15 -15
  21. package/src/helper/render/imageOverlay.js +4 -4
  22. package/src/helper/render/index.js +2 -2
  23. package/src/helper/render/loader.js +4 -4
  24. package/src/helper/render/margin.js +5 -5
  25. package/src/helper/render/mergedGeometry.js +2 -2
  26. package/src/helper/render/moduleField.js +2 -2
  27. package/src/helper/render/node.js +2 -2
  28. package/src/helper/render/obstacle.js +3 -3
  29. package/src/helper/render/overlay.js +3 -3
  30. package/src/helper/render/panel.js +4 -4
  31. package/src/helper/render/projectionMaterial.js +2 -2
  32. package/src/helper/render/roof.js +6 -6
  33. package/src/helper/render/texture.js +3 -3
  34. package/src/helper/render/tile.js +80 -72
  35. package/src/helper/render/tileProjection.js +7 -7
  36. package/src/helper/renderMixin.js +61 -57
  37. package/src/helper/threeMixin.js +10 -8
  38. package/src/main.js +4 -4
  39. package/src/store/hydrateData.js +30 -30
  40. package/src/store/nodesEdgesCreation.js +9 -9
  41. package/src/store/store.js +2 -2
  42. package/src/store/three-d-module.js +8 -8
  43. package/src/utils/constants.js +1 -1
  44. package/src/utils/layers.js +31 -31
  45. package/src/utils/leaflet-config.service.js +13 -13
@@ -1,328 +1,337 @@
1
1
  <template>
2
2
  <div
3
- class="canvas3DContainer"
4
3
  ref="canvas3DContainer"
5
- :style="{ height: '100%', width: '100%', display: 'flex' }"
4
+ class="canvas3DContainer"
6
5
  crossorigin
7
- />
6
+ :style="{ height: '100%', width: '100%', display: 'flex' }"
7
+ ></div>
8
8
  </template>
9
9
 
10
10
  <script>
11
- import { mapActions, mapState, mapGetters, mapMutations } from 'vuex'
12
- import {
13
- addVector,
14
- multiplyVector,
15
- updateComputedGeometryPolygon,
16
- normalizeVector
17
- } from '@eturnity/eturnity_maths'
18
- import OverlayLayer from '../Overlay/OverlayLayer.js'
19
- import threeMixin from '../helper/threeMixin'
20
-
21
- export default {
22
- name: 'ThreeCanvas',
23
- data() {
24
- return {
25
- layers: null,
26
- provider: null,
27
- pointer: { x: 0, y: 0 },
28
- areModuleFieldsVisible: false,
29
- areUserDeactivatedPanelsVisible: false,
30
- animationFrameId: null,
31
- intervalId: null
32
- }
33
- },
34
- beforeDestroy() {
35
- clearInterval(this.intervalId)
36
- cancelAnimationFrame(this.animationFrameId)
37
- OverlayLayer.removeEventListener(
38
- 'overlay-is-ready',
39
- this.updateOverlayRendering
40
- )
41
- },
42
- mixins: [threeMixin],
43
- async mounted() {
44
- await this.hydrateData(this.geometryData)
45
- let isPerspectiveCamera = true
46
- if (this.useCustomCamera && this.cameraPerspectiveSettings) {
47
- isPerspectiveCamera =
48
- this.cameraPerspectiveSettings.viewType == 'perspective'
49
- }
50
- this.initialiseThree({
51
- isInteractive: this.isInteractive,
52
- isPerspectiveCamera,
53
- DOMElement: this.$refs.canvas3DContainer
54
- })
11
+ import { mapActions, mapState, mapGetters, mapMutations } from 'vuex'
12
+ import {
13
+ addVector,
14
+ multiplyVector,
15
+ updateComputedGeometryPolygon,
16
+ normalizeVector,
17
+ } from '@eturnity/eturnity_maths'
18
+ import OverlayLayer from '../Overlay/OverlayLayer.js'
19
+ import threeMixin from '../helper/threeMixin'
55
20
 
56
- await this.loadPanelsTexture()
57
- this.renderRealisticGeometry()
58
- if (!this.isBuildingVisible) {
59
- this.hideBuildings()
60
- }
61
- await this.updateProjectionMaterials()
62
-
63
- if (this.useCustomCamera) {
64
- if (isPerspectiveCamera) {
65
- this.setPerspectiveCameraPositionTo(
66
- this.cameraPerspectiveSettings.position,
67
- this.cameraPerspectiveSettings.target
68
- )
69
- } else {
70
- this.setOrthographicCameraPositionFromCameraParameters(
71
- this.cameraPerspectiveSettings.cameraParameters
72
- )
21
+ export default {
22
+ name: 'ThreeCanvas',
23
+ mixins: [threeMixin],
24
+ data() {
25
+ return {
26
+ layers: null,
27
+ provider: null,
28
+ pointer: { x: 0, y: 0 },
29
+ areModuleFieldsVisible: false,
30
+ areUserDeactivatedPanelsVisible: false,
31
+ animationFrameId: null,
32
+ intervalId: null,
73
33
  }
74
- } else {
75
- const polygon = this.polygons.find((p) => p.id == this.uuid)
76
- this.setCamera(polygon, this.view_mode)
77
- }
78
- this.isReady.geometry = true
79
- this.intervalId = setInterval(() => this.render(), 500)
80
- OverlayLayer.addEventListener(
81
- 'overlay-is-ready',
82
- this.updateOverlayRendering
83
- )
84
- this.render()
85
- },
86
- computed: {
87
- ...mapState({
88
- geometryData: (state) => state.threeDModule.geometryData,
89
- uuid: (state) => state.threeDModule.uuid,
90
- view_mode: (state) => state.threeDModule.view_mode,
91
- useCustomCamera: (state) => state.threeDModule.useCustomCamera,
92
- cameraPerspectiveSettings: (state) =>
93
- state.threeDModule.cameraPerspectiveSettings,
94
- isInteractive: (state) => state.threeDModule.isInteractive,
95
- isBuildingVisible: (state) => state.threeDModule.isBuildingVisible,
96
- imageOverlay: (state) => state.threeDModule.imageOverlay
97
- }),
98
- ...mapGetters({
99
- polygons: 'getPolygons',
100
- edges: 'getEdges3D',
101
- nodes: 'getNodes3D',
102
- mapConfig: 'getMapConfig',
103
- roofsBounds: 'getRoofsBounds',
104
- layoutSettings: 'getLayoutSettings',
105
- roofs: 'getRoofs',
106
- obstacles: 'getObstacles',
107
- moduleFields: 'getModuleFields',
108
- panels: 'getPanels',
109
- userDeactivatedPanels: 'getUserDeactivatedPanels'
110
- })
111
- },
112
- methods: {
113
- ...mapActions({
114
- hydrateData: 'hydrateData'
115
- }),
116
- ...mapMutations({
117
- setSelectedMapLayer: 'mutate_selectedMapLayer'
118
- }),
119
- hideEdges() {
120
- Object.values(this.meshes.edgeMeshes).forEach(
121
- (mesh) => (mesh.visible = false)
122
- )
123
34
  },
124
- hideWarningRoofs() {
125
- Object.values(this.meshes.flatRoofMeshes).forEach(
126
- (mesh) => (mesh.visible = false)
35
+ beforeDestroy() {
36
+ clearInterval(this.intervalId)
37
+ cancelAnimationFrame(this.animationFrameId)
38
+ OverlayLayer.removeEventListener(
39
+ 'overlay-is-ready',
40
+ this.updateOverlayRendering
127
41
  )
128
42
  },
129
- hideBuildings() {
130
- Object.values(this.meshes.roofMeshes).forEach(
131
- (mesh) => (mesh.visible = false)
132
- )
133
- Object.values(this.meshes.baseMeshes).forEach(
134
- (mesh) => (mesh.visible = false)
135
- )
136
- Object.values(this.meshes.obstacleMeshes).forEach(
137
- (mesh) => (mesh.visible = false)
138
- )
139
- Object.values(this.meshes.edgeMeshes).forEach(
140
- (mesh) => (mesh.visible = false)
141
- )
142
- Object.values(this.meshes.panelsMeshes).forEach(
143
- (mesh) => (mesh.visible = false)
144
- )
145
- this.hideMesh(this.mergedBaseMesh)
146
- this.hideMesh(this.mergedRoofMesh)
147
- this.hideMesh(this.mergedObstacleMesh)
148
- this.hideMesh(this.mergedObstacleSideMesh)
149
- this.hidePanels()
150
- },
151
- hideMesh(mesh) {
152
- if (mesh) {
153
- mesh.visible = false
43
+ async mounted() {
44
+ await this.hydrateData(this.geometryData)
45
+ let isPerspectiveCamera = true
46
+ if (this.useCustomCamera && this.cameraPerspectiveSettings) {
47
+ isPerspectiveCamera =
48
+ this.cameraPerspectiveSettings.viewType == 'perspective'
154
49
  }
155
- },
156
- setCamera(polygon, view_mode) {
157
- let margin = 0.2
158
- if (!polygon || view_mode == 'global') {
159
- let roofsBounds = this.roofsBounds
160
- const position = [0, 0, 100]
161
- const target = [0, 0, 0]
162
- this.orthographicCamera.position.set(...position)
163
- this.orthographicCamera.lookAt(...target)
164
- this.isReady.camera = true
50
+ this.initialiseThree({
51
+ isInteractive: this.isInteractive,
52
+ isPerspectiveCamera,
53
+ DOMElement: this.$refs.canvas3DContainer,
54
+ })
165
55
 
166
- let { xMin, xMax, yMin, yMax } = this.orthographicBounds(
167
- roofsBounds,
168
- margin
169
- )
170
-
171
- this.orthographicCamera.left = xMin / 1000
172
- this.orthographicCamera.right = xMax / 1000
173
- this.orthographicCamera.top = yMax / 1000
174
- this.orthographicCamera.bottom = yMin / 1000
175
- this.orthographicCamera.updateProjectionMatrix()
176
- } else if (polygon) {
177
- let polygonRef = polygon
56
+ await this.loadPanelsTexture()
57
+ this.renderRealisticGeometry()
58
+ if (!this.isBuildingVisible) {
59
+ this.hideBuildings()
60
+ }
61
+ await this.updateProjectionMaterials()
178
62
 
179
- //get polygonMesh
180
- let mesh
181
- let target
182
- let distance = 45
183
- if (polygonRef.layer == 'roof') {
184
- mesh = this.meshes.roofMeshes[polygonRef.id]
185
- } else if (polygonRef.layer == 'moduleField') {
186
- mesh = this.meshes.moduleFieldsMeshes[polygonRef.id]
63
+ if (this.useCustomCamera) {
64
+ if (isPerspectiveCamera) {
65
+ this.setPerspectiveCameraPositionTo(
66
+ this.cameraPerspectiveSettings.position,
67
+ this.cameraPerspectiveSettings.target
68
+ )
69
+ } else {
70
+ this.setOrthographicCameraPositionFromCameraParameters(
71
+ this.cameraPerspectiveSettings.cameraParameters
72
+ )
187
73
  }
74
+ } else {
75
+ const polygon = this.polygons.find((p) => p.id == this.uuid)
76
+ this.setCamera(polygon, this.view_mode)
77
+ }
78
+ this.isReady.geometry = true
79
+ this.intervalId = setInterval(() => this.render(), 500)
80
+ OverlayLayer.addEventListener(
81
+ 'overlay-is-ready',
82
+ this.updateOverlayRendering
83
+ )
84
+ this.render()
85
+ },
86
+ computed: {
87
+ ...mapState({
88
+ geometryData: (state) => state.threeDModule.geometryData,
89
+ uuid: (state) => state.threeDModule.uuid,
90
+ view_mode: (state) => state.threeDModule.view_mode,
91
+ useCustomCamera: (state) => state.threeDModule.useCustomCamera,
92
+ cameraPerspectiveSettings: (state) =>
93
+ state.threeDModule.cameraPerspectiveSettings,
94
+ isInteractive: (state) => state.threeDModule.isInteractive,
95
+ isBuildingVisible: (state) => state.threeDModule.isBuildingVisible,
96
+ imageOverlay: (state) => state.threeDModule.imageOverlay,
97
+ }),
98
+ ...mapGetters({
99
+ polygons: 'getPolygons',
100
+ edges: 'getEdges3D',
101
+ nodes: 'getNodes3D',
102
+ mapConfig: 'getMapConfig',
103
+ roofsBounds: 'getRoofsBounds',
104
+ layoutSettings: 'getLayoutSettings',
105
+ roofs: 'getRoofs',
106
+ obstacles: 'getObstacles',
107
+ moduleFields: 'getModuleFields',
108
+ panels: 'getPanels',
109
+ userDeactivatedPanels: 'getUserDeactivatedPanels',
110
+ }),
111
+ },
112
+ methods: {
113
+ ...mapActions({
114
+ hydrateData: 'hydrateData',
115
+ }),
116
+ ...mapMutations({
117
+ setSelectedMapLayer: 'mutate_selectedMapLayer',
118
+ }),
119
+ hideEdges() {
120
+ Object.values(this.meshes.edgeMeshes).forEach(
121
+ (mesh) => (mesh.visible = false)
122
+ )
123
+ },
124
+ hideWarningRoofs() {
125
+ Object.values(this.meshes.flatRoofMeshes).forEach(
126
+ (mesh) => (mesh.visible = false)
127
+ )
128
+ },
129
+ hideBuildings() {
130
+ Object.values(this.meshes.roofMeshes).forEach(
131
+ (mesh) => (mesh.visible = false)
132
+ )
133
+ Object.values(this.meshes.baseMeshes).forEach(
134
+ (mesh) => (mesh.visible = false)
135
+ )
136
+ Object.values(this.meshes.obstacleMeshes).forEach(
137
+ (mesh) => (mesh.visible = false)
138
+ )
139
+ Object.values(this.meshes.edgeMeshes).forEach(
140
+ (mesh) => (mesh.visible = false)
141
+ )
142
+ Object.values(this.meshes.panelsMeshes).forEach(
143
+ (mesh) => (mesh.visible = false)
144
+ )
145
+ this.hideMesh(this.mergedBaseMesh)
146
+ this.hideMesh(this.mergedRoofMesh)
147
+ this.hideMesh(this.mergedObstacleMesh)
148
+ this.hideMesh(this.mergedObstacleSideMesh)
149
+ this.hidePanels()
150
+ },
151
+ hideMesh(mesh) {
188
152
  if (mesh) {
189
- const geometry = mesh.geometry
190
- if (geometry.boundingSphere === null) geometry.computeBoundingSphere()
191
- target = [
192
- geometry.boundingSphere.center.x,
193
- geometry.boundingSphere.center.y,
194
- geometry.boundingSphere.center.z
195
- ]
196
- let objectRadius = geometry.boundingSphere.radius
197
-
198
- distance =
199
- 5 + objectRadius / Math.sin(((this.camera.fov / 2) * Math.PI) / 180)
200
- }
201
- try {
202
- polygonRef = updateComputedGeometryPolygon(polygonRef)
203
- } catch (err) {
204
- console.error(err)
153
+ mesh.visible = false
205
154
  }
206
- const targetVector = polygonRef.meanPoint
207
- //const target=[targetVector.x/1000,targetVector.y/1000,targetVector.z/1000]
208
- let cameraMoveVector = { x: 0, y: 0, z: 0 }
209
- let flatRoof =
210
- polygonRef.normalVector.x == 0 && polygonRef.normalVector.y == 0
211
- if (view_mode == 'ortho') {
212
- cameraMoveVector = multiplyVector(
213
- distance * 1000,
214
- polygonRef.normalVector
215
- )
216
- } else if (view_mode == 'top') {
217
- let polygonBounds = polygonRef.getBounds()
218
- polygonBounds.xMin -= 1000
219
- polygonBounds.xMax += 1000
220
- polygonBounds.yMin -= 1000
221
- polygonBounds.yMax += 1000
155
+ },
156
+ setCamera(polygon, view_mode) {
157
+ let margin = 0.2
158
+ if (!polygon || view_mode == 'global') {
159
+ let roofsBounds = this.roofsBounds
222
160
  const position = [0, 0, 100]
223
161
  const target = [0, 0, 0]
162
+ this.orthographicCamera.position.set(...position)
163
+ this.orthographicCamera.lookAt(...target)
164
+ this.isReady.camera = true
224
165
 
225
166
  let { xMin, xMax, yMin, yMax } = this.orthographicBounds(
226
- polygonBounds,
167
+ roofsBounds,
227
168
  margin
228
169
  )
229
- this.orthographicCamera.position.set(...position)
230
- this.orthographicCamera.lookAt(...target)
231
170
 
232
171
  this.orthographicCamera.left = xMin / 1000
233
172
  this.orthographicCamera.right = xMax / 1000
234
173
  this.orthographicCamera.top = yMax / 1000
235
174
  this.orthographicCamera.bottom = yMin / 1000
236
175
  this.orthographicCamera.updateProjectionMatrix()
237
- } else {
238
- //street view
239
- let horizontalVector = { ...polygonRef.normalVector, z: 0 }
240
- if (horizontalVector.x == 0 && horizontalVector.y == 0) {
241
- horizontalVector.y = 1
176
+ } else if (polygon) {
177
+ let polygonRef = polygon
178
+
179
+ //get polygonMesh
180
+ let mesh
181
+ let target
182
+ let distance = 45
183
+ if (polygonRef.layer == 'roof') {
184
+ mesh = this.meshes.roofMeshes[polygonRef.id]
185
+ } else if (polygonRef.layer == 'moduleField') {
186
+ mesh = this.meshes.moduleFieldsMeshes[polygonRef.id]
242
187
  }
243
- horizontalVector = normalizeVector(horizontalVector)
188
+ if (mesh) {
189
+ const geometry = mesh.geometry
190
+ if (geometry.boundingSphere === null)
191
+ geometry.computeBoundingSphere()
192
+ target = [
193
+ geometry.boundingSphere.center.x,
194
+ geometry.boundingSphere.center.y,
195
+ geometry.boundingSphere.center.z,
196
+ ]
197
+ let objectRadius = geometry.boundingSphere.radius
244
198
 
245
- cameraMoveVector = multiplyVector(distance * 1000, horizontalVector)
246
- }
199
+ distance =
200
+ 5 +
201
+ objectRadius / Math.sin(((this.camera.fov / 2) * Math.PI) / 180)
202
+ }
203
+ try {
204
+ polygonRef = updateComputedGeometryPolygon(polygonRef)
205
+ } catch (err) {
206
+ console.error(err)
207
+ }
208
+ const targetVector = polygonRef.meanPoint
209
+ //const target=[targetVector.x/1000,targetVector.y/1000,targetVector.z/1000]
210
+ let cameraMoveVector = { x: 0, y: 0, z: 0 }
211
+ let flatRoof =
212
+ polygonRef.normalVector.x == 0 && polygonRef.normalVector.y == 0
213
+ if (view_mode == 'ortho') {
214
+ cameraMoveVector = multiplyVector(
215
+ distance * 1000,
216
+ polygonRef.normalVector
217
+ )
218
+ } else if (view_mode == 'top') {
219
+ let polygonBounds = polygonRef.getBounds()
220
+ polygonBounds.xMin -= 1000
221
+ polygonBounds.xMax += 1000
222
+ polygonBounds.yMin -= 1000
223
+ polygonBounds.yMax += 1000
224
+ const position = [0, 0, 100]
225
+ const target = [0, 0, 0]
247
226
 
248
- const positionVector = addVector(polygonRef.meanPoint, cameraMoveVector)
249
- if (flatRoof) positionVector.z += 2000
250
- const position = [
251
- positionVector.x / 1000,
252
- positionVector.y / 1000 - 1,
253
- positionVector.z / 1000
254
- ]
227
+ let { xMin, xMax, yMin, yMax } = this.orthographicBounds(
228
+ polygonBounds,
229
+ margin
230
+ )
231
+ this.orthographicCamera.position.set(...position)
232
+ this.orthographicCamera.lookAt(...target)
255
233
 
256
- this.camera.position.set(...position)
257
- this.camera.lookAt(...target)
258
- this.camera.updateProjectionMatrix()
234
+ this.orthographicCamera.left = xMin / 1000
235
+ this.orthographicCamera.right = xMax / 1000
236
+ this.orthographicCamera.top = yMax / 1000
237
+ this.orthographicCamera.bottom = yMin / 1000
238
+ this.orthographicCamera.updateProjectionMatrix()
239
+ } else {
240
+ //street view
241
+ let horizontalVector = { ...polygonRef.normalVector, z: 0 }
242
+ if (horizontalVector.x == 0 && horizontalVector.y == 0) {
243
+ horizontalVector.y = 1
244
+ }
245
+ horizontalVector = normalizeVector(horizontalVector)
259
246
 
260
- this.isReady.camera = true
261
- }
262
- },
263
- orthographicBounds(bounds, margin) {
264
- let ratioCanvas = this.canvasHeight / this.canvasWidth
247
+ cameraMoveVector = multiplyVector(distance * 1000, horizontalVector)
248
+ }
265
249
 
266
- let width = (bounds.xMax - bounds.xMin) * (1 + margin)
267
- let height = (bounds.yMax - bounds.yMin) * (1 + margin)
268
- let ratio = height / width
250
+ const positionVector = addVector(
251
+ polygonRef.meanPoint,
252
+ cameraMoveVector
253
+ )
254
+ if (flatRoof) positionVector.z += 2000
255
+ const position = [
256
+ positionVector.x / 1000,
257
+ positionVector.y / 1000 - 1,
258
+ positionVector.z / 1000,
259
+ ]
269
260
 
270
- let xCenter = (bounds.xMax + bounds.xMin) / 2
271
- let yCenter = (bounds.yMax + bounds.yMin) / 2
272
- let xMin
273
- let xMax
274
- let yMin
275
- let yMax
276
- if (ratioCanvas < ratio) {
277
- //canvas wider
278
- xMin = xCenter - height / (2 * ratioCanvas)
279
- xMax = xCenter + height / (2 * ratioCanvas)
280
- yMin = yCenter - height / 2
281
- yMax = yCenter + height / 2
282
- } else {
283
- xMin = xCenter - width / 2
284
- xMax = xCenter + width / 2
285
- yMin = yCenter - (width * ratioCanvas) / 2
286
- yMax = yCenter + (width * ratioCanvas) / 2
287
- }
288
- return { xMin, xMax, yMin, yMax }
289
- },
290
- animate() {
291
- this.render()
292
- this.animationFrameId = requestAnimationFrame(this.animate)
293
- },
294
- render() {
295
- this.renderer.clear()
296
- if (['top', 'global'].includes(this.view_mode) && !this.useCustomCamera) {
297
- this.renderer.render(this.scene, this.orthographicCamera)
298
- } else {
299
- this.renderer.render(this.scene, this.camera)
300
- }
301
- }
302
- },
303
- watch: {
304
- isReady: {
305
- handler() {
306
- const overlayReady = OverlayLayer.getItems().length == 0 || this.isReady.overlay
261
+ this.camera.position.set(...position)
262
+ this.camera.lookAt(...target)
263
+ this.camera.updateProjectionMatrix()
264
+
265
+ this.isReady.camera = true
266
+ }
267
+ },
268
+ orthographicBounds(bounds, margin) {
269
+ let ratioCanvas = this.canvasHeight / this.canvasWidth
270
+
271
+ let width = (bounds.xMax - bounds.xMin) * (1 + margin)
272
+ let height = (bounds.yMax - bounds.yMin) * (1 + margin)
273
+ let ratio = height / width
274
+
275
+ let xCenter = (bounds.xMax + bounds.xMin) / 2
276
+ let yCenter = (bounds.yMax + bounds.yMin) / 2
277
+ let xMin
278
+ let xMax
279
+ let yMin
280
+ let yMax
281
+ if (ratioCanvas < ratio) {
282
+ //canvas wider
283
+ xMin = xCenter - height / (2 * ratioCanvas)
284
+ xMax = xCenter + height / (2 * ratioCanvas)
285
+ yMin = yCenter - height / 2
286
+ yMax = yCenter + height / 2
287
+ } else {
288
+ xMin = xCenter - width / 2
289
+ xMax = xCenter + width / 2
290
+ yMin = yCenter - (width * ratioCanvas) / 2
291
+ yMax = yCenter + (width * ratioCanvas) / 2
292
+ }
293
+ return { xMin, xMax, yMin, yMax }
294
+ },
295
+ animate() {
296
+ this.render()
297
+ this.animationFrameId = requestAnimationFrame(this.animate)
298
+ },
299
+ render() {
300
+ this.renderer.clear()
307
301
  if (
308
- this.isReady.texturesToLoad == this.isReady.texturesLoaded &&
309
- this.isReady.geometry &&
310
- overlayReady
302
+ ['top', 'global'].includes(this.view_mode) &&
303
+ !this.useCustomCamera
311
304
  ) {
312
- var event = new CustomEvent('screenshotable')
313
- // dispatch the custom event
314
- document.dispatchEvent(event)
315
- this.screenshotable = true
305
+ this.renderer.render(this.scene, this.orthographicCamera)
306
+ } else {
307
+ this.renderer.render(this.scene, this.camera)
316
308
  }
317
309
  },
318
- deep: true
319
- }
310
+ },
311
+ watch: {
312
+ isReady: {
313
+ handler() {
314
+ const overlayReady =
315
+ OverlayLayer.getItems().length == 0 || this.isReady.overlay
316
+ if (
317
+ this.isReady.texturesToLoad == this.isReady.texturesLoaded &&
318
+ this.isReady.geometry &&
319
+ overlayReady
320
+ ) {
321
+ var event = new CustomEvent('screenshotable')
322
+ // dispatch the custom event
323
+ document.dispatchEvent(event)
324
+ this.screenshotable = true
325
+ }
326
+ },
327
+ deep: true,
328
+ },
329
+ },
320
330
  }
321
- }
322
331
  </script>
323
332
 
324
333
  <style>
325
- .canvas3DContainer {
334
+ .canvas3DContainer {
326
335
  width: 100%;
327
336
  height: 100%;
328
337
  width: 100%;