@eturnity/eturnity_maths 7.48.2 → 7.51.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": "7.48.2",
3
+ "version": "7.51.0",
4
4
  "author": "Eturnity Team",
5
5
  "main": "src/index.js",
6
6
  "private": false,
package/src/geometry.js CHANGED
@@ -848,19 +848,19 @@ export function groupAdjacentObjects(objects) {
848
848
  if (visited.indexOf(currentObjectIndex) == -1) {
849
849
  //if next queued index hasn't been visited, we mark it as visited and we collect all neighbourg to queue
850
850
  visited.push(currentObjectIndex)
851
- let x = objects[currentObjectIndex].index[0]
852
- let y = objects[currentObjectIndex].index[1]
851
+ let x = objects[currentObjectIndex].row_index
852
+ let y = objects[currentObjectIndex].col_index
853
853
  const left = objects.findIndex(
854
- (o) => o.index[0] == x - 1 && o.index[1] == y
854
+ (o) => o.row_index == x - 1 && o.col_index == y
855
855
  )
856
856
  const right = objects.findIndex(
857
- (o) => o.index[0] == x + 1 && o.index[1] == y
857
+ (o) => o.row_index == x + 1 && o.col_index == y
858
858
  )
859
859
  const top = objects.findIndex(
860
- (o) => o.index[0] == x && o.index[1] == y - 1
860
+ (o) => o.row_index == x && o.col_index == y - 1
861
861
  )
862
862
  const bottom = objects.findIndex(
863
- (o) => o.index[0] == x && o.index[1] == y + 1
863
+ (o) => o.row_index == x && o.col_index == y + 1
864
864
  )
865
865
  if (left != -1 && visited.indexOf(left) == -1) queue.push(left)
866
866
  if (right != -1 && visited.indexOf(right) == -1) queue.push(right)
@@ -887,19 +887,19 @@ export function areAdjacent(objects) {
887
887
  if (visited.indexOf(currentObjectIndex) == -1) {
888
888
  //if next queued index hasn't been visited, we mark it as visited and we collect all neighbourg to queue
889
889
  visited.push(currentObjectIndex)
890
- let x = objects[currentObjectIndex].index[0]
891
- let y = objects[currentObjectIndex].index[1]
890
+ let x = objects[currentObjectIndex].row_index
891
+ let y = objects[currentObjectIndex].col_index
892
892
  const left = objects.findIndex(
893
- (o) => o.index[0] == x - 1 && o.index[1] == y
893
+ (o) => o.row_index == x - 1 && o.col_index == y
894
894
  )
895
895
  const right = objects.findIndex(
896
- (o) => o.index[0] == x + 1 && o.index[1] == y
896
+ (o) => o.row_index == x + 1 && o.col_index == y
897
897
  )
898
898
  const top = objects.findIndex(
899
- (o) => o.index[0] == x && o.index[1] == y - 1
899
+ (o) => o.row_index == x && o.col_index == y - 1
900
900
  )
901
901
  const bottom = objects.findIndex(
902
- (o) => o.index[0] == x && o.index[1] == y + 1
902
+ (o) => o.row_index == x && o.col_index == y + 1
903
903
  )
904
904
  if (left != -1 && visited.indexOf(left) == -1) queue.push(left)
905
905
  if (right != -1 && visited.indexOf(right) == -1) queue.push(right)
@@ -38,8 +38,7 @@ export class Polygon {
38
38
  this.angleOffset = 0
39
39
  if (this.layer == 'obstacle') {
40
40
  this.isParallel = true
41
- }
42
- if (this.layer == 'roof') {
41
+ } else if (this.layer == 'roof') {
43
42
  this.moduleFields = []
44
43
  }
45
44
  }
@@ -244,7 +243,8 @@ export class Polygon {
244
243
  this.panels.forEach((p) => {
245
244
  modules.push({
246
245
  id: p.id,
247
- index: p.index,
246
+ row_index: p.row_index,
247
+ col_index: p.col_index,
248
248
  outline: p.outline,
249
249
  status: p.status || 'active',
250
250
  clipped: p.clipped || false,
@@ -255,7 +255,8 @@ export class Polygon {
255
255
  this.userDeactivatedPanels.forEach((p) => {
256
256
  modules.push({
257
257
  id: p.id,
258
- index: p.index,
258
+ row_index: p.row_index,
259
+ col_index: p.col_index,
259
260
  outline: p.outline,
260
261
  status: p.status || 'user_deactivated',
261
262
  clipped: p.clipped || false,
@@ -275,10 +276,12 @@ export class Polygon {
275
276
  extraSerialization.needsOptimisation = this.needsOptimisation
276
277
  extraSerialization.priority = this.priority
277
278
  } else if (this.layer == 'panel') {
278
- extraSerialization.index = this.index
279
+ extraSerialization.row_index = this.row_index
280
+ extraSerialization.col_index = this.col_index
279
281
  extraSerialization.moduleField = { id: this.moduleField.id }
280
282
  } else if (this.layer == 'user_deactivated_panel') {
281
- extraSerialization.index = this.index
283
+ extraSerialization.row_index = this.row_index
284
+ extraSerialization.col_index = this.col_index
282
285
  extraSerialization.moduleField = { id: this.moduleField.id }
283
286
  }
284
287
  return JSON.parse(
@@ -348,7 +351,8 @@ export class Polygon {
348
351
  } else if (['panel', 'user_deactivated_panel'].includes(this.layer)) {
349
352
  return {
350
353
  id: this.id,
351
- index: this.index,
354
+ row_index: this.row_index,
355
+ col_index: this.col_index,
352
356
  outline: this.outline.map((v) => [v.x, v.y, v.z]),
353
357
  moduleField: {
354
358
  id: this.moduleField.id,
@@ -16,10 +16,12 @@ export function hydratePolygon(serializedPolygon) {
16
16
  polygon.panels = []
17
17
  polygon.userDeactivatedPanels = []
18
18
  } else if (layer == 'panel') {
19
- polygon.index = serializedPolygon.index
19
+ polygon.row_index = serializedPolygon.row_index
20
+ polygon.col_index = serializedPolygon.col_index
20
21
  polygon.moduleField = serializedPolygon.moduleField
21
22
  } else if (layer == 'user_deactivated_panel') {
22
- polygon.index = serializedPolygon.index
23
+ polygon.row_index = serializedPolygon.row_index
24
+ polygon.col_index = serializedPolygon.col_index
23
25
  polygon.moduleField = serializedPolygon.moduleField
24
26
  }
25
27
  return polygon