@makefully/platypus 4.1.5 → 4.1.6
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/CHANGELOG.md +10 -0
- package/README.md +3 -3
- package/lib/platypus.js +1 -1
- package/package.json +6 -5
- package/src/AABB.js +685 -0
- package/src/ActionState.js +121 -0
- package/src/AssetManager.js +206 -0
- package/src/CollisionData.js +96 -0
- package/src/CollisionDataContainer.js +127 -0
- package/src/CollisionShape.js +315 -0
- package/src/Component.js +231 -0
- package/src/Data.js +64 -0
- package/src/DataMap.js +204 -0
- package/src/Entity.js +404 -0
- package/src/EntityLinker.js +113 -0
- package/src/EventHandler.js +115 -0
- package/src/EventHandlerList.js +251 -0
- package/src/Game.js +840 -0
- package/src/Gamepad.js +175 -0
- package/src/ID3CaptionPlayer.js +61 -0
- package/src/Messenger.js +365 -0
- package/src/PIXIAnimation.js +622 -0
- package/src/RandomSet.js +140 -0
- package/src/SFXPlayer.js +120 -0
- package/src/StateMap.js +252 -0
- package/src/Storage.js +152 -0
- package/src/TickerClient.js +48 -0
- package/src/TickerServer.js +23 -0
- package/src/TimeEvent.js +50 -0
- package/src/TimeEventList.js +100 -0
- package/src/VOPlayer.js +684 -0
- package/src/Vector.js +702 -0
- package/src/components/AIChaser.js +161 -0
- package/src/components/AIPacer.js +107 -0
- package/src/components/AudioMusic.js +151 -0
- package/src/components/AudioSFX.js +673 -0
- package/src/components/AudioVO.js +301 -0
- package/src/components/CollisionBasic.js +826 -0
- package/src/components/CollisionFilter.js +74 -0
- package/src/components/CollisionGroup.js +448 -0
- package/src/components/CollisionTiles.js +608 -0
- package/src/components/ComponentSwitcher.js +173 -0
- package/src/components/ControllerInput.js +65 -0
- package/src/components/Counter.js +165 -0
- package/src/components/EntityCamera.js +215 -0
- package/src/components/EntityContainer.js +549 -0
- package/src/components/EntityController.js +541 -0
- package/src/components/HandlerCamera.js +1052 -0
- package/src/components/HandlerCollision.js +1318 -0
- package/src/components/HandlerController.js +291 -0
- package/src/components/HandlerLogic.js +394 -0
- package/src/components/HandlerRender.js +217 -0
- package/src/components/Interactive.js +502 -0
- package/src/components/LevelBuilder.js +524 -0
- package/src/components/LogicAngularMovement.js +154 -0
- package/src/components/LogicAttachment.js +265 -0
- package/src/components/LogicButton.js +466 -0
- package/src/components/LogicCarrier.js +39 -0
- package/src/components/LogicDestroyMe.js +58 -0
- package/src/components/LogicDirectionalMovement.js +325 -0
- package/src/components/LogicDragDrop.js +371 -0
- package/src/components/LogicImpactLaunch.js +144 -0
- package/src/components/LogicPacingPlatform.js +64 -0
- package/src/components/LogicPortable.js +112 -0
- package/src/components/LogicPortal.js +115 -0
- package/src/components/LogicPushable.js +98 -0
- package/src/components/LogicRebounder.js +136 -0
- package/src/components/LogicRegionSpawner.js +139 -0
- package/src/components/LogicRotationalMovement.js +205 -0
- package/src/components/LogicSpawner.js +159 -0
- package/src/components/LogicStateMachine.js +382 -0
- package/src/components/LogicSwitch.js +77 -0
- package/src/components/LogicTeleportee.js +68 -0
- package/src/components/LogicTeleporter.js +93 -0
- package/src/components/LogicTimer.js +178 -0
- package/src/components/LogicWindUpRacer.js +179 -0
- package/src/components/Motion.js +371 -0
- package/src/components/Mover.js +566 -0
- package/src/components/Node.js +289 -0
- package/src/components/NodeMap.js +295 -0
- package/src/components/NodeResident.js +636 -0
- package/src/components/Orientation.js +697 -0
- package/src/components/RandomEvents.js +73 -0
- package/src/components/RelativePosition.js +204 -0
- package/src/components/RelayFamily.js +106 -0
- package/src/components/RelayGame.js +53 -0
- package/src/components/RelayLinker.js +94 -0
- package/src/components/RelayParent.js +57 -0
- package/src/components/RelaySelf.js +55 -0
- package/src/components/Render.js +178 -0
- package/src/components/RenderAnimator.js +275 -0
- package/src/components/RenderContainer.js +646 -0
- package/src/components/RenderDebug.js +319 -0
- package/src/components/RenderDestroyMe.js +59 -0
- package/src/components/RenderLottie.js +149 -0
- package/src/components/RenderProgress.js +120 -0
- package/src/components/RenderSpine.js +833 -0
- package/src/components/RenderSprite.js +527 -0
- package/src/components/RenderText.js +147 -0
- package/src/components/RenderTiles.js +1391 -0
- package/src/components/SceneChanger.js +128 -0
- package/src/components/TiledLoader.js +1451 -0
- package/src/components/Timeline.js +314 -0
- package/src/components/Tutorial.js +267 -0
- package/src/components/Tween.js +296 -0
- package/src/components/VoiceOver.js +373 -0
- package/src/components/XHR.js +129 -0
- package/src/components/index.js +79 -0
- package/src/factory.js +305 -0
- package/src/index.js +159 -0
- package/src/mixins/PIXI.Graphics.js +41 -0
- package/src/platypus.css +68 -0
- package/src/sayHello.js +50 -0
- package/src/shapes/Capsule.js +74 -0
- package/src/shapes/Circle.js +43 -0
- package/src/shapes/Ellipse.js +117 -0
- package/src/shapes/Point.js +191 -0
- package/src/shapes/Polygon.js +112 -0
- package/src/shapes/Polyline.js +97 -0
- package/src/shapes/Rectangle.js +78 -0
- package/src/shapes/RoundedRectangle.js +33 -0
- package/src/shapes/Segment.js +346 -0
- package/src/shapes/adjustedXY.js +19 -0
- package/src/shapes/castFromBox2D.js +92 -0
- package/src/shapes/castFromObject.js +53 -0
- package/src/shapes/castFromPixiGraphics.js +6 -0
- package/src/shapes/castFromPixiShape.js +89 -0
- package/src/shapes/castToBox2D.js +190 -0
- package/src/shapes/castToPixiGraphics.js +100 -0
- package/src/shapes/castToPixiShape.js +61 -0
- package/src/shapes/checkPointsMap.js +313 -0
- package/src/shapes/index.js +35 -0
- package/src/utils/array.js +73 -0
- package/src/utils/string.js +39 -0
- package/lib/243.platypus.mjs +0 -1
- package/lib/platypus.mjs +0 -1
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
const
|
|
2
|
+
dot = (a, b) => a.x * b.x + a.y * b.y,
|
|
3
|
+
clamp01 = (val) => Math.max(0, Math.min(1, val)),
|
|
4
|
+
swap = (response) => {
|
|
5
|
+
if (response.list) {
|
|
6
|
+
return {
|
|
7
|
+
...response,
|
|
8
|
+
list: response.list.map((pair) => swap(pair)),
|
|
9
|
+
a: response.b,
|
|
10
|
+
b: response.a
|
|
11
|
+
}
|
|
12
|
+
} else {
|
|
13
|
+
return {
|
|
14
|
+
...response,
|
|
15
|
+
a: response.b,
|
|
16
|
+
b: response.a
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
subtractRadiusA = ({a, b, distance, list, intersects = false}) => {
|
|
21
|
+
const
|
|
22
|
+
{radius} = a;
|
|
23
|
+
|
|
24
|
+
if (radius >= distance) {
|
|
25
|
+
return {a: b, b, distance: 0, intersects: true};
|
|
26
|
+
} else {
|
|
27
|
+
const
|
|
28
|
+
outerDistance = distance - radius,
|
|
29
|
+
r = outerDistance / distance;
|
|
30
|
+
|
|
31
|
+
if (list) {
|
|
32
|
+
const
|
|
33
|
+
offsetList = list.map(({a, b}) => ({a: {
|
|
34
|
+
x: b.x + (a.x - b.x) * r,
|
|
35
|
+
y: b.y + (a.y - b.y) * r
|
|
36
|
+
}, b}));
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
a: offsetList[0],
|
|
40
|
+
b,
|
|
41
|
+
distance: outerDistance,
|
|
42
|
+
list: offsetList,
|
|
43
|
+
intersects
|
|
44
|
+
};
|
|
45
|
+
} else {
|
|
46
|
+
return {
|
|
47
|
+
a: {
|
|
48
|
+
x: b.x + (a.x - b.x) * r,
|
|
49
|
+
y: b.y + (a.y - b.y) * r,
|
|
50
|
+
},
|
|
51
|
+
b,
|
|
52
|
+
distance: outerDistance,
|
|
53
|
+
intersects
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
subtractRadiusB = ({a, b, distance, list, intersects = false}) => {
|
|
59
|
+
const
|
|
60
|
+
{radius} = b;
|
|
61
|
+
|
|
62
|
+
if (radius >= distance) {
|
|
63
|
+
return {a, b: a, distance: 0, intersects: true};
|
|
64
|
+
} else {
|
|
65
|
+
const
|
|
66
|
+
outerDistance = distance - radius,
|
|
67
|
+
r = outerDistance / distance;
|
|
68
|
+
|
|
69
|
+
if (list) {
|
|
70
|
+
const
|
|
71
|
+
offsetList = list.map(({a, b}) => ({a, b: {
|
|
72
|
+
x: a.x + (b.x - a.x) * r,
|
|
73
|
+
y: a.y + (b.y - a.y) * r
|
|
74
|
+
}}));
|
|
75
|
+
|
|
76
|
+
return {
|
|
77
|
+
a,
|
|
78
|
+
b: offsetList[0],
|
|
79
|
+
distance: outerDistance,
|
|
80
|
+
list: offsetList,
|
|
81
|
+
intersects
|
|
82
|
+
};
|
|
83
|
+
} else {
|
|
84
|
+
return {
|
|
85
|
+
a,
|
|
86
|
+
b: {
|
|
87
|
+
x: a.x + (b.x - a.x) * r,
|
|
88
|
+
y: a.y + (b.y - a.y) * r,
|
|
89
|
+
},
|
|
90
|
+
distance: outerDistance,
|
|
91
|
+
intersects
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
subtractRadii = (resp) => subtractRadiusA(subtractRadiusB(resp)),
|
|
97
|
+
polySegmentLoop = (shape, poly, test) => {
|
|
98
|
+
const closest = [];
|
|
99
|
+
let min = Infinity;
|
|
100
|
+
|
|
101
|
+
poly.forEach((segment) => {
|
|
102
|
+
const res = test(shape, segment);
|
|
103
|
+
if (res.distance < min) {
|
|
104
|
+
closest.length = 0;
|
|
105
|
+
closest.push(res);
|
|
106
|
+
min = res.distance;
|
|
107
|
+
} else if (res.distance === min) {
|
|
108
|
+
closest.push(res);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
return {a: closest[0].a, b: closest[0].b, list: closest, distance: min};
|
|
113
|
+
},
|
|
114
|
+
pointToPoint = (a, b) => ({a, b, distance: Math.hypot(b.x - a.x, b.y - a.y)}),
|
|
115
|
+
pointToSegment = (point, {a, b}) => {
|
|
116
|
+
const
|
|
117
|
+
ab = {x: b.x - a.x, y: b.y - a.y},
|
|
118
|
+
denom = dot(ab, ab);
|
|
119
|
+
|
|
120
|
+
if (denom === 0) {
|
|
121
|
+
return pointToPoint(point, a);
|
|
122
|
+
} else {
|
|
123
|
+
const
|
|
124
|
+
t = clamp01(dot({
|
|
125
|
+
x: point.x - a.x,
|
|
126
|
+
y: point.y - a.y
|
|
127
|
+
}, ab) / denom);
|
|
128
|
+
|
|
129
|
+
return pointToPoint(point, {
|
|
130
|
+
x: a.x + ab.x * t,
|
|
131
|
+
y: a.y + ab.y * t
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
pointToCapsule = (a, b) => subtractRadiusB(pointToSegment(a, b)),
|
|
136
|
+
pointToCircle = (a, b) => subtractRadiusB(pointToPoint(a, b)),
|
|
137
|
+
pointToPolyline = (point, polyline) => polySegmentLoop(point, polyline, pointToSegment),
|
|
138
|
+
pointToPolygon = (point, polygon) => ({
|
|
139
|
+
...polySegmentLoop(point, polygon, pointToSegment),
|
|
140
|
+
intersects: polygon.isPointInside(point)
|
|
141
|
+
}),
|
|
142
|
+
pointToRoundedPolygon = (a, b) => subtractRadiusB(pointToPolygon(a, b)),
|
|
143
|
+
segmentToPoint = (a, b) => swap(pointToSegment(b, a)),
|
|
144
|
+
segmentToSegment = (a, b) => {
|
|
145
|
+
// Vector form of the segments
|
|
146
|
+
const
|
|
147
|
+
{a: a1, b: b1} = a,
|
|
148
|
+
d1 = { x: b1.x - a1.x, y: b1.y - a1.y }, // Direction of a
|
|
149
|
+
sqr1 = dot(d1, d1); // squared length of d1
|
|
150
|
+
|
|
151
|
+
if (sqr1 === 0) {
|
|
152
|
+
return pointToSegment(a1, b);
|
|
153
|
+
} else {
|
|
154
|
+
const
|
|
155
|
+
{a: a2, b: b2} = b,
|
|
156
|
+
d2 = { x: b2.x - a2.x, y: b2.y - a2.y }, // Direction of b
|
|
157
|
+
sqr2 = dot(d2, d2); // squared length of d2
|
|
158
|
+
|
|
159
|
+
if (sqr2 === 0) {
|
|
160
|
+
return segmentToPoint(a, b1);
|
|
161
|
+
} else {
|
|
162
|
+
const
|
|
163
|
+
r = { x: a1.x - a2.x, y: a1.y - a2.y },
|
|
164
|
+
f = dot(d2, r),
|
|
165
|
+
c = dot(d1, r),
|
|
166
|
+
|
|
167
|
+
g = dot(d1, d2),
|
|
168
|
+
denom = sqr1 * sqr2 - g * g,
|
|
169
|
+
s = Math.abs(denom) > 0 ? clamp01((g * f - c * sqr2) / denom) : 0, // Parallel lines
|
|
170
|
+
t = clamp01((g * s + f) / sqr2),
|
|
171
|
+
cs = t === 0 ? clamp01(-c / sqr1) : t === 1 ? clamp01((g - c) / sqr1) : s;
|
|
172
|
+
|
|
173
|
+
return pointToPoint({
|
|
174
|
+
x: a1.x + d1.x * cs,
|
|
175
|
+
y: a1.y + d1.y * cs
|
|
176
|
+
}, {
|
|
177
|
+
x: a2.x + d2.x * t,
|
|
178
|
+
y: a2.y + d2.y * t
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
segmentToCapsule = (a, b) => subtractRadiusB(segmentToSegment(a, b)),
|
|
184
|
+
segmentToPoly = (segment, poly) => polySegmentLoop(segment, poly, segmentToSegment),
|
|
185
|
+
capsuleToPoint = (a, b) => swap(pointToCapsule(b, a)),
|
|
186
|
+
capsuleToSegment = (a, b) => swap(segmentToCapsule(b, a)),
|
|
187
|
+
capsuleToCapsule = (a, b) => subtractRadiusA(segmentToCapsule(a, b)),
|
|
188
|
+
capsuleToCircle = (a, b) => swap(circleToCapsule(b, a)),
|
|
189
|
+
capsuleToPoly = (a, b) => subtractRadiusA(segmentToPoly(a, b)),
|
|
190
|
+
capsuleToRoundedPoly = (a, b) => subtractRadii(segmentToPoly(a, b)),
|
|
191
|
+
circleToCapsule = (a, b) => subtractRadiusA(pointToCapsule(a, b)),
|
|
192
|
+
circleToPolygon = (a, b) => subtractRadiusA(pointToPolygon(a, b)),
|
|
193
|
+
ellipseToPoly = (a, b) => capsuleToPoly(a.toCapsule(), b),
|
|
194
|
+
polyToSegment = (poly, segment) => swap(segmentToPoly(segment, poly)),
|
|
195
|
+
polyToPoly = (a, b) => polySegmentLoop(a, b, polyToSegment),
|
|
196
|
+
polygonToPoint = (a, b) => swap(pointToPolygon(b, a)),
|
|
197
|
+
polyToCapsule = (a, b) => subtractRadiusB(polyToSegment(a, b)),
|
|
198
|
+
polygonToCircle = (a, b) => subtractRadiusB(polygonToPoint(a, b)),
|
|
199
|
+
polyToEllipse = (a, b) => polyToCapsule(a, b.toCapsule()),
|
|
200
|
+
polyToRoundedPoly = (a, b) => subtractRadiusB(polyToPoly(a, b)),
|
|
201
|
+
roundedPolyToCapsule = (a, b) => subtractRadii(polyToSegment(a, b)),
|
|
202
|
+
roundedPolyToPoly = (a, b) => subtractRadiusA(polyToPoly(a, b)),
|
|
203
|
+
point = {
|
|
204
|
+
point: pointToPoint,
|
|
205
|
+
segment: pointToSegment,
|
|
206
|
+
capsule: pointToCapsule,
|
|
207
|
+
circle: pointToCircle,
|
|
208
|
+
ellipse: (a, b) => pointToCapsule(a, b.toCapsule()),
|
|
209
|
+
polygon: pointToPolygon,
|
|
210
|
+
polyline: pointToPolyline,
|
|
211
|
+
rectangle: pointToPolygon,
|
|
212
|
+
roundedRectangle: pointToRoundedPolygon
|
|
213
|
+
},
|
|
214
|
+
segment = {
|
|
215
|
+
point: segmentToPoint,
|
|
216
|
+
segment: segmentToSegment,
|
|
217
|
+
capsule: segmentToCapsule,
|
|
218
|
+
circle: (a, b) => subtractRadiusB(segmentToPoint(a, b)),
|
|
219
|
+
ellipse: (a, b) => segmentToCapsule(a, b.toCapsule()),
|
|
220
|
+
polygon: segmentToPoly,
|
|
221
|
+
polyline: segmentToPoly,
|
|
222
|
+
rectangle: segmentToPoly,
|
|
223
|
+
roundedRectangle: (a, b) => subtractRadiusB(segmentToPoly(a, b))
|
|
224
|
+
},
|
|
225
|
+
capsule = {
|
|
226
|
+
point: capsuleToPoint,
|
|
227
|
+
segment: capsuleToSegment,
|
|
228
|
+
capsule: capsuleToCapsule,
|
|
229
|
+
circle: capsuleToCircle,
|
|
230
|
+
ellipse: (a, b) => capsuleToCapsule(a, b.toCapsule()),
|
|
231
|
+
polygon: capsuleToPoly,
|
|
232
|
+
polyline: capsuleToPoly,
|
|
233
|
+
rectangle: capsuleToPoly,
|
|
234
|
+
roundedRectangle: capsuleToRoundedPoly
|
|
235
|
+
},
|
|
236
|
+
circle = {
|
|
237
|
+
point: (a, b) => swap(pointToCircle(b, a)),
|
|
238
|
+
segment: (a, b) => subtractRadiusA(pointToSegment(a, b)),
|
|
239
|
+
capsule: circleToCapsule,
|
|
240
|
+
circle: (a, b) => subtractRadiusA(pointToCircle(a, b)),
|
|
241
|
+
ellipse: (a, b) => circleToCapsule(a, b.toCapsule()),
|
|
242
|
+
polygon: circleToPolygon,
|
|
243
|
+
polyline: (a, b) => subtractRadiusA(pointToPolyline(a, b)),
|
|
244
|
+
rectangle: circleToPolygon,
|
|
245
|
+
roundedRectangle: (a, b) => subtractRadii(pointToPolygon(a, b))
|
|
246
|
+
},
|
|
247
|
+
ellipse = {
|
|
248
|
+
point: (a, b) => capsuleToPoint(a.toCapsule(), b),
|
|
249
|
+
segment: (a, b) => capsuleToSegment(a.toCapsule(), b),
|
|
250
|
+
capsule: (a, b) => capsuleToCapsule(a.toCapsule(), b),
|
|
251
|
+
circle: (a, b) => capsuleToCircle(a.toCapsule(), b),
|
|
252
|
+
ellipse: (a, b) => capsuleToCapsule(a.toCapsule(), b.toCapsule()),
|
|
253
|
+
polygon: ellipseToPoly,
|
|
254
|
+
polyline: ellipseToPoly,
|
|
255
|
+
rectangle: ellipseToPoly,
|
|
256
|
+
roundedRectangle: (a, b) => capsuleToRoundedPoly(a.toCapsule(), b)
|
|
257
|
+
},
|
|
258
|
+
polygon = {
|
|
259
|
+
point: polygonToPoint,
|
|
260
|
+
segment: polyToSegment,
|
|
261
|
+
capsule: polyToCapsule,
|
|
262
|
+
circle: polygonToCircle,
|
|
263
|
+
ellipse: polyToEllipse,
|
|
264
|
+
polygon: polyToPoly,
|
|
265
|
+
polyline: polyToPoly,
|
|
266
|
+
rectangle: polyToPoly,
|
|
267
|
+
roundedRectangle: polyToRoundedPoly
|
|
268
|
+
},
|
|
269
|
+
polyline = {
|
|
270
|
+
point: (a, b) => swap(pointToPolyline(b, a)),
|
|
271
|
+
segment: polyToSegment,
|
|
272
|
+
capsule: polyToCapsule,
|
|
273
|
+
circle: (a, b) => subtractRadiusB(swap(pointToPolyline(b, a))),
|
|
274
|
+
ellipse: polyToEllipse,
|
|
275
|
+
polygon: polyToPoly,
|
|
276
|
+
polyline: polyToPoly,
|
|
277
|
+
rectangle: polyToPoly,
|
|
278
|
+
roundedRectangle: polyToRoundedPoly
|
|
279
|
+
},
|
|
280
|
+
rectangle = {
|
|
281
|
+
point: polygonToPoint,
|
|
282
|
+
segment: polyToSegment,
|
|
283
|
+
capsule: polyToCapsule,
|
|
284
|
+
circle: polygonToCircle,
|
|
285
|
+
ellipse: polyToEllipse,
|
|
286
|
+
polygon: polyToPoly,
|
|
287
|
+
polyline: polyToPoly,
|
|
288
|
+
rectangle: polyToPoly,
|
|
289
|
+
roundedRectangle: polyToRoundedPoly
|
|
290
|
+
},
|
|
291
|
+
roundedRectangle = {
|
|
292
|
+
point: (a, b) => swap(pointToRoundedPolygon(b, a)),
|
|
293
|
+
segment: (a, b) => subtractRadiusA(polyToSegment(a, b)),
|
|
294
|
+
capsule: roundedPolyToCapsule,
|
|
295
|
+
circle: (a, b) => subtractRadiusB(swap(subtractRadiusB(pointToPolygon(b, a)))),
|
|
296
|
+
ellipse: (a, b) => roundedPolyToCapsule(a, b.toCapsule()),
|
|
297
|
+
polygon: roundedPolyToPoly,
|
|
298
|
+
polyline: roundedPolyToPoly,
|
|
299
|
+
rectangle: roundedPolyToPoly,
|
|
300
|
+
roundedRectangle: (a, b) => subtractRadii(polyToPoly(a, b))
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export default {
|
|
304
|
+
capsule,
|
|
305
|
+
circle,
|
|
306
|
+
ellipse,
|
|
307
|
+
polygon,
|
|
308
|
+
polyline,
|
|
309
|
+
point,
|
|
310
|
+
rectangle,
|
|
311
|
+
roundedRectangle,
|
|
312
|
+
segment
|
|
313
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Capsule from "./Capsule";
|
|
2
|
+
import Circle from "./Circle";
|
|
3
|
+
import Ellipse from "./Ellipse";
|
|
4
|
+
import Polygon from "./Polygon";
|
|
5
|
+
import Polyline from "./Polyline";
|
|
6
|
+
import Rectangle from "./Rectangle";
|
|
7
|
+
import RoundedRectangle from "./RoundedRectangle";
|
|
8
|
+
import Segment from "./Segment";
|
|
9
|
+
import Point from "./Point";
|
|
10
|
+
import shapeFromBox2D from './castFromBox2D';
|
|
11
|
+
import shapeFromObject from './castFromObject';
|
|
12
|
+
import shapeFromPixiGraphics from './castFromPixiGraphics';
|
|
13
|
+
import shapeFromPixiShape from './castFromPixiShape';
|
|
14
|
+
import shapeToBox2D from './castToBox2D';
|
|
15
|
+
import shapeToPixiGraphics from './castToPixiGraphics';
|
|
16
|
+
import shapeToPixiShape from './castToPixiShape';
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
Capsule,
|
|
20
|
+
Circle,
|
|
21
|
+
Ellipse,
|
|
22
|
+
Polygon,
|
|
23
|
+
Polyline,
|
|
24
|
+
Rectangle,
|
|
25
|
+
RoundedRectangle,
|
|
26
|
+
Segment,
|
|
27
|
+
Point,
|
|
28
|
+
shapeFromBox2D,
|
|
29
|
+
shapeFromObject,
|
|
30
|
+
shapeFromPixiGraphics,
|
|
31
|
+
shapeFromPixiShape,
|
|
32
|
+
shapeToBox2D,
|
|
33
|
+
shapeToPixiGraphics,
|
|
34
|
+
shapeToPixiShape
|
|
35
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import recycle from 'recycle';
|
|
2
|
+
|
|
3
|
+
export const arrayCache = recycle.add(Array, 'Array', null, null, false);
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Merges items from one array into the other, making sure to not duplicate identical entries.
|
|
7
|
+
*
|
|
8
|
+
* @method union
|
|
9
|
+
* @param arrayTo {Array} The array into which items will be inserted.
|
|
10
|
+
* @param ...arrayFrom {Array} The array(s) containing items to be merged.
|
|
11
|
+
* @return Array
|
|
12
|
+
*/
|
|
13
|
+
export function union (arrayTo, ...arrayFrom) {
|
|
14
|
+
|
|
15
|
+
for (let i = 0; i < arrayFrom.length; i++) {
|
|
16
|
+
const incoming = arrayFrom[i];
|
|
17
|
+
|
|
18
|
+
if (incoming && incoming.length) {
|
|
19
|
+
for (let j = 0; j < incoming.length; j++) {
|
|
20
|
+
if (arrayTo.indexOf(incoming[j]) === -1) {
|
|
21
|
+
arrayTo.push(incoming[j]);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return arrayTo;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Slices, but uses a recycled array. Note that this slice does not accept parameters and makes a shallow copy of the original array.
|
|
32
|
+
*
|
|
33
|
+
* @method greenSlice
|
|
34
|
+
* @param array {Array} The array to copy.
|
|
35
|
+
* @return Array
|
|
36
|
+
*/
|
|
37
|
+
export function greenSlice (array) {
|
|
38
|
+
const
|
|
39
|
+
arr = arrayCache.setUp(),
|
|
40
|
+
len = array.length;
|
|
41
|
+
|
|
42
|
+
for (let i = 0; i < len; i++) {
|
|
43
|
+
arr[i] = array[i];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return arr;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Splices, but only removes a single item and returns the item itself, not an array.
|
|
51
|
+
*
|
|
52
|
+
* @method greenSplice
|
|
53
|
+
* @param array {Array} The array from which an item is to be extracted.
|
|
54
|
+
* @param index {Number} The index of the item to extract.
|
|
55
|
+
* @return {any}
|
|
56
|
+
*/
|
|
57
|
+
export function greenSplice (array, index) {
|
|
58
|
+
const
|
|
59
|
+
item = array[index],
|
|
60
|
+
len = array.length;
|
|
61
|
+
|
|
62
|
+
if ((index < 0) || (index >= len)) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
for (let i = index + 1; i < len; i++) {
|
|
67
|
+
array[i - 1] = array[i];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
array.length -= 1;
|
|
71
|
+
|
|
72
|
+
return item;
|
|
73
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {arrayCache} from './array.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Splits a string, but populates an array from the array cache instead of creating a new one.
|
|
5
|
+
*
|
|
6
|
+
* @method greenSplit
|
|
7
|
+
* @param text {String} String to split.
|
|
8
|
+
* @param [splitter] {String} String demarking where to split. If not provided, each character in the split string becomes an array item.
|
|
9
|
+
* @return Array
|
|
10
|
+
*/
|
|
11
|
+
export function greenSplit (text, splitter) {
|
|
12
|
+
const
|
|
13
|
+
arr = arrayCache.setUp();
|
|
14
|
+
let str = text.toString();
|
|
15
|
+
|
|
16
|
+
if (splitter) {
|
|
17
|
+
const
|
|
18
|
+
d = splitter.length;
|
|
19
|
+
let i = str.indexOf(splitter);
|
|
20
|
+
|
|
21
|
+
while (i >= 0) {
|
|
22
|
+
arr.push(str.substr(0, i));
|
|
23
|
+
str = str.substr(i + d);
|
|
24
|
+
i = str.indexOf(splitter);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
arr.push(str);
|
|
28
|
+
} else {
|
|
29
|
+
let i = str.length;
|
|
30
|
+
const
|
|
31
|
+
d = i - 1;
|
|
32
|
+
|
|
33
|
+
while (i--) {
|
|
34
|
+
arr.push(str[d - i]);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return arr;
|
|
39
|
+
}
|
package/lib/243.platypus.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
self.onmessage=({data:e})=>{let a=0;if(e.begin){let t=performance.now();clearInterval(a),a=setInterval(()=>{const e=performance.now();self.postMessage({deltaTime:e-t}),t=e},e.begin.delta)}e.stop&&clearInterval(a)};
|