@eturnity/eturnity_3d 7.42.2 → 7.42.3-qa-25.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_3d",
3
3
  "private": false,
4
- "version": "7.42.2",
4
+ "version": "7.42.3-qa-25.0",
5
5
  "files": [
6
6
  "dist",
7
7
  "src"
@@ -15,9 +15,9 @@
15
15
  "prettier": "prettier --write \"**/*.{js,vue}\""
16
16
  },
17
17
  "dependencies": {
18
- "@eturnity/eturnity_maths": "7.42.1",
18
+ "@eturnity/eturnity_maths": "7.42.2-qa-25.0",
19
19
  "@originjs/vite-plugin-commonjs": "1.0.3",
20
- "core-js": "2.6.12",
20
+ "core-js": "3.30.2",
21
21
  "cors": "2.8.5",
22
22
  "earcut": "2.2.4",
23
23
  "express": "4.18.2",
@@ -26,7 +26,7 @@
26
26
  "leaflet.gridlayer.googlemutant": "0.14.0",
27
27
  "lodash": "4.17.21",
28
28
  "svd-js": "1.1.1",
29
- "three": "0.142.0",
29
+ "three": "0.167.0",
30
30
  "tween": "0.9.0",
31
31
  "uuid": "9.0.0",
32
32
  "vite-plugin-require": "1.2.14",
@@ -35,6 +35,8 @@ export default class GLBOverlay extends ThreeDModelOverlay {
35
35
  this.type = 'custom_3d_model'
36
36
  }
37
37
  overlayMesh.traverse((object) => {
38
+ object.castShadow = true
39
+ object.receiveShadow = true
38
40
  if (object.material) {
39
41
  object.material.metalness = 0
40
42
  }
@@ -150,6 +150,8 @@ export default class Overlay extends Item {
150
150
  }
151
151
 
152
152
  const callback = (texture) => {
153
+ texture.encoding = THREE.sRGBEncoding
154
+ texture.colorSpace = THREE.SRGBColorSpace
153
155
  texture.needsUpdate = true
154
156
  this.setImageOverlayCameraPosition()
155
157
  let imageOverlayProjectionMaterial = new ProjectedMaterial({
@@ -157,6 +159,7 @@ export default class Overlay extends Item {
157
159
  texture,
158
160
  transparent: true,
159
161
  side: THREE.DoubleSide,
162
+ shadowSide: THREE.DoubleSide,
160
163
  })
161
164
 
162
165
  imageOverlayProjectionMaterial.userData = {}
@@ -424,7 +424,7 @@ export default class ThreeDModelOverlay extends Overlay {
424
424
  ambientLight.name = 'overlayAmbientLight'
425
425
  scene.add(ambientLight)
426
426
  const light = new THREE.HemisphereLight(0xffffff, 0xffffff, 0.8)
427
- ambientLight.name = 'overlayHemisphereLight'
427
+ light.name = 'overlayHemisphereLight'
428
428
  scene.add(light)
429
429
 
430
430
  // Set camera position and look at the center of the model
@@ -17,7 +17,7 @@ export default {
17
17
  },
18
18
  created() {
19
19
  this.perspectiveCamera = new THREE.PerspectiveCamera(
20
- 50,
20
+ 80,
21
21
  300 / 300,
22
22
  1,
23
23
  50000
@@ -48,8 +48,18 @@ export class CustomProvider extends MapProvider {
48
48
  const xMax = xMin + resolution_mPerTile
49
49
  const yMin = tileY * resolution_mPerTile - earthPerimeter / 2
50
50
  const yMax = yMin + resolution_mPerTile
51
-
52
- imageSrc += `&service=WMS&request=GetMap&layers=rgb&styles=&format=image%2Fjpeg&transparent=false&version=1.1.1&id=bkg_image&layerTypeAPI=bkgHexagonGermanyLayer&width=256&height=256&srs=EPSG%3A3857&bbox=${xMin},${yMin},${xMax},${yMax}`
51
+ imageSrc =
52
+ imageSrc +
53
+ '&service=WMS' +
54
+ '&request=GetMap' +
55
+ '&layers=BKG_DOP20,dop10' +
56
+ '&format=image%2Fpng' +
57
+ '&transparent=false' +
58
+ '&version=1.3.0' +
59
+ '&width=256' +
60
+ '&height=256' +
61
+ '&srs=EPSG%3A3857' +
62
+ `&bbox=${xMin},${yMin},${xMax},${yMax}`
53
63
  } else if (this.layer.key == 'azureSatelliteLayer') {
54
64
  const { apiVersion, tilesetId, subscriptionKey } =
55
65
  this.layer.layerData.options
@@ -8,6 +8,8 @@ export default {
8
8
  preserveDrawingBuffer: true,
9
9
  powerPreference: 'high-performance',
10
10
  })
11
+ this.renderer.shadowMap.enabled = true
12
+ this.renderer.shadowMap.type = THREE.BasicShadowMap
11
13
  this.raycaster = new THREE.Raycaster()
12
14
  this.loader = new THREE.TextureLoader()
13
15
  },
@@ -22,11 +22,13 @@ export default {
22
22
  side: THREE.DoubleSide,
23
23
  })
24
24
 
25
- this.material.wall = new THREE.MeshLambertMaterial({
25
+ this.material.wall = new THREE.MeshPhongMaterial({
26
26
  color: wallColor,
27
27
  side: THREE.DoubleSide,
28
28
  transparent: true,
29
29
  opacity: this.wallColor == '#ffffff00' ? 0.2 : 1,
30
+ shadowSide: THREE.DoubleSide,
31
+ flatShading: true,
30
32
  })
31
33
 
32
34
  this.material.obstacle = new THREE.MeshPhongMaterial({
@@ -69,9 +71,13 @@ export default {
69
71
  defaultTextureUrls[k],
70
72
  function (texture) {}
71
73
  )
72
- this.material.panel['default_' + k] = new THREE.MeshBasicMaterial({
74
+ texture.encoding = THREE.sRGBEncoding
75
+ texture.colorSpace = THREE.SRGBColorSpace
76
+ this.material.panel['default_' + k] = new THREE.MeshPhongMaterial({
73
77
  map: texture,
74
78
  side: THREE.DoubleSide,
79
+ shadowSide: THREE.DoubleSide,
80
+ flatShading: true,
75
81
  })
76
82
  }
77
83
  this.material.panel['userDeactivatedPanel'] = new THREE.MeshBasicMaterial({
@@ -94,6 +100,7 @@ export default {
94
100
  specular: 0x009900,
95
101
  shininess: 0,
96
102
  flatShading: true,
103
+ shadowSide: THREE.DoubleSide,
97
104
  side: THREE.DoubleSide,
98
105
  transparent: true,
99
106
  opacity: 0.5,
@@ -104,6 +111,7 @@ export default {
104
111
  specular: 0x009900,
105
112
  shininess: 0,
106
113
  flatShading: true,
114
+ shadowSide: THREE.DoubleSide,
107
115
  side: THREE.DoubleSide,
108
116
  transparent: true,
109
117
  opacity: 0.4,
@@ -114,6 +122,7 @@ export default {
114
122
  specular: 0x009900,
115
123
  shininess: 0,
116
124
  flatShading: true,
125
+ shadowSide: THREE.DoubleSide,
117
126
  side: THREE.DoubleSide,
118
127
  transparent: true,
119
128
  opacity: 0.5,
@@ -143,6 +152,7 @@ export default {
143
152
  specular: 0x009900,
144
153
  shininess: 0,
145
154
  flatShading: true,
155
+ shadowSide: THREE.DoubleSide,
146
156
  side: THREE.DoubleSide,
147
157
  transparent: true,
148
158
  opacity: 0.5,
@@ -39,6 +39,8 @@ export default {
39
39
  mesh.userData.polygonId = roofPolygon.id
40
40
  mesh.matrixAutoUpdate = false
41
41
  mesh.frustumCulled = false
42
+ mesh.receiveShadow = true
43
+ mesh.castShadow = true
42
44
  this.meshes.baseMeshes[roofPolygon.id] = mesh
43
45
  }
44
46
  baseGeometries.push(this.meshes.baseMeshes[roofPolygon.id].geometry)
@@ -50,6 +52,8 @@ export default {
50
52
  this.material.wall
51
53
  )
52
54
  this.mergedBaseMesh.renderOrder = 10
55
+ this.mergedBaseMesh.receiveShadow = true
56
+ this.mergedBaseMesh.castShadow = true
53
57
  },
54
58
  },
55
59
  }
@@ -10,10 +10,14 @@ export default {
10
10
  this.material.panel[pvId] = this.material.panel.default
11
11
  } else {
12
12
  const texture = this.loader.load(component.texture_img_url)
13
- this.material.panel[pvId] = new THREE.MeshBasicMaterial({
13
+ texture.encoding = THREE.sRGBEncoding
14
+ texture.colorSpace = THREE.SRGBColorSpace
15
+ this.material.panel[pvId] = new THREE.MeshPhongMaterial({
14
16
  map: texture,
15
17
  side: THREE.FrontSide,
16
18
  transparent: false,
19
+ shadowSide: THREE.DoubleSide,
20
+ flatShading: true,
17
21
  })
18
22
  }
19
23
  }
@@ -30,10 +34,14 @@ export default {
30
34
  } else {
31
35
  await new Promise((resolve) => {
32
36
  this.loader.load(mf.data.texture_img_url, (texture) => {
33
- this.material.panel[pvId] = new THREE.MeshBasicMaterial({
37
+ texture.encoding = THREE.sRGBEncoding
38
+ texture.colorSpace = THREE.SRGBColorSpace
39
+ this.material.panel[pvId] = new THREE.MeshPhongMaterial({
34
40
  map: texture,
35
41
  side: THREE.FrontSide,
36
42
  transparent: false,
43
+ shadowSide: THREE.DoubleSide,
44
+ flatShading: true,
37
45
  })
38
46
  resolve(texture)
39
47
  })
@@ -40,6 +40,7 @@ export default {
40
40
  specular: 0x009900,
41
41
  shininess: 0,
42
42
  flatShading: true,
43
+ shadowSide: THREE.DoubleSide,
43
44
  side: THREE.DoubleSide,
44
45
  transparent: true,
45
46
  opacity: 0.8,
@@ -65,6 +66,7 @@ export default {
65
66
  specular: 0x009900,
66
67
  shininess: 0,
67
68
  flatShading: true,
69
+ shadowSide: THREE.DoubleSide,
68
70
  side: THREE.DoubleSide,
69
71
  transparent: true,
70
72
  opacity: 0.8,
@@ -82,6 +82,11 @@ export default {
82
82
  this.material.wall
83
83
  )
84
84
  this.mergedObstacleSideMesh.renderOrder = 10
85
+ //shadow
86
+ this.mergedObstacleSideMesh.receiveShadow = true
87
+ this.mergedObstacleSideMesh.castShadow = true
88
+ this.mergedObstacleMesh.receiveShadow = true
89
+ this.mergedObstacleMesh.castShadow = true
85
90
  this.applyTextureOnObstacles(this.material.roof)
86
91
  },
87
92
  },
@@ -162,7 +162,6 @@ export default {
162
162
  mesh.userData.type = 'panelsMeshes'
163
163
  mesh.userData.meshId = panelPolygon.id + '_top'
164
164
  mesh.userData.polygonId = panelPolygon.id
165
- //this.scene.add(mesh)
166
165
  mesh.matrixAutoUpdate = false
167
166
  this.meshes.panelsMeshes[panelPolygon.id + '_top'] = mesh
168
167
  }
@@ -214,6 +213,8 @@ export default {
214
213
  this.material.panel[key],
215
214
  'panelTop_' + key
216
215
  )
216
+ this.mergedPanelTopMeshes[key].receiveShadow = true
217
+ this.mergedPanelTopMeshes[key].castShadow = true
217
218
  this.mergedPanelTopMeshes[key].renderOrder = 10
218
219
  }
219
220
  if (this.arePanelVisible) {
@@ -114,6 +114,8 @@ export default {
114
114
  mesh.userData.meshId = roofPolygon.id
115
115
  mesh.userData.polygonId = roofPolygon.id
116
116
  mesh.frustumCulled = false
117
+ mesh.receiveShadow = true
118
+ mesh.castShadow = true
117
119
  this.meshes.roofMeshes[roofPolygon.id] = mesh
118
120
  this.scene.add(mesh)
119
121
  }
@@ -280,15 +280,18 @@ export default {
280
280
  mesh.userData.meshId = meshId
281
281
  mesh.frustumCulled = false
282
282
  mesh.needsUpdate = true
283
+ mesh.receiveShadow = true
284
+ mesh.castShadow = false
283
285
  mesh.updateMatrix()
284
286
  } else {
285
- material = new THREE.MeshBasicMaterial({
287
+ texture.encoding = THREE.sRGBEncoding
288
+ texture.colorSpace = THREE.SRGBColorSpace
289
+ material = new THREE.MeshPhongMaterial({
286
290
  map: texture,
287
291
  color: 0xffffff,
288
292
  side: THREE.FrontSide,
289
293
  transparent: false,
290
- // opacity:isTileOnRoofBound?0.8:1,
291
- // color:isTileOnRoofBound?'red':'white'
294
+ shininess: 0,
292
295
  })
293
296
  material.map = texture
294
297
  material.needsUpdate = true
@@ -299,7 +302,8 @@ export default {
299
302
  mesh.userData.meshId = meshId
300
303
  mesh.userData.mapLayer = this.provider.mapLayer
301
304
  mesh.name = meshId
302
-
305
+ mesh.receiveShadow = true
306
+ mesh.castShadow = false
303
307
  if (!this.scene.getObjectByName(meshId)) {
304
308
  this.meshes.tileMeshes[meshId] = mesh
305
309
  this.scene.add(this.meshes.tileMeshes[meshId])
@@ -383,6 +387,7 @@ export default {
383
387
 
384
388
  let planeGeometry = []
385
389
  let planeMaterial = []
390
+ let planeTexture = []
386
391
  let zoomLevels = [
387
392
  roofsBoundZoomLvl,
388
393
  roofsBoundZoomLvl - 2,
@@ -423,18 +428,21 @@ export default {
423
428
  this.isReady.texturesToLoad++
424
429
  this.loader.load(googleBackgroundUrl, (texture) => {
425
430
  this.isReady.texturesLoaded++
426
- texture[indexGoogleBackground] = texture
431
+ texture.encoding = THREE.sRGBEncoding
432
+ texture.colorSpace = THREE.SRGBColorSpace
433
+ planeTexture[indexGoogleBackground] = texture
427
434
  if (indexGoogleBackground == 0) {
428
435
  this.newGoogleTileMaterial(
429
- texture[indexGoogleBackground],
436
+ planeTexture[indexGoogleBackground],
430
437
  sizeInMeter,
431
438
  roofsBoundCenterMeter,
432
439
  googleMapType
433
440
  )
434
441
  }
435
- planeMaterial[indexGoogleBackground] = new THREE.MeshBasicMaterial({
436
- map: texture[indexGoogleBackground],
442
+ planeMaterial[indexGoogleBackground] = new THREE.MeshPhongMaterial({
443
+ map: planeTexture[indexGoogleBackground],
437
444
  side: THREE.DoubleSide,
445
+ shininess: 0,
438
446
  })
439
447
  backgroundPlane[indexGoogleBackground] = new THREE.Mesh(
440
448
  planeGeometry[indexGoogleBackground],
@@ -448,6 +456,9 @@ export default {
448
456
  -indexGoogleBackground / 2
449
457
  backgroundPlane[indexGoogleBackground].visible = true
450
458
  backgroundPlane[indexGoogleBackground].needsUpdate = true
459
+
460
+ backgroundPlane[indexGoogleBackground].receiveShadow = true
461
+ backgroundPlane[indexGoogleBackground].castShadow = false
451
462
  backgroundPlane[indexGoogleBackground].userData.index =
452
463
  indexGoogleBackground
453
464
  const meshToRemove = this.googleBackgroundMap.children.find(
@@ -462,6 +473,8 @@ export default {
462
473
  if (this.numberOfTilesRendered == this.numberOfTilesToRender) {
463
474
  this.googleBackgroundMap.needsUpdate = true
464
475
  this.googleBackgroundMap.visible = true
476
+ this.googleBackgroundMap.receiveShadow = true
477
+ this.googleBackgroundMap.castShadow = false
465
478
  this.render()
466
479
  }
467
480
  })
@@ -27,6 +27,7 @@ export default {
27
27
  texture: texture,
28
28
  transparent: true,
29
29
  side: THREE.DoubleSide,
30
+ shadowSide: THREE.DoubleSide
30
31
  })
31
32
  tileProjectionMaterial.camera = cameraProjection
32
33
  tileProjectionMaterial.userData = {}
@@ -7,6 +7,11 @@ import materialMixin from './materialMixin'
7
7
  import renderMixin from './renderMixin'
8
8
  import initializeThree from './initializeThree'
9
9
  import { MAP_LAYER_TYPE } from '../utils/constants'
10
+ import {
11
+ fromSphericalCoordinatesToENU,
12
+ addVector,
13
+ multiplyVector,
14
+ } from '@eturnity/eturnity_maths'
10
15
  export default {
11
16
  data() {
12
17
  return {
@@ -50,6 +55,8 @@ export default {
50
55
 
51
56
  this.initialiseSky()
52
57
 
58
+ this.updateSunLight()
59
+
53
60
  this.initialiseThreeMap()
54
61
 
55
62
  if (isInteractive) {
@@ -105,40 +112,94 @@ export default {
105
112
  })
106
113
  },
107
114
  initialiseLights() {
108
- // const ambientLight = new THREE.AmbientLight(0xffffff, 0.5)
109
- var hemiLight = new THREE.HemisphereLight(0xffffff, 0x444444)
110
- hemiLight.position.set(0, 0, 300)
111
- this.scene.add(hemiLight)
112
- let directionalLight = new THREE.DirectionalLight(0xffffff, 0.5)
113
- directionalLight.position.set(0, 1000, 500)
114
- let directionalLight2 = new THREE.DirectionalLight(0xffffff, 0.5)
115
- directionalLight2.position.set(0, -1000, 500)
116
- this.scene.add(directionalLight)
117
- this.scene.add(directionalLight2)
115
+ const ambientLight = new THREE.HemisphereLight(0xffffff, 0xffffff, 0.8)
116
+ ambientLight.position.set(0, 0, 1)
117
+ this.scene.add(ambientLight)
118
+ var light = new THREE.DirectionalLight(0xffffff, 3)
119
+ light.name = 'sunLight'
120
+ light.position.set(0, 10, 100)
121
+ light.castShadow = true
122
+
123
+ // Shadow settings
124
+ light.shadow.mapSize.width = 2048 // High quality shadow map
125
+ light.shadow.mapSize.height = 2048
126
+ light.shadow.camera.near = 0.5
127
+ light.shadow.camera.far = 500
128
+ light.shadow.camera.left = -5
129
+ light.shadow.camera.right = 5
130
+ light.shadow.camera.top = 5
131
+ light.shadow.camera.bottom = -5
132
+ light.shadow.bias = -0.001
133
+ light.shadow.intensity = 1
134
+ // Add the light to the scene
135
+ this.scene.add(light)
118
136
  },
119
137
  initialiseSky() {
120
138
  // Add Sky
121
139
  let sky = new Sky()
122
140
  sky.scale.setScalar(450000)
141
+ sky.name = 'sky'
123
142
  this.scene.add(sky)
124
143
  this.clearThreeObjects(sky)
125
- let sun = new THREE.Vector3()
126
-
127
144
  const uniforms = sky.material.uniforms
128
145
  uniforms.up.value = new THREE.Vector3(0, 0, 1)
129
146
  uniforms['turbidity'].value = 20
130
- uniforms['rayleigh'].value = 0.06
147
+ uniforms['rayleigh'].value = 0.3
131
148
  uniforms['mieCoefficient'].value = 0.01
132
149
  uniforms['mieDirectionalG'].value = 0.1
133
- const elevation = 10
134
- const azimuth = -20
135
- const phi = THREE.MathUtils.degToRad(90 - elevation)
136
- const theta = THREE.MathUtils.degToRad(azimuth)
137
-
138
- sun.setFromSphericalCoords(1, phi, theta)
139
-
140
- uniforms['sunPosition'].value.copy(sun)
141
- sun = null
150
+ },
151
+ updateSunLight() {
152
+ //require sunPosition (state) and projectBoundingSphere (getter) to work
153
+ let altitude = (35 * Math.PI) / 180
154
+ let azimuth = 0
155
+ if (this.sunPosition) {
156
+ altitude = this.sunPosition.altitude
157
+ azimuth = this.sunPosition.azimuth
158
+ }
159
+ let {
160
+ x: xSun,
161
+ y: ySun,
162
+ z: zSun,
163
+ } = fromSphericalCoordinatesToENU(1, altitude, azimuth)
164
+ let sunVector = new THREE.Vector3(xSun, ySun, zSun)
165
+ const sunLight = this.scene.getObjectByName('sunLight')
166
+ const sky = this.scene.getObjectByName('sky')
167
+ if (sky) {
168
+ const uniforms = sky.material.uniforms
169
+ uniforms['sunPosition'].value.copy(sunVector)
170
+ }
171
+ if (sunLight) {
172
+ let center = { x: 0, y: 0, z: 0 }
173
+ let radius = 1
174
+ if (this.projectBoundingSphere) {
175
+ sunLight.castShadow = true
176
+ radius = this.projectBoundingSphere.radius
177
+ center = this.projectBoundingSphere.center
178
+ } else {
179
+ sunLight.castShadow = false
180
+ }
181
+ let sunVectorPosition = addVector(
182
+ center,
183
+ multiplyVector(radius, sunVector)
184
+ )
185
+ sunLight.position.set(
186
+ sunVectorPosition.x,
187
+ sunVectorPosition.y,
188
+ sunVectorPosition.z
189
+ )
190
+ sunLight.shadow.camera.near = 0
191
+ sunLight.shadow.camera.far = 500
192
+ sunLight.shadow.camera.left = -radius
193
+ sunLight.shadow.camera.right = radius
194
+ sunLight.shadow.camera.top = radius
195
+ sunLight.shadow.camera.bottom = -radius
196
+ sunLight.shadow.camera.updateProjectionMatrix()
197
+ sunLight.shadow.camera.updateMatrix()
198
+ sunLight.target.position.set(center.x, center.y, center.z)
199
+ sunLight.target.updateMatrixWorld()
200
+ sunLight.visible = altitude > 0
201
+ }
202
+ this.render()
142
203
  },
143
204
  initialiseThreeMap() {
144
205
  //Extention of the map with geo-map
@@ -155,12 +155,12 @@ function getLayers() {
155
155
  }
156
156
  )
157
157
  const bkgHexagonImage = L.tileLayer.wms(
158
- 'https://terramapserver.org/Proxy/geoserver/BKG/wms?kid=eag20.1',
158
+ 'https://geo.terramapserver.de/Proxy/Demo/wms?kid=hXgn.Demo_sXDLWAsF33',
159
159
  {
160
- layers: 'rgb',
161
- id: 'bkg_image',
162
- attribution:
163
- '&copy; <a href="https://www.bkg.bund.de" target="_blank">Bundesamt für Kartographie und Geodäsie</a>',
160
+ layers: 'BKG_DOP20,dop10',
161
+ format: 'image/png',
162
+ id: 'bkgHexagonImage',
163
+ attribution: GeoBasis-DE/BKG ${new Date().getFullYear()}, powered by HxGN`,
164
164
  maxZoom: leafletMapLayersConfig['bkgHexagonGermanyLayer']['maxZoom'],
165
165
  maxNativeZoom:
166
166
  leafletMapLayersConfig['bkgHexagonGermanyLayer']['maxNativeZoom'],
@@ -274,7 +274,7 @@ function getLayers() {
274
274
  layerData: ignLayerMap,
275
275
  },
276
276
  {
277
- name: 'BKG satellite image',
277
+ name: 'Hexagon (satellite)',
278
278
  key: 'bkgHexagonGermanyLayer',
279
279
  layerData: bkgHexagonImage,
280
280
  },