Skip to content

Commit a6fa4c6

Browse files
author
Julien
committed
fix(sdk): simplify parsing of points
1 parent b3537a3 commit a6fa4c6

File tree

3 files changed

+4
-17
lines changed

3 files changed

+4
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.factorypath
12
target/
23
.settings
34
.classpath

engine/modules/entities/src/main/resources/view/entity-module/Polygon.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { Shape } from './Shape.js'
22

3-
/* global PIXI */
4-
53
export class Polygon extends Shape {
64
constructor () {
75
super()
@@ -28,9 +26,7 @@ export class Polygon extends Shape {
2826
}
2927

3028
this.graphics.lineStyle(globalData.atLeastOnePixel(state.lineWidth), state.lineColor, state.lineAlpha)
31-
this.graphics.drawPolygon(state.points.map(pos =>
32-
new PIXI.Point(pos.x * globalData.toWorldUnits, pos.y * globalData.toWorldUnits)
33-
))
29+
this.graphics.drawPolygon(state.points.map(coord => coord * globalData.toWorldUnits))
3430
if (state.fillColor !== null) {
3531
this.graphics.endFill()
3632
}

engine/modules/entities/src/main/resources/view/entity-module/properties.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {lerp, lerpColor, lerpAngle} from '../core/utils.js'
1+
import { lerp, lerpColor, lerpAngle } from '../core/utils.js'
22

33
const noLerp = (a, b, u) => u < 1 ? a : b
44
const timeLerp = (a, b, u) => b < a ? b : lerp(a, b, u)
@@ -116,17 +116,7 @@ export const PROPERTIES = {
116116
if (!value) {
117117
return []
118118
}
119-
const points = []
120-
let currentPoint = {}
121-
value.split(',').forEach((coord, idx) => {
122-
currentPoint['xy'[idx % 2]] = parseInt(coord)
123-
if (idx % 2 == 1) {
124-
points.push(currentPoint)
125-
currentPoint = {}
126-
}
127-
});
128-
129-
return points
119+
return value.split(',').map(v => parseInt(v))
130120
}
131121
}
132122
}

0 commit comments

Comments
 (0)