@eturnity/eturnity_3d 9.13.0 → 9.16.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": "9.13.0",
4
+ "version": "9.16.0",
5
5
  "files": [
6
6
  "dist",
7
7
  "src"
@@ -88,8 +88,6 @@ export default {
88
88
  cylinder.userData.edgeId = edge.id
89
89
  cylinder.userData.type = 'edgeMeshes'
90
90
  cylinder.userData.layer = edge.layer
91
- cylinder.frustumCulled = false
92
-
93
91
  cylinder.frustumCulled = false
94
92
  cylinder.renderOrder = 15
95
93
  this.meshes.edgeMeshes[edge.id] = cylinder
@@ -9,10 +9,22 @@ export default {
9
9
  this.mergedObstacleSideMesh = null
10
10
  },
11
11
  methods: {
12
- applyTextureOnObstacles(material = this.material.roof) {
12
+ applyTextureOnObstacles() {
13
13
  this.reorderRoofMaterials()
14
14
  if (this.mergedObstacleMesh) {
15
- this.applyTextureOnMesh(material, this.mergedObstacleMesh)
15
+ const geometry = this.mergedObstacleMesh.geometry
16
+ geometry.computeBoundingBox()
17
+ const bounds = {
18
+ xMin: geometry.boundingBox.min.x,
19
+ xMax: geometry.boundingBox.max.x,
20
+ yMin: geometry.boundingBox.min.y,
21
+ yMax: geometry.boundingBox.max.y,
22
+ }
23
+ const materials = this.getMaterialsFromBounds(
24
+ bounds,
25
+ this.material.roof
26
+ )
27
+ this.applyTextureOnMesh(materials, this.mergedObstacleMesh)
16
28
  }
17
29
  },
18
30
  renderObstacles() {
@@ -75,7 +87,7 @@ export default {
75
87
  this.mergedObstacleMesh,
76
88
  obstacleGeometries
77
89
  )
78
- this.applyTextureOnObstacles(this.material.roof)
90
+ this.applyTextureOnObstacles()
79
91
 
80
92
  this.mergedObstacleSideMesh = this.updateOrCreateMergedMesh(
81
93
  this.mergedObstacleSideMesh,
@@ -1,11 +1,3 @@
1
- import * as THREE from 'three'
2
- function cloneMaterialArrayAndAddEmission(material, color) {
3
- let newMaterial = material.clone()
4
- newMaterial.camera = material.camera
5
- newMaterial.emissiveEnabled = true
6
- newMaterial.emissive.set(color)
7
- return newMaterial
8
- }
9
1
  export default {
10
2
  methods: {
11
3
  reorderRoofMaterials() {
@@ -16,14 +8,9 @@ export default {
16
8
  })
17
9
  },
18
10
  async updateProjectionMaterials() {
19
- //this.setImageOverlayCameraPosition()
20
11
  this.overlayMaterials = (await this.getOverlaysMaterials()).filter(
21
12
  (m) => !!m
22
13
  )
23
- // this.material.selectedWarningRoof = this.material.roof.map((material) =>
24
- // cloneMaterialArrayAndAddEmission(material, 0x808080)
25
- // )
26
- //add or remove imageOverlayMaterial
27
14
  this.material.roof = this.material.roof.filter(
28
15
  (material) => material.userData.type != 'overlayMaterial'
29
16
  )
@@ -32,5 +19,53 @@ export default {
32
19
  this.applyTextureOnRoofs()
33
20
  this.applyTextureOnObstacles()
34
21
  },
22
+ /**
23
+ *
24
+ * @param {Object} bounds in meters { xMin, xMax, yMin, yMax }
25
+ * @param {Array} materials array of materials
26
+ * @returns {Array} array of all non-tile and relevant tile materials
27
+ */
28
+ getMaterialsFromBounds(bounds, materials = []) {
29
+ if (!materials?.length) return materials
30
+ const nonTile = []
31
+ const tileMats = []
32
+ for (const m of materials) {
33
+ if (m?.userData?.type === 'tileProjectionMaterial') {
34
+ tileMats.push(m)
35
+ } else {
36
+ nonTile.push(m)
37
+ }
38
+ }
39
+ if (tileMats.length === 0) return materials
40
+ const relevantTiles = bounds
41
+ ? tileMats.filter((m) => this.materialOverlapsBounds(m, bounds))
42
+ : tileMats
43
+ const combined = [...nonTile, ...relevantTiles]
44
+ combined.sort((a, b) => (a.priority || 0) - (b.priority || 0))
45
+ return combined
46
+ },
47
+ /**
48
+ *
49
+ * @param {Object} material
50
+ * @param {Object} bounds in meters { xMin, xMax, yMin, yMax }
51
+ * @returns {boolean} true if material overlaps bounds
52
+ */
53
+ materialOverlapsBounds(material, bounds) {
54
+ if (!bounds || !material?.camera) return true
55
+ const cam = material.camera
56
+ if (!cam.isOrthographicCamera) return true
57
+ const left = cam.left
58
+ const right = cam.right
59
+ const bottom = cam.bottom
60
+ const top = cam.top
61
+ const tileMinX = Math.min(left, right)
62
+ const tileMaxX = Math.max(left, right)
63
+ const tileMinY = Math.min(bottom, top)
64
+ const tileMaxY = Math.max(bottom, top)
65
+ const { xMin, xMax, yMin, yMax } = bounds
66
+ const separated =
67
+ xMax < tileMinX || xMin > tileMaxX || yMax < tileMinY || yMin > tileMaxY
68
+ return !separated
69
+ },
35
70
  },
36
71
  }
@@ -68,14 +68,27 @@ export default {
68
68
 
69
69
  return geometry
70
70
  },
71
-
71
+ getMaterialsForRoof(roofPolygon) {
72
+ const bounds = roofPolygon.getBounds()
73
+ // convert bounds to meters
74
+ const boundsMeters = {
75
+ xMin: bounds.xMin / 1000,
76
+ xMax: bounds.xMax / 1000,
77
+ yMin: bounds.yMin / 1000,
78
+ yMax: bounds.yMax / 1000,
79
+ }
80
+ const materials = this.getMaterialsFromBounds(
81
+ boundsMeters,
82
+ this.material.roof
83
+ )
84
+ return materials
85
+ },
72
86
  applyTextureOnRoofs() {
73
87
  this.reorderRoofMaterials()
74
- const material = this.material.roof
75
88
  this.roofs.forEach((roof) => {
76
89
  const roofMesh = this.meshes.roofMeshes[roof.id]
77
90
  if (roofMesh) {
78
- this.applyTextureOnMesh(material, roofMesh)
91
+ this.applyTextureOnMesh(this.getMaterialsForRoof(roof), roofMesh)
79
92
  }
80
93
  })
81
94
  this.render()
@@ -84,7 +97,7 @@ export default {
84
97
  this.clearRemovedOnes('roofMeshes')
85
98
  this.roofs.forEach((roofPolygon) => {
86
99
  const material = roofPolygon.isFlat
87
- ? this.material.roof
100
+ ? this.getMaterialsForRoof(roofPolygon)
88
101
  : this.material.warningRoof
89
102
  let mesh
90
103
  let geometry
@@ -289,6 +289,7 @@ export default {
289
289
  material = mesh.material
290
290
  geometry = updateBufferRoofGeometry(corners, [], geometry)
291
291
  mesh.geometry = geometry
292
+ if (geometry) geometry.computeBoundingSphere()
292
293
  material.map = texture
293
294
  material.needsUpdate = true
294
295
  mesh.userData.mapLayer = this.provider.mapLayer
@@ -310,6 +311,7 @@ export default {
310
311
  material.needsUpdate = true
311
312
  geometry = getBufferRoofGeometry(corners)
312
313
  if (geometry) {
314
+ geometry.computeBoundingSphere()
313
315
  mesh = new THREE.Mesh(geometry, material)
314
316
  mesh.userData.type = 'tileMeshes'
315
317
  mesh.userData.meshId = meshId
Binary file
Binary file
@@ -1,43 +0,0 @@
1
- const theme = {
2
- colors: {
3
- primary: '#282387',
4
- secondary: '#818181',
5
- tertiary: '#d5d5d5',
6
- black: '#263238',
7
- yellow: '#fdb813',
8
- darkGray: '#818181',
9
- mediumGray: '#d5d5d5',
10
- lightGray: '#f2f2f2',
11
- white: '#fff',
12
- blue: '#48a2d0',
13
- red: '#FF5656',
14
- blue1: '#e4efff',
15
- blue2: '#F6FAFF',
16
- grey1: '#666',
17
- grey2: '#c4c4c4',
18
- grey3: '#b2b9c5',
19
- grey4: '#dee2eb',
20
- grey5: '#fafafa',
21
- grey6: '#555d61',
22
- turquoise: '#20A4CA',
23
- green: '#99db0c',
24
- purple: '#505ca6',
25
- disabled: '#dfe1e1',
26
- transparentWhite1: '#ffffff32',
27
- transparentBlack1: '#263238e6',
28
- transparentBlue1: '#20a4cae6',
29
- blueElectric: '#66dffa',
30
- eturnityGrey: '#263238'
31
- },
32
-
33
- screen: {
34
- mobileSmall: '345px',
35
- mobile: '425px',
36
- mobileLarge: '530px',
37
- tablet: '768px',
38
- tabletLarge: '950px'
39
- },
40
- borderRadius: '4px'
41
- }
42
-
43
- export default theme
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>