@eturnity/eturnity_maths 6.32.0 → 6.33.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_maths",
3
- "version": "6.32.0",
3
+ "version": "6.33.0",
4
4
  "author": "Eturnity Team",
5
5
  "main": "src/index.js",
6
6
  "private": false,
@@ -21,7 +21,7 @@ export function updateComputedGeometryState(state) {
21
21
  })
22
22
  return state
23
23
  }
24
- export function updateOutlineFromInclineDirection(incline, direction, outline,initialAverageHeight) {
24
+ export function updateOutlineFromInclineDirection(incline, direction, outline,initialAverageHeight,isRoofOnRoof = false) {
25
25
  const newNormalVector = {}
26
26
  newNormalVector.x =
27
27
  Math.sin((incline * Math.PI) / 180) * Math.sin((direction * Math.PI) / 180)
@@ -29,14 +29,21 @@ export function updateOutlineFromInclineDirection(incline, direction, outline,in
29
29
  Math.sin((incline * Math.PI) / 180) * Math.cos((direction * Math.PI) / 180)
30
30
  newNormalVector.z = Math.cos((incline * Math.PI) / 180)
31
31
  let meanPoint = meanVector(outline)
32
- let minAltitude=Math.min(...outline.map(p=>p.z))
33
32
  meanPoint.z=initialAverageHeight
34
33
  let newOutline = outline.map((p) => {
35
34
  return verticalProjectionOnPlane(p, newNormalVector, meanPoint)
36
35
  })
37
36
  //if some points are with negative altitude, we offset the whole roof
38
- const newMinAltitude = Math.min(...newOutline.map((p) => p.z))
39
- let altitudeOffset=newMinAltitude-minAltitude
37
+ let altitudeOffset
38
+ let minAltitude=Math.min(...outline.map(p=>p.z))
39
+ let maxAltitude=Math.max(...outline.map(p=>p.z))
40
+ let newMinAltitude = Math.min(...newOutline.map((p) => p.z))
41
+ let newMaxAltitude = Math.max(...newOutline.map((p) => p.z))
42
+ if(isRoofOnRoof && maxAltitude!=0){
43
+ altitudeOffset=newMaxAltitude-maxAltitude
44
+ }else{
45
+ altitudeOffset=newMinAltitude-minAltitude
46
+ }
40
47
  newOutline.forEach((p) => (p.z -= altitudeOffset))
41
48
 
42
49
  //if some points are with altitude>50000, we limit those points