@eturnity/eturnity_3d 6.34.6 → 6.34.7
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 +2 -2
- package/src/components/ThreeCanvasViewer.vue +14 -21
- package/src/helper/materialMixin.js +10 -7
- package/src/helper/render/base.js +14 -5
- package/src/helper/render/imageOverlay.js +4 -4
- package/src/helper/render/index.js +3 -3
- package/src/helper/render/loader.js +4 -4
- package/src/helper/render/mergedGeometry.js +108 -0
- package/src/helper/render/obstacle.js +38 -8
- package/src/helper/render/panel.js +82 -14
- package/src/helper/render/projectionMaterial.js +2 -28
- package/src/helper/render/roof.js +24 -24
- package/src/helper/render/texture.js +3 -0
- package/src/helper/render/tile.js +92 -63
- package/src/helper/render/tileProjection.js +3 -3
- package/src/helper/renderMixin.js +105 -43
- package/src/helper/threeMixin.js +15 -4
- package/src/helper/MapView.js +0 -221
- package/src/helper/materials.js +0 -77
- package/src/helper/render/mapProjection.js +0 -100
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eturnity/eturnity_3d",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "6.34.
|
|
4
|
+
"version": "6.34.7",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vue-cli-service serve --skip-plugins @vue/cli-plugin-eslint",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"prettier": "prettier --write \"**/*.{js,vue}\""
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@eturnity/eturnity_maths": "6.34.
|
|
13
|
+
"@eturnity/eturnity_maths": "6.34.3",
|
|
14
14
|
"axios": "^1.3.2",
|
|
15
15
|
"core-js": "^2.6.12",
|
|
16
16
|
"cors": "^2.8.5",
|
|
@@ -10,7 +10,12 @@
|
|
|
10
10
|
<script>
|
|
11
11
|
import { mapActions, mapState, mapGetters, mapMutations } from 'vuex'
|
|
12
12
|
import * as THREE from 'three'
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
addVector,
|
|
15
|
+
multiplyVector,
|
|
16
|
+
updateComputedGeometryPolygon,
|
|
17
|
+
normalizeVector
|
|
18
|
+
} from '@eturnity/eturnity_maths'
|
|
14
19
|
|
|
15
20
|
import threeMixin from '../helper/threeMixin'
|
|
16
21
|
import materialMixin from '../helper/materialMixin'
|
|
@@ -47,7 +52,6 @@ export default {
|
|
|
47
52
|
tweenOrbit: null,
|
|
48
53
|
three_map: null,
|
|
49
54
|
backgroundImagesizeInMm: null,
|
|
50
|
-
textureLoader: new THREE.TextureLoader(),
|
|
51
55
|
isReady: {
|
|
52
56
|
texturesLoaded: 0,
|
|
53
57
|
texturesToLoad: 0,
|
|
@@ -72,7 +76,6 @@ export default {
|
|
|
72
76
|
this.renderGeometry()
|
|
73
77
|
this.onWindowResize()
|
|
74
78
|
this.updateProjectionMaterials()
|
|
75
|
-
this.animate()
|
|
76
79
|
this.$root.$on('on-roofSelected', (polygon) =>
|
|
77
80
|
this.setCameraOrthogonalTo(polygon)
|
|
78
81
|
)
|
|
@@ -81,6 +84,8 @@ export default {
|
|
|
81
84
|
const polygon = this.polygons.find((p) => p.id == this.uuid)
|
|
82
85
|
this.setCamera(polygon, this.view_mode)
|
|
83
86
|
this.isReady.geometry = true
|
|
87
|
+
this.render()
|
|
88
|
+
//this.animate()
|
|
84
89
|
},
|
|
85
90
|
computed: {
|
|
86
91
|
...mapState({
|
|
@@ -153,9 +158,9 @@ export default {
|
|
|
153
158
|
geometry.boundingSphere.center.z
|
|
154
159
|
]
|
|
155
160
|
let objectRadius = geometry.boundingSphere.radius
|
|
156
|
-
|
|
161
|
+
|
|
157
162
|
distance =
|
|
158
|
-
|
|
163
|
+
5 + objectRadius / Math.sin(((this.camera.fov / 2) * Math.PI) / 180)
|
|
159
164
|
}
|
|
160
165
|
|
|
161
166
|
polygonRef = updateComputedGeometryPolygon(polygonRef)
|
|
@@ -194,15 +199,11 @@ export default {
|
|
|
194
199
|
let horizontalVector = { ...polygonRef.normalVector, z: 0 }
|
|
195
200
|
|
|
196
201
|
if (horizontalVector.x == 0 && horizontalVector.y == 0) {
|
|
197
|
-
//if flat roof=> go south
|
|
198
202
|
horizontalVector.y = 1
|
|
199
203
|
}
|
|
200
|
-
horizontalVector=normalizeVector(horizontalVector)
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
// distanceCoefficient = 1.5
|
|
204
|
-
// }
|
|
205
|
-
cameraMoveVector = multiplyVector(distance * 1000 , horizontalVector)
|
|
204
|
+
horizontalVector = normalizeVector(horizontalVector)
|
|
205
|
+
|
|
206
|
+
cameraMoveVector = multiplyVector(distance * 1000, horizontalVector)
|
|
206
207
|
}
|
|
207
208
|
|
|
208
209
|
const positionVector = addVector(polygonRef.meanPoint, cameraMoveVector)
|
|
@@ -253,14 +254,6 @@ export default {
|
|
|
253
254
|
},
|
|
254
255
|
render() {
|
|
255
256
|
this.renderer.clear()
|
|
256
|
-
if (this.orbitControl) {
|
|
257
|
-
this.orbitControl.target.set(
|
|
258
|
-
this.orbitControl.target.x,
|
|
259
|
-
this.orbitControl.target.y,
|
|
260
|
-
2
|
|
261
|
-
)
|
|
262
|
-
this.orbitControl.update()
|
|
263
|
-
}
|
|
264
257
|
if (['top', 'global'].includes(this.view_mode)) {
|
|
265
258
|
this.renderer.render(this.scene, this.orthographicCamera)
|
|
266
259
|
} else {
|
|
@@ -296,7 +289,7 @@ export default {
|
|
|
296
289
|
height: 100%;
|
|
297
290
|
}
|
|
298
291
|
|
|
299
|
-
.canvas3DContainer>canvas {
|
|
292
|
+
.canvas3DContainer > canvas {
|
|
300
293
|
width: 100%;
|
|
301
294
|
height: 100%;
|
|
302
295
|
}
|
|
@@ -8,15 +8,20 @@ import {
|
|
|
8
8
|
} from '../config'
|
|
9
9
|
export default {
|
|
10
10
|
data() {
|
|
11
|
-
return {
|
|
12
|
-
material: {}
|
|
13
|
-
}
|
|
11
|
+
return {}
|
|
14
12
|
},
|
|
15
13
|
created() {
|
|
14
|
+
this.material = {}
|
|
16
15
|
let wallColor = 0xdddddd
|
|
17
16
|
if (this.wallColor) {
|
|
18
17
|
wallColor = new THREE.Color(this.wallColor)
|
|
19
18
|
}
|
|
19
|
+
|
|
20
|
+
this.material.panelSide = new THREE.MeshLambertMaterial({
|
|
21
|
+
color: 0xdddddd,
|
|
22
|
+
side: THREE.DoubleSide
|
|
23
|
+
})
|
|
24
|
+
|
|
20
25
|
this.material.wall = new THREE.MeshLambertMaterial({
|
|
21
26
|
color: wallColor,
|
|
22
27
|
side: THREE.DoubleSide
|
|
@@ -39,13 +44,11 @@ export default {
|
|
|
39
44
|
opacity: node3dOpacity,
|
|
40
45
|
transparent: true
|
|
41
46
|
})
|
|
42
|
-
|
|
43
|
-
// loader.crossOrigin = 'anonymous'
|
|
44
|
-
// texture.minFilter = THREE.LinearFilter
|
|
47
|
+
|
|
45
48
|
this.material.panel = {}
|
|
46
49
|
|
|
47
50
|
for (let k = 0; k < defaultTextureUrls.length; k++) {
|
|
48
|
-
let texture = loader.load(defaultTextureUrls[k], function (texture) {})
|
|
51
|
+
let texture = this.loader.load(defaultTextureUrls[k], function (texture) {})
|
|
49
52
|
this.material.panel['default_' + k] = new THREE.MeshBasicMaterial({
|
|
50
53
|
map: texture,
|
|
51
54
|
side: THREE.DoubleSide
|
|
@@ -5,12 +5,17 @@ import {
|
|
|
5
5
|
} from './geometryHandler'
|
|
6
6
|
export default {
|
|
7
7
|
methods: {
|
|
8
|
+
data(){
|
|
9
|
+
return {
|
|
10
|
+
mergedBaseMesh:null
|
|
11
|
+
}
|
|
12
|
+
},
|
|
8
13
|
renderBase() {
|
|
9
14
|
//rendering of walls
|
|
10
|
-
//this.clearByType('baseMeshes')
|
|
11
15
|
this.clearRemovedOnes('baseMeshes')
|
|
12
16
|
let geometry
|
|
13
17
|
let mesh
|
|
18
|
+
let baseGeometries=[]
|
|
14
19
|
this.roofs.forEach((roofPolygon) => {
|
|
15
20
|
//everythime the essencials data are changed, version goes up. we compare polygon version and mesh version to know if we have to rerender
|
|
16
21
|
if (
|
|
@@ -18,7 +23,6 @@ export default {
|
|
|
18
23
|
this.meshes.baseMeshes[roofPolygon.id].userData.version <
|
|
19
24
|
roofPolygon.version
|
|
20
25
|
) {
|
|
21
|
-
//this.clearMesh(this.meshes.baseMeshes[roofPolygon.id])
|
|
22
26
|
mesh = this.meshes.baseMeshes[roofPolygon.id]
|
|
23
27
|
geometry = mesh.geometry
|
|
24
28
|
geometry = updateBufferWallGeometry(roofPolygon, geometry)
|
|
@@ -35,12 +39,17 @@ export default {
|
|
|
35
39
|
mesh.userData.polygonId = roofPolygon.id
|
|
36
40
|
mesh.matrixAutoUpdate = false
|
|
37
41
|
mesh.frustumCulled = false
|
|
38
|
-
//geometry.dispose()
|
|
39
|
-
//geometry=null
|
|
40
|
-
this.scene.add(mesh)
|
|
41
42
|
this.meshes.baseMeshes[roofPolygon.id] = mesh
|
|
42
43
|
}
|
|
44
|
+
baseGeometries.push(this.meshes.baseMeshes[roofPolygon.id].geometry)
|
|
43
45
|
})
|
|
46
|
+
|
|
47
|
+
this.mergedBaseMesh=this.updateOrCreateMergedMesh(
|
|
48
|
+
this.mergedBaseMesh,
|
|
49
|
+
baseGeometries,
|
|
50
|
+
this.material.wall
|
|
51
|
+
)
|
|
52
|
+
|
|
44
53
|
}
|
|
45
54
|
}
|
|
46
55
|
}
|
|
@@ -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
|
-
|
|
63
|
-
|
|
64
|
-
)
|
|
61
|
+
// this.applyTextureOnMesh(
|
|
62
|
+
// [this.imageOverlayMaterial],
|
|
63
|
+
// this.meshes.backgroundMesh
|
|
64
|
+
// )
|
|
65
65
|
}
|
|
66
66
|
this.meshes.backgroundMesh.visible = true
|
|
67
67
|
},
|
|
@@ -10,11 +10,11 @@ import obstacle from './obstacle'
|
|
|
10
10
|
import panel from './panel'
|
|
11
11
|
import roof from './roof'
|
|
12
12
|
import imageOverlay from './imageOverlay'
|
|
13
|
-
import mapProjection from './mapProjection'
|
|
14
13
|
import texture from './texture'
|
|
15
14
|
import projectionMaterial from './projectionMaterial'
|
|
16
15
|
import tile from './tile'
|
|
17
16
|
import tileProjection from './tileProjection'
|
|
17
|
+
import mergedGeometry from './mergedGeometry'
|
|
18
18
|
|
|
19
19
|
export default {
|
|
20
20
|
//mixins:[node,background,clear,edge,loader,margin,moduleField,obstacle,panel,roof,base]
|
|
@@ -32,9 +32,9 @@ export default {
|
|
|
32
32
|
loader,
|
|
33
33
|
imageOverlay,
|
|
34
34
|
texture,
|
|
35
|
-
mapProjection,
|
|
36
35
|
projectionMaterial,
|
|
37
36
|
tile,
|
|
38
|
-
tileProjection
|
|
37
|
+
tileProjection,
|
|
38
|
+
mergedGeometry
|
|
39
39
|
]
|
|
40
40
|
}
|
|
@@ -13,8 +13,8 @@ export default {
|
|
|
13
13
|
let texture = this.loader.load(component.texture_img_url)
|
|
14
14
|
this.material.panel[pvId] = new THREE.MeshBasicMaterial({
|
|
15
15
|
map: texture,
|
|
16
|
-
side: THREE.
|
|
17
|
-
transparent:
|
|
16
|
+
side: THREE.FrontSide,
|
|
17
|
+
transparent: false,
|
|
18
18
|
})
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -31,8 +31,8 @@ export default {
|
|
|
31
31
|
let texture = await this.loader.load(mf.data.texture_img_url)
|
|
32
32
|
this.material.panel[pvId] = new THREE.MeshBasicMaterial({
|
|
33
33
|
map: texture,
|
|
34
|
-
side: THREE.
|
|
35
|
-
transparent:
|
|
34
|
+
side: THREE.FrontSide,
|
|
35
|
+
transparent: false,
|
|
36
36
|
})
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import * as THREE from 'three'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
methods: {
|
|
5
|
+
updateMergedGeometry(geometries, mergedGeometry) {
|
|
6
|
+
const mergedVertices = []
|
|
7
|
+
const mergedNormals = []
|
|
8
|
+
const mergedUvs = []
|
|
9
|
+
|
|
10
|
+
geometries.forEach((geometry) => {
|
|
11
|
+
const positions = geometry.attributes.position.array
|
|
12
|
+
const normals = geometry.attributes.normal.array
|
|
13
|
+
|
|
14
|
+
mergedVertices.push(...positions)
|
|
15
|
+
mergedNormals.push(...normals)
|
|
16
|
+
|
|
17
|
+
if (geometry.attributes.uv) {
|
|
18
|
+
const uvs = geometry.attributes.uv.array
|
|
19
|
+
mergedUvs.push(...uvs)
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
//position
|
|
24
|
+
if (
|
|
25
|
+
mergedGeometry.attributes.position &&
|
|
26
|
+
mergedGeometry.attributes.uv &&
|
|
27
|
+
mergedGeometry.attributes.normal &&
|
|
28
|
+
mergedGeometry.attributes.position.array.length >=
|
|
29
|
+
mergedVertices.length &&
|
|
30
|
+
mergedGeometry.attributes.uv.array.length >= mergedUvs.length &&
|
|
31
|
+
mergedGeometry.attributes.normal.array.length >= mergedNormals.length
|
|
32
|
+
) {
|
|
33
|
+
let positions = mergedGeometry.attributes.position.array
|
|
34
|
+
let uvs = mergedGeometry.attributes.uv.array
|
|
35
|
+
let normals = mergedGeometry.attributes.normal.array
|
|
36
|
+
for (let k in mergedVertices) {
|
|
37
|
+
positions[k] = mergedVertices[k]
|
|
38
|
+
}
|
|
39
|
+
for (let k in mergedUvs) {
|
|
40
|
+
uvs[k] = mergedUvs[k]
|
|
41
|
+
}
|
|
42
|
+
for (let k in mergedNormals) {
|
|
43
|
+
normals[k] = mergedNormals[k]
|
|
44
|
+
}
|
|
45
|
+
mergedGeometry.setDrawRange(0, mergedVertices.length / 3)
|
|
46
|
+
mergedGeometry.setDrawRange(0, mergedUvs.length / 2)
|
|
47
|
+
mergedGeometry.setDrawRange(0, mergedNormals.length / 3)
|
|
48
|
+
} else {
|
|
49
|
+
mergedGeometry.dispose()
|
|
50
|
+
mergedGeometry = null
|
|
51
|
+
mergedGeometry = this.createMergedGeometry(geometries)
|
|
52
|
+
}
|
|
53
|
+
mergedGeometry.attributes.position.needsUpdate = true
|
|
54
|
+
mergedGeometry.attributes.normal.needsUpdate = true
|
|
55
|
+
mergedGeometry.needsUpdate = true
|
|
56
|
+
return mergedGeometry
|
|
57
|
+
},
|
|
58
|
+
createMergedGeometry(geometries) {
|
|
59
|
+
const mergedGeometry = new THREE.BufferGeometry()
|
|
60
|
+
const mergedVertices = []
|
|
61
|
+
const mergedNormals = []
|
|
62
|
+
const mergedUvs = []
|
|
63
|
+
|
|
64
|
+
geometries.forEach((geometry) => {
|
|
65
|
+
const positions = geometry.attributes.position.array
|
|
66
|
+
const normals = geometry.attributes.normal.array
|
|
67
|
+
|
|
68
|
+
mergedVertices.push(...positions)
|
|
69
|
+
mergedNormals.push(...normals)
|
|
70
|
+
|
|
71
|
+
if (geometry.attributes.uv) {
|
|
72
|
+
const uvs = geometry.attributes.uv.array
|
|
73
|
+
mergedUvs.push(...uvs)
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
mergedGeometry.setAttribute(
|
|
78
|
+
'position',
|
|
79
|
+
new THREE.BufferAttribute(new Float32Array(mergedVertices), 3)
|
|
80
|
+
)
|
|
81
|
+
mergedGeometry.setAttribute(
|
|
82
|
+
'normal',
|
|
83
|
+
new THREE.BufferAttribute(new Float32Array(mergedNormals), 3)
|
|
84
|
+
)
|
|
85
|
+
mergedGeometry.setAttribute(
|
|
86
|
+
'uv',
|
|
87
|
+
new THREE.BufferAttribute(new Float32Array(mergedUvs), 2)
|
|
88
|
+
)
|
|
89
|
+
mergedGeometry.computeVertexNormals()
|
|
90
|
+
return mergedGeometry
|
|
91
|
+
},
|
|
92
|
+
updateOrCreateMergedMesh(mesh, geometries, material) {
|
|
93
|
+
if (!mesh) {
|
|
94
|
+
let mergedGeometry = this.createMergedGeometry(geometries)
|
|
95
|
+
mesh = new THREE.Mesh(mergedGeometry, material)
|
|
96
|
+
// Add the merged mesh to the scene
|
|
97
|
+
this.scene.add(mesh)
|
|
98
|
+
} else {
|
|
99
|
+
let mergedGeometry = this.updateMergedGeometry(
|
|
100
|
+
geometries,
|
|
101
|
+
mesh.geometry
|
|
102
|
+
)
|
|
103
|
+
mesh.geometry = mergedGeometry
|
|
104
|
+
}
|
|
105
|
+
return mesh
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -5,9 +5,22 @@ import {
|
|
|
5
5
|
} from './geometryHandler'
|
|
6
6
|
export default {
|
|
7
7
|
methods: {
|
|
8
|
+
data() {
|
|
9
|
+
return {
|
|
10
|
+
mergedObstacleMesh: null,
|
|
11
|
+
mergedObstacleSideMesh: null
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
applyTextureOnObstacles(material = this.material.roof) {
|
|
15
|
+
this.reorderRoofMaterials()
|
|
16
|
+
if (this.mergedObstacleMesh) {
|
|
17
|
+
this.applyTextureOnMesh(material, this.mergedObstacleMesh)
|
|
18
|
+
}
|
|
19
|
+
},
|
|
8
20
|
renderObstacles() {
|
|
9
21
|
this.clearByType('obstacleMeshes')
|
|
10
|
-
|
|
22
|
+
let obstacleGeometries = []
|
|
23
|
+
let obstacleSideGeometries = []
|
|
11
24
|
this.roofs.forEach((roofPolygon) => {
|
|
12
25
|
roofPolygon.holes
|
|
13
26
|
.filter((poly) => poly.layer == 'obstacle')
|
|
@@ -24,7 +37,7 @@ export default {
|
|
|
24
37
|
if (geometry && geometrySide) {
|
|
25
38
|
const mesh = new THREE.Mesh(geometry, this.material.roof)
|
|
26
39
|
const meshSide = new THREE.Mesh(geometrySide, this.material.wall)
|
|
27
|
-
this.applyTextureOnMesh(this.material.roof, mesh)
|
|
40
|
+
// this.applyTextureOnMesh(this.material.roof, mesh)
|
|
28
41
|
|
|
29
42
|
mesh.userData.version = obstaclePolygon.version
|
|
30
43
|
mesh.userData.type = 'obstacleMeshes'
|
|
@@ -37,12 +50,6 @@ export default {
|
|
|
37
50
|
obstaclePolygon.id + '-' + roofPolygon.id + '_side'
|
|
38
51
|
meshSide.userData.polygonId = obstaclePolygon.id
|
|
39
52
|
|
|
40
|
-
mesh.matrixAutoUpdate = false
|
|
41
|
-
meshSide.matrixAutoUpdate = false
|
|
42
|
-
mesh.frustumCulled = false
|
|
43
|
-
meshSide.frustumCulled = false
|
|
44
|
-
this.scene.add(mesh)
|
|
45
|
-
this.scene.add(meshSide)
|
|
46
53
|
this.meshes.obstacleMeshes[
|
|
47
54
|
obstaclePolygon.id + '-' + roofPolygon.id + '_top'
|
|
48
55
|
] = mesh
|
|
@@ -50,8 +57,31 @@ export default {
|
|
|
50
57
|
obstaclePolygon.id + '-' + roofPolygon.id + '_side'
|
|
51
58
|
] = meshSide
|
|
52
59
|
}
|
|
60
|
+
obstacleGeometries.push(
|
|
61
|
+
this.meshes.obstacleMeshes[
|
|
62
|
+
obstaclePolygon.id + '-' + roofPolygon.id + '_top'
|
|
63
|
+
].geometry
|
|
64
|
+
)
|
|
65
|
+
obstacleSideGeometries.push(
|
|
66
|
+
this.meshes.obstacleMeshes[
|
|
67
|
+
obstaclePolygon.id + '-' + roofPolygon.id + '_side'
|
|
68
|
+
].geometry
|
|
69
|
+
)
|
|
53
70
|
})
|
|
54
71
|
})
|
|
72
|
+
|
|
73
|
+
// Create the mesh using the merged geometry and shared material
|
|
74
|
+
this.mergedObstacleMesh = this.updateOrCreateMergedMesh(
|
|
75
|
+
this.mergedObstacleMesh,
|
|
76
|
+
obstacleGeometries,
|
|
77
|
+
this.material.roof
|
|
78
|
+
)
|
|
79
|
+
this.mergedObstacleSideMesh = this.updateOrCreateMergedMesh(
|
|
80
|
+
this.mergedObstacleSideMesh,
|
|
81
|
+
obstacleSideGeometries,
|
|
82
|
+
this.material.wall
|
|
83
|
+
)
|
|
84
|
+
this.applyTextureOnObstacles(this.material.roof)
|
|
55
85
|
}
|
|
56
86
|
}
|
|
57
87
|
}
|
|
@@ -6,7 +6,33 @@ import {
|
|
|
6
6
|
updateBufferPanelSideGeometry
|
|
7
7
|
} from './geometryHandler'
|
|
8
8
|
export default {
|
|
9
|
+
data() {
|
|
10
|
+
return {
|
|
11
|
+
mergedPanelSideMesh: null,
|
|
12
|
+
mergedPanelTopMeshes: {}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
9
15
|
methods: {
|
|
16
|
+
hidePanels() {
|
|
17
|
+
if (this.mergedPanelTopMeshes) {
|
|
18
|
+
Object.values(this.mergedPanelTopMeshes).forEach((mesh) => {
|
|
19
|
+
mesh.visible = false
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
if (this.mergedPanelSideMesh) {
|
|
23
|
+
this.mergedPanelSideMesh.visible = false
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
showPanels() {
|
|
27
|
+
if (this.mergedPanelTopMeshes) {
|
|
28
|
+
Object.values(this.mergedPanelTopMeshes).forEach((mesh) => {
|
|
29
|
+
mesh.visible = true
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
if (this.mergedPanelSideMesh) {
|
|
33
|
+
this.mergedPanelSideMesh.visible = true
|
|
34
|
+
}
|
|
35
|
+
},
|
|
10
36
|
renderPanels() {
|
|
11
37
|
this.clearRemovedOnes('panelsMeshes')
|
|
12
38
|
Object.values(this.meshes.panelsMeshes).forEach((mesh) => {
|
|
@@ -29,22 +55,28 @@ export default {
|
|
|
29
55
|
}
|
|
30
56
|
})
|
|
31
57
|
|
|
58
|
+
let panelSideGeometries = []
|
|
59
|
+
let panelTopGeometries = {}
|
|
32
60
|
this.panels.forEach((panelPolygon) => {
|
|
33
61
|
//definition of the material
|
|
34
62
|
if (panelPolygon.moduleField.data.number_of_panels_override) return
|
|
35
|
-
let
|
|
36
|
-
|
|
63
|
+
let materialId = 'default_' + this.moduleTextureVersionId
|
|
64
|
+
let material = this.material.panel[materialId]
|
|
37
65
|
material.transparent = true
|
|
38
66
|
material.opacity = this.panelOpacity
|
|
39
67
|
if (panelPolygon.moduleField.pvData) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
material = this.material.panel[
|
|
68
|
+
if (this.material.panel[panelPolygon.moduleField.pvData.id]) {
|
|
69
|
+
materialId = panelPolygon.moduleField.pvData.id
|
|
70
|
+
material = this.material.panel[materialId]
|
|
43
71
|
}
|
|
44
72
|
} else if (panelPolygon.moduleField.data) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
73
|
+
if (
|
|
74
|
+
this.material.panel[
|
|
75
|
+
panelPolygon.moduleField.data.component_id_pv_module
|
|
76
|
+
]
|
|
77
|
+
) {
|
|
78
|
+
materialId = panelPolygon.moduleField.data.component_id_pv_module
|
|
79
|
+
material = this.material.panel[materialId]
|
|
48
80
|
}
|
|
49
81
|
}
|
|
50
82
|
|
|
@@ -54,10 +86,17 @@ export default {
|
|
|
54
86
|
) {
|
|
55
87
|
const geometry = getBufferPanelGeometry(panelPolygon)
|
|
56
88
|
const geometrySide = getBufferPanelSideGeometry(panelPolygon)
|
|
57
|
-
|
|
89
|
+
if (!panelTopGeometries[materialId]) {
|
|
90
|
+
panelTopGeometries[materialId] = []
|
|
91
|
+
}
|
|
92
|
+
panelTopGeometries[materialId].push(geometry)
|
|
93
|
+
panelSideGeometries.push(geometrySide)
|
|
58
94
|
if (geometry && geometrySide) {
|
|
59
95
|
const mesh = new THREE.Mesh(geometry, material)
|
|
60
|
-
const meshSide = new THREE.Mesh(
|
|
96
|
+
const meshSide = new THREE.Mesh(
|
|
97
|
+
geometrySide,
|
|
98
|
+
this.material.panelSide
|
|
99
|
+
)
|
|
61
100
|
mesh.userData.version = panelPolygon.version
|
|
62
101
|
mesh.userData.type = 'panelsMeshes'
|
|
63
102
|
mesh.userData.meshId = panelPolygon.id + '_top'
|
|
@@ -68,8 +107,6 @@ export default {
|
|
|
68
107
|
meshSide.userData.polygonId = panelPolygon.id
|
|
69
108
|
geometry.dispose()
|
|
70
109
|
geometrySide.dispose()
|
|
71
|
-
this.scene.add(mesh)
|
|
72
|
-
this.scene.add(meshSide)
|
|
73
110
|
mesh.matrixAutoUpdate = false
|
|
74
111
|
meshSide.matrixAutoUpdate = false
|
|
75
112
|
this.meshes.panelsMeshes[panelPolygon.id + '_top'] = mesh
|
|
@@ -79,18 +116,49 @@ export default {
|
|
|
79
116
|
const topMesh = this.meshes.panelsMeshes[panelPolygon.id + '_top']
|
|
80
117
|
const sideMesh = this.meshes.panelsMeshes[panelPolygon.id + '_side']
|
|
81
118
|
if (panelPolygon.version > topMesh.userData.version) {
|
|
82
|
-
|
|
119
|
+
let topGeometry = updateBufferPanelGeometry(
|
|
83
120
|
panelPolygon,
|
|
84
121
|
topMesh.geometry
|
|
85
122
|
)
|
|
86
|
-
|
|
123
|
+
let sideGeometry = updateBufferPanelSideGeometry(
|
|
87
124
|
panelPolygon,
|
|
88
125
|
sideMesh.geometry
|
|
89
126
|
)
|
|
127
|
+
|
|
128
|
+
topMesh.geometry = topGeometry
|
|
129
|
+
sideMesh.geometry = sideGeometry
|
|
90
130
|
}
|
|
131
|
+
panelSideGeometries.push(sideMesh.geometry)
|
|
132
|
+
if (!panelTopGeometries[materialId]) {
|
|
133
|
+
panelTopGeometries[materialId] = []
|
|
134
|
+
}
|
|
135
|
+
panelTopGeometries[materialId].push(topMesh.geometry)
|
|
91
136
|
topMesh.material = material
|
|
92
137
|
}
|
|
93
138
|
})
|
|
139
|
+
|
|
140
|
+
//removing unused mesh
|
|
141
|
+
const materialIds = Object.keys(panelTopGeometries)
|
|
142
|
+
const materialIdsToRemove = Object.keys(this.mergedPanelTopMeshes).filter(
|
|
143
|
+
(key) => !materialIds.includes(key)
|
|
144
|
+
)
|
|
145
|
+
for (let materialId of materialIdsToRemove) {
|
|
146
|
+
this.clearMesh(this.mergedPanelTopMeshes[materialId])
|
|
147
|
+
delete this.mergedPanelTopMeshes[materialId]
|
|
148
|
+
}
|
|
149
|
+
this.mergedPanelSideMesh = this.updateOrCreateMergedMesh(
|
|
150
|
+
this.mergedPanelSideMesh,
|
|
151
|
+
panelSideGeometries,
|
|
152
|
+
this.material.panelSide
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
for (let [key, geometries] of Object.entries(panelTopGeometries)) {
|
|
156
|
+
this.mergedPanelTopMeshes[key] = this.updateOrCreateMergedMesh(
|
|
157
|
+
this.mergedPanelTopMeshes[key],
|
|
158
|
+
geometries,
|
|
159
|
+
this.material.panel[key]
|
|
160
|
+
)
|
|
161
|
+
}
|
|
94
162
|
}
|
|
95
163
|
}
|
|
96
164
|
}
|
|
@@ -9,35 +9,9 @@ export default {
|
|
|
9
9
|
},
|
|
10
10
|
async updateProjectionMaterials() {
|
|
11
11
|
this.setImageOverlayCameraPosition()
|
|
12
|
-
|
|
13
|
-
this.getMapProjectionMaterial(),
|
|
14
|
-
this.getImageOverlayMaterial()
|
|
15
|
-
]
|
|
16
|
-
let materials = await Promise.all(materialPromises)
|
|
17
|
-
this.mapProjectionMaterial = materials[0]
|
|
18
|
-
this.imageOverlayMaterial = materials[1]
|
|
12
|
+
this.imageOverlayMaterial = await this.getImageOverlayMaterial()
|
|
19
13
|
|
|
20
|
-
|
|
21
|
-
(material) => material.userData.type == 'mapProjectionMaterial'
|
|
22
|
-
)
|
|
23
|
-
if (this.mapProjectionMaterial) {
|
|
24
|
-
if (index >= 0) {
|
|
25
|
-
this.material.roof[index] = this.mapProjectionMaterial
|
|
26
|
-
this.material.roof = [...this.material.roof]
|
|
27
|
-
} else {
|
|
28
|
-
this.material.roof = [
|
|
29
|
-
...this.material.roof,
|
|
30
|
-
this.mapProjectionMaterial
|
|
31
|
-
]
|
|
32
|
-
this.reorderRoofMaterials()
|
|
33
|
-
}
|
|
34
|
-
} else if (index >= 0) {
|
|
35
|
-
this.material.roof[index].dispose()
|
|
36
|
-
this.material.roof.splice(index, 1)
|
|
37
|
-
this.material.roof = [...this.material.roof]
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
index = this.material.roof.findIndex(
|
|
14
|
+
const index = this.material.roof.findIndex(
|
|
41
15
|
(material) => material.userData.type == 'imageOverlayMaterial'
|
|
42
16
|
)
|
|
43
17
|
if (this.imageOverlayMaterial) {
|