@eturnity/eturnity_3d 7.8.0 → 7.10.0-EPDM-10188.1
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/config.js +2 -1
- package/src/helper/UpdateRoofModuleFieldRelations.js +1 -1
- package/src/helper/cameraMixin.js +32 -0
- package/src/helper/render/clear.js +7 -7
- package/src/helper/render/edge.js +2 -0
- package/src/helper/render/geometryHandler.js +64 -37
- package/src/helper/render/imageOverlay.js +1 -1
- package/src/helper/render/mergedGeometry.js +2 -2
- package/src/helper/render/panel.js +62 -46
- package/src/helper/render/tile.js +1 -1
- package/src/helper/renderMixin.js +35 -13
- package/src/helper/threeMixin.js +6 -4
- package/src/store/nodesEdgesCreation.js +22 -20
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eturnity/eturnity_3d",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.10.0-EPDM-10188.1",
|
|
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": "7.
|
|
13
|
+
"@eturnity/eturnity_maths": "7.10.0",
|
|
14
14
|
"core-js": "^2.6.12",
|
|
15
15
|
"cors": "^2.8.5",
|
|
16
16
|
"earcut": "^2.2.4",
|
package/src/config.js
CHANGED
|
@@ -4,7 +4,8 @@ export const snapToPointTolerance = 15
|
|
|
4
4
|
export const snapToIntersectionPointTolerance = 15
|
|
5
5
|
export const snapToLineTolerance = 10
|
|
6
6
|
export const distanceToCloseNode = 70
|
|
7
|
-
export const mmTolerance =
|
|
7
|
+
export const mmTolerance = 5
|
|
8
|
+
export const mmTolerance3dNode = 50
|
|
8
9
|
export const earthRadius = 6371008
|
|
9
10
|
export const marginAroundBuildingForCameraViewInMeter = 5
|
|
10
11
|
export const layerColors = {
|
|
@@ -35,7 +35,7 @@ export function UpdateRoofModuleFieldRelations(state) {
|
|
|
35
35
|
const intersection = intersectOutlines(moduleField.outline, roof.outline)
|
|
36
36
|
if (intersection.length == 0) return false
|
|
37
37
|
const intersectionArea = calculateArea(intersection[0])
|
|
38
|
-
return intersectionArea > 100 && moduleField.area <= roof.area
|
|
38
|
+
return intersectionArea > 100 && moduleField.area <= roof.area + 0.1
|
|
39
39
|
})
|
|
40
40
|
//roofs on roof can lead to multiple roof under a point. moduleField is on the smallest
|
|
41
41
|
let smallestRoof = null
|
|
@@ -315,6 +315,38 @@ export default {
|
|
|
315
315
|
y
|
|
316
316
|
})
|
|
317
317
|
},
|
|
318
|
+
setCameraInitialPosition() {
|
|
319
|
+
if (this.roofs.length == 0) return
|
|
320
|
+
let newFov = 50
|
|
321
|
+
let bounds = this.roofsBounds
|
|
322
|
+
let targetVector = {
|
|
323
|
+
x: (bounds.xMax + bounds.xMin) / 2000,
|
|
324
|
+
y: (bounds.yMax + bounds.yMin) / 2000,
|
|
325
|
+
z: 0
|
|
326
|
+
}
|
|
327
|
+
let objectRadius_m = Math.max(
|
|
328
|
+
(bounds.xMax - bounds.xMin) / 2000,
|
|
329
|
+
(bounds.yMax - bounds.yMin) / 2000
|
|
330
|
+
)
|
|
331
|
+
let distance =
|
|
332
|
+
5 + objectRadius_m / Math.sin(((newFov / 2) * Math.PI) / 180)
|
|
333
|
+
let cameraMoveVector = { x: 0, y: 0, z: distance }
|
|
334
|
+
const positionVector = addVector(targetVector, cameraMoveVector)
|
|
335
|
+
const position = [
|
|
336
|
+
positionVector.x,
|
|
337
|
+
positionVector.y - distance,
|
|
338
|
+
positionVector.z
|
|
339
|
+
]
|
|
340
|
+
let target = [targetVector.x, targetVector.y, targetVector.z]
|
|
341
|
+
|
|
342
|
+
this.camera.position.set(position[0], position[1], position[2])
|
|
343
|
+
this.camera.updateProjectionMatrix()
|
|
344
|
+
|
|
345
|
+
this.orbitControl.target.set(target[0], target[1], target[2])
|
|
346
|
+
if (this.orbitControl && this.orbitControl.update) {
|
|
347
|
+
this.orbitControl.update()
|
|
348
|
+
}
|
|
349
|
+
},
|
|
318
350
|
setCameraGlobalPosition() {
|
|
319
351
|
if (this.roofs.length == 0) return
|
|
320
352
|
if (this.camera.isOrthographicCamera) {
|
|
@@ -35,18 +35,18 @@ export default {
|
|
|
35
35
|
let meshTop = this.meshes.panelsMeshes[panel.id + '_top']
|
|
36
36
|
let meshSide = this.meshes.panelsMeshes[panel.id + '_side']
|
|
37
37
|
if (meshTop || meshSide) {
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
38
|
+
this.clearMeshFromScene(meshTop, this.scene)
|
|
39
|
+
this.clearMeshFromScene(meshSide, this.scene)
|
|
40
40
|
}
|
|
41
41
|
})
|
|
42
42
|
)
|
|
43
43
|
)
|
|
44
44
|
},
|
|
45
|
-
|
|
46
|
-
if (!mesh || !
|
|
45
|
+
clearMeshFromScene(mesh, scene) {
|
|
46
|
+
if (!mesh || !scene) {
|
|
47
47
|
return
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
scene.remove(mesh)
|
|
50
50
|
if (mesh.geometry && mesh.geometry.dispose) {
|
|
51
51
|
mesh.geometry.dispose()
|
|
52
52
|
mesh.geometry = null
|
|
@@ -72,14 +72,14 @@ export default {
|
|
|
72
72
|
clearEdgesRemovedOnes() {
|
|
73
73
|
Object.values(this.meshes['edgeMeshes']).forEach((mesh) => {
|
|
74
74
|
if (!this.edgeIds.includes(mesh.userData.edgeId)) {
|
|
75
|
-
this.
|
|
75
|
+
this.clearMeshFromScene(mesh, this.scene)
|
|
76
76
|
}
|
|
77
77
|
})
|
|
78
78
|
},
|
|
79
79
|
clearRemovedOnes(type) {
|
|
80
80
|
Object.values(this.meshes[type]).forEach((mesh) => {
|
|
81
81
|
if (!this.polygonIds.includes(mesh.userData.polygonId)) {
|
|
82
|
-
this.
|
|
82
|
+
this.clearMeshFromScene(mesh, this.scene)
|
|
83
83
|
}
|
|
84
84
|
})
|
|
85
85
|
},
|
|
@@ -80,7 +80,6 @@ export function updateBufferRoofGeometry(
|
|
|
80
80
|
return null
|
|
81
81
|
}
|
|
82
82
|
const vertices = new Float32Array(triangleVertices)
|
|
83
|
-
// itemSize = 3 because there are 3 values (components) per vertex
|
|
84
83
|
if (
|
|
85
84
|
geometry.attributes.position &&
|
|
86
85
|
geometry.attributes.position.array.length >= vertices.length
|
|
@@ -98,6 +97,7 @@ export function updateBufferRoofGeometry(
|
|
|
98
97
|
geometry.setDrawRange(0, vertices.length / 3)
|
|
99
98
|
geometry.attributes.position.needsUpdate = true
|
|
100
99
|
geometry.computeVertexNormals()
|
|
100
|
+
geometry.needsUpdate = true
|
|
101
101
|
return geometry
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -458,7 +458,7 @@ export function getBufferImageOverlayGeometry(corners) {
|
|
|
458
458
|
geometry.computeVertexNormals()
|
|
459
459
|
return geometry
|
|
460
460
|
}
|
|
461
|
-
export function
|
|
461
|
+
export function getPanelOutlineWithHeightOffset(panelPolygon) {
|
|
462
462
|
let panelNormalVector = getNormalVectorFrom3Points(
|
|
463
463
|
panelPolygon.outline[0],
|
|
464
464
|
panelPolygon.outline[1],
|
|
@@ -471,15 +471,19 @@ export function getBufferPanelGeometry(panelPolygon) {
|
|
|
471
471
|
//get lowest verticalProjection
|
|
472
472
|
|
|
473
473
|
const panelOutlineTop = []
|
|
474
|
-
const geometry = new THREE.BufferGeometry()
|
|
475
|
-
//Calcul of triangles using cutear algo
|
|
476
|
-
const trianglesVertices = []
|
|
477
474
|
panelPolygon.outline.forEach((p) => {
|
|
478
475
|
const vectorFromBottomToTop = multiplyVector(panelHeight, panelNormalVector)
|
|
479
476
|
let p_up_0 = addVector(p, vectorFromBottomToTop)
|
|
480
477
|
|
|
481
478
|
panelOutlineTop.push(p_up_0)
|
|
482
479
|
})
|
|
480
|
+
return panelOutlineTop
|
|
481
|
+
}
|
|
482
|
+
export function getBufferPanelGeometry(panelPolygon) {
|
|
483
|
+
const geometry = new THREE.BufferGeometry()
|
|
484
|
+
//Calcul of triangles using cutear algo
|
|
485
|
+
const trianglesVertices = []
|
|
486
|
+
const panelOutlineTop = getPanelOutlineWithHeightOffset(panelPolygon)
|
|
483
487
|
trianglesVertices.push(...getTriangleVerticesFromOutline(panelOutlineTop))
|
|
484
488
|
|
|
485
489
|
if (hasNaN(trianglesVertices)) {
|
|
@@ -514,41 +518,22 @@ export function getBufferPanelGeometry(panelPolygon) {
|
|
|
514
518
|
return geometry
|
|
515
519
|
}
|
|
516
520
|
export function updateBufferPanelGeometry(panelPolygon, geometry) {
|
|
517
|
-
|
|
521
|
+
const panelOutlineTop = getPanelOutlineWithHeightOffset(panelPolygon)
|
|
522
|
+
geometry = updateBufferRoofGeometry(panelOutlineTop, [], geometry)
|
|
518
523
|
return geometry
|
|
519
524
|
}
|
|
520
525
|
|
|
521
|
-
export function
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
export function getBufferPanelSideGeometry(panelPolygon) {
|
|
526
|
-
let panelNormalVector = getNormalVectorFrom3Points(
|
|
527
|
-
panelPolygon.outline[0],
|
|
528
|
-
panelPolygon.outline[1],
|
|
529
|
-
panelPolygon.outline[2]
|
|
530
|
-
)
|
|
531
|
-
if (panelNormalVector.z < 0) {
|
|
532
|
-
panelNormalVector = multiplyVector(-1, panelNormalVector)
|
|
533
|
-
}
|
|
534
|
-
const roofPolygon = panelPolygon.roof
|
|
535
|
-
const panelHeight = parseInt(panelPolygon.height || 50)
|
|
536
|
-
// const normalVector = roofPolygon.normalVector
|
|
537
|
-
// const passByPoint = roofPolygon.flatOutline[0]
|
|
538
|
-
|
|
539
|
-
const geometry = new THREE.BufferGeometry()
|
|
540
|
-
//Calcul of triangles using cutear algo
|
|
541
|
-
const panelLength = panelPolygon.outline.length
|
|
542
|
-
const trianglesVertices = []
|
|
543
|
-
const panelOutlineTop = []
|
|
544
|
-
panelPolygon.outline.forEach((p, index) => {
|
|
526
|
+
export function getTriangleVerticesForSidePanels(outlineBottom, outlineUp) {
|
|
527
|
+
const triangleVertices = []
|
|
528
|
+
const length = outlineBottom.length
|
|
529
|
+
for (let index = 0; index < length; index++) {
|
|
545
530
|
//const vectorFromBottomToTop=multiplyVector(obstacleHeight,{normalVector})
|
|
546
|
-
const
|
|
547
|
-
const
|
|
548
|
-
const
|
|
549
|
-
let p_up_0 =
|
|
550
|
-
let p_up_1 =
|
|
551
|
-
|
|
531
|
+
const nextIndex = (index + 1) % length
|
|
532
|
+
const p_bottom_0 = outlineBottom[index]
|
|
533
|
+
const p_bottom_1 = outlineBottom[nextIndex]
|
|
534
|
+
let p_up_0 = outlineUp[index]
|
|
535
|
+
let p_up_1 = outlineUp[nextIndex]
|
|
536
|
+
triangleVertices.push(
|
|
552
537
|
...[
|
|
553
538
|
p_up_0.x / 1000,
|
|
554
539
|
p_up_0.y / 1000,
|
|
@@ -570,7 +555,49 @@ export function getBufferPanelSideGeometry(panelPolygon) {
|
|
|
570
555
|
p_bottom_1.z / 1000
|
|
571
556
|
]
|
|
572
557
|
)
|
|
573
|
-
}
|
|
558
|
+
}
|
|
559
|
+
return triangleVertices
|
|
560
|
+
}
|
|
561
|
+
export function updateBufferPanelSideGeometry(panelPolygon, geometry) {
|
|
562
|
+
const panelOutlineTop = getPanelOutlineWithHeightOffset(panelPolygon)
|
|
563
|
+
const triangleVertices = getTriangleVerticesForSidePanels(
|
|
564
|
+
panelPolygon.outline,
|
|
565
|
+
panelOutlineTop
|
|
566
|
+
)
|
|
567
|
+
|
|
568
|
+
if (hasNaN(triangleVertices)) {
|
|
569
|
+
return null
|
|
570
|
+
}
|
|
571
|
+
const vertices = new Float32Array(triangleVertices)
|
|
572
|
+
if (
|
|
573
|
+
geometry.attributes.position &&
|
|
574
|
+
geometry.attributes.position.array.length >= vertices.length
|
|
575
|
+
) {
|
|
576
|
+
let positions = geometry.attributes.position.array
|
|
577
|
+
for (let k in vertices) {
|
|
578
|
+
positions[k] = vertices[k]
|
|
579
|
+
}
|
|
580
|
+
} else {
|
|
581
|
+
geometry.dispose()
|
|
582
|
+
geometry = null
|
|
583
|
+
geometry = new THREE.BufferGeometry()
|
|
584
|
+
geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3))
|
|
585
|
+
}
|
|
586
|
+
geometry.setDrawRange(0, vertices.length / 3)
|
|
587
|
+
geometry.attributes.position.needsUpdate = true
|
|
588
|
+
geometry.computeVertexNormals()
|
|
589
|
+
geometry.needsUpdate = true
|
|
590
|
+
|
|
591
|
+
return geometry
|
|
592
|
+
}
|
|
593
|
+
export function getBufferPanelSideGeometry(panelPolygon) {
|
|
594
|
+
const panelOutlineTop = getPanelOutlineWithHeightOffset(panelPolygon)
|
|
595
|
+
const geometry = new THREE.BufferGeometry()
|
|
596
|
+
//Calcul of triangles using cutear algo
|
|
597
|
+
const trianglesVertices = getTriangleVerticesForSidePanels(
|
|
598
|
+
panelPolygon.outline,
|
|
599
|
+
panelOutlineTop
|
|
600
|
+
)
|
|
574
601
|
if (hasNaN(trianglesVertices)) {
|
|
575
602
|
return null
|
|
576
603
|
}
|
|
@@ -34,7 +34,7 @@ export default {
|
|
|
34
34
|
methods: {
|
|
35
35
|
renderImageOverlayOnBackground() {
|
|
36
36
|
if (!this.imageOverlay || !this.imageOverlayMaterial) {
|
|
37
|
-
this.
|
|
37
|
+
this.clearMeshFromScene(this.meshes.backgroundMesh, this.scene)
|
|
38
38
|
this.meshes.backgroundMesh = null
|
|
39
39
|
return
|
|
40
40
|
}
|
|
@@ -15,10 +15,10 @@ export default {
|
|
|
15
15
|
|
|
16
16
|
if (geometry.attributes.uv) {
|
|
17
17
|
const uvs = geometry.attributes.uv.array
|
|
18
|
-
mergedUvs.push(...uvs)
|
|
18
|
+
mergedUvs.push(...uvs.slice(0, 3 * geometry.drawRange.count))
|
|
19
19
|
}
|
|
20
20
|
})
|
|
21
|
-
|
|
21
|
+
console.log('mergedVertices', mergedVertices[0],geometries)
|
|
22
22
|
//position
|
|
23
23
|
if (
|
|
24
24
|
mergedGeometry.attributes.position &&
|
|
@@ -48,14 +48,14 @@ export default {
|
|
|
48
48
|
poly.layer == 'user_deactivated_panel'
|
|
49
49
|
)
|
|
50
50
|
) {
|
|
51
|
-
this.
|
|
51
|
+
this.clearMeshFromScene(mesh, this.scene)
|
|
52
52
|
}
|
|
53
53
|
//clear panel on moduleField with overriden number of panel
|
|
54
54
|
let panel = this.polygons.find(
|
|
55
55
|
(poly) => mesh.userData.polygonId == poly.id
|
|
56
56
|
)
|
|
57
57
|
if (!panel || panel.moduleField.data.number_of_panels_override) {
|
|
58
|
-
this.
|
|
58
|
+
this.clearMeshFromScene(mesh, this.scene)
|
|
59
59
|
}
|
|
60
60
|
})
|
|
61
61
|
|
|
@@ -67,11 +67,16 @@ export default {
|
|
|
67
67
|
return ['panel', 'user_deactivated_panel'].includes(polygon.layer)
|
|
68
68
|
})
|
|
69
69
|
}
|
|
70
|
+
if (panels.length > 0) {
|
|
71
|
+
console.log('z', panels[0].outline[0].z)
|
|
72
|
+
}
|
|
73
|
+
|
|
70
74
|
panels.forEach((panelPolygon) => {
|
|
71
75
|
//for each visible panels
|
|
72
76
|
//1. define materialId and material
|
|
73
77
|
//2. create or update individual meshes
|
|
74
78
|
// 2a. Fill in panelTopGeometries & panelSideGeometries
|
|
79
|
+
|
|
75
80
|
if (!panelPolygon.visible) {
|
|
76
81
|
return
|
|
77
82
|
}
|
|
@@ -95,7 +100,7 @@ export default {
|
|
|
95
100
|
|
|
96
101
|
materialId = 'default_' + moduleTextureId
|
|
97
102
|
material = this.material.panel[materialId]
|
|
98
|
-
|
|
103
|
+
|
|
99
104
|
if (panelPolygon.moduleField.data) {
|
|
100
105
|
if (
|
|
101
106
|
this.material.panel[
|
|
@@ -115,67 +120,74 @@ export default {
|
|
|
115
120
|
material.opacity = this.panelOpacity
|
|
116
121
|
}
|
|
117
122
|
//2. create or update individual meshes
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
//update existing geometry
|
|
124
|
+
if (this.meshes.panelsMeshes[panelPolygon.id + '_top']) {
|
|
125
|
+
const topMesh = this.meshes.panelsMeshes[panelPolygon.id + '_top']
|
|
126
|
+
if (panelPolygon.version > topMesh.userData.version) {
|
|
127
|
+
let topGeometry = updateBufferPanelGeometry(
|
|
128
|
+
panelPolygon,
|
|
129
|
+
topMesh.geometry
|
|
130
|
+
)
|
|
131
|
+
topMesh.geometry = topGeometry
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (!panelTopGeometries[materialId]) {
|
|
135
|
+
panelTopGeometries[materialId] = []
|
|
136
|
+
}
|
|
137
|
+
panelTopGeometries[materialId].push(topMesh.geometry)
|
|
138
|
+
topMesh.material = material
|
|
139
|
+
}
|
|
140
|
+
if (this.meshes.panelsMeshes[panelPolygon.id + '_side']) {
|
|
141
|
+
const sideMesh = this.meshes.panelsMeshes[panelPolygon.id + '_side']
|
|
142
|
+
if (panelPolygon.version > sideMesh.userData.version) {
|
|
143
|
+
let sideGeometry = updateBufferPanelSideGeometry(
|
|
144
|
+
panelPolygon,
|
|
145
|
+
sideMesh.geometry
|
|
146
|
+
)
|
|
147
|
+
sideMesh.geometry = sideGeometry
|
|
148
|
+
}
|
|
149
|
+
if (panelPolygon.layer != 'user_deactivated_panel') {
|
|
150
|
+
panelSideGeometries.push(sideMesh.geometry)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//2a.Fill in panelTopGeometries & panelSideGeometries
|
|
154
|
+
//mesh creation
|
|
155
|
+
if (!this.meshes.panelsMeshes[panelPolygon.id + '_top']) {
|
|
126
156
|
//gather all geometry with similar material together to merge them for faster rendering
|
|
157
|
+
const geometry = getBufferPanelGeometry(panelPolygon)
|
|
127
158
|
if (!panelTopGeometries[materialId]) {
|
|
128
159
|
panelTopGeometries[materialId] = []
|
|
129
160
|
}
|
|
130
161
|
panelTopGeometries[materialId].push(geometry)
|
|
162
|
+
if (geometry) {
|
|
163
|
+
const mesh = new THREE.Mesh(geometry, this.material.hidden)
|
|
164
|
+
mesh.userData.version = panelPolygon.version
|
|
165
|
+
mesh.userData.type = 'panelsMeshes'
|
|
166
|
+
mesh.userData.meshId = panelPolygon.id + '_top'
|
|
167
|
+
mesh.userData.polygonId = panelPolygon.id
|
|
168
|
+
//this.scene.add(mesh)
|
|
169
|
+
mesh.matrixAutoUpdate = false
|
|
170
|
+
this.meshes.panelsMeshes[panelPolygon.id + '_top'] = mesh
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (!this.meshes.panelsMeshes[panelPolygon.id + '_side']) {
|
|
174
|
+
//sidemesh creation
|
|
175
|
+
const geometrySide = getBufferPanelSideGeometry(panelPolygon)
|
|
131
176
|
if (panelPolygon.layer != 'user_deactivated_panel') {
|
|
132
177
|
panelSideGeometries.push(geometrySide)
|
|
133
178
|
}
|
|
134
|
-
if (
|
|
135
|
-
const mesh = new THREE.Mesh(geometry, this.material.hidden)
|
|
179
|
+
if (geometrySide) {
|
|
136
180
|
const meshSide = new THREE.Mesh(
|
|
137
181
|
geometrySide,
|
|
138
182
|
this.material.panelSide
|
|
139
183
|
)
|
|
140
|
-
mesh.userData.version = panelPolygon.version
|
|
141
|
-
mesh.userData.type = 'panelsMeshes'
|
|
142
|
-
mesh.userData.meshId = panelPolygon.id + '_top'
|
|
143
|
-
mesh.userData.polygonId = panelPolygon.id
|
|
144
|
-
this.scene.add(mesh)
|
|
145
184
|
meshSide.userData.version = panelPolygon.version
|
|
146
185
|
meshSide.userData.type = 'panelsMeshes'
|
|
147
186
|
meshSide.userData.meshId = panelPolygon.id + '_side'
|
|
148
187
|
meshSide.userData.polygonId = panelPolygon.id
|
|
149
|
-
mesh.matrixAutoUpdate = false
|
|
150
188
|
meshSide.matrixAutoUpdate = false
|
|
151
|
-
this.meshes.panelsMeshes[panelPolygon.id + '_top'] = mesh
|
|
152
189
|
this.meshes.panelsMeshes[panelPolygon.id + '_side'] = meshSide
|
|
153
190
|
}
|
|
154
|
-
} else {
|
|
155
|
-
//update existing geometry
|
|
156
|
-
const topMesh = this.meshes.panelsMeshes[panelPolygon.id + '_top']
|
|
157
|
-
const sideMesh = this.meshes.panelsMeshes[panelPolygon.id + '_side']
|
|
158
|
-
if (panelPolygon.version > topMesh.userData.version) {
|
|
159
|
-
let topGeometry = updateBufferPanelGeometry(
|
|
160
|
-
panelPolygon,
|
|
161
|
-
topMesh.geometry
|
|
162
|
-
)
|
|
163
|
-
let sideGeometry = updateBufferPanelSideGeometry(
|
|
164
|
-
panelPolygon,
|
|
165
|
-
sideMesh.geometry
|
|
166
|
-
)
|
|
167
|
-
|
|
168
|
-
topMesh.geometry = topGeometry
|
|
169
|
-
sideMesh.geometry = sideGeometry
|
|
170
|
-
}
|
|
171
|
-
if (panelPolygon.layer != 'user_deactivated_panel') {
|
|
172
|
-
panelSideGeometries.push(sideMesh.geometry)
|
|
173
|
-
}
|
|
174
|
-
if (!panelTopGeometries[materialId]) {
|
|
175
|
-
panelTopGeometries[materialId] = []
|
|
176
|
-
}
|
|
177
|
-
panelTopGeometries[materialId].push(topMesh.geometry)
|
|
178
|
-
topMesh.material = material
|
|
179
191
|
}
|
|
180
192
|
})
|
|
181
193
|
|
|
@@ -186,7 +198,10 @@ export default {
|
|
|
186
198
|
)
|
|
187
199
|
//if no panels, no materialIds,
|
|
188
200
|
for (let materialId of materialIdsToRemove) {
|
|
189
|
-
this.
|
|
201
|
+
this.clearMeshFromScene(
|
|
202
|
+
this.mergedPanelTopMeshes[materialId],
|
|
203
|
+
this.scene
|
|
204
|
+
)
|
|
190
205
|
delete this.mergedPanelTopMeshes[materialId]
|
|
191
206
|
}
|
|
192
207
|
this.mergedPanelSideMesh = this.updateOrCreateMergedMesh(
|
|
@@ -202,6 +217,7 @@ export default {
|
|
|
202
217
|
this.material.panel[key],
|
|
203
218
|
'panelTop_' + key
|
|
204
219
|
)
|
|
220
|
+
this.mergedPanelTopMeshes[key].renderOrder = 10
|
|
205
221
|
}
|
|
206
222
|
if (this.arePanelVisible) {
|
|
207
223
|
this.showPanels()
|
|
@@ -65,6 +65,13 @@ export default {
|
|
|
65
65
|
e.name == 'setCameraGlobalPosition'
|
|
66
66
|
)
|
|
67
67
|
},
|
|
68
|
+
setInitialPositionRenderNeeded() {
|
|
69
|
+
return !!this.geometryEvents.find(
|
|
70
|
+
(e) =>
|
|
71
|
+
e.id > this.lastGeometryEventIdDone &&
|
|
72
|
+
e.name == 'setInitialPositionRenderNeeded'
|
|
73
|
+
)
|
|
74
|
+
},
|
|
68
75
|
fullRenderNeeded() {
|
|
69
76
|
return !!this.geometryEvents.find(
|
|
70
77
|
(e) => e.id > this.lastGeometryEventIdDone && e.name == 'full'
|
|
@@ -74,6 +81,9 @@ export default {
|
|
|
74
81
|
return this.geometryEvents.filter(
|
|
75
82
|
(e) => e.id > this.lastGeometryEventIdDone
|
|
76
83
|
)
|
|
84
|
+
},
|
|
85
|
+
geometryEventsToDoWithoutFull() {
|
|
86
|
+
return this.geometryEventsToDo.filter((e) => e.name != 'full')
|
|
77
87
|
}
|
|
78
88
|
},
|
|
79
89
|
methods: {
|
|
@@ -81,22 +91,17 @@ export default {
|
|
|
81
91
|
let methodList = []
|
|
82
92
|
if (this.fullRenderNeeded) {
|
|
83
93
|
methodList = this.renderingMethodsByEvent({ name: 'full' })
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
for (let renderingMethod of this.renderingMethodsByEvent(
|
|
92
|
-
geometryEvent
|
|
93
|
-
)) {
|
|
94
|
-
if (!methodList.map((m) => m.name).includes(renderingMethod.name)) {
|
|
95
|
-
methodList.push(renderingMethod)
|
|
96
|
-
}
|
|
94
|
+
}
|
|
95
|
+
for (let geometryEvent of this.geometryEventsToDoWithoutFull) {
|
|
96
|
+
for (let renderingMethod of this.renderingMethodsByEvent(
|
|
97
|
+
geometryEvent
|
|
98
|
+
)) {
|
|
99
|
+
if (!methodList.map((m) => m.name).includes(renderingMethod.name)) {
|
|
100
|
+
methodList.push(renderingMethod)
|
|
97
101
|
}
|
|
98
102
|
}
|
|
99
103
|
}
|
|
104
|
+
|
|
100
105
|
if (methodList.length) {
|
|
101
106
|
this.renderMethods(methodList)
|
|
102
107
|
this.render()
|
|
@@ -131,6 +136,13 @@ export default {
|
|
|
131
136
|
arg: []
|
|
132
137
|
})
|
|
133
138
|
break
|
|
139
|
+
case 'setCameraInitialPosition':
|
|
140
|
+
methodList.push({
|
|
141
|
+
name: 'setCameraInitialPosition',
|
|
142
|
+
method: this.setCameraInitialPosition,
|
|
143
|
+
arg: []
|
|
144
|
+
})
|
|
145
|
+
break
|
|
134
146
|
case 'toolChange': //params.toolName
|
|
135
147
|
methodList.push({
|
|
136
148
|
name: 'renderEdges',
|
|
@@ -213,6 +225,11 @@ export default {
|
|
|
213
225
|
method: this.renderObstacles,
|
|
214
226
|
arg: []
|
|
215
227
|
})
|
|
228
|
+
methodList.push({
|
|
229
|
+
name: 'renderNodes',
|
|
230
|
+
method: this.renderNodes,
|
|
231
|
+
arg: []
|
|
232
|
+
})
|
|
216
233
|
} else if (params.layer == 'obstacle') {
|
|
217
234
|
methodList.push({
|
|
218
235
|
name: 'renderBase',
|
|
@@ -257,6 +274,11 @@ export default {
|
|
|
257
274
|
case 'newRoofs':
|
|
258
275
|
case 'moveNodesZ': //params.nodes
|
|
259
276
|
case 'solveFlatness': //params.roof
|
|
277
|
+
methodList.push({
|
|
278
|
+
name: 'renderEdges',
|
|
279
|
+
method: this.renderEdges,
|
|
280
|
+
arg: []
|
|
281
|
+
})
|
|
260
282
|
methodList.push({
|
|
261
283
|
name: 'renderBuilding',
|
|
262
284
|
method: this.renderBuilding,
|
package/src/helper/threeMixin.js
CHANGED
|
@@ -66,12 +66,14 @@ export default {
|
|
|
66
66
|
},
|
|
67
67
|
initialiseRenderer() {
|
|
68
68
|
this.resizeRenderer(this.DOMElement)
|
|
69
|
-
this.renderer
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
if (this.renderer) {
|
|
70
|
+
this.renderer.setPixelRatio(window.devicePixelRatio)
|
|
71
|
+
this.renderer.toneMappingExposure = 0.01
|
|
72
|
+
this.DOMElement.appendChild(this.renderer.domElement)
|
|
73
|
+
}
|
|
72
74
|
},
|
|
73
75
|
resizeRenderer() {
|
|
74
|
-
if(this.DOMElement){
|
|
76
|
+
if (this.DOMElement) {
|
|
75
77
|
const width = this.DOMElement.clientWidth
|
|
76
78
|
const height = this.DOMElement.clientHeight
|
|
77
79
|
this.renderer.domElement.style.width = width + 'px'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Point, Line } from '@eturnity/eturnity_maths'
|
|
2
|
-
import { mmTolerance } from '../config'
|
|
2
|
+
import { mmTolerance, mmTolerance3dNode } from '../config'
|
|
3
3
|
import {
|
|
4
4
|
isAlmostSamePoint3D,
|
|
5
5
|
isAlmostSameSegment2D,
|
|
@@ -54,20 +54,17 @@ export function generateNodes2D(polygons) {
|
|
|
54
54
|
//all nodes has been created. now lets update open/selected field
|
|
55
55
|
nodes2D.forEach((node2D) => {
|
|
56
56
|
if (node2D.masterHandle) {
|
|
57
|
-
node2D.masterHandle.open =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
node2D.belongsTo.filter(
|
|
69
|
-
(item) => item.polygon.outline[item.index].selected
|
|
70
|
-
).length == node2D.belongsTo.length
|
|
57
|
+
node2D.masterHandle.open = node2D.belongsTo.some(
|
|
58
|
+
(item) =>
|
|
59
|
+
item.polygon.outline[item.index].open ||
|
|
60
|
+
item.polygon.outline[item.index].hasWarning
|
|
61
|
+
)
|
|
62
|
+
node2D.masterHandle.hasWarning = node2D.belongsTo.some(
|
|
63
|
+
(item) => item.polygon.outline[item.index].hasWarning
|
|
64
|
+
)
|
|
65
|
+
node2D.masterHandle.selected = node2D.belongsTo.every(
|
|
66
|
+
(item) => item.polygon.outline[item.index].selected
|
|
67
|
+
)
|
|
71
68
|
}
|
|
72
69
|
})
|
|
73
70
|
return nodes2D
|
|
@@ -84,7 +81,7 @@ export function generateNodes3D(polygons) {
|
|
|
84
81
|
outline.forEach((point, i) => {
|
|
85
82
|
//check if nodes2D already exist
|
|
86
83
|
let node3D = nodes3D.find((node) =>
|
|
87
|
-
isAlmostSamePoint3D(node, point,
|
|
84
|
+
isAlmostSamePoint3D(node, point, mmTolerance3dNode)
|
|
88
85
|
)
|
|
89
86
|
if (!node3D) {
|
|
90
87
|
node3D = new Point(point.x, point.y, point.z, polygon.layer)
|
|
@@ -111,9 +108,9 @@ export function generateNodes3D(polygons) {
|
|
|
111
108
|
//all nodes has been created. now lets update open/selected field
|
|
112
109
|
nodes3D.forEach((node3D) => {
|
|
113
110
|
if (node3D.masterHandle) {
|
|
114
|
-
node3D.masterHandle.open =
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
node3D.masterHandle.open = node3D.belongsTo.some(
|
|
112
|
+
(item) => item.polygon.outline[item.index].open
|
|
113
|
+
)
|
|
117
114
|
node3D.masterHandle.selected = node3D.belongsTo.every(
|
|
118
115
|
(item) => item.polygon.outline[item.index].selected
|
|
119
116
|
)
|
|
@@ -131,7 +128,8 @@ export function generateEdges2D(polygons) {
|
|
|
131
128
|
.forEach((polygon) => {
|
|
132
129
|
const outline = polygon.outline
|
|
133
130
|
outline.forEach((point, i) => {
|
|
134
|
-
|
|
131
|
+
const isLastPointOfPolygon = i == outline.length - 1
|
|
132
|
+
if (!polygon.isClosed && isLastPointOfPolygon) {
|
|
135
133
|
return
|
|
136
134
|
}
|
|
137
135
|
//check if edge2D already exist
|
|
@@ -176,6 +174,10 @@ export function generateEdges3D(polygons) {
|
|
|
176
174
|
.forEach((polygon) => {
|
|
177
175
|
const outline = polygon.outline
|
|
178
176
|
outline.forEach((point, i) => {
|
|
177
|
+
const isLastPointOfPolygon = i == outline.length - 1
|
|
178
|
+
if (!polygon.isClosed && isLastPointOfPolygon) {
|
|
179
|
+
return
|
|
180
|
+
}
|
|
179
181
|
//check if edge2D already exist
|
|
180
182
|
const nextPoint = outline[(i + 1) % outline.length]
|
|
181
183
|
let edge3D = edges3D.find((edge) => {
|