@eturnity/eturnity_3d 9.7.0 → 9.10.0

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": "9.7.0",
4
+ "version": "9.10.0",
5
5
  "files": [
6
6
  "dist",
7
7
  "src"
@@ -519,26 +519,7 @@ export function getBufferPanelGeometry(panelPolygon) {
519
519
  return null
520
520
  }
521
521
  const vertices = new Float32Array(trianglesVertices)
522
- var A = panelPolygon.outline[2]
523
- var B = panelPolygon.outline[3]
524
- var C = panelPolygon.outline[1]
525
- var D = panelPolygon.outline[0]
526
- const AB = getDistanceBetweenPoints(A, B)
527
- const AC = getDistanceBetweenPoints(A, C)
528
- let uvs
529
- if (AB < AC) {
530
- uvs = new Float32Array([
531
- 0, 1, 0, 0, 1, 0,
532
-
533
- 0, 1, 1, 0, 1, 1,
534
- ])
535
- } else {
536
- uvs = new Float32Array([
537
- 0, 0, 1, 0, 1, 1,
538
-
539
- 1, 0, 0, 1, 1, 1,
540
- ])
541
- }
522
+ const uvs = getPanelUVsFromOutline(panelPolygon.outline)
542
523
 
543
524
  geometry.setAttribute('position', new THREE.BufferAttribute(vertices, 3))
544
525
  geometry.setAttribute('uv', new THREE.BufferAttribute(uvs, 2))
@@ -549,9 +530,27 @@ export function getBufferPanelGeometry(panelPolygon) {
549
530
  export function updateBufferPanelGeometry(panelPolygon, geometry) {
550
531
  const panelOutlineTop = getPanelOutlineWithHeightOffset(panelPolygon)
551
532
  geometry = updateBufferRoofGeometry(panelOutlineTop, [], geometry)
533
+ if (geometry && panelPolygon.outline && panelPolygon.outline.length >= 4) {
534
+ const uvs = getPanelUVsFromOutline(panelPolygon.outline)
535
+ geometry.setAttribute('uv', new THREE.BufferAttribute(uvs, 2))
536
+ geometry.attributes.uv.needsUpdate = true
537
+ }
552
538
  return geometry
553
539
  }
554
540
 
541
+ export function getPanelUVsFromOutline(outline) {
542
+ const A = outline[3]
543
+ const B = outline[2]
544
+ const C = outline[0]
545
+ const AB = getDistanceBetweenPoints(A, B)
546
+ const AC = getDistanceBetweenPoints(A, C)
547
+ const uvs =
548
+ AB < AC
549
+ ? new Float32Array([0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1])
550
+ : new Float32Array([1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0])
551
+ return uvs
552
+ }
553
+
555
554
  export function getTriangleVerticesForSidePanels(outlineBottom, outlineUp) {
556
555
  const triangleVertices = []
557
556
  const length = outlineBottom.length