@eturnity/eturnity_3d 7.20.1 → 7.24.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.
Files changed (41) hide show
  1. package/package.json +2 -2
  2. package/src/EventManager/EventManager.js +48 -0
  3. package/src/Item/Item.js +12 -0
  4. package/src/Layer/Layer.js +119 -0
  5. package/src/Overlay/AirTeamOverlay.js +605 -0
  6. package/src/Overlay/ImageOverlay.js +309 -0
  7. package/src/Overlay/Overlay.js +255 -0
  8. package/src/Overlay/OverlayFactory.js +19 -0
  9. package/src/Overlay/OverlayLayer.js +36 -0
  10. package/src/components/ThreeCanvasViewer.vue +17 -6
  11. package/src/config.js +120 -17
  12. package/src/helper/UpdateRoofModuleFieldRelations.js +65 -25
  13. package/src/helper/cameraMixin.js +25 -0
  14. package/src/helper/materialMixin.js +14 -1
  15. package/src/helper/projectedMaterial.js +662 -0
  16. package/src/helper/render/base.js +5 -5
  17. package/src/helper/render/clear.js +0 -17
  18. package/src/helper/render/edge.js +2 -0
  19. package/src/helper/render/geometryHandler.js +60 -31
  20. package/src/helper/render/imageOverlay.js +25 -144
  21. package/src/helper/render/index.js +2 -0
  22. package/src/helper/render/mergedGeometry.js +11 -2
  23. package/src/helper/render/obstacle.js +2 -1
  24. package/src/helper/render/overlay.js +41 -0
  25. package/src/helper/render/projectionMaterial.js +17 -19
  26. package/src/helper/render/roof.js +49 -52
  27. package/src/helper/render/texture.js +25 -0
  28. package/src/helper/render/tile.js +84 -24
  29. package/src/helper/render/tileProjection.js +23 -14
  30. package/src/helper/renderMixin.js +22 -8
  31. package/src/helper/threeMixin.js +5 -2
  32. package/src/store/hydrateData.js +23 -11
  33. package/src/store/nodesEdgesCreation.js +78 -4
  34. package/src/store/three-d-module.js +1 -1
  35. package/dist/css/app.58568098.css +0 -1
  36. package/dist/img/reneSola_Virtus_2_JC320S_24_Bbw.85a0cb6d.png +0 -0
  37. package/dist/index.html +0 -15
  38. package/dist/js/app-legacy.aa792c98.js +0 -2
  39. package/dist/js/app-legacy.aa792c98.js.map +0 -1
  40. package/dist/js/chunk-vendors-legacy.9bb3863d.js +0 -41
  41. package/dist/js/chunk-vendors-legacy.9bb3863d.js.map +0 -1
@@ -25,23 +25,6 @@ export default {
25
25
  if (obj.material.dispose) obj.material.dispose()
26
26
  }
27
27
  },
28
- clearPanelsFromChangingRoofs(roofIds) {
29
- const roofs = this.polygons.filter((polygon) =>
30
- roofIds.includes(polygon.id)
31
- )
32
- roofs.forEach((roof) =>
33
- roof.moduleFields.forEach((mf) =>
34
- mf.panels.forEach((panel) => {
35
- let meshTop = this.meshes.panelsMeshes[panel.id + '_top']
36
- let meshSide = this.meshes.panelsMeshes[panel.id + '_side']
37
- if (meshTop || meshSide) {
38
- this.clearMeshFromScene(meshTop, this.scene)
39
- this.clearMeshFromScene(meshSide, this.scene)
40
- }
41
- })
42
- )
43
- )
44
- },
45
28
  clearMeshFromScene(mesh, scene) {
46
29
  if (!mesh || !scene) {
47
30
  return
@@ -87,6 +87,8 @@ export default {
87
87
  cylinder.userData.edgeId = edge.id
88
88
  cylinder.userData.type = 'edgeMeshes'
89
89
  cylinder.userData.layer = edge.layer
90
+ cylinder.frustumCulled = false
91
+ cylinder.renderOrder = 10
90
92
 
91
93
  cylinder.frustumCulled = false
92
94
  cylinder.renderOrder = 10
@@ -8,7 +8,8 @@ import {
8
8
  getNormalVectorFrom3Points,
9
9
  hasNaN,
10
10
  getDistanceBetweenPoints,
11
- intersectOutlines
11
+ intersectOutlines,
12
+ isSameSegment2D
12
13
  } from '@eturnity/eturnity_maths'
13
14
 
14
15
  export function getTriangleVerticesFromOutline(
@@ -52,6 +53,10 @@ export function getTriangleVerticesFromOutline(
52
53
 
53
54
  var triangles = []
54
55
  try {
56
+ let verticesLength = dataVertices.length
57
+ holesStartingIndexes = holesStartingIndexes.filter(
58
+ (index) => index < verticesLength / 3
59
+ )
55
60
  triangles = earcut(dataVertices, holesStartingIndexes, 3)
56
61
  } catch (err) {
57
62
  console.error(err)
@@ -71,6 +76,8 @@ export function updateBufferRoofGeometry(
71
76
  holesOutline = [],
72
77
  geometry
73
78
  ) {
79
+ const geometryVersion = geometry.userData.version || 0
80
+ let geometryChanged = false
74
81
  //Calcul of triangles using cutear algo
75
82
  const triangleVertices = getTriangleVerticesFromOutline(
76
83
  polygonOutline,
@@ -86,13 +93,21 @@ export function updateBufferRoofGeometry(
86
93
  ) {
87
94
  let positions = geometry.attributes.position.array
88
95
  for (let k in vertices) {
89
- positions[k] = vertices[k]
96
+ if (positions[k] != vertices[k]) {
97
+ geometryChanged = true
98
+ positions[k] = vertices[k]
99
+ }
90
100
  }
91
101
  } else {
102
+ geometryChanged = true
92
103
  geometry.dispose()
93
104
  geometry = null
94
105
  geometry = new THREE.BufferGeometry()
95
106
  geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3))
107
+ geometry.userData.version = geometryVersion + 1
108
+ }
109
+ if (geometryChanged) {
110
+ geometry.userData.version = geometryVersion + 1
96
111
  }
97
112
  geometry.setDrawRange(0, vertices.length / 3)
98
113
  geometry.attributes.position.needsUpdate = true
@@ -117,6 +132,7 @@ export function getBufferRoofGeometry(polygonOutline, holesOutline = []) {
117
132
  geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3))
118
133
  geometry.setAttribute('uv', new THREE.BufferAttribute(uvs, 2))
119
134
  geometry.computeVertexNormals()
135
+ geometry.userData.version = 0
120
136
  return geometry
121
137
  }
122
138
 
@@ -142,17 +158,17 @@ export function getWallVertices(polygon) {
142
158
  p_up_1.x / 1000,
143
159
  p_up_1.y / 1000,
144
160
  p_up_1.z / 1000,
145
- p_bottom_0.x / 1000,
146
- p_bottom_0.y / 1000,
147
- p_bottom_0.z / 1000,
148
161
  p_bottom_1.x / 1000,
149
162
  p_bottom_1.y / 1000,
150
- p_bottom_1.z / 1000
163
+ p_bottom_1.z / 1000,
164
+ p_bottom_0.x / 1000,
165
+ p_bottom_0.y / 1000,
166
+ p_bottom_0.z / 1000
151
167
  ]
152
168
  )
153
169
  })
154
170
 
155
- polygon.holes.forEach((hole) => {
171
+ polygon.holes.forEach((hole, holeIndex) => {
156
172
  let obstacleWallOutline =
157
173
  intersectOutlines(hole.outline, polygon.outline)[0] || []
158
174
  obstacleWallOutline = obstacleWallOutline.map((p) => {
@@ -165,34 +181,47 @@ export function getWallVertices(polygon) {
165
181
  ).z
166
182
  }
167
183
  })
184
+
168
185
  const lengthHole = obstacleWallOutline.length
169
186
  obstacleWallOutline.forEach((p_up_0, index) => {
170
187
  const p_up_1 = obstacleWallOutline[(index + 1) % lengthHole]
171
188
  const p_bottom_0 = { ...p_up_0, z: 0 }
172
189
  const p_bottom_1 = { ...p_up_1, z: 0 }
173
190
 
174
- trianglesVertices.push(
175
- ...[
176
- p_up_0.x / 1000,
177
- p_up_0.y / 1000,
178
- p_up_0.z / 1000,
179
- p_up_1.x / 1000,
180
- p_up_1.y / 1000,
181
- p_up_1.z / 1000,
182
- p_bottom_0.x / 1000,
183
- p_bottom_0.y / 1000,
184
- p_bottom_0.z / 1000,
185
- p_up_1.x / 1000,
186
- p_up_1.y / 1000,
187
- p_up_1.z / 1000,
188
- p_bottom_0.x / 1000,
189
- p_bottom_0.y / 1000,
190
- p_bottom_0.z / 1000,
191
- p_bottom_1.x / 1000,
192
- p_bottom_1.y / 1000,
193
- p_bottom_1.z / 1000
194
- ]
195
- )
191
+ const isEdgeConnectedToRoof = !polygon.holes.some((hole, i) => {
192
+ return (
193
+ holeIndex != i &&
194
+ hole.outline.some((p, p_index, outline) => {
195
+ let p_next_index = (p_index + 1) % outline.length
196
+ return isSameSegment2D([p_up_0, p_up_1], [p, outline[p_next_index]])
197
+ })
198
+ )
199
+ })
200
+
201
+ if (isEdgeConnectedToRoof) {
202
+ trianglesVertices.push(
203
+ ...[
204
+ p_up_0.x / 1000,
205
+ p_up_0.y / 1000,
206
+ p_up_0.z / 1000,
207
+ p_up_1.x / 1000,
208
+ p_up_1.y / 1000,
209
+ p_up_1.z / 1000,
210
+ p_bottom_0.x / 1000,
211
+ p_bottom_0.y / 1000,
212
+ p_bottom_0.z / 1000,
213
+ p_up_1.x / 1000,
214
+ p_up_1.y / 1000,
215
+ p_up_1.z / 1000,
216
+ p_bottom_0.x / 1000,
217
+ p_bottom_0.y / 1000,
218
+ p_bottom_0.z / 1000,
219
+ p_bottom_1.x / 1000,
220
+ p_bottom_1.y / 1000,
221
+ p_bottom_1.z / 1000
222
+ ]
223
+ )
224
+ }
196
225
  })
197
226
  })
198
227
  if (hasNaN(trianglesVertices)) {
@@ -564,7 +593,7 @@ export function updateBufferPanelSideGeometry(panelPolygon, geometry) {
564
593
  panelPolygon.outline,
565
594
  panelOutlineTop
566
595
  )
567
-
596
+
568
597
  if (hasNaN(triangleVertices)) {
569
598
  return null
570
599
  }
@@ -587,7 +616,7 @@ export function updateBufferPanelSideGeometry(panelPolygon, geometry) {
587
616
  geometry.attributes.position.needsUpdate = true
588
617
  geometry.computeVertexNormals()
589
618
  geometry.needsUpdate = true
590
-
619
+
591
620
  return geometry
592
621
  }
593
622
  export function getBufferPanelSideGeometry(panelPolygon) {
@@ -1,18 +1,7 @@
1
1
  import * as THREE from 'three'
2
2
  import { mapGetters } from 'vuex'
3
- import ProjectedMaterial from 'three-projected-material'
4
- import {
5
- substractVector,
6
- addVector,
7
- multiplyVector,
8
- getDistanceBetweenPoints,
9
- getAngleInDegFromCanvasVector
10
- } from '@eturnity/eturnity_maths'
11
- import {
12
- getBufferImageOverlayGeometry,
13
- updateBufferRoofGeometry
14
- } from './geometryHandler'
15
3
 
4
+ import OverlayLayer from '../../Overlay/OverlayLayer'
16
5
  export default {
17
6
  created() {
18
7
  this.imageOverlayProjectionCamera = new THREE.PerspectiveCamera(
@@ -31,145 +20,37 @@ export default {
31
20
  },
32
21
  methods: {
33
22
  renderImageOverlayOnBackground() {
34
- if (!this.imageOverlay || !this.imageOverlayMaterial) {
35
- this.clearMeshFromScene(this.meshes.backgroundMesh, this.scene)
36
- this.meshes.backgroundMesh = null
37
- return
38
- }
39
- let corners = this.imageOverlay.corners.map((p) => {
40
- return { ...p, z: 100 }
41
- })
42
- if (this.meshes.backgroundMesh && this.meshes.backgroundMesh.geometry) {
43
- let geometry = this.meshes.backgroundMesh.geometry
44
- geometry = updateBufferRoofGeometry(corners, [], geometry)
45
- //updateBufferRoofGeometry(corners,[],geometry)
46
- this.meshes.backgroundMesh.geometry = geometry
47
- } else {
48
- let planeGeometry = getBufferImageOverlayGeometry(corners)
49
- let planeMaterial = this.imageOverlayMaterial
50
-
51
- this.meshes.backgroundMesh = new THREE.Mesh(
52
- planeGeometry,
53
- planeMaterial
54
- )
23
+ const overlayGeometries = OverlayLayer.getReadyItems()
24
+ .filter((overlay) => overlay.isReady && overlay.corners)
25
+ .map((overlay) => {
26
+ return overlay.getBackgroundGeometry()
27
+ })
28
+ const newBackgroundMesh = this.updateOrCreateMergedMesh(
29
+ this.meshes.backgroundMesh,
30
+ overlayGeometries,
31
+ this.overlayMaterials
32
+ )
33
+ if (!this.meshes.backgroundMesh) {
34
+ this.meshes.backgroundMesh = newBackgroundMesh
55
35
  this.scene.add(this.meshes.backgroundMesh)
36
+ } else {
37
+ this.meshes.backgroundMesh = newBackgroundMesh
56
38
  }
57
39
  this.meshes.backgroundMesh.position.z = 0.15
58
- if (this.imageOverlayMaterial) {
59
- this.applyTextureOnMesh(
60
- [this.imageOverlayMaterial],
61
- this.meshes.backgroundMesh
62
- )
63
- }
40
+ this.applyTextureOnMesh(this.overlayMaterials, this.meshes.backgroundMesh)
41
+
64
42
  this.meshes.backgroundMesh.visible = true
65
- },
66
- async changeImageOverlay() {
67
- if (this.imageOverlayMaterial) {
68
- this.imageOverlayMaterial.dispose()
69
- this.imageOverlayMaterial = null
70
- }
71
- await this.updateProjectionMaterials()
72
- },
73
- async getImageOverlayMaterial() {
74
- if (!this.imageOverlay || !this.imageOverlay.url) {
75
- if (this.imageOverlayMaterial) {
76
- this.imageOverlayMaterial.dispose()
77
- }
78
- this.imageOverlayMaterial = null
79
- return null
80
- }
81
43
 
82
- if (
83
- !this.imageOverlayMaterial ||
84
- this.imageOverlay.url != this.imageOverlayMaterial.userData.url
85
- ) {
86
- this.imageOverlayMaterial = await this.newImageOverlayMaterial()
87
- } else {
88
- this.setImageOverlayCameraPosition()
89
- }
90
- return this.imageOverlayMaterial
44
+ return
91
45
  },
92
- removeImageOverlay() {
93
- if (this.imageOverlayMaterial && this.imageOverlayMaterial.dispose)
94
- this.imageOverlayMaterial.dispose()
95
- this.imageOverlayMaterial = null
96
- this.material.roof = this.material.roof.filter(
97
- (material) => material.userData.type != 'imageOverlayMaterial'
98
- )
99
- },
100
- async newImageOverlayMaterial() {
101
- return new Promise((resolve) => {
102
- this.loader.load(this.imageOverlay.url, (texture) => {
103
- this.imageOverlayTexture = texture
104
- this.setImageOverlayCameraPosition()
105
- let imageOverlayProjectionMaterial = new ProjectedMaterial({
106
- camera: this.imageOverlayProjectionCamera,
107
- texture: this.imageOverlayTexture,
108
- transparent: true,
109
- side: THREE.DoubleSide,
110
- depthWrite: false
111
- })
112
- imageOverlayProjectionMaterial.userData = {}
113
- imageOverlayProjectionMaterial.userData.type = 'imageOverlayMaterial'
114
- imageOverlayProjectionMaterial.priority = 20
115
- imageOverlayProjectionMaterial.userData.url = this.imageOverlay.url
116
- resolve(imageOverlayProjectionMaterial)
117
- })
46
+ async getOverlaysMaterials() {
47
+ let overlayMaterialsPromises = []
48
+ OverlayLayer.getReadyItems().forEach((overlay) => {
49
+ overlayMaterialsPromises.push(overlay.getProjectionMaterial())
118
50
  })
119
- },
120
- setImageOverlayCameraPosition() {
121
- if (!this.imageOverlay || !this.imageOverlay.url) return
122
- let height = getDistanceBetweenPoints(
123
- this.imageOverlay.corners[1],
124
- this.imageOverlay.corners[2]
125
- )
126
- let width = getDistanceBetweenPoints(
127
- this.imageOverlay.corners[0],
128
- this.imageOverlay.corners[1]
129
- )
130
- this.imageOverlayProjectionCamera.aspect = width / height
131
- let projectionAltitude =
132
- height /
133
- (2 * Math.tan((this.imageOverlayProjectionCamera.fov * Math.PI) / 360))
134
-
135
- //set projection camera over background_map_center
136
- let imageOverlayProjectionCameraPosition = {
137
- x: 0,
138
- y: 0,
139
- z: projectionAltitude / 1000
140
- }
141
-
142
- let positionInMm = multiplyVector(
143
- 0.5,
144
- addVector(this.imageOverlay.corners[0], this.imageOverlay.corners[2])
145
- )
146
- imageOverlayProjectionCameraPosition.x = positionInMm.x / 1000
147
- imageOverlayProjectionCameraPosition.y = positionInMm.y / 1000
148
-
149
- this.imageOverlayProjectionCamera.position.set(
150
- imageOverlayProjectionCameraPosition.x,
151
- imageOverlayProjectionCameraPosition.y,
152
- projectionAltitude / 1000
153
- )
154
- this.imageOverlayProjectionCamera.lookAt(
155
- imageOverlayProjectionCameraPosition.x,
156
- imageOverlayProjectionCameraPosition.y,
157
- 0
158
- )
159
- let zAngle = getAngleInDegFromCanvasVector(
160
- substractVector(
161
- this.imageOverlay.corners[3],
162
- this.imageOverlay.corners[0]
163
- )
164
- )
165
- this.imageOverlayProjectionCamera.rotation.set(
166
- 0,
167
- 0,
168
- (zAngle * Math.PI) / 180
169
- )
170
- this.imageOverlayProjectionCamera.far = projectionAltitude * 1.5
171
- this.imageOverlayProjectionCamera.near = projectionAltitude * 0.8
172
- this.imageOverlayProjectionCamera.updateProjectionMatrix()
51
+ overlayMaterialsPromises = overlayMaterialsPromises.filter((p) => !!p)
52
+ this.imageOverlayMaterial = await Promise.all(overlayMaterialsPromises)
53
+ return this.imageOverlayMaterial
173
54
  }
174
55
  }
175
56
  }
@@ -9,6 +9,7 @@ import obstacle from './obstacle'
9
9
  import panel from './panel'
10
10
  import roof from './roof'
11
11
  import imageOverlay from './imageOverlay'
12
+ import overlay from './overlay'
12
13
  import texture from './texture'
13
14
  import projectionMaterial from './projectionMaterial'
14
15
  import tile from './tile'
@@ -28,6 +29,7 @@ export default {
28
29
  clear,
29
30
  loader,
30
31
  imageOverlay,
32
+ overlay,
31
33
  texture,
32
34
  projectionMaterial,
33
35
  tile,
@@ -6,7 +6,8 @@ export default {
6
6
  const mergedVertices = []
7
7
  const mergedNormals = []
8
8
  const mergedUvs = []
9
-
9
+ const geometryVersion = mergedGeometry.userData.version || 0
10
+ let geometryChanged = false
10
11
  geometries.forEach((geometry) => {
11
12
  const positions = geometry.attributes.position.array
12
13
  const normals = geometry.attributes.normal.array
@@ -32,7 +33,10 @@ export default {
32
33
  let uvs = mergedGeometry.attributes.uv.array
33
34
  let normals = mergedGeometry.attributes.normal.array
34
35
  for (let k in mergedVertices) {
35
- positions[k] = mergedVertices[k]
36
+ if (positions[k] != mergedVertices[k]) {
37
+ geometryChanged = true
38
+ positions[k] = mergedVertices[k]
39
+ }
36
40
  }
37
41
  for (let k in mergedUvs) {
38
42
  uvs[k] = mergedUvs[k]
@@ -42,10 +46,14 @@ export default {
42
46
  }
43
47
  mergedGeometry.setDrawRange(0, mergedVertices.length / 3)
44
48
  } else {
49
+ geometryChanged = true
45
50
  mergedGeometry.dispose()
46
51
  mergedGeometry = null
47
52
  mergedGeometry = this.createMergedGeometry(geometries)
48
53
  }
54
+ if (geometryChanged) {
55
+ mergedGeometry.userData.version = geometryVersion + 1
56
+ }
49
57
  mergedGeometry.attributes.position.needsUpdate = true
50
58
  mergedGeometry.attributes.normal.needsUpdate = true
51
59
  mergedGeometry.needsUpdate = true
@@ -83,6 +91,7 @@ export default {
83
91
  new THREE.BufferAttribute(new Float32Array(mergedUvs), 2)
84
92
  )
85
93
  mergedGeometry.computeVertexNormals()
94
+ mergedGeometry.userData.version = 0
86
95
  return mergedGeometry
87
96
  },
88
97
 
@@ -74,13 +74,14 @@ export default {
74
74
  this.mergedObstacleMesh = this.updateOrCreateMergedMesh(
75
75
  this.mergedObstacleMesh,
76
76
  obstacleGeometries,
77
- this.material.roof
77
+ this.material.selectedRoof
78
78
  )
79
79
  this.mergedObstacleSideMesh = this.updateOrCreateMergedMesh(
80
80
  this.mergedObstacleSideMesh,
81
81
  obstacleSideGeometries,
82
82
  this.material.wall
83
83
  )
84
+ this.mergedObstacleSideMesh.renderOrder = 10
84
85
  this.applyTextureOnObstacles(this.material.roof)
85
86
  }
86
87
  }
@@ -0,0 +1,41 @@
1
+ import * as THREE from 'three'
2
+ import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'
3
+ import { mapState } from 'vuex'
4
+ import OverlayLayer from '../../Overlay/OverlayLayer.js'
5
+
6
+ export default {
7
+ data() {
8
+ return {}
9
+ },
10
+ created() {
11
+ this.glbLoader = new GLTFLoader()
12
+ },
13
+ computed: {
14
+ ...mapState({})
15
+ },
16
+ methods: {
17
+ renderOverlays() {
18
+ let overlays = OverlayLayer.getItems()
19
+
20
+ let overlaysIds = overlays.map((o) => o.id)
21
+ let overlayMeshesIds = Object.keys(this.meshes.overlayMeshes)
22
+ overlayMeshesIds.forEach((meshId) => {
23
+ if (!overlaysIds.includes(meshId)) {
24
+ const mesh = this.meshes.overlayMeshes[meshId]
25
+ this.clearMeshFromScene(mesh, this.scene)
26
+ }
27
+ })
28
+ OverlayLayer.getItems().forEach((overlay) => {
29
+ overlay.renderOnThreeJS(this)
30
+ })
31
+ },
32
+ updateOverlayRendering() {
33
+ if (this.isReady) {
34
+ this.isReady.overlay = true
35
+ }
36
+ this.renderOverlays()
37
+ this.updateProjectionMaterials()
38
+ this.render()
39
+ }
40
+ }
41
+ }
@@ -1,3 +1,10 @@
1
+ function cloneMaterialArrayAndAddEmission(material, color) {
2
+ let newMaterial = material.clone()
3
+ newMaterial.camera = material.camera
4
+ newMaterial.emissiveEnabled = true
5
+ newMaterial.emissive.set(color)
6
+ return newMaterial
7
+ }
1
8
  export default {
2
9
  methods: {
3
10
  reorderRoofMaterials() {
@@ -8,27 +15,18 @@ export default {
8
15
  })
9
16
  },
10
17
  async updateProjectionMaterials() {
11
- this.setImageOverlayCameraPosition()
12
- this.imageOverlayMaterial = await this.getImageOverlayMaterial()
18
+ //this.setImageOverlayCameraPosition()
19
+ this.overlayMaterials = (await this.getOverlaysMaterials()).filter(
20
+ (m) => !!m
21
+ )
22
+ // this.material.selectedWarningRoof = this.material.roof.map((material) =>
23
+ // cloneMaterialArrayAndAddEmission(material, 0x808080)
24
+ // )
13
25
  //add or remove imageOverlayMaterial
14
- const index = this.material.roof.findIndex(
15
- (material) => material.userData.type == 'imageOverlayMaterial'
26
+ this.material.roof = this.material.roof.filter(
27
+ (material) => material.userData.type != 'overlayMaterial'
16
28
  )
17
- if (this.imageOverlayMaterial) {
18
- if (index >= 0) {
19
- this.material.roof[index] = this.imageOverlayMaterial
20
- this.material.roof = [...this.material.roof]
21
- } else {
22
- this.material.roof = [
23
- ...this.material.roof,
24
- this.imageOverlayMaterial
25
- ]
26
- }
27
- } else if (index >= 0) {
28
- this.material.roof[index].dispose()
29
- this.material.roof.splice(index, 1)
30
- this.material.roof = [...this.material.roof]
31
- }
29
+ this.material.roof = [...this.material.roof, ...this.overlayMaterials]
32
30
  this.renderImageOverlayOnBackground()
33
31
  this.applyTextureOnRoofs()
34
32
  }