@eturnity/eturnity_3d 6.34.7 → 6.37.0

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.
@@ -51,11 +51,9 @@ export default {
51
51
  tweenCamera: null,
52
52
  tweenOrbit: null,
53
53
  three_map: null,
54
- backgroundImagesizeInMm: null,
55
54
  isReady: {
56
55
  texturesLoaded: 0,
57
56
  texturesToLoad: 0,
58
- backgroundImage: false,
59
57
  threeMap: false,
60
58
  geometry: false,
61
59
  camera: false
@@ -74,6 +72,21 @@ export default {
74
72
  this.initialiseThreeMap()
75
73
  await this.loadPanelsTexture()
76
74
  this.renderGeometry()
75
+ if(!this.isBuildingVisible){
76
+ Object.values(this.meshes.roofMeshes).forEach(mesh=>mesh.visible=false)
77
+ Object.values(this.meshes.baseMeshes).forEach(mesh=>mesh.visible=false)
78
+ Object.values(this.meshes.obstacleMeshes).forEach(mesh=>mesh.visible=false)
79
+ Object.values(this.meshes.edgeMeshes).forEach(mesh=>mesh.visible=false)
80
+ Object.values(this.meshes.panelsMeshes).forEach(mesh=>mesh.visible=false)
81
+ this.hideMesh(this.mergedBaseMesh)
82
+ this.hideMesh(this.mergedRoofMesh)
83
+ this.hideMesh(this.mergedObstacleMesh)
84
+ this.hideMesh(this.mergedObstacleSideMesh)
85
+ this.hidePanels()
86
+
87
+ }
88
+ Object.values(this.meshes.flatRoofMeshes).forEach(mesh=>mesh.visible=false)
89
+ Object.values(this.meshes.edgeMeshes).forEach(mesh=>mesh.visible=false)
77
90
  this.onWindowResize()
78
91
  this.updateProjectionMaterials()
79
92
  this.$root.$on('on-roofSelected', (polygon) =>
@@ -93,7 +106,8 @@ export default {
93
106
  uuid: (state) => state.threeDModule.uuid,
94
107
  view_mode: (state) => state.threeDModule.view_mode,
95
108
  isInteractive: (state) => state.threeDModule.isInteractive,
96
- imageOverlay: (state) => state.threeDModule.imageOverlay
109
+ isBuildingVisible: (state) => state.threeDModule.isBuildingVisible,
110
+ imageOverlay: (state) => state.threeDModule.imageOverlay,
97
111
  }),
98
112
  ...mapGetters({
99
113
  polygons: 'getPolygons',
@@ -116,6 +130,11 @@ export default {
116
130
  ...mapMutations({
117
131
  setModuleTextureVersionId: 'mutate_moduleTextureVersionId'
118
132
  }),
133
+ hideMesh(mesh){
134
+ if(mesh){
135
+ mesh.visible = false
136
+ }
137
+ },
119
138
  setCamera(polygon, view_mode) {
120
139
  let margin = 0.2
121
140
  if (!polygon || view_mode == 'global') {
@@ -165,6 +184,7 @@ export default {
165
184
 
166
185
  polygonRef = updateComputedGeometryPolygon(polygonRef)
167
186
  const targetVector = polygonRef.meanPoint
187
+ //const target=[targetVector.x/1000,targetVector.y/1000,targetVector.z/1000]
168
188
  let cameraMoveVector = { x: 0, y: 0, z: 0 }
169
189
  let flatRoof =
170
190
  polygonRef.normalVector.x == 0 && polygonRef.normalVector.y == 0
@@ -197,7 +217,6 @@ export default {
197
217
  } else {
198
218
  //street view
199
219
  let horizontalVector = { ...polygonRef.normalVector, z: 0 }
200
-
201
220
  if (horizontalVector.x == 0 && horizontalVector.y == 0) {
202
221
  horizontalVector.y = 1
203
222
  }
@@ -207,7 +226,7 @@ export default {
207
226
  }
208
227
 
209
228
  const positionVector = addVector(polygonRef.meanPoint, cameraMoveVector)
210
- positionVector.z += 1000
229
+ if (flatRoof) positionVector.z += 2000
211
230
  const position = [
212
231
  positionVector.x / 1000,
213
232
  positionVector.y / 1000 - 1,
@@ -266,7 +285,6 @@ export default {
266
285
  handler() {
267
286
  if (
268
287
  this.isReady.texturesToLoad == this.isReady.texturesLoaded &&
269
- this.isReady.backgroundImage &&
270
288
  this.isReady.geometry &&
271
289
  this.isReady.threeMap &&
272
290
  this.isReady.camera
@@ -42,6 +42,18 @@ export function UpdateRoofObstacleRelations(state, updateVersionEnable = true) {
42
42
 
43
43
  let heightReference = 0
44
44
  for (let roof of roofsWithObstacle) {
45
+ //updateObstacle z values
46
+ if (obstacle.layer == 'obstacle') {
47
+ obstacle.outline.forEach(
48
+ (p) =>
49
+ (p.z = verticalProjectionOnPlane(
50
+ p,
51
+ roof.normalVector,
52
+ roof.flatOutline[0]
53
+ ).z)
54
+ )
55
+ }
56
+
45
57
  heightReference = obstacle.outline.reduce((acc, cur) => {
46
58
  acc = Math.max(
47
59
  acc,
@@ -8,6 +8,7 @@ export class CustomProvider extends MapProvider {
8
8
  this.layer = layer
9
9
  this.mapLayer = map_layer
10
10
  this.maxZoom = this.layer.layerData.options.maxNativeZoom || 20
11
+ this.minZoom = this.layer.layerData.options.minZoom || 17
11
12
  this.defaultImage = document.createElement('img')
12
13
  this.defaultImage.src = require('../assets/images/white_tile.png')
13
14
  this.defaultImage.crossOrigin = 'Anonymous'
@@ -99,7 +99,9 @@ export default {
99
99
  this.scene.remove(mesh)
100
100
  })
101
101
  this.meshes[type] = {}
102
- this.renderer.renderLists.dispose()
102
+ if (this.renderer) {
103
+ this.renderer.renderLists.dispose()
104
+ }
103
105
  }
104
106
  }
105
107
  }
@@ -58,10 +58,10 @@ export default {
58
58
  }
59
59
  this.meshes.backgroundMesh.position.z = 0.15
60
60
  if (this.imageOverlayMaterial) {
61
- // this.applyTextureOnMesh(
62
- // [this.imageOverlayMaterial],
63
- // this.meshes.backgroundMesh
64
- // )
61
+ this.applyTextureOnMesh(
62
+ [this.imageOverlayMaterial],
63
+ this.meshes.backgroundMesh
64
+ )
65
65
  }
66
66
  this.meshes.backgroundMesh.visible = true
67
67
  },
@@ -1,5 +1,4 @@
1
1
  import node from './node'
2
- import background from './background'
3
2
  import base from './base'
4
3
  import clear from './clear'
5
4
  import edge from './edge'
@@ -17,11 +16,9 @@ import tileProjection from './tileProjection'
17
16
  import mergedGeometry from './mergedGeometry'
18
17
 
19
18
  export default {
20
- //mixins:[node,background,clear,edge,loader,margin,moduleField,obstacle,panel,roof,base]
21
19
  mixins: [
22
20
  margin,
23
21
  node,
24
- background,
25
22
  base,
26
23
  roof,
27
24
  edge,
@@ -89,7 +89,8 @@ export default {
89
89
  mergedGeometry.computeVertexNormals()
90
90
  return mergedGeometry
91
91
  },
92
- updateOrCreateMergedMesh(mesh, geometries, material) {
92
+
93
+ updateOrCreateMergedMesh(mesh, geometries, material, type = undefined) {
93
94
  if (!mesh) {
94
95
  let mergedGeometry = this.createMergedGeometry(geometries)
95
96
  mesh = new THREE.Mesh(mergedGeometry, material)
@@ -54,12 +54,13 @@ export default {
54
54
  this.clearMesh(mesh)
55
55
  }
56
56
  })
57
-
58
57
  let panelSideGeometries = []
59
58
  let panelTopGeometries = {}
60
59
  this.panels.forEach((panelPolygon) => {
61
60
  //definition of the material
62
- if (panelPolygon.moduleField.data.number_of_panels_override) return
61
+ if (panelPolygon.moduleField.data.number_of_panels_override) {
62
+ return
63
+ }
63
64
  let materialId = 'default_' + this.moduleTextureVersionId
64
65
  let material = this.material.panel[materialId]
65
66
  material.transparent = true
@@ -149,14 +150,15 @@ export default {
149
150
  this.mergedPanelSideMesh = this.updateOrCreateMergedMesh(
150
151
  this.mergedPanelSideMesh,
151
152
  panelSideGeometries,
152
- this.material.panelSide
153
+ this.material.panelSide,
154
+ 'panelSide'
153
155
  )
154
-
155
156
  for (let [key, geometries] of Object.entries(panelTopGeometries)) {
156
157
  this.mergedPanelTopMeshes[key] = this.updateOrCreateMergedMesh(
157
158
  this.mergedPanelTopMeshes[key],
158
159
  geometries,
159
- this.material.panel[key]
160
+ this.material.panel[key],
161
+ 'panelTop_' + key
160
162
  )
161
163
  }
162
164
  }
@@ -10,7 +10,7 @@ export default {
10
10
  async updateProjectionMaterials() {
11
11
  this.setImageOverlayCameraPosition()
12
12
  this.imageOverlayMaterial = await this.getImageOverlayMaterial()
13
-
13
+ //add or remove imageOverlayMaterial
14
14
  const index = this.material.roof.findIndex(
15
15
  (material) => material.userData.type == 'imageOverlayMaterial'
16
16
  )
@@ -12,10 +12,10 @@ export default {
12
12
  for (let m = 0; m < materials.length; m++) {
13
13
  if (materials[m].project) {
14
14
  materials[m].project(mesh)
15
- materials[m].needsUpdate = true
16
- mesh.needsUpdate = true
17
15
  }
16
+ materials[m].needsUpdate = true
18
17
  }
18
+ mesh.needsUpdate = true
19
19
  }
20
20
  }
21
21
  }
@@ -120,7 +120,7 @@ export default {
120
120
  }
121
121
  }
122
122
 
123
- while (zoomLvl > 16) {
123
+ while (zoomLvl > 17) {
124
124
  xTileMin = xTileMin / 2 - 1
125
125
  xTileMax = (xTileMax + 1) / 2
126
126
  yTileMin = yTileMin / 2 - 1
@@ -118,6 +118,7 @@ export default {
118
118
  },
119
119
  watch: {
120
120
  selectedMapLayer(newMapLayer) {
121
+ if (!newMapLayer) return
121
122
  this.disposeTileMaterialDifferentMapLayer(newMapLayer.key)
122
123
  }
123
124
  }
package/src/main.js CHANGED
@@ -9,6 +9,9 @@ Vue.use(Vuex)
9
9
  const Renderer = class {
10
10
  constructor() {}
11
11
  mount(identifier, geometryData, specificData, isInteractive = false) {
12
+ if(specificData.isBuildingVisible===undefined){
13
+ specificData.isBuildingVisible=true
14
+ }
12
15
  const myStore = new Vuex.Store({
13
16
  modules: {
14
17
  threeDModule: {
@@ -14,6 +14,11 @@ export async function hydrateData({ state, commit }, data) {
14
14
  let moduleFieldsResponse = data.moduleFields
15
15
  const layoutSettingResponse = data.layoutSettings
16
16
  const imageOverlayResponse = data.imageOverlay
17
+ const mapType = data.mapType
18
+ let layers = getLayers()
19
+ let selectedLayer = layers.find((layer) => layer.key == mapType)
20
+ commit('mutate_selectedMapLayer', selectedLayer)
21
+
17
22
  //removing empty roof,obstacle and modulefield generated by BE on variant creation
18
23
  roofsResponse = roofsResponse.reduce((acc, cur) => {
19
24
  if (cur.roof_outline.length > 0) {
@@ -49,19 +54,6 @@ export async function hydrateData({ state, commit }, data) {
49
54
  commit('mutate_layoutSettings', layoutSetting)
50
55
  commit('mutate_moduleTextureVersionId', moduleTextureVersionId)
51
56
  commit('mutate_wallColor', layoutSetting.wall_color)
52
- let layers = getLayers()
53
- let selectedLayer
54
- if (
55
- layoutSetting.background_map_settings &&
56
- layoutSetting.background_map_settings.layerKey
57
- ) {
58
- selectedLayer = layers.find(
59
- (layer) => layer.key == layoutSetting.background_map_settings.layerKey
60
- )
61
- } else {
62
- selectedLayer = layers.find((layer) => layer.key == 'googleLayer')
63
- }
64
- commit('mutate_selectedMapLayer', selectedLayer)
65
57
 
66
58
  //end of layoutSetting correction
67
59
  const newMapConfig = state.mapConfig
@@ -69,7 +61,7 @@ export async function hydrateData({ state, commit }, data) {
69
61
  lat: layoutSetting.layout_latitude,
70
62
  lng: layoutSetting.layout_longitude
71
63
  }
72
- newMapConfig.layer = layoutSetting.map_layer
64
+ newMapConfig.layer = selectedLayer
73
65
  newMapConfig.zoom = layoutSetting.map_zoom
74
66
  commit('mutate_mapConfig', newMapConfig)
75
67
  }
@@ -21,10 +21,9 @@ const init_state = {
21
21
  buildingLocation: null,
22
22
  imageOverlay: null,
23
23
  layoutSettings: {
24
- base64_image_url: null,
25
24
  layout_latitude: null,
26
25
  layout_longitude: null,
27
- map_layer: 'swisstopoLayer_swissimage',
26
+ map_layer: 'googleLayerTerrain',
28
27
  map_zoom: 19,
29
28
  camera_3d: {}
30
29
  },
@@ -1,23 +1,26 @@
1
- export function cancellablePromise(promise){
2
- let status='pending'
3
- let isCancel=false
4
- const promiseObject=new Promise(function(res,rej){
5
- promise
6
- .then(data=>{
7
- if(!isCancel){res(data);status='resolved'}else{
8
- status='resolved but cancelled before'
9
- }
10
- })
11
- .catch(data=>{
12
- status='rejected'
13
- if(!isCancel) rej(data)
14
- })
15
- })
16
- promiseObject.getStatus=()=>{
17
- return status
18
- }
19
- promiseObject.cancel=()=>{
20
- isCancel=true
21
- }
22
- return promiseObject
23
- }
1
+ export function cancellablePromise(promise) {
2
+ let status = 'pending'
3
+ let isCancel = false
4
+ const promiseObject = new Promise(function (res, rej) {
5
+ promise
6
+ .then((data) => {
7
+ if (!isCancel) {
8
+ res(data)
9
+ status = 'resolved'
10
+ } else {
11
+ status = 'resolved but cancelled before'
12
+ }
13
+ })
14
+ .catch((data) => {
15
+ status = 'rejected'
16
+ if (!isCancel) rej(data)
17
+ })
18
+ })
19
+ promiseObject.getStatus = () => {
20
+ return status
21
+ }
22
+ promiseObject.cancel = () => {
23
+ isCancel = true
24
+ }
25
+ return promiseObject
26
+ }
@@ -1,5 +0,0 @@
1
- import * as THREE from 'three'
2
-
3
- export default {
4
- methods: {}
5
- }