@eturnity/eturnity_3d 7.10.0 → 7.10.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eturnity/eturnity_3d",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "7.10.
|
|
4
|
+
"version": "7.10.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.10.
|
|
13
|
+
"@eturnity/eturnity_maths": "7.10.2",
|
|
14
14
|
"core-js": "^2.6.12",
|
|
15
15
|
"cors": "^2.8.5",
|
|
16
16
|
"earcut": "^2.2.4",
|
|
@@ -73,4 +73,4 @@
|
|
|
73
73
|
"> 1%",
|
|
74
74
|
"last 2 versions"
|
|
75
75
|
]
|
|
76
|
-
}
|
|
76
|
+
}
|
|
@@ -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
|
}
|
|
@@ -15,10 +15,9 @@ 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
|
-
|
|
22
21
|
//position
|
|
23
22
|
if (
|
|
24
23
|
mergedGeometry.attributes.position &&
|
|
@@ -67,7 +67,7 @@ export default {
|
|
|
67
67
|
return ['panel', 'user_deactivated_panel'].includes(polygon.layer)
|
|
68
68
|
})
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
panels.forEach((panelPolygon) => {
|
|
71
71
|
//for each visible panels
|
|
72
72
|
//1. define materialId and material
|
|
73
73
|
//2. create or update individual meshes
|
|
@@ -95,7 +95,7 @@ export default {
|
|
|
95
95
|
|
|
96
96
|
materialId = 'default_' + moduleTextureId
|
|
97
97
|
material = this.material.panel[materialId]
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
if (panelPolygon.moduleField.data) {
|
|
100
100
|
if (
|
|
101
101
|
this.material.panel[
|
|
@@ -115,67 +115,74 @@ export default {
|
|
|
115
115
|
material.opacity = this.panelOpacity
|
|
116
116
|
}
|
|
117
117
|
//2. create or update individual meshes
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
118
|
+
//update existing geometry
|
|
119
|
+
if (this.meshes.panelsMeshes[panelPolygon.id + '_top']) {
|
|
120
|
+
const topMesh = this.meshes.panelsMeshes[panelPolygon.id + '_top']
|
|
121
|
+
if (panelPolygon.version > topMesh.userData.version) {
|
|
122
|
+
let topGeometry = updateBufferPanelGeometry(
|
|
123
|
+
panelPolygon,
|
|
124
|
+
topMesh.geometry
|
|
125
|
+
)
|
|
126
|
+
topMesh.geometry = topGeometry
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (!panelTopGeometries[materialId]) {
|
|
130
|
+
panelTopGeometries[materialId] = []
|
|
131
|
+
}
|
|
132
|
+
panelTopGeometries[materialId].push(topMesh.geometry)
|
|
133
|
+
topMesh.material = material
|
|
134
|
+
}
|
|
135
|
+
if (this.meshes.panelsMeshes[panelPolygon.id + '_side']) {
|
|
136
|
+
const sideMesh = this.meshes.panelsMeshes[panelPolygon.id + '_side']
|
|
137
|
+
if (panelPolygon.version > sideMesh.userData.version) {
|
|
138
|
+
let sideGeometry = updateBufferPanelSideGeometry(
|
|
139
|
+
panelPolygon,
|
|
140
|
+
sideMesh.geometry
|
|
141
|
+
)
|
|
142
|
+
sideMesh.geometry = sideGeometry
|
|
143
|
+
}
|
|
144
|
+
if (panelPolygon.layer != 'user_deactivated_panel') {
|
|
145
|
+
panelSideGeometries.push(sideMesh.geometry)
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//2a.Fill in panelTopGeometries & panelSideGeometries
|
|
149
|
+
//mesh creation
|
|
150
|
+
if (!this.meshes.panelsMeshes[panelPolygon.id + '_top']) {
|
|
126
151
|
//gather all geometry with similar material together to merge them for faster rendering
|
|
152
|
+
const geometry = getBufferPanelGeometry(panelPolygon)
|
|
127
153
|
if (!panelTopGeometries[materialId]) {
|
|
128
154
|
panelTopGeometries[materialId] = []
|
|
129
155
|
}
|
|
130
156
|
panelTopGeometries[materialId].push(geometry)
|
|
157
|
+
if (geometry) {
|
|
158
|
+
const mesh = new THREE.Mesh(geometry, this.material.hidden)
|
|
159
|
+
mesh.userData.version = panelPolygon.version
|
|
160
|
+
mesh.userData.type = 'panelsMeshes'
|
|
161
|
+
mesh.userData.meshId = panelPolygon.id + '_top'
|
|
162
|
+
mesh.userData.polygonId = panelPolygon.id
|
|
163
|
+
//this.scene.add(mesh)
|
|
164
|
+
mesh.matrixAutoUpdate = false
|
|
165
|
+
this.meshes.panelsMeshes[panelPolygon.id + '_top'] = mesh
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (!this.meshes.panelsMeshes[panelPolygon.id + '_side']) {
|
|
169
|
+
//sidemesh creation
|
|
170
|
+
const geometrySide = getBufferPanelSideGeometry(panelPolygon)
|
|
131
171
|
if (panelPolygon.layer != 'user_deactivated_panel') {
|
|
132
172
|
panelSideGeometries.push(geometrySide)
|
|
133
173
|
}
|
|
134
|
-
if (
|
|
135
|
-
const mesh = new THREE.Mesh(geometry, this.material.hidden)
|
|
174
|
+
if (geometrySide) {
|
|
136
175
|
const meshSide = new THREE.Mesh(
|
|
137
176
|
geometrySide,
|
|
138
177
|
this.material.panelSide
|
|
139
178
|
)
|
|
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
179
|
meshSide.userData.version = panelPolygon.version
|
|
146
180
|
meshSide.userData.type = 'panelsMeshes'
|
|
147
181
|
meshSide.userData.meshId = panelPolygon.id + '_side'
|
|
148
182
|
meshSide.userData.polygonId = panelPolygon.id
|
|
149
|
-
mesh.matrixAutoUpdate = false
|
|
150
183
|
meshSide.matrixAutoUpdate = false
|
|
151
|
-
this.meshes.panelsMeshes[panelPolygon.id + '_top'] = mesh
|
|
152
184
|
this.meshes.panelsMeshes[panelPolygon.id + '_side'] = meshSide
|
|
153
185
|
}
|
|
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
186
|
}
|
|
180
187
|
})
|
|
181
188
|
|
|
@@ -186,7 +193,10 @@ export default {
|
|
|
186
193
|
)
|
|
187
194
|
//if no panels, no materialIds,
|
|
188
195
|
for (let materialId of materialIdsToRemove) {
|
|
189
|
-
this.clearMeshFromScene(
|
|
196
|
+
this.clearMeshFromScene(
|
|
197
|
+
this.mergedPanelTopMeshes[materialId],
|
|
198
|
+
this.scene
|
|
199
|
+
)
|
|
190
200
|
delete this.mergedPanelTopMeshes[materialId]
|
|
191
201
|
}
|
|
192
202
|
this.mergedPanelSideMesh = this.updateOrCreateMergedMesh(
|
|
@@ -202,6 +212,7 @@ export default {
|
|
|
202
212
|
this.material.panel[key],
|
|
203
213
|
'panelTop_' + key
|
|
204
214
|
)
|
|
215
|
+
this.mergedPanelTopMeshes[key].renderOrder = 10
|
|
205
216
|
}
|
|
206
217
|
if (this.arePanelVisible) {
|
|
207
218
|
this.showPanels()
|