@eturnity/eturnity_3d 9.10.0 → 9.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/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ .canvas3DContainer{height:100%;width:100%}.canvas3DContainer>canvas{height:100%;width:100%}
package/dist/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_3d",
3
3
  "private": false,
4
- "version": "9.10.0",
4
+ "version": "9.10.1",
5
5
  "files": [
6
6
  "dist",
7
7
  "src"
@@ -16,7 +16,7 @@
16
16
  "merge-remote-master": "node scripts/merge-remote-master.js"
17
17
  },
18
18
  "dependencies": {
19
- "@eturnity/eturnity_maths": "9.7.0",
19
+ "@eturnity/eturnity_maths": "9.10.0",
20
20
  "@originjs/vite-plugin-commonjs": "1.0.3",
21
21
  "core-js": "3.30.2",
22
22
  "cors": "2.8.5",
@@ -122,7 +122,6 @@ export default class ThreeDModelOverlay extends Overlay {
122
122
  return
123
123
  }
124
124
  group = new this.Paper.Group()
125
-
126
125
  group.addChild(this.renderImagePlaceHolder(paperJSComponent))
127
126
  group.itemType = 'placeholderOverlays'
128
127
  group.type = 'imageOverlays'
@@ -138,7 +137,6 @@ export default class ThreeDModelOverlay extends Overlay {
138
137
  this.hasPlaceholderPath = true
139
138
  return
140
139
  }
141
-
142
140
  if (this.hasPlaceholderPath) {
143
141
  if (group) {
144
142
  paperJSComponent.clearPath(group)
@@ -440,7 +440,10 @@ export default {
440
440
  this.setTweenTo({ position, target })
441
441
  }
442
442
  },
443
- setCameraGlobalPosition() {
443
+ setCameraGlobalPositionImmediately() {
444
+ this.setCameraGlobalPosition({ duration: 0 })
445
+ },
446
+ setCameraGlobalPosition({ duration = 1500 } = {}) {
444
447
  if (this.camera.isOrthographicCamera) {
445
448
  this.setOrthographicCameraGlobalPosition()
446
449
  } else {
@@ -466,10 +469,41 @@ export default {
466
469
  positionVector.z,
467
470
  ]
468
471
  let target = [targetVector.x, targetVector.y, targetVector.z]
469
- this.setTweenTo({ position, target, fov: newFov })
472
+ this.setTweenTo({ position, target, fov: newFov, duration })
473
+ }
474
+ },
475
+ setCameraGlobalAlmostVerticalPosition({ duration = 1000 } = {}) {
476
+ let position, target
477
+ if (this.roofs.length != 0) {
478
+ let bounds = this.roofsBounds
479
+ let targetVector = {
480
+ x: (bounds.xMax + bounds.xMin) / 2000,
481
+ y: (bounds.yMax + bounds.yMin) / 2000,
482
+ z: 0,
483
+ }
484
+ let objectRadius_m = Math.max(
485
+ (bounds.xMax - bounds.xMin) / 2000,
486
+ (bounds.yMax - bounds.yMin) / 2000
487
+ )
488
+
489
+ let distance =
490
+ 2 *
491
+ (objectRadius_m / Math.sin(((this.camera.fov / 2) * Math.PI) / 180))
492
+ let cameraMoveVector = { x: 0, y: 0, z: distance }
493
+ const positionVector = addVector(targetVector, cameraMoveVector)
494
+ position = [positionVector.x, positionVector.y - 1, positionVector.z]
495
+ target = [targetVector.x, targetVector.y, targetVector.z]
496
+ } else {
497
+ position = [0, -1, 300]
498
+ target = [0, 0, 0]
470
499
  }
500
+ this.setTweenTo({
501
+ position,
502
+ target,
503
+ duration,
504
+ })
471
505
  },
472
- setCameraGlobalVerticalPosition() {
506
+ setCameraGlobalVerticalPosition(changeCameraTypeAsCallback = true) {
473
507
  let position, target
474
508
  let newFov = 10
475
509
  if (this.roofs.length != 0) {
@@ -498,10 +532,12 @@ export default {
498
532
  position,
499
533
  target,
500
534
  fov: newFov,
501
- callback: this.turnPerspectiveCameraToOrthogonal,
535
+ callback: changeCameraTypeAsCallback
536
+ ? this.turnPerspectiveCameraToOrthogonal
537
+ : undefined,
502
538
  })
503
539
  },
504
- setCameraOrthogonalTo(polygon) {
540
+ setCameraOrthogonalTo(polygon, { duration = 1000 } = {}) {
505
541
  if (polygon) {
506
542
  let polygonRef = polygon
507
543
  const targetVector = polygonRef.meanPoint
@@ -519,7 +555,7 @@ export default {
519
555
  positionVector.y / 1000 - 1,
520
556
  positionVector.z / 1000,
521
557
  ]
522
- this.setTweenTo({ position, target })
558
+ this.setTweenTo({ position, target, duration })
523
559
  }
524
560
  },
525
561
  setCameraSideTo(polygon) {
@@ -553,11 +589,24 @@ export default {
553
589
  position,
554
590
  target,
555
591
  fov = 50,
556
- duration = 2000,
592
+ duration = 1500,
557
593
  callback = () => {},
558
594
  } = payload
559
595
  TWEEN.removeAll()
560
596
  if (this.camera) {
597
+ if (duration == 0) {
598
+ this.camera.fov = fov
599
+ this.camera.position.set(position[0], position[1], position[2])
600
+
601
+ this.camera.updateProjectionMatrix()
602
+
603
+ this.orbitControl.target.set(target[0], target[1], target[2])
604
+ if (this.orbitControl && this.orbitControl.update) {
605
+ this.orbitControl.update()
606
+ }
607
+ callback()
608
+ return
609
+ }
561
610
  const currentTweenVar = {
562
611
  t: 0,
563
612
  }
@@ -60,7 +60,7 @@ export default {
60
60
  (edge.layer != 'moduleField' ||
61
61
  !this.selectedModuleField ||
62
62
  !edge.belongsTo
63
- .map((i) => i.polygonId)
63
+ .map((i) => i.itemId)
64
64
  .includes(this.selectedModuleField.id))
65
65
  ) {
66
66
  return
@@ -263,7 +263,7 @@ export function getBufferWallGeometry(polygon) {
263
263
  // itemSize = 3 because there are 3 values (components) per vertex
264
264
  geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3))
265
265
  geometry.computeVertexNormals()
266
-
266
+ geometry.userData.version = 0
267
267
  return geometry
268
268
  }
269
269
 
@@ -321,6 +321,7 @@ export function getBufferObstacleGeometry(obstaclePolygon, roofPolygon) {
321
321
  // itemSize = 3 because there are 3 values (components) per vertex
322
322
  geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3))
323
323
  geometry.computeVertexNormals()
324
+ geometry.userData.version = 0
324
325
  return geometry
325
326
  }
326
327
 
@@ -405,6 +406,7 @@ export function getBufferObstacleSideGeometry(obstaclePolygon, roofPolygon) {
405
406
  // itemSize = 3 because there are 3 values (components) per vertex
406
407
  geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3))
407
408
  geometry.computeVertexNormals()
409
+ geometry.userData.version = 0
408
410
  return geometry
409
411
  }
410
412
 
@@ -440,6 +442,7 @@ export function getBufferModuleFieldGeometry(moduleFieldPolygon) {
440
442
  geometry.setAttribute('uv', new THREE.BufferAttribute(uvs, 2))
441
443
 
442
444
  geometry.computeVertexNormals()
445
+ geometry.userData.version = 0
443
446
  return geometry
444
447
  }
445
448
 
@@ -485,6 +488,7 @@ export function getBufferImageOverlayGeometry(corners) {
485
488
  geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3))
486
489
  geometry.setAttribute('uv', new THREE.BufferAttribute(uvs, 2))
487
490
  geometry.computeVertexNormals()
491
+ geometry.userData.version = 0
488
492
  return geometry
489
493
  }
490
494
  export function getPanelOutlineWithHeightOffset(panelPolygon) {
@@ -525,6 +529,7 @@ export function getBufferPanelGeometry(panelPolygon) {
525
529
  geometry.setAttribute('uv', new THREE.BufferAttribute(uvs, 2))
526
530
 
527
531
  geometry.computeVertexNormals()
532
+ geometry.userData.version = 0
528
533
  return geometry
529
534
  }
530
535
  export function updateBufferPanelGeometry(panelPolygon, geometry) {
@@ -635,6 +640,7 @@ export function getBufferPanelSideGeometry(panelPolygon) {
635
640
  // itemSize = 3 because there are 3 values (components) per vertex
636
641
  geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3))
637
642
  geometry.computeVertexNormals()
643
+ geometry.userData.version = 0
638
644
  return geometry
639
645
  }
640
646
 
@@ -6,9 +6,12 @@ export default {
6
6
  const mergedVertices = []
7
7
  const mergedNormals = []
8
8
  const mergedUvs = []
9
- const geometryVersion = mergedGeometry.userData.version || 0
9
+ const geometryVersion = mergedGeometry?.userData?.version || 0
10
10
  let geometryChanged = false
11
11
  geometries.forEach((geometry) => {
12
+ if (!geometry || !geometry.attributes?.position || !geometry.attributes?.normal) {
13
+ return
14
+ }
12
15
  const positions = geometry.attributes.position.array
13
16
  const normals = geometry.attributes.normal.array
14
17
  mergedVertices.push(...positions.slice(0, 3 * geometry.drawRange.count))
@@ -66,6 +69,9 @@ export default {
66
69
  const mergedUvs = []
67
70
 
68
71
  geometries.forEach((geometry) => {
72
+ if (!geometry || !geometry.attributes?.position || !geometry.attributes?.normal) {
73
+ return
74
+ }
69
75
  const positions = geometry.attributes.position.array
70
76
  const normals = geometry.attributes.normal.array
71
77
 
@@ -96,11 +102,16 @@ export default {
96
102
  },
97
103
 
98
104
  updateOrCreateMergedMesh(mesh, geometries, material) {
99
- if (!mesh) {
105
+ if (!mesh || !mesh.geometry) {
100
106
  let mergedGeometry = this.createMergedGeometry(geometries)
101
- mesh = new THREE.Mesh(mergedGeometry, material)
102
- // Add the merged mesh to the scene
103
- this.scene.add(mesh)
107
+ if (!mesh) {
108
+ mesh = new THREE.Mesh(mergedGeometry, material)
109
+ // Add the merged mesh to the scene
110
+ this.scene.add(mesh)
111
+ } else {
112
+ mesh.geometry = mergedGeometry
113
+ if (material) mesh.material = material
114
+ }
104
115
  } else {
105
116
  let mergedGeometry = this.updateMergedGeometry(
106
117
  geometries,
@@ -99,8 +99,10 @@ export default {
99
99
  geometry = mesh.geometry
100
100
  geometry = this.updateRoofGeometry(geometry, roofPolygon)
101
101
  //in order to be able to render multiple material on it (background and image overlay)
102
- mesh.geometry = geometry
103
- mesh.updateMatrix()
102
+ if (geometry) {
103
+ mesh.geometry = geometry
104
+ mesh.updateMatrix()
105
+ }
104
106
  }
105
107
 
106
108
  if (!this.meshes.roofMeshes[roofPolygon.id]) {
@@ -137,7 +139,9 @@ export default {
137
139
  [],
138
140
  mesh.geometry
139
141
  )
140
- mesh.geometry = geometry
142
+ if (geometry) {
143
+ mesh.geometry = geometry
144
+ }
141
145
  mesh.userData.version = roofPolygon.version
142
146
  }
143
147
  mesh.visible = roofPolygon.maximumGap > maximumGapLimit
@@ -10,7 +10,7 @@ export function getEdgesForHorizonForShader(plane, edges) {
10
10
  let obstacleEdgesForHorizon = edges
11
11
  .filter((e) => e.layer == 'obstacle')
12
12
  .map((e) => {
13
- const obstaclePolygon = e.belongsTo[0].polygon
13
+ const obstaclePolygon = e.belongsTo[0].item
14
14
  let obstacleHeight
15
15
  if (obstaclePolygon.isParallel) {
16
16
  obstacleHeight = parseInt(obstaclePolygon.height || 0)
@@ -1,7 +1,7 @@
1
1
  export default {
2
2
  methods: {
3
3
  applyTextureOnMesh(materials, mesh) {
4
- if (mesh && materials && materials.length > 0) {
4
+ if (mesh && mesh.geometry && materials && materials.length > 0) {
5
5
  const materialsVersionsOnMesh = mesh.userData.materialsVersions
6
6
  if (materialsVersionsOnMesh) {
7
7
  const materialUuids = materials.map((m) => m.uuid)
@@ -155,6 +155,14 @@ export default {
155
155
  arg: [],
156
156
  })
157
157
  break
158
+ case 'setCameraGlobalPositionImmediately':
159
+ methodList.push({
160
+ name: 'setCameraGlobalPositionImmediately',
161
+ method: this.setCameraGlobalPositionImmediately,
162
+ arg: [],
163
+ })
164
+ break
165
+
158
166
  case 'setCameraInitialPosition':
159
167
  methodList.push({
160
168
  name: 'setCameraInitialPosition',