@eturnity/eturnity_3d 6.29.0 → 6.29.2
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 +6 -6
- package/src/components/ThreeCanvasViewer.vue +0 -2
- package/src/config.js +1 -0
- package/src/helper/cameraMixin.js +95 -0
- package/src/helper/render/background.js +40 -0
- package/src/helper/render/base.js +43 -0
- package/src/helper/render/clear.js +93 -0
- package/src/helper/render/edge.js +85 -0
- package/src/helper/{geometryHandler.js → render/geometryHandler.js} +1 -1
- package/src/helper/render/index.js +16 -0
- package/src/helper/render/loader.js +97 -0
- package/src/helper/render/margin.js +72 -0
- package/src/helper/render/moduleField.js +27 -0
- package/src/helper/render/node.js +47 -0
- package/src/helper/render/obstacle.js +61 -0
- package/src/helper/render/panel.js +88 -0
- package/src/helper/render/roof.js +134 -0
- package/src/helper/renderMixin.js +39 -805
- package/src/helper/threeMixin.js +3 -4
- package/src/store/hydrateData.js +1 -0
- package/src/utils/layers.js +1 -1
- package/src/helper/DFS.js +0 -80
- package/src/helper/clearThreeObjects.js +0 -21
- package/src/helper/graphCreation.js +0 -43
- package/src/helper/projectedMaterial.js +0 -502
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eturnity/eturnity_3d",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "6.29.
|
|
4
|
+
"version": "6.29.2",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vue-cli-service serve --skip-plugins @vue/cli-plugin-eslint",
|
|
8
8
|
"build": "vue-cli-service build --skip-plugins @vue/cli-plugin-eslint"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@eturnity/eturnity_maths": "6.
|
|
11
|
+
"@eturnity/eturnity_maths": "6.29.0",
|
|
12
12
|
"axios": "^1.3.2",
|
|
13
|
-
"cors": "^2.8.5",
|
|
14
13
|
"core-js": "^2.6.12",
|
|
14
|
+
"cors": "^2.8.5",
|
|
15
15
|
"earcut": "^2.2.4",
|
|
16
16
|
"express": "^4.18.2",
|
|
17
17
|
"geo-three": "^0.1.11",
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"leaflet.gridlayer.googlemutant": "^0.14.0",
|
|
20
20
|
"svd-js": "^1.1.1",
|
|
21
21
|
"three": "^0.149.0",
|
|
22
|
+
"three-projected-material": "2.2.1",
|
|
23
|
+
"tween": "0.9.0",
|
|
22
24
|
"uuid": "^9.0.0",
|
|
23
25
|
"vue": "^2.7.14",
|
|
24
26
|
"vue-template-compiler": "^2.7.14",
|
|
25
|
-
"vuex": "^3.0.1"
|
|
26
|
-
"three-projected-material": "2.2.1",
|
|
27
|
-
"tween": "0.9.0"
|
|
27
|
+
"vuex": "^3.0.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/core": "^7.21.0",
|
|
@@ -110,8 +110,6 @@ export default {
|
|
|
110
110
|
let margin=0.2
|
|
111
111
|
if (!polygon || view_mode == 'global') {
|
|
112
112
|
let roofsBounds = this.roofsBounds
|
|
113
|
-
//let distance = 5 + objectRadius / Math.sin(((this.orthographicCamera.fov / 2) * Math.PI) / 180)
|
|
114
|
-
//console.log('distance:',distance)
|
|
115
113
|
const position = [0, 0, 100]
|
|
116
114
|
const target = [0, 0, 0]
|
|
117
115
|
this.orthographicCamera.position.set(...position)
|
package/src/config.js
CHANGED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import TWEEN from 'tween'
|
|
2
|
+
import {
|
|
3
|
+
addVector,
|
|
4
|
+
multiplyVector,
|
|
5
|
+
} from '@eturnity/eturnity_maths'
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
methods:{
|
|
9
|
+
setCameraGlobalPosition() {
|
|
10
|
+
if(this.roofs.length==0)return
|
|
11
|
+
let bounds=this.roofsBounds
|
|
12
|
+
let targetVector={x:(bounds.xMax+bounds.xMin)/2000,y:(bounds.yMax+bounds.yMin)/2000,z:0}
|
|
13
|
+
let objectRadius_m=Math.max((bounds.xMax-bounds.xMin)/2000,(bounds.yMax-bounds.yMin)/2000)
|
|
14
|
+
let distance =
|
|
15
|
+
5 + objectRadius_m / Math.sin(((this.camera.fov / 2) * Math.PI) / 180)
|
|
16
|
+
let cameraMoveVector = { x: 0, y: 0, z: distance }
|
|
17
|
+
const positionVector = addVector(targetVector, cameraMoveVector)
|
|
18
|
+
const position = [
|
|
19
|
+
positionVector.x,
|
|
20
|
+
positionVector.y - distance,
|
|
21
|
+
positionVector.z
|
|
22
|
+
]
|
|
23
|
+
let target=[
|
|
24
|
+
targetVector.x,
|
|
25
|
+
targetVector.y,
|
|
26
|
+
targetVector.z
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
this.setTweenTo(position,target)
|
|
30
|
+
},
|
|
31
|
+
setCameraOrthogonalTo(polygon) {
|
|
32
|
+
if (polygon) {
|
|
33
|
+
let polygonRef = polygon
|
|
34
|
+
const targetVector = polygonRef.meanPoint
|
|
35
|
+
const target = [
|
|
36
|
+
targetVector.x / 1000,
|
|
37
|
+
targetVector.y / 1000,
|
|
38
|
+
targetVector.z / 1000
|
|
39
|
+
]
|
|
40
|
+
const positionVector = addVector(
|
|
41
|
+
polygonRef.meanPoint,
|
|
42
|
+
multiplyVector(45000, polygonRef.normalVector)
|
|
43
|
+
)
|
|
44
|
+
const position = [
|
|
45
|
+
positionVector.x / 1000,
|
|
46
|
+
positionVector.y / 1000 - 1,
|
|
47
|
+
positionVector.z / 1000
|
|
48
|
+
]
|
|
49
|
+
this.setTweenTo(position,target)
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
setCameraSideTo(polygon) {
|
|
53
|
+
if (polygon) {
|
|
54
|
+
let polygonRef = polygon
|
|
55
|
+
const targetVector = polygonRef.meanPoint
|
|
56
|
+
const target = [
|
|
57
|
+
targetVector.x / 1000,
|
|
58
|
+
targetVector.y / 1000,
|
|
59
|
+
targetVector.z / 1000
|
|
60
|
+
]
|
|
61
|
+
let sideVector={x:-Math.cos((polygonRef.direction+45)*Math.PI/180),y:Math.sin((polygonRef.direction+45)*Math.PI/180),z: 0}
|
|
62
|
+
const positionVector = addVector(
|
|
63
|
+
polygonRef.meanPoint,
|
|
64
|
+
multiplyVector(45000, sideVector)
|
|
65
|
+
)
|
|
66
|
+
const position = [
|
|
67
|
+
positionVector.x / 1000,
|
|
68
|
+
positionVector.y / 1000,
|
|
69
|
+
positionVector.z / 1000 +5
|
|
70
|
+
]
|
|
71
|
+
this.setTweenTo(position,target)
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
setTweenTo(position,target){
|
|
75
|
+
if (this.orbitControl) {
|
|
76
|
+
this.tweenOrbit = new TWEEN.Tween(this.orbitControl.target)
|
|
77
|
+
.to({ x: target[0], y: target[1], z: target[2] }, 2000)
|
|
78
|
+
.easing(TWEEN.Easing.Sinusoidal.Out)
|
|
79
|
+
.onUpdate(() => {
|
|
80
|
+
this.orbitControl.update()
|
|
81
|
+
})
|
|
82
|
+
.start()
|
|
83
|
+
}
|
|
84
|
+
if (this.camera) {
|
|
85
|
+
this.tweenCamera = new TWEEN.Tween(this.camera.position)
|
|
86
|
+
.to({ x: position[0], y: position[1], z: position[2] }, 2000)
|
|
87
|
+
.easing(TWEEN.Easing.Sinusoidal.Out)
|
|
88
|
+
.onUpdate(() => {
|
|
89
|
+
this.orbitControl.update()
|
|
90
|
+
})
|
|
91
|
+
.start()
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as THREE from 'three'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
methods:{
|
|
5
|
+
renderBackground() {
|
|
6
|
+
// if(this.meshes.backgroundMesh){
|
|
7
|
+
// let sizeInMm={width:2000000,height:2000000}
|
|
8
|
+
// let positionInMm={x:0,y:0}
|
|
9
|
+
// if(this.layoutSettings.background_map_settings && this.layoutSettings.background_map_settings.sizeInMm){
|
|
10
|
+
// sizeInMm=this.layoutSettings.background_map_settings.sizeInMm
|
|
11
|
+
// positionInMm=this.layoutSettings.background_map_settings.positionInMm
|
|
12
|
+
// }
|
|
13
|
+
|
|
14
|
+
// this.meshes.backgroundMesh.geometry.dispose()
|
|
15
|
+
// let xMin=positionInMm.x/1000-sizeInMm.width/2000
|
|
16
|
+
// let xMax=positionInMm.x/1000+sizeInMm.width/2000
|
|
17
|
+
// let yMin=positionInMm.y/1000-sizeInMm.height/2000
|
|
18
|
+
// let yMax=positionInMm.y/1000+sizeInMm.height/2000
|
|
19
|
+
// let c1=[xMin,yMax,0.1]
|
|
20
|
+
// let c2=[xMax,yMax,0.1]
|
|
21
|
+
// let c3=[xMax,yMin,0.1]
|
|
22
|
+
// let c4=[xMin,yMin,0.1]
|
|
23
|
+
// let geometry = new THREE.BufferGeometry();
|
|
24
|
+
// const vertices = new Float32Array( [
|
|
25
|
+
// ...c1,
|
|
26
|
+
// ...c4,
|
|
27
|
+
// ...c3,
|
|
28
|
+
// ...c3,
|
|
29
|
+
// ...c2,
|
|
30
|
+
// ...c1
|
|
31
|
+
// ] );
|
|
32
|
+
// geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
|
|
33
|
+
// geometry.computeVertexNormals()
|
|
34
|
+
// this.meshes.backgroundMesh.geometry=geometry
|
|
35
|
+
// }else{
|
|
36
|
+
// this.initialiseThreeMap()
|
|
37
|
+
// }
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as THREE from 'three'
|
|
2
|
+
import { getBufferWallGeometry, updateBufferWallGeometry } from './geometryHandler'
|
|
3
|
+
export default {
|
|
4
|
+
methods:{
|
|
5
|
+
renderBase() {
|
|
6
|
+
//rendering of walls
|
|
7
|
+
//this.clearByType('baseMeshes')
|
|
8
|
+
this.clearRemovedOnes('baseMeshes')
|
|
9
|
+
let geometry
|
|
10
|
+
let mesh
|
|
11
|
+
this.roofs.forEach((roofPolygon) => {
|
|
12
|
+
//everythime the essencials data are changed, version goes up. we compare polygon version and mesh version to know if we have to rerender
|
|
13
|
+
if (
|
|
14
|
+
this.meshes.baseMeshes[roofPolygon.id] &&
|
|
15
|
+
this.meshes.baseMeshes[roofPolygon.id].userData.version <
|
|
16
|
+
roofPolygon.version
|
|
17
|
+
) {
|
|
18
|
+
//this.clearMesh(this.meshes.baseMeshes[roofPolygon.id])
|
|
19
|
+
mesh = this.meshes.baseMeshes[roofPolygon.id]
|
|
20
|
+
geometry = mesh.geometry
|
|
21
|
+
geometry = updateBufferWallGeometry(roofPolygon, geometry)
|
|
22
|
+
mesh.geometry = geometry
|
|
23
|
+
mesh.updateMatrix()
|
|
24
|
+
}
|
|
25
|
+
if (!this.meshes.baseMeshes[roofPolygon.id]) {
|
|
26
|
+
//create
|
|
27
|
+
geometry = getBufferWallGeometry(roofPolygon)
|
|
28
|
+
mesh = new THREE.Mesh(geometry, this.material.wall)
|
|
29
|
+
mesh.userData.version = roofPolygon.version
|
|
30
|
+
mesh.userData.type = 'baseMeshes'
|
|
31
|
+
mesh.userData.meshId = roofPolygon.id
|
|
32
|
+
mesh.userData.polygonId = roofPolygon.id
|
|
33
|
+
mesh.matrixAutoUpdate = false
|
|
34
|
+
mesh.frustumCulled = false
|
|
35
|
+
//geometry.dispose()
|
|
36
|
+
//geometry=null
|
|
37
|
+
this.scene.add(mesh)
|
|
38
|
+
this.meshes.baseMeshes[roofPolygon.id] = mesh
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
},
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
methods:{
|
|
3
|
+
clearThreeObjects(obj) {
|
|
4
|
+
while (obj.children.length > 0) {
|
|
5
|
+
this.clearThreeObjects(obj.children[0])
|
|
6
|
+
obj.remove(obj.children[0])
|
|
7
|
+
}
|
|
8
|
+
if (obj.geometry) obj.geometry.dispose()
|
|
9
|
+
if (obj.texture) obj.texture.dispose()
|
|
10
|
+
|
|
11
|
+
if (obj.material) {
|
|
12
|
+
//in case of map, bumpMap, normalMap, envMap ...
|
|
13
|
+
Object.keys(obj.material).forEach((prop) => {
|
|
14
|
+
if (!obj.material[prop]) return
|
|
15
|
+
if (
|
|
16
|
+
obj.material[prop] !== null &&
|
|
17
|
+
typeof obj.material[prop].dispose === 'function'
|
|
18
|
+
)
|
|
19
|
+
obj.material[prop].dispose()
|
|
20
|
+
})
|
|
21
|
+
obj.material.dispose()
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
clearPanelsFromChangingRoofs(roofIds){
|
|
25
|
+
const roofs=this.polygons.filter(polygon=>roofIds.includes(polygon.id))
|
|
26
|
+
roofs.forEach(roof=>roof.moduleFields.forEach(mf=>mf.panels.forEach(panel=>{
|
|
27
|
+
let meshTop=this.meshes.panelsMeshes[panel.id+'_top']
|
|
28
|
+
let meshSide=this.meshes.panelsMeshes[panel.id+'_side']
|
|
29
|
+
if(meshTop || meshSide){
|
|
30
|
+
this.clearMesh(meshTop)
|
|
31
|
+
this.clearMesh(meshSide)
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
)
|
|
35
|
+
)
|
|
36
|
+
},
|
|
37
|
+
clearMesh(mesh) {
|
|
38
|
+
if (!mesh) return
|
|
39
|
+
this.scene.remove(mesh)
|
|
40
|
+
if (mesh.geometry && mesh.geometry.dispose) {
|
|
41
|
+
mesh.geometry.dispose()
|
|
42
|
+
mesh.geometry = null
|
|
43
|
+
}
|
|
44
|
+
if (mesh.material && mesh.material.dispose) {
|
|
45
|
+
mesh.material.dispose()
|
|
46
|
+
mesh.material = null
|
|
47
|
+
}
|
|
48
|
+
if (
|
|
49
|
+
mesh.userData.meshId &&
|
|
50
|
+
this.meshes[mesh.userData.type][mesh.userData.meshId]
|
|
51
|
+
) {
|
|
52
|
+
delete this.meshes[mesh.userData.type][mesh.userData.meshId]
|
|
53
|
+
} else {
|
|
54
|
+
this.meshes[mesh.userData.type] = null
|
|
55
|
+
}
|
|
56
|
+
mesh = null
|
|
57
|
+
},
|
|
58
|
+
clearEdgesRemovedOnes() {
|
|
59
|
+
Object.values(this.meshes['edgeMeshes']).forEach((mesh) => {
|
|
60
|
+
if (!this.edgeIds.includes(mesh.userData.edgeId)) {
|
|
61
|
+
this.clearMesh(mesh)
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
},
|
|
65
|
+
clearNodesRemovedOnes() {
|
|
66
|
+
Object.values(this.meshes['nodeMeshes']).forEach((mesh) => {
|
|
67
|
+
if (!this.nodeIds.includes(mesh.userData.nodeId)) {
|
|
68
|
+
this.clearMesh(mesh)
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
},
|
|
72
|
+
clearRemovedOnes(type) {
|
|
73
|
+
Object.values(this.meshes[type]).forEach((mesh) => {
|
|
74
|
+
if (!this.polygonIds.includes(mesh.userData.polygonId)) {
|
|
75
|
+
this.clearMesh(mesh)
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
},
|
|
79
|
+
clearByType(type) {
|
|
80
|
+
Object.values(this.meshes[type]).forEach((mesh) => {
|
|
81
|
+
mesh.geometry.dispose()
|
|
82
|
+
mesh.geometry = null
|
|
83
|
+
if (mesh.material && mesh.material.dispose) {
|
|
84
|
+
mesh.material.dispose()
|
|
85
|
+
}
|
|
86
|
+
mesh.material = null
|
|
87
|
+
this.scene.remove(mesh)
|
|
88
|
+
})
|
|
89
|
+
this.meshes[type] = {}
|
|
90
|
+
this.renderer.renderLists.dispose()
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as THREE from 'three'
|
|
2
|
+
export default {
|
|
3
|
+
methods:{
|
|
4
|
+
renderEdges() {
|
|
5
|
+
this.clearEdgesRemovedOnes('edgeMeshes')
|
|
6
|
+
let cylinder
|
|
7
|
+
//this.clearByType('edgeMeshes')
|
|
8
|
+
// const material = new THREE.LineBasicMaterial( { color: beamColor,transparent:true,opacity:beamOpacity ,sizeAttenuation: true} );
|
|
9
|
+
// material.linewidth=5
|
|
10
|
+
const material = this.material.edge
|
|
11
|
+
this.edges
|
|
12
|
+
.filter((edge) => edge.layer == 'roof')
|
|
13
|
+
.forEach((edge) => {
|
|
14
|
+
cylinder = this.meshes.edgeMeshes[edge.id]
|
|
15
|
+
if (cylinder) {
|
|
16
|
+
//update
|
|
17
|
+
const point_0 = new THREE.Vector3(
|
|
18
|
+
edge.outline[0].x / 1000,
|
|
19
|
+
edge.outline[0].y / 1000,
|
|
20
|
+
edge.outline[0].z / 1000
|
|
21
|
+
)
|
|
22
|
+
const point_1 = new THREE.Vector3(
|
|
23
|
+
edge.outline[1].x / 1000,
|
|
24
|
+
edge.outline[1].y / 1000,
|
|
25
|
+
edge.outline[1].z / 1000
|
|
26
|
+
)
|
|
27
|
+
const midPoint = point_0.clone().add(point_1).multiplyScalar(0.5)
|
|
28
|
+
var direction = new THREE.Vector3().subVectors(point_1, point_0)
|
|
29
|
+
let length = direction.length()
|
|
30
|
+
//cylinder.rotation.set(arrow.rotation)
|
|
31
|
+
var axis = new THREE.Vector3(0, 1, 0)
|
|
32
|
+
cylinder.quaternion.setFromUnitVectors(
|
|
33
|
+
axis,
|
|
34
|
+
direction.clone().normalize()
|
|
35
|
+
)
|
|
36
|
+
//cylinder.position.set(new THREE.Vector3().addVectors( pointX, direction.multiplyScalar(0.5) ))
|
|
37
|
+
cylinder.position.copy(midPoint.clone())
|
|
38
|
+
let oldLength = cylinder.userData.cylinderLength
|
|
39
|
+
let newLength = length
|
|
40
|
+
if (oldLength != 0) {
|
|
41
|
+
let scaleRatio = newLength / oldLength
|
|
42
|
+
//let scaleVector=direction.multiplyScalar(scaleRatio-1)
|
|
43
|
+
cylinder.scale.set(1, newLength, 1)
|
|
44
|
+
cylinder.userData.cylinderLength = newLength
|
|
45
|
+
}
|
|
46
|
+
cylinder.updateMatrix()
|
|
47
|
+
//change cylinder length
|
|
48
|
+
} else {
|
|
49
|
+
const point_0 = new THREE.Vector3(
|
|
50
|
+
edge.outline[0].x / 1000,
|
|
51
|
+
edge.outline[0].y / 1000,
|
|
52
|
+
edge.outline[0].z / 1000
|
|
53
|
+
)
|
|
54
|
+
const point_1 = new THREE.Vector3(
|
|
55
|
+
edge.outline[1].x / 1000,
|
|
56
|
+
edge.outline[1].y / 1000,
|
|
57
|
+
edge.outline[1].z / 1000
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
const midPoint = point_0.clone().add(point_1).multiplyScalar(0.5)
|
|
61
|
+
var direction = new THREE.Vector3().subVectors(point_1, point_0)
|
|
62
|
+
let length = direction.length()
|
|
63
|
+
const geometry = new THREE.CylinderGeometry(0.1, 0.1, 1, 6)
|
|
64
|
+
cylinder = new THREE.Mesh(geometry, material)
|
|
65
|
+
cylinder.scale.set(1, length, 1)
|
|
66
|
+
cylinder.userData.cylinderLength = length
|
|
67
|
+
//cylinder.rotation.set(arrow.rotation)
|
|
68
|
+
var axis = new THREE.Vector3(0, 1, 0)
|
|
69
|
+
cylinder.quaternion.setFromUnitVectors(
|
|
70
|
+
axis,
|
|
71
|
+
direction.clone().normalize()
|
|
72
|
+
)
|
|
73
|
+
//cylinder.position.set(new THREE.Vector3().addVectors( pointX, direction.multiplyScalar(0.5) ))
|
|
74
|
+
cylinder.position.copy(midPoint.clone())
|
|
75
|
+
//cylinder.position.set(edge.outline[0].x/1000, edge.outline[0].y/1000, edge.outline[0].z/1000);
|
|
76
|
+
cylinder.userData.edgeId = edge.id
|
|
77
|
+
cylinder.matrixAutoUpdate = false
|
|
78
|
+
this.meshes.edgeMeshes[edge.id] = cylinder
|
|
79
|
+
this.scene.add(cylinder)
|
|
80
|
+
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import node from './node'
|
|
2
|
+
import background from './background'
|
|
3
|
+
import base from './base'
|
|
4
|
+
import clear from './clear'
|
|
5
|
+
import edge from './edge'
|
|
6
|
+
import loader from './loader'
|
|
7
|
+
import margin from './margin'
|
|
8
|
+
import moduleField from './moduleField'
|
|
9
|
+
import obstacle from './obstacle'
|
|
10
|
+
import panel from './panel'
|
|
11
|
+
import roof from './roof'
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
//mixins:[node,background,clear,edge,loader,margin,moduleField,obstacle,panel,roof,base]
|
|
15
|
+
mixins:[margin,node,background, base,roof,edge,obstacle,moduleField,panel,clear,loader]
|
|
16
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as THREE from 'three'
|
|
2
|
+
import ProjectedMaterial from 'three-projected-material'
|
|
3
|
+
export default {
|
|
4
|
+
methods:{
|
|
5
|
+
loadNewTexture(){
|
|
6
|
+
Object.values(this.pvDataMemo).forEach((component) => {
|
|
7
|
+
const pvId = component.id
|
|
8
|
+
if (!this.material.panel[pvId]) {
|
|
9
|
+
if (!component.texture_img_url) {
|
|
10
|
+
this.material.panel[pvId] = this.material.panel.default
|
|
11
|
+
} else {
|
|
12
|
+
let texture = this.loader.load(component.texture_img_url)
|
|
13
|
+
this.material.panel[pvId] = new THREE.MeshBasicMaterial({
|
|
14
|
+
map: texture,
|
|
15
|
+
side: THREE.DoubleSide
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
},
|
|
21
|
+
async loadTextureFromModuleFields(){
|
|
22
|
+
for(let k=0;k<this.moduleFields.length;k++){
|
|
23
|
+
let mf=this.moduleFields[k]
|
|
24
|
+
const pvId = mf.data.component_id_pv_module
|
|
25
|
+
if (!this.material.panel[pvId]) {
|
|
26
|
+
if (!mf.data.texture_img_url) {
|
|
27
|
+
this.material.panel[pvId] = this.material.panel.default
|
|
28
|
+
} else {
|
|
29
|
+
let texture = await this.loader.load(mf.data.texture_img_url)
|
|
30
|
+
this.material.panel[pvId] = new THREE.MeshBasicMaterial({
|
|
31
|
+
map: texture,
|
|
32
|
+
side: THREE.DoubleSide
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
async loadProjectionMaterial() {
|
|
39
|
+
const _this=this
|
|
40
|
+
if(!this.layoutSettings.base64_image_url)
|
|
41
|
+
{
|
|
42
|
+
this.loader.load(require("../../assets/images/white_tile.png"),(texture)=>{
|
|
43
|
+
let projectionMaterial = new ProjectedMaterial({
|
|
44
|
+
camera: _this.cameraprojection,
|
|
45
|
+
texture: texture
|
|
46
|
+
})
|
|
47
|
+
this.material.roof = projectionMaterial
|
|
48
|
+
})
|
|
49
|
+
return
|
|
50
|
+
}
|
|
51
|
+
let projectedMaterialLoaded= await new Promise((resolve,reject) => {
|
|
52
|
+
this.loader.load(this.layoutSettings.base64_image_url,(texture)=>{
|
|
53
|
+
let backgroundImageZoomLvl=_this.layoutSettings.map_zoom
|
|
54
|
+
let backgroundImageCenter={
|
|
55
|
+
lat:_this.layoutSettings.layout_latitude,
|
|
56
|
+
lng:_this.layoutSettings.layout_longitude
|
|
57
|
+
}
|
|
58
|
+
if(_this.layoutSettings.background_map_settings){
|
|
59
|
+
backgroundImageZoomLvl=_this.layoutSettings.background_map_settings.zoom_lvl
|
|
60
|
+
backgroundImageCenter={
|
|
61
|
+
lat:_this.layoutSettings.background_map_settings.lat,
|
|
62
|
+
lng:_this.layoutSettings.background_map_settings.lng
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
_this.backgroundImagesizeInMm=_this.layoutSettings.background_map_settings.sizeInMm
|
|
66
|
+
if (_this.backgroundImagesizeInMm) {
|
|
67
|
+
_this.cameraprojection.aspect =
|
|
68
|
+
_this.backgroundImagesizeInMm.width / _this.backgroundImagesizeInMm.height
|
|
69
|
+
let projectionAltitude =
|
|
70
|
+
_this.backgroundImagesizeInMm.height /
|
|
71
|
+
(2 * Math.tan((_this.cameraprojection.fov * Math.PI) / 360))
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
//set projection camera over background_map_center
|
|
75
|
+
let cameraProjectionPosition={x:0,y:0,z:projectionAltitude / 1000}
|
|
76
|
+
if(_this.layoutSettings.background_map_settings && _this.layoutSettings.background_map_settings.positionInMm){
|
|
77
|
+
let positionInMm=this.layoutSettings.background_map_settings.positionInMm
|
|
78
|
+
cameraProjectionPosition.x=positionInMm.x/1000
|
|
79
|
+
cameraProjectionPosition.y=positionInMm.y/1000
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
_this.cameraprojection.position.set(cameraProjectionPosition.x, cameraProjectionPosition.y, projectionAltitude / 1000)
|
|
83
|
+
_this.cameraprojection.far = projectionAltitude * 16
|
|
84
|
+
_this.cameraprojection.updateProjectionMatrix()
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let projectionMaterial = new ProjectedMaterial({
|
|
88
|
+
camera: _this.cameraprojection,
|
|
89
|
+
texture: texture
|
|
90
|
+
})
|
|
91
|
+
resolve(projectionMaterial)
|
|
92
|
+
})
|
|
93
|
+
})
|
|
94
|
+
this.material.roof =projectedMaterialLoaded
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as THREE from 'three'
|
|
2
|
+
import {
|
|
3
|
+
colorArrayBase,
|
|
4
|
+
} from '../../config'
|
|
5
|
+
import {
|
|
6
|
+
getBufferRoofMarginGeometry
|
|
7
|
+
} from './geometryHandler'
|
|
8
|
+
export default {
|
|
9
|
+
methods:{
|
|
10
|
+
renderRoofsMargin() {
|
|
11
|
+
this.clearByType('roofMarginMeshes')
|
|
12
|
+
|
|
13
|
+
if (this.selectedTool == 'selectMargin') {
|
|
14
|
+
this.roofs.forEach((roofPolygon) => {
|
|
15
|
+
const geometries = getBufferRoofMarginGeometry(roofPolygon)
|
|
16
|
+
|
|
17
|
+
geometries.forEach((geometry, index) => {
|
|
18
|
+
if (geometry) {
|
|
19
|
+
const marginColor = roofPolygon.margins.isSameMargin
|
|
20
|
+
? colorArrayBase[0]
|
|
21
|
+
: colorArrayBase[index % colorArrayBase.length]
|
|
22
|
+
let material = new THREE.MeshPhongMaterial({
|
|
23
|
+
color: marginColor,
|
|
24
|
+
specular: 0x009900,
|
|
25
|
+
shininess: 0,
|
|
26
|
+
flatShading: true,
|
|
27
|
+
side: THREE.DoubleSide,
|
|
28
|
+
transparent: true,
|
|
29
|
+
opacity: 0.8
|
|
30
|
+
})
|
|
31
|
+
const mesh = new THREE.Mesh(geometry, material)
|
|
32
|
+
geometry.dispose()
|
|
33
|
+
this.scene.add(mesh)
|
|
34
|
+
this.meshes.roofMarginMeshes[roofPolygon.id + '_' + index] = mesh
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
roofPolygon.holes.forEach((obstaclePolygon) => {
|
|
38
|
+
const geometries = getBufferRoofMarginGeometry(
|
|
39
|
+
obstaclePolygon,
|
|
40
|
+
roofPolygon
|
|
41
|
+
)
|
|
42
|
+
geometries.forEach((geometry, index) => {
|
|
43
|
+
if (geometry) {
|
|
44
|
+
const marginColor = obstaclePolygon.margins.isSameMargin
|
|
45
|
+
? colorArrayBase[0]
|
|
46
|
+
: colorArrayBase[index % colorArrayBase.length]
|
|
47
|
+
let material = new THREE.MeshPhongMaterial({
|
|
48
|
+
color: marginColor,
|
|
49
|
+
specular: 0x009900,
|
|
50
|
+
shininess: 0,
|
|
51
|
+
flatShading: true,
|
|
52
|
+
side: THREE.DoubleSide,
|
|
53
|
+
transparent: true,
|
|
54
|
+
opacity: 0.8
|
|
55
|
+
})
|
|
56
|
+
const mesh = new THREE.Mesh(geometry, material)
|
|
57
|
+
geometry.dispose()
|
|
58
|
+
geometry = null
|
|
59
|
+
material.dispose()
|
|
60
|
+
material = null
|
|
61
|
+
this.scene.add(mesh)
|
|
62
|
+
this.meshes.roofMarginMeshes[
|
|
63
|
+
obstaclePolygon.id + '_' + roofPolygon.id + '_' + index
|
|
64
|
+
] = mesh
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as THREE from 'three'
|
|
2
|
+
import {
|
|
3
|
+
getBufferModuleFieldGeometry,
|
|
4
|
+
} from './geometryHandler'
|
|
5
|
+
export default {
|
|
6
|
+
methods:{
|
|
7
|
+
renderModuleFields() {
|
|
8
|
+
this.clearByType('moduleFieldsMeshes')
|
|
9
|
+
|
|
10
|
+
this.moduleFields.forEach((moduleFieldPolygon) => {
|
|
11
|
+
if(!moduleFieldPolygon.data.number_of_panels_override && !this.areModuleFieldsVisible )return
|
|
12
|
+
const geometry = getBufferModuleFieldGeometry(moduleFieldPolygon)
|
|
13
|
+
if (geometry) {
|
|
14
|
+
const mesh = new THREE.Mesh(geometry, this.material.moduleField)
|
|
15
|
+
geometry.dispose()
|
|
16
|
+
mesh.matrixAutoUpdate = false
|
|
17
|
+
mesh.userData.version = moduleFieldPolygon.version
|
|
18
|
+
mesh.userData.type = 'moduleFieldsMeshes'
|
|
19
|
+
mesh.userData.meshId = moduleFieldPolygon.id
|
|
20
|
+
mesh.userData.polygonId = moduleFieldPolygon.id
|
|
21
|
+
this.scene.add(mesh)
|
|
22
|
+
this.meshes.moduleFieldsMeshes[moduleFieldPolygon.id] = mesh
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
}
|