@safe-engine/pixi 8.4.6 → 8.5.1
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/README.md +14 -23
- package/dist/box2d-wasm/ContactListener.d.ts +1 -1
- package/dist/box2d-wasm/ContactListener.d.ts.map +1 -1
- package/dist/box2d-wasm/ContactListener.js +50 -18
- package/dist/box2d-wasm/PhysicsComponent.d.ts +27 -30
- package/dist/box2d-wasm/PhysicsComponent.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsComponent.js +44 -11
- package/dist/box2d-wasm/PhysicsSprite.d.ts +3 -0
- package/dist/box2d-wasm/PhysicsSprite.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsSprite.js +24 -3
- package/dist/box2d-wasm/PhysicsSystem.d.ts +4 -2
- package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsSystem.js +134 -44
- package/dist/collider/CollideComponent.d.ts +27 -10
- package/dist/collider/CollideComponent.d.ts.map +1 -1
- package/dist/collider/CollideComponent.js +10 -12
- package/dist/collider/helper/Intersection.d.ts +6 -6
- package/dist/collider/helper/Intersection.d.ts.map +1 -1
- package/dist/collider/helper/Intersection.js +4 -4
- package/dist/components/NodeComp.js +1 -1
- package/dist/helper/utils.d.ts +0 -6
- package/dist/helper/utils.d.ts.map +1 -1
- package/dist/helper/utils.js +0 -12
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/{src/spine/lib/require-shim.ts → dist/spine/lib/assets/atlasLoader.d.ts} +5 -14
- package/dist/spine/lib/assets/atlasLoader.d.ts.map +1 -0
- package/dist/spine/lib/assets/atlasLoader.js +122 -0
- package/{src/spine/lib/darktint/DarkTintShader.ts → dist/spine/lib/assets/skeletonLoader.d.ts} +3 -47
- package/dist/spine/lib/assets/skeletonLoader.d.ts.map +1 -0
- package/dist/spine/lib/assets/skeletonLoader.js +70 -0
- package/package.json +6 -2
- package/.github/workflows/npm-publish.yml +0 -35
- package/dist/@types/safex.d.ts +0 -15
- package/src/@types/index.d.ts +0 -2
- package/src/app.ts +0 -91
- package/src/base/EnhancedComponent.ts +0 -38
- package/src/base/gworld.ts +0 -20
- package/src/base/index.ts +0 -14
- package/src/base/utils.ts +0 -23
- package/src/box2d-wasm/ContactListener.ts +0 -66
- package/src/box2d-wasm/PhysicsComponent.ts +0 -83
- package/src/box2d-wasm/PhysicsSprite.ts +0 -42
- package/src/box2d-wasm/PhysicsSystem.ts +0 -142
- package/src/box2d-wasm/debugDraw.ts +0 -249
- package/src/box2d-wasm/index.ts +0 -19
- package/src/collider/CollideComponent.ts +0 -257
- package/src/collider/CollideSystem.ts +0 -166
- package/src/collider/helper/Intersection.ts +0 -139
- package/src/collider/helper/utils.ts +0 -37
- package/src/collider/index.ts +0 -16
- package/src/components/BaseComponent.ts +0 -17
- package/src/components/NodeComp.ts +0 -442
- package/src/components/Scene.ts +0 -17
- package/src/core/Color.ts +0 -7
- package/src/core/LoadingBar.ts +0 -63
- package/src/core/NodePool.ts +0 -28
- package/src/core/Size.ts +0 -21
- package/src/core/Vec2.ts +0 -108
- package/src/core/director.ts +0 -11
- package/src/core/index.ts +0 -7
- package/src/core/loader.ts +0 -14
- package/src/core/math.ts +0 -22
- package/src/dragonbones/DragonBonesComponent.ts +0 -32
- package/src/dragonbones/DragonBonesSystem.ts +0 -35
- package/src/dragonbones/index.ts +0 -11
- package/src/gui/GUIComponent.ts +0 -155
- package/src/gui/GUISystem.ts +0 -125
- package/src/helper/utils.ts +0 -50
- package/src/index.ts +0 -19
- package/src/norender/NoRenderComponent.ts +0 -60
- package/src/norender/NoRenderSystem.ts +0 -67
- package/src/norender/Touch.ts +0 -37
- package/src/planck/PhysicsComponent.ts +0 -83
- package/src/planck/PhysicsSprite.ts +0 -43
- package/src/planck/PhysicsSystem.ts +0 -201
- package/src/planck/index.ts +0 -3
- package/src/render/RenderComponent.ts +0 -132
- package/src/render/RenderSystem.ts +0 -64
- package/src/richtext/RichTextComp.ts +0 -50
- package/src/richtext/RichTextSystem.ts +0 -26
- package/src/richtext/html-text-parser.ts +0 -87
- package/src/richtext/index.ts +0 -8
- package/src/spine/SpineComponent.ts +0 -18
- package/src/spine/SpineSystem.ts +0 -30
- package/src/spine/index.ts +0 -11
- package/src/spine/lib/BatchableSpineSlot.ts +0 -138
- package/src/spine/lib/Spine.ts +0 -894
- package/src/spine/lib/SpineDebugRenderer.ts +0 -615
- package/src/spine/lib/SpinePipe.ts +0 -203
- package/src/spine/lib/SpineTexture.ts +0 -143
- package/src/spine/lib/darktint/DarkTintBatchGeometry.ts +0 -92
- package/src/spine/lib/darktint/DarkTintBatcher.ts +0 -186
- package/src/spine/lib/darktint/darkTintBit.ts +0 -77
- package/src/spine/lib/index.ts +0 -43
- package/tsconfig.json +0 -18
- /package/{dist/@types → @types}/index.d.ts +0 -0
|
@@ -7,24 +7,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
-
var t = {};
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
-
t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
10
|
import Box2DFactory from 'box2d-wasm';
|
|
22
11
|
import { EventTypes } from 'entityx-ts';
|
|
23
12
|
import { Graphics } from 'pixi.js';
|
|
24
|
-
import { GameWorld, instantiate, NodeComp } from '..';
|
|
13
|
+
import { GameWorld, instantiate, NodeComp, Vec2 } from '..';
|
|
25
14
|
import { makeContactListener } from './ContactListener';
|
|
26
15
|
import { makeDebugDraw } from './debugDraw';
|
|
27
|
-
import {
|
|
16
|
+
import { PhysicsBoxCollider, PhysicsCircleCollider, PhysicsPolygonCollider, RigidBody } from './PhysicsComponent';
|
|
28
17
|
import { PhysicsSprite } from './PhysicsSprite';
|
|
29
18
|
// Box2D.b2Fixture.prototype.shouldCollide = function (other) {
|
|
30
19
|
// const nodeThis: NodeComp = this.getBody().getUserData()
|
|
@@ -32,6 +21,9 @@ import { PhysicsSprite } from './PhysicsSprite';
|
|
|
32
21
|
// const { colliderMatrix } = GameWorld.Instance.systems.get(PhysicsSystem)
|
|
33
22
|
// return colliderMatrix[nodeOther.group][nodeThis.group]
|
|
34
23
|
// }
|
|
24
|
+
export const DynamicBody = 2;
|
|
25
|
+
export const KinematicBody = 1;
|
|
26
|
+
export const StaticBody = 0;
|
|
35
27
|
export let box2D;
|
|
36
28
|
export function initBox2d() {
|
|
37
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -50,7 +42,7 @@ const pixelsPerMeter = 1;
|
|
|
50
42
|
export class PhysicsSystem {
|
|
51
43
|
constructor() {
|
|
52
44
|
this.listRemoveBody = [];
|
|
53
|
-
|
|
45
|
+
// listRemoveShape: Box2D.b2Shape[] = []
|
|
54
46
|
this.colliderMatrix = [[true]];
|
|
55
47
|
}
|
|
56
48
|
addDebug() {
|
|
@@ -58,7 +50,7 @@ export class PhysicsSystem {
|
|
|
58
50
|
this.world.SetDebugDraw(debugDraw);
|
|
59
51
|
}
|
|
60
52
|
configure(event_manager) {
|
|
61
|
-
const { b2BodyDef,
|
|
53
|
+
const { b2BodyDef, b2FixtureDef, b2PolygonShape, b2CircleShape, b2Vec2, b2World, pointsToVec2Array, getPointer } = box2D;
|
|
62
54
|
const gravity = new b2Vec2(0, 10);
|
|
63
55
|
this.world = new b2World(gravity);
|
|
64
56
|
console.log('configure world', event_manager.world.app);
|
|
@@ -66,69 +58,167 @@ export class PhysicsSystem {
|
|
|
66
58
|
const graphics = new Graphics();
|
|
67
59
|
this.graphics = graphics;
|
|
68
60
|
graphics.zIndex = 1000;
|
|
69
|
-
event_manager.world
|
|
61
|
+
const { app } = event_manager.world;
|
|
62
|
+
app.stage.addChild(graphics);
|
|
70
63
|
// event_manager.subscribe(ComponentAddedEvent(RigidBody), this);
|
|
71
|
-
event_manager.subscribe(EventTypes.ComponentAdded,
|
|
72
|
-
console.log('ComponentAddedEvent BoxColliderPhysics',
|
|
64
|
+
event_manager.subscribe(EventTypes.ComponentAdded, PhysicsBoxCollider, ({ entity, component: box }) => {
|
|
65
|
+
console.log('ComponentAddedEvent BoxColliderPhysics', box);
|
|
73
66
|
let rigidBody = entity.getComponent(RigidBody);
|
|
74
67
|
if (!rigidBody) {
|
|
75
68
|
rigidBody = instantiate(RigidBody);
|
|
76
69
|
entity.assign(rigidBody);
|
|
77
70
|
}
|
|
78
|
-
const { type =
|
|
79
|
-
const
|
|
80
|
-
const { density = 1, friction = 0.5, restitution = 0.3 } = (physicsMaterial === null || physicsMaterial === void 0 ? void 0 : physicsMaterial.props) || {};
|
|
81
|
-
const box = component;
|
|
71
|
+
const { type = StaticBody, gravityScale = 1, density = 1, friction = 0.5, restitution = 0.3, isSensor } = rigidBody.props;
|
|
72
|
+
const { width, height, offset = [] } = box.props;
|
|
82
73
|
const node = entity.getComponent(NodeComp);
|
|
83
|
-
const _a = box.props, { width, height } = _a, colliderProps = __rest(_a, ["width", "height"]);
|
|
84
|
-
// ett.assign(instantiate(ColliderPhysics, { tag, offset }))
|
|
85
|
-
const { x = 0, y = 0 } = colliderProps.offset || {};
|
|
86
74
|
const zero = new b2Vec2(0, 0);
|
|
87
|
-
const position = new b2Vec2(node.posX, node.posY);
|
|
88
|
-
const offset = new b2Vec2(x, y);
|
|
89
75
|
const bd = new b2BodyDef();
|
|
90
|
-
bd.set_type(type
|
|
76
|
+
bd.set_type(type);
|
|
91
77
|
bd.set_position(zero);
|
|
92
78
|
bd.set_gravityScale(gravityScale);
|
|
93
79
|
const body = this.world.CreateBody(bd);
|
|
94
80
|
rigidBody.body = body;
|
|
81
|
+
const physicsNode = new PhysicsSprite(node.instance, rigidBody.body);
|
|
82
|
+
rigidBody.physicSprite = physicsNode;
|
|
83
|
+
rigidBody.node = node;
|
|
95
84
|
// console.log('body', type, b2_dynamicBody, b2_staticBody, getPointer(body));
|
|
96
85
|
// body.setMassData({ mass: 1 } as any)
|
|
97
|
-
const
|
|
86
|
+
const position = new b2Vec2(node.posX, node.posY);
|
|
98
87
|
const square = new b2PolygonShape();
|
|
99
|
-
|
|
88
|
+
const [x = 0, y = 0] = offset;
|
|
89
|
+
square.SetAsBox(width / 2, height / 2, new b2Vec2(node.width / 2 + x, node.height / 2 + y), 0);
|
|
100
90
|
const fixtureDef = new b2FixtureDef();
|
|
101
91
|
fixtureDef.set_shape(square);
|
|
102
92
|
fixtureDef.set_density(density);
|
|
103
93
|
fixtureDef.set_friction(friction);
|
|
104
94
|
fixtureDef.set_restitution(restitution);
|
|
95
|
+
fixtureDef.set_isSensor(isSensor);
|
|
96
|
+
rigidBody.body.CreateFixture(fixtureDef);
|
|
97
|
+
rigidBody.body.SetTransform(position, 0);
|
|
98
|
+
rigidBody.body.SetLinearVelocity(zero);
|
|
99
|
+
rigidBody.body.SetAwake(true);
|
|
100
|
+
rigidBody.body.SetEnabled(true);
|
|
101
|
+
metadata[getPointer(rigidBody.body)] = node;
|
|
102
|
+
box.node = node;
|
|
103
|
+
});
|
|
104
|
+
event_manager.subscribe(EventTypes.ComponentAdded, PhysicsCircleCollider, ({ entity, component }) => {
|
|
105
|
+
// console.log('ComponentAddedEvent PhysicsCircleCollider', component)
|
|
106
|
+
let rigidBody = entity.getComponent(RigidBody);
|
|
107
|
+
if (!rigidBody) {
|
|
108
|
+
rigidBody = instantiate(RigidBody);
|
|
109
|
+
entity.assign(rigidBody);
|
|
110
|
+
}
|
|
111
|
+
const { type = StaticBody, gravityScale = 1, density = 100, friction = 0.5, restitution = 0.3, isSensor = false } = rigidBody.props;
|
|
112
|
+
const node = entity.getComponent(NodeComp);
|
|
113
|
+
const { radius, offset = [] } = component.props;
|
|
114
|
+
const [x = 0, y = 0] = offset;
|
|
115
|
+
const zero = new b2Vec2(0, 0);
|
|
116
|
+
const position = new b2Vec2(node.posX, node.posY);
|
|
117
|
+
const bd = new b2BodyDef();
|
|
118
|
+
bd.set_type(type);
|
|
119
|
+
bd.set_position(zero);
|
|
120
|
+
bd.set_gravityScale(gravityScale);
|
|
121
|
+
const body = this.world.CreateBody(bd);
|
|
122
|
+
rigidBody.body = body;
|
|
123
|
+
// console.log('body', type, b2_dynamicBody, b2_staticBody, getPointer(body));
|
|
124
|
+
// body.setMassData({ mass: 1 } as any)
|
|
125
|
+
const physicsNode = new PhysicsSprite(node.instance, body);
|
|
126
|
+
const circleShape = new b2CircleShape();
|
|
127
|
+
circleShape.set_m_radius(radius);
|
|
128
|
+
circleShape.set_m_p(new b2Vec2(x, y));
|
|
129
|
+
const fixtureDef = new b2FixtureDef();
|
|
130
|
+
fixtureDef.set_shape(circleShape);
|
|
131
|
+
fixtureDef.set_density(density);
|
|
132
|
+
fixtureDef.set_isSensor(isSensor);
|
|
133
|
+
fixtureDef.set_friction(friction);
|
|
134
|
+
fixtureDef.set_restitution(restitution);
|
|
105
135
|
body.CreateFixture(fixtureDef);
|
|
106
136
|
body.SetTransform(position, 0);
|
|
107
137
|
body.SetLinearVelocity(zero);
|
|
108
138
|
body.SetAwake(true);
|
|
109
139
|
body.SetEnabled(true);
|
|
110
140
|
metadata[getPointer(body)] = node;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
box.node = node;
|
|
141
|
+
rigidBody.physicSprite = physicsNode;
|
|
142
|
+
rigidBody.node = node;
|
|
143
|
+
component.node = node;
|
|
115
144
|
});
|
|
116
|
-
event_manager.subscribe(EventTypes.ComponentAdded,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
145
|
+
event_manager.subscribe(EventTypes.ComponentAdded, PhysicsPolygonCollider, ({ entity, component }) => {
|
|
146
|
+
// console.log('ComponentAddedEvent PhysicsPolygonCollider', component)
|
|
147
|
+
let rigidBody = entity.getComponent(RigidBody);
|
|
148
|
+
if (!rigidBody) {
|
|
149
|
+
rigidBody = instantiate(RigidBody);
|
|
150
|
+
entity.assign(rigidBody);
|
|
151
|
+
}
|
|
152
|
+
const { type = StaticBody, gravityScale = 1, density = 1, friction = 0.5, restitution = 0.3, isSensor } = rigidBody.props;
|
|
153
|
+
const node = entity.getComponent(NodeComp);
|
|
154
|
+
const { points, offset = [] } = component.props;
|
|
155
|
+
const [x = 0, y = 0] = offset;
|
|
156
|
+
const zero = new b2Vec2(0, 0);
|
|
157
|
+
const position = new b2Vec2(node.posX, node.posY);
|
|
158
|
+
const { width, height } = node.getContentSize();
|
|
159
|
+
const { scaleX, scaleY, anchorX, anchorY } = node;
|
|
160
|
+
const bd = new b2BodyDef();
|
|
161
|
+
bd.set_type(type);
|
|
162
|
+
bd.set_position(zero);
|
|
163
|
+
bd.set_gravityScale(gravityScale);
|
|
164
|
+
const body = this.world.CreateBody(bd);
|
|
165
|
+
rigidBody.body = body;
|
|
166
|
+
// console.log('body', type, b2_dynamicBody, b2_staticBody, getPointer(body));
|
|
167
|
+
// body.setMassData({ mass: 1 } as any)
|
|
168
|
+
const physicsNode = new PhysicsSprite(node.instance, body);
|
|
169
|
+
const polygonShape = new b2PolygonShape();
|
|
170
|
+
const fixedPoints = points.map((p) => {
|
|
171
|
+
if (p.x)
|
|
172
|
+
return Vec2(p.x + x - width * anchorX * scaleX, -p.y + y + height * scaleY * anchorY);
|
|
173
|
+
return Vec2(p[0] + x - width * anchorX * scaleX, -p[1] + y + height * scaleY * anchorY);
|
|
174
|
+
});
|
|
175
|
+
const [vecArr, destroyVecArr] = pointsToVec2Array(fixedPoints);
|
|
176
|
+
// console.log('vecArr', vecArr, vecArr.Length())
|
|
177
|
+
polygonShape.Set(vecArr, points.length);
|
|
178
|
+
destroyVecArr();
|
|
179
|
+
const fixtureDef = new b2FixtureDef();
|
|
180
|
+
fixtureDef.set_shape(polygonShape);
|
|
181
|
+
fixtureDef.set_density(density);
|
|
182
|
+
fixtureDef.set_friction(friction);
|
|
183
|
+
fixtureDef.set_restitution(restitution);
|
|
184
|
+
fixtureDef.set_isSensor(isSensor);
|
|
185
|
+
body.CreateFixture(fixtureDef);
|
|
186
|
+
body.SetTransform(position, 0);
|
|
187
|
+
// body.SetLinearVelocity(zero)
|
|
188
|
+
body.SetAwake(true);
|
|
189
|
+
body.SetEnabled(true);
|
|
190
|
+
metadata[getPointer(body)] = node;
|
|
191
|
+
rigidBody.physicSprite = physicsNode;
|
|
192
|
+
rigidBody.node = node;
|
|
193
|
+
component.node = node;
|
|
194
|
+
});
|
|
195
|
+
event_manager.subscribe(EventTypes.ComponentRemoved, RigidBody, ({ component }) => {
|
|
196
|
+
// console.log('ComponentRemovedEvent NodeComp', component)
|
|
197
|
+
if (component.physicSprite instanceof PhysicsSprite) {
|
|
198
|
+
const body = component.physicSprite.getBody();
|
|
199
|
+
// this.listRemoveShape.push(...body.shapeList)
|
|
200
|
+
this.listRemoveBody.push(body);
|
|
201
|
+
}
|
|
126
202
|
});
|
|
127
203
|
const listener = makeContactListener(this.world, metadata, box2D);
|
|
128
204
|
this.world.SetContactListener(listener);
|
|
129
205
|
}
|
|
130
206
|
update(entities, events, dt) {
|
|
131
207
|
if (this.world) {
|
|
208
|
+
const { getPointer } = box2D;
|
|
209
|
+
for (const entt of entities.entities_with_components(RigidBody)) {
|
|
210
|
+
const comp = entt.getComponent(RigidBody);
|
|
211
|
+
if (comp.node.active && comp.enabled) {
|
|
212
|
+
comp.physicSprite.update(dt);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
// remove bodies and shapes
|
|
216
|
+
this.listRemoveBody.forEach((body) => {
|
|
217
|
+
if (body) {
|
|
218
|
+
this.world.DestroyBody(getPointer(body));
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
this.listRemoveBody = [];
|
|
132
222
|
const clampedDelta = Math.min(dt, maxTimeStep);
|
|
133
223
|
this.world.Step(clampedDelta, velocityIterations, positionIterations);
|
|
134
224
|
this.graphics.clear();
|
|
@@ -1,23 +1,40 @@
|
|
|
1
|
-
import { Graphics,
|
|
1
|
+
import { Graphics, Rectangle, Size } from 'pixi.js';
|
|
2
|
+
import { Vec2 } from '..';
|
|
2
3
|
import { NoRenderComponentX } from '../components/BaseComponent';
|
|
3
4
|
interface ColliderProps {
|
|
4
|
-
offset?:
|
|
5
|
+
offset?: Vec2;
|
|
5
6
|
tag?: number;
|
|
6
|
-
enabled?: boolean;
|
|
7
7
|
onCollisionEnter?: (other: Collider) => void;
|
|
8
8
|
onCollisionExit?: (other: Collider) => void;
|
|
9
9
|
onCollisionStay?: (other: Collider) => void;
|
|
10
10
|
}
|
|
11
11
|
export declare class Collider<T = ColliderProps> extends NoRenderComponentX<T> {
|
|
12
|
-
_worldPoints:
|
|
13
|
-
_worldPosition:
|
|
12
|
+
_worldPoints: Vec2[];
|
|
13
|
+
_worldPosition: Vec2;
|
|
14
14
|
_worldRadius: any;
|
|
15
15
|
_AABB: Rectangle;
|
|
16
16
|
_preAabb: Rectangle;
|
|
17
|
-
update(dt: number, draw?: Graphics): void;
|
|
18
17
|
getAABB(): Rectangle;
|
|
19
18
|
get world(): {
|
|
20
|
-
points:
|
|
19
|
+
points: {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
equals(other: /*elided*/ any): boolean;
|
|
23
|
+
add(value: import("pixi.js").Point | Vec2): /*elided*/ any;
|
|
24
|
+
addSelf(value: import("pixi.js").Point | Vec2): /*elided*/ any;
|
|
25
|
+
sub(value: import("pixi.js").Point | Vec2): /*elided*/ any;
|
|
26
|
+
mul(multiply: number): /*elided*/ any;
|
|
27
|
+
mulSelf(multiply: number): /*elided*/ any;
|
|
28
|
+
mag(): number;
|
|
29
|
+
normalizeSelf(): /*elided*/ any;
|
|
30
|
+
normalize(): /*elided*/ any;
|
|
31
|
+
cross(other: Vec2): number;
|
|
32
|
+
signAngle(other: Vec2): number;
|
|
33
|
+
lengthSqr(): number;
|
|
34
|
+
dot(other: Vec2): number;
|
|
35
|
+
angle(other: Vec2): number;
|
|
36
|
+
distance(other: /*elided*/ any): number;
|
|
37
|
+
}[];
|
|
21
38
|
preAabb: Rectangle;
|
|
22
39
|
};
|
|
23
40
|
}
|
|
@@ -37,11 +54,11 @@ export declare class CircleCollider extends Collider<CircleColliderProps> {
|
|
|
37
54
|
update(dt: any, draw: Graphics): void;
|
|
38
55
|
}
|
|
39
56
|
interface PolygonColliderProps extends ColliderProps {
|
|
40
|
-
points: Array<
|
|
57
|
+
points: Array<Vec2>;
|
|
41
58
|
}
|
|
42
59
|
export declare class PolygonCollider extends Collider<PolygonColliderProps> {
|
|
43
|
-
get points():
|
|
44
|
-
set points(points:
|
|
60
|
+
get points(): Vec2[];
|
|
61
|
+
set points(points: Vec2[]);
|
|
45
62
|
update(dt: any, draw: Graphics): void;
|
|
46
63
|
}
|
|
47
64
|
export declare enum CollisionType {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CollideComponent.d.ts","sourceRoot":"","sources":["../../src/collider/CollideComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"CollideComponent.d.ts","sourceRoot":"","sources":["../../src/collider/CollideComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAEnD,OAAO,EAAa,IAAI,EAAE,MAAM,IAAI,CAAA;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAgBhE,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,IAAI,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAA;IAC5C,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAA;IAC3C,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAA;CAC5C;AAED,qBAAa,QAAQ,CAAC,CAAC,GAAG,aAAa,CAAE,SAAQ,kBAAkB,CAAC,CAAC,CAAC;IACpE,YAAY,EAAE,IAAI,EAAE,CAAK;IACzB,cAAc,EAAE,IAAI,CAAA;IACpB,YAAY,MAAA;IACZ,KAAK,EAAE,SAAS,CAA4B;IAC5C,QAAQ,EAAE,SAAS,CAA4B;IAG/C,OAAO;IAGP,IAAI,KAAK;;;;;;;;;;;;;;;;;;;;;MAKR;CACF;AAED,UAAU,gBAAiB,SAAQ,aAAa;IAC9C,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AACD,qBAAa,WAAY,SAAQ,QAAQ,CAAC,gBAAgB,CAAC;IACzD,IAAI,IAAI,IAAI,IAAI,CAEf;IAED,IAAI,IAAI,CAAC,CAAC,EAAE,IAAI,EAGf;IAED,MAAM,CAAC,EAAE,KAAA,EAAE,IAAI,EAAE,QAAQ;CAkC1B;AAED,UAAU,mBAAoB,SAAQ,aAAa;IACjD,MAAM,EAAE,MAAM,CAAA;CACf;AAED,qBAAa,cAAe,SAAQ,QAAQ,CAAC,mBAAmB,CAAC;IAC/D,MAAM,CAAC,EAAE,KAAA,EAAE,IAAI,EAAE,QAAQ;CAuB1B;AAED,UAAU,oBAAqB,SAAQ,aAAa;IAClD,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAA;CACpB;AACD,qBAAa,eAAgB,SAAQ,QAAQ,CAAC,oBAAoB,CAAC;IACjE,IAAI,MAAM,IAAI,IAAI,EAAE,CAInB;IAED,IAAI,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,EAExB;IAED,MAAM,CAAC,EAAE,KAAA,EAAE,IAAI,EAAE,QAAQ;CAsB1B;AAED,oBAAY,aAAa;IACvB,IAAI,IAAA;IACJ,KAAK,IAAA;IACL,IAAI,IAAA;IACJ,IAAI,IAAA;CACL;AASD,qBAAa,QAAQ;IACnB,UAAU,EAAE,QAAQ,CAAA;IACpB,UAAU,EAAE,QAAQ,CAAA;IACpB,SAAS,EAAE,OAAO,CAAA;IAClB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,eAAe,EAAE,OAAO,CAAA;IACxB,gBAAgB,EAAE,OAAO,CAAA;gBAEb,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ;IAsBpD,WAAW;IAiBX,IAAI;CAyBL"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Rectangle } from 'pixi.js';
|
|
2
|
-
import { GameWorld } from '..';
|
|
2
|
+
import { GameWorld, Vec2 } from '..';
|
|
3
3
|
import { NoRenderComponentX } from '../components/BaseComponent';
|
|
4
|
-
import { v2 } from '../helper/utils';
|
|
5
4
|
import { circleCircle, polygonCircle, polygonPolygon } from './helper/Intersection';
|
|
6
5
|
import { getMax, getMin } from './helper/utils';
|
|
7
6
|
function getNodeToWorldTransformAR(node) {
|
|
@@ -21,8 +20,7 @@ export class Collider extends NoRenderComponentX {
|
|
|
21
20
|
this._AABB = new Rectangle(0, 0, 0, 0);
|
|
22
21
|
this._preAabb = new Rectangle(0, 0, 0, 0);
|
|
23
22
|
}
|
|
24
|
-
//
|
|
25
|
-
update(dt, draw) { }
|
|
23
|
+
// update(dt: number, draw?: Graphics) { }
|
|
26
24
|
getAABB() {
|
|
27
25
|
return this._AABB;
|
|
28
26
|
}
|
|
@@ -45,7 +43,7 @@ export class BoxCollider extends Collider {
|
|
|
45
43
|
if (!this.node) {
|
|
46
44
|
return;
|
|
47
45
|
}
|
|
48
|
-
const { x, y } = this.props.offset ||
|
|
46
|
+
const { x, y } = this.props.offset || Vec2();
|
|
49
47
|
// const hw = this.width * 0.5
|
|
50
48
|
// const hh = this.height * 0.5
|
|
51
49
|
const transform = getNodeToWorldTransformAR(this.node);
|
|
@@ -53,11 +51,11 @@ export class BoxCollider extends Collider {
|
|
|
53
51
|
// const dy = y - hh
|
|
54
52
|
const collider = this.getComponent(Collider);
|
|
55
53
|
collider._worldPoints = [
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
].map(p => transform.apply(p));
|
|
54
|
+
Vec2(x, y),
|
|
55
|
+
Vec2(x, y + this.props.height),
|
|
56
|
+
Vec2(x + this.props.width, y + this.props.height),
|
|
57
|
+
Vec2(x + this.props.width, y),
|
|
58
|
+
].map((p) => transform.apply(p));
|
|
61
59
|
// console.log("_worldPoints", collider._worldPoints, rectTrs)
|
|
62
60
|
// collider._worldPoints = collider._worldPoints.map(p => transform.apply(p))
|
|
63
61
|
const listX = collider._worldPoints.map(({ x }) => x);
|
|
@@ -104,7 +102,7 @@ export class CircleCollider extends Collider {
|
|
|
104
102
|
export class PolygonCollider extends Collider {
|
|
105
103
|
get points() {
|
|
106
104
|
const { x, y } = this.props.offset;
|
|
107
|
-
const pointsList = this.props.points.map((p) =>
|
|
105
|
+
const pointsList = this.props.points.map((p) => Vec2(p.x + x, p.y + y));
|
|
108
106
|
return pointsList;
|
|
109
107
|
}
|
|
110
108
|
set points(points) {
|
|
@@ -119,7 +117,7 @@ export class PolygonCollider extends Collider {
|
|
|
119
117
|
collider._worldPoints = this.points.map((p) => transform.apply(p));
|
|
120
118
|
// log(polyPoints);
|
|
121
119
|
if (draw) {
|
|
122
|
-
const drawList = collider._worldPoints.map(({ x, y }) =>
|
|
120
|
+
const drawList = collider._worldPoints.map(({ x, y }) => Vec2(x, GameWorld.Instance.app.screen.height - y));
|
|
123
121
|
draw.poly(drawList);
|
|
124
122
|
}
|
|
125
123
|
const listX = collider._worldPoints.map(({ x }) => x);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function pointInPolygon(pos:
|
|
3
|
-
export declare function pointLineDistance(point:
|
|
4
|
-
export declare function polygonPolygon(pts1:
|
|
5
|
-
export declare function circleCircle(p1:
|
|
6
|
-
export declare function polygonCircle(pts1:
|
|
1
|
+
import { Vec2 } from '../..';
|
|
2
|
+
export declare function pointInPolygon(pos: Vec2, polygon: Vec2[]): boolean;
|
|
3
|
+
export declare function pointLineDistance(point: Vec2, start: Vec2, end: Vec2, isSegment: any): number;
|
|
4
|
+
export declare function polygonPolygon(pts1: Vec2[], pts2: Vec2[]): boolean;
|
|
5
|
+
export declare function circleCircle(p1: Vec2, r1: number, p2: Vec2, r2: number): boolean;
|
|
6
|
+
export declare function polygonCircle(pts1: Vec2[], p2: Vec2, r2: number): boolean;
|
|
7
7
|
//# sourceMappingURL=Intersection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Intersection.d.ts","sourceRoot":"","sources":["../../../src/collider/helper/Intersection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Intersection.d.ts","sourceRoot":"","sources":["../../../src/collider/helper/Intersection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAE5B,wBAAgB,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,WAuBxD;AAmCD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,KAAA,UAwB/E;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,WA6BxD;AAED,wBAAgB,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,WAGtE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,WAe/D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Vec2 } from '../..';
|
|
2
2
|
export function pointInPolygon(pos, polygon) {
|
|
3
3
|
let inside = false;
|
|
4
4
|
const x = pos.x;
|
|
@@ -48,7 +48,7 @@ export function pointLineDistance(point, start, end, isSegment) {
|
|
|
48
48
|
const t = ((point.x - start.x) * dx + (point.y - start.y) * dy) / d;
|
|
49
49
|
let p;
|
|
50
50
|
if (!isSegment) {
|
|
51
|
-
p =
|
|
51
|
+
p = Vec2(start.x + t * dx, start.y + t * dy);
|
|
52
52
|
}
|
|
53
53
|
else if (d) {
|
|
54
54
|
if (t < 0) {
|
|
@@ -58,7 +58,7 @@ export function pointLineDistance(point, start, end, isSegment) {
|
|
|
58
58
|
p = end;
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
|
-
p =
|
|
61
|
+
p = Vec2(start.x + t * dx, start.y + t * dy);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
else {
|
|
@@ -93,7 +93,7 @@ export function polygonPolygon(pts1, pts2) {
|
|
|
93
93
|
return false;
|
|
94
94
|
}
|
|
95
95
|
export function circleCircle(p1, r1, p2, r2) {
|
|
96
|
-
const d =
|
|
96
|
+
const d = p1.distance(p2);
|
|
97
97
|
return d < r1 + r2;
|
|
98
98
|
}
|
|
99
99
|
export function polygonCircle(pts1, p2, r2) {
|
|
@@ -260,7 +260,7 @@ export class NodeComp {
|
|
|
260
260
|
}
|
|
261
261
|
setScale(scaleX, scaleY) {
|
|
262
262
|
this.instance.scale.x = scaleX;
|
|
263
|
-
this.instance.scale.
|
|
263
|
+
this.instance.scale.y = scaleY || scaleX;
|
|
264
264
|
}
|
|
265
265
|
runAction(act) {
|
|
266
266
|
const animation = actionManager.runAction(this.instance, act);
|
package/dist/helper/utils.d.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { Constructor, EntityManager, EventManager } from 'entityx-ts';
|
|
2
|
-
import { Point } from 'pixi.js';
|
|
3
2
|
import { EnhancedComponent, GameWorld } from '../base';
|
|
4
|
-
export declare function v2(x?: number | {
|
|
5
|
-
x: number;
|
|
6
|
-
y: number;
|
|
7
|
-
}, y?: number): Point;
|
|
8
|
-
export declare function getDistance(point1: Point, point2: Point): number;
|
|
9
3
|
export declare function registerSystem<T extends EnhancedComponent<any>>(component: Constructor<T>): {
|
|
10
4
|
new (): {
|
|
11
5
|
configure(event_manager: EventManager<GameWorld>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/helper/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAoC,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/helper/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAoC,MAAM,YAAY,CAAA;AACvG,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAItD,wBAAgB,cAAc,CAAC,CAAC,SAAS,iBAAiB,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,CAAC;;iCAK7D,YAAY,CAAC,SAAS,CAAC;yBAU/B,aAAa,UAAU,YAAY,CAAC,SAAS,CAAC,MAAM,MAAM;;EAe9E"}
|
package/dist/helper/utils.js
CHANGED
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import { EventTypes } from 'entityx-ts';
|
|
2
|
-
import { Point } from 'pixi.js';
|
|
3
2
|
import { GameWorld } from '../base';
|
|
4
3
|
import { NodeComp } from '../components/NodeComp';
|
|
5
|
-
export function v2(x = 0, y = 0) {
|
|
6
|
-
if (typeof x === 'object' && 'x' in x && 'y' in x) {
|
|
7
|
-
return new Point(x.x, x.y);
|
|
8
|
-
}
|
|
9
|
-
return new Point(x, y);
|
|
10
|
-
}
|
|
11
|
-
export function getDistance(point1, point2) {
|
|
12
|
-
const dx = point2.x - point1.x;
|
|
13
|
-
const dy = point2.y - point1.y;
|
|
14
|
-
return Math.sqrt(dx * dx + dy * dy);
|
|
15
|
-
}
|
|
16
4
|
export function registerSystem(component) {
|
|
17
5
|
if (GameWorld.Instance.systems.isRegistered(`${component.name}System`)) {
|
|
18
6
|
return;
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AACrB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,gCAAgC,CAAA;AAC9C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,kBAAkB,CAAA;AAChC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AACrB,cAAc,QAAQ,CAAA;AACtB,cAAc,YAAY,CAAA;AAC1B,cAAc,gCAAgC,CAAA;AAC9C,cAAc,4BAA4B,CAAA;AAC1C,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,QAAQ,CAAA;AACtB,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,kBAAkB,CAAA;AAChC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -26,18 +26,9 @@
|
|
|
26
26
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
|
|
27
27
|
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
28
28
|
*****************************************************************************/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
import { TextureSource } from 'pixi.js';
|
|
30
|
+
export interface ISpineAtlasMetadata {
|
|
31
|
+
imageMetadata?: any;
|
|
32
|
+
images?: TextureSource | string | Record<string, TextureSource | string>;
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
if (typeof window !== 'undefined' && window.PIXI) {
|
|
36
|
-
const prevRequire = window.require;
|
|
37
|
-
(window as any).require = (x: string) => {
|
|
38
|
-
if (prevRequire) return prevRequire(x);
|
|
39
|
-
else if (x.startsWith("@pixi/") || x.startsWith("pixi.js")) return window.PIXI;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export { };
|
|
34
|
+
//# sourceMappingURL=atlasLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atlasLoader.d.ts","sourceRoot":"","sources":["../../../../src/spine/lib/assets/atlasLoader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;+EA2B+E;AAE/E,OAAO,EAQN,aAAa,EACb,MAAM,SAAS,CAAC;AAiHjB,MAAM,WAAW,mBAAmB;IAEnC,aAAa,CAAC,EAAE,GAAG,CAAC;IAGpB,MAAM,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAAC,CAAC;CACzE"}
|