@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.
- package/package.json +7 -5
- package/src/App.vue +12 -12
- package/src/Overlay/AirTeamOverlay.js +15 -15
- package/src/Overlay/ImageOverlay.js +10 -10
- package/src/Overlay/Overlay.js +8 -8
- package/src/Overlay/OverlayFactory.js +1 -1
- package/src/assets/theme.js +3 -3
- package/src/components/ThreeCanvasViewer.vue +289 -280
- package/src/config.js +48 -48
- package/src/helper/UpdateRoofModuleFieldRelations.js +5 -5
- package/src/helper/UpdateRoofObstacleRelations.js +1 -1
- package/src/helper/cameraMixin.js +34 -34
- package/src/helper/customProvider.js +0 -1
- package/src/helper/initializeThree.js +2 -2
- package/src/helper/materialMixin.js +17 -17
- package/src/helper/projectedMaterial.js +27 -25
- package/src/helper/render/base.js +4 -4
- package/src/helper/render/clear.js +9 -8
- package/src/helper/render/edge.js +2 -2
- package/src/helper/render/geometryHandler.js +15 -15
- package/src/helper/render/imageOverlay.js +4 -4
- package/src/helper/render/index.js +2 -2
- package/src/helper/render/loader.js +4 -4
- package/src/helper/render/margin.js +5 -5
- package/src/helper/render/mergedGeometry.js +2 -2
- package/src/helper/render/moduleField.js +2 -2
- package/src/helper/render/node.js +2 -2
- package/src/helper/render/obstacle.js +3 -3
- package/src/helper/render/overlay.js +3 -3
- package/src/helper/render/panel.js +4 -4
- package/src/helper/render/projectionMaterial.js +2 -2
- package/src/helper/render/roof.js +6 -6
- package/src/helper/render/texture.js +3 -3
- package/src/helper/render/tile.js +80 -72
- package/src/helper/render/tileProjection.js +7 -7
- package/src/helper/renderMixin.js +61 -57
- package/src/helper/threeMixin.js +10 -8
- package/src/main.js +4 -4
- package/src/store/hydrateData.js +30 -30
- package/src/store/nodesEdgesCreation.js +9 -9
- package/src/store/store.js +2 -2
- package/src/store/three-d-module.js +8 -8
- package/src/utils/constants.js +1 -1
- package/src/utils/layers.js +31 -31
- 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
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
)
|
|
170
|
-
|
|
171
|
-
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
} else
|
|
186
|
-
|
|
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
|
-
|
|
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
|
-
|
|
207
|
-
|
|
208
|
-
let
|
|
209
|
-
|
|
210
|
-
|
|
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
|
-
|
|
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
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
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
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
|
-
|
|
261
|
-
|
|
262
|
-
},
|
|
263
|
-
orthographicBounds(bounds, margin) {
|
|
264
|
-
let ratioCanvas = this.canvasHeight / this.canvasWidth
|
|
247
|
+
cameraMoveVector = multiplyVector(distance * 1000, horizontalVector)
|
|
248
|
+
}
|
|
265
249
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
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
|
-
|
|
309
|
-
this.
|
|
310
|
-
overlayReady
|
|
302
|
+
['top', 'global'].includes(this.view_mode) &&
|
|
303
|
+
!this.useCustomCamera
|
|
311
304
|
) {
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|
-
|
|
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%;
|