@safe-engine/pixi 8.4.1 → 8.4.3
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/dist/app.d.ts +3 -3
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +3 -2
- package/dist/base/gworld.d.ts +2 -1
- package/dist/base/gworld.d.ts.map +1 -1
- package/dist/base/index.d.ts +8 -0
- package/dist/base/index.d.ts.map +1 -1
- package/dist/base/utils.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsSystem.d.ts +2 -1
- package/dist/box2d-wasm/PhysicsSystem.d.ts.map +1 -1
- package/dist/box2d-wasm/PhysicsSystem.js +6 -5
- package/dist/box2d-wasm/debugDraw.d.ts +1 -1
- package/dist/box2d-wasm/debugDraw.d.ts.map +1 -1
- package/dist/box2d-wasm/debugDraw.js +7 -7
- package/dist/components/NodeComp.d.ts +10 -8
- package/dist/components/NodeComp.d.ts.map +1 -1
- package/dist/components/NodeComp.js +17 -11
- package/dist/core/Vec2.d.ts +30 -0
- package/dist/core/Vec2.d.ts.map +1 -0
- package/dist/core/Vec2.js +88 -0
- package/dist/core/index.d.ts +7 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +7 -0
- package/dist/core/loader.d.ts +3 -0
- package/dist/core/loader.d.ts.map +1 -0
- package/dist/core/loader.js +21 -0
- package/dist/core/math.d.ts +1 -0
- package/dist/core/math.d.ts.map +1 -1
- package/dist/core/math.js +9 -0
- package/dist/gui/GUISystem.d.ts.map +1 -1
- package/dist/gui/GUISystem.js +4 -4
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -5
- package/dist/norender/NoRenderComponent.d.ts +2 -2
- package/dist/norender/NoRenderComponent.d.ts.map +1 -1
- package/dist/norender/NoRenderSystem.d.ts.map +1 -1
- package/dist/norender/NoRenderSystem.js +7 -6
- package/dist/norender/Touch.d.ts +32 -0
- package/dist/norender/Touch.d.ts.map +1 -0
- package/dist/norender/Touch.js +32 -0
- package/dist/render/RenderComponent.d.ts +3 -3
- package/dist/render/RenderComponent.d.ts.map +1 -1
- package/dist/render/RenderComponent.js +18 -28
- package/dist/render/RenderSystem.d.ts.map +1 -1
- package/dist/render/RenderSystem.js +3 -2
- package/package.json +2 -1
- package/src/app.ts +10 -4
- package/src/base/gworld.ts +2 -1
- package/src/base/index.ts +11 -0
- package/src/base/utils.ts +4 -4
- package/src/box2d-wasm/PhysicsSystem.ts +45 -48
- package/src/box2d-wasm/debugDraw.ts +80 -88
- package/src/components/NodeComp.ts +30 -30
- package/src/core/Vec2.ts +108 -0
- package/src/core/index.ts +7 -0
- package/src/core/loader.ts +12 -0
- package/src/core/math.ts +9 -0
- package/src/gui/GUISystem.ts +15 -9
- package/src/index.ts +3 -5
- package/src/norender/NoRenderComponent.ts +2 -2
- package/src/norender/NoRenderSystem.ts +12 -11
- package/src/norender/Touch.ts +37 -0
- package/src/render/RenderComponent.ts +35 -41
- package/src/render/RenderSystem.ts +5 -8
- package/dist/helper/html-text-parser.d.ts +0 -20
- package/dist/helper/html-text-parser.d.ts.map +0 -1
- package/dist/helper/html-text-parser.js +0 -64
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * from 'pixi-action-ease';
|
|
2
2
|
export * from 'pixi.js';
|
|
3
|
-
export { Vec2 } from 'planck';
|
|
4
3
|
export * from './app';
|
|
5
4
|
export * from './base';
|
|
6
5
|
export * from './collider';
|
|
@@ -8,15 +7,13 @@ export * from './collider/helper/Intersection';
|
|
|
8
7
|
export * from './components/BaseComponent';
|
|
9
8
|
export * from './components/NodeComp';
|
|
10
9
|
export * from './components/Scene';
|
|
11
|
-
export * from './core
|
|
12
|
-
export * from './core/director';
|
|
13
|
-
export * from './core/math';
|
|
14
|
-
export * from './core/NodePool';
|
|
10
|
+
export * from './core';
|
|
15
11
|
export * from './dragonbones';
|
|
16
12
|
export * from './gui/GUIComponent';
|
|
17
13
|
export * from './gui/GUISystem';
|
|
18
14
|
export * from './helper/utils';
|
|
19
15
|
export * from './norender/NoRenderComponent';
|
|
16
|
+
export * from './norender/Touch';
|
|
20
17
|
export * from './render/RenderComponent';
|
|
21
18
|
export * from './render/RenderSystem';
|
|
22
19
|
export * from './richtext';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FederatedPointerEvent } from 'pixi.js';
|
|
2
1
|
import { NoRenderComponentX } from '../components/BaseComponent';
|
|
3
2
|
import { EventCallbackType, EventMap, NodeComp } from '../components/NodeComp';
|
|
4
|
-
|
|
3
|
+
import { Touch } from './Touch';
|
|
4
|
+
export type TouchEventCallback = (touch?: Touch, node?: NodeComp) => void;
|
|
5
5
|
export declare class EventRegister extends NoRenderComponentX {
|
|
6
6
|
events: EventMap;
|
|
7
7
|
on(name: string, callback: EventCallbackType, target?: any): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoRenderComponent.d.ts","sourceRoot":"","sources":["../../src/norender/NoRenderComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"NoRenderComponent.d.ts","sourceRoot":"","sources":["../../src/norender/NoRenderComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAA;AAC9E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAO/B,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,QAAQ,KAAK,IAAI,CAAA;AAEzE,qBAAa,aAAc,SAAQ,kBAAkB;IACnD,MAAM,EAAE,QAAQ,CAAK;IAErB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,GAAG;IAS1D,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,GAAG;IAK5D,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG;CAKlC;AAED,UAAU,eAAe;IACvB,YAAY,CAAC,EAAE,kBAAkB,CAAA;IACjC,WAAW,CAAC,EAAE,kBAAkB,CAAA;IAChC,UAAU,CAAC,EAAE,kBAAkB,CAAA;IAC/B,aAAa,CAAC,EAAE,kBAAkB,CAAA;CACnC;AACD,qBAAa,kBAAmB,SAAQ,kBAAkB,CAAC,eAAe,CAAC;IACzE,QAAQ,EAAE,aAAa,CAAA;IACvB,KAAK,EAAE,KAAK,CAAA;CACb;AAED,UAAU,cAAc;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,GAAG,CAAA;CACX;AACD,qBAAa,aAAc,SAAQ,kBAAkB,CAAC,cAAc,CAAC;IACnE,IAAI,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAK;IAEjC,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC;IAG1B,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;CAG/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NoRenderSystem.d.ts","sourceRoot":"","sources":["../../src/norender/NoRenderSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAc,MAAM,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"NoRenderSystem.d.ts","sourceRoot":"","sources":["../../src/norender/NoRenderSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAc,MAAM,EAAE,MAAM,YAAY,CAAA;AAQ7D,qBAAa,cAAe,YAAW,MAAM;IAC3C,SAAS,CAAC,aAAa,EAAE,YAAY;CAyDtC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { EventTypes } from 'entityx-ts';
|
|
2
2
|
import { NodeComp } from '../components/NodeComp';
|
|
3
3
|
import { ExtraDataComp, TouchEventRegister } from './NoRenderComponent';
|
|
4
|
+
import { Touch } from './Touch';
|
|
4
5
|
export class NoRenderSystem {
|
|
5
6
|
configure(event_manager) {
|
|
6
|
-
event_manager.subscribe(EventTypes.ComponentAdded, ExtraDataComp, ({
|
|
7
|
+
event_manager.subscribe(EventTypes.ComponentAdded, ExtraDataComp, ({ component }) => {
|
|
7
8
|
const { key, value } = component.props;
|
|
8
9
|
component.data[key] = value;
|
|
9
10
|
});
|
|
@@ -15,26 +16,26 @@ export class NoRenderSystem {
|
|
|
15
16
|
const container = nodeComp.instance;
|
|
16
17
|
if (touchComp.props.onTouchStart) {
|
|
17
18
|
container.on('pointerdown', (event) => {
|
|
18
|
-
touchComp.props.onTouchStart(event, nodeComp);
|
|
19
|
+
touchComp.props.onTouchStart(new Touch(event), nodeComp);
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
22
|
if (touchComp.props.onTouchMove) {
|
|
22
23
|
container.on('pointermove', (event) => {
|
|
23
|
-
touchComp.props.onTouchMove(event, nodeComp);
|
|
24
|
+
touchComp.props.onTouchMove(new Touch(event), nodeComp);
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
if (touchComp.props.onTouchEnd) {
|
|
27
28
|
container.on('pointerup', (event) => {
|
|
28
|
-
touchComp.props.onTouchEnd(event, nodeComp);
|
|
29
|
+
touchComp.props.onTouchEnd(new Touch(event), nodeComp);
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
if (touchComp.props.onTouchEnd) {
|
|
32
33
|
container.on('pointercancel', (event) => {
|
|
33
|
-
touchComp.props.onTouchEnd(event, nodeComp);
|
|
34
|
+
touchComp.props.onTouchEnd(new Touch(event), nodeComp);
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
});
|
|
37
|
-
event_manager.subscribe(EventTypes.ComponentRemoved, TouchEventRegister, ({
|
|
38
|
+
event_manager.subscribe(EventTypes.ComponentRemoved, TouchEventRegister, ({ component }) => {
|
|
38
39
|
console.log('ComponentRemovedEvent TouchEventRegister', event);
|
|
39
40
|
// const ett = event.entity
|
|
40
41
|
// const nodeComp = ett.getComponent(NodeComp)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Vec2 } from '..';
|
|
2
|
+
export declare class Touch {
|
|
3
|
+
private event;
|
|
4
|
+
constructor(event: any);
|
|
5
|
+
getLocation(): import("pixi.js").Point;
|
|
6
|
+
getLocationX(): number;
|
|
7
|
+
getLocationY(): number;
|
|
8
|
+
getDelta(): {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
equals(other: /*elided*/ any): boolean;
|
|
12
|
+
add(value: import("pixi.js").Point | Vec2): /*elided*/ any;
|
|
13
|
+
addSelf(value: import("pixi.js").Point | Vec2): /*elided*/ any;
|
|
14
|
+
sub(value: import("pixi.js").Point | Vec2): /*elided*/ any;
|
|
15
|
+
mul(multiply: number): /*elided*/ any;
|
|
16
|
+
mulSelf(multiply: number): /*elided*/ any;
|
|
17
|
+
mag(): number;
|
|
18
|
+
normalizeSelf(): /*elided*/ any;
|
|
19
|
+
normalize(): /*elided*/ any;
|
|
20
|
+
cross(other: Vec2): number;
|
|
21
|
+
signAngle(other: Vec2): number;
|
|
22
|
+
lengthSqr(): number;
|
|
23
|
+
dot(other: Vec2): number;
|
|
24
|
+
angle(other: Vec2): number;
|
|
25
|
+
distance(other: /*elided*/ any): number;
|
|
26
|
+
};
|
|
27
|
+
getDeltaX(): number;
|
|
28
|
+
getDeltaY(): number;
|
|
29
|
+
getLocationInView(view: any): any;
|
|
30
|
+
getLocationInNode(node: any): any;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=Touch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Touch.d.ts","sourceRoot":"","sources":["../../src/norender/Touch.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AAEzB,qBAAa,KAAK;IAChB,OAAO,CAAC,KAAK,CAAuB;gBACxB,KAAK,KAAA;IAIjB,WAAW;IAGX,YAAY;IAGZ,YAAY;IAGZ,QAAQ;;;;;;;;;;;;;;;;;;;IAGR,SAAS;IAGT,SAAS;IAGT,iBAAiB,CAAC,IAAI,EAAE,GAAG;IAI3B,iBAAiB,CAAC,IAAI,EAAE,GAAG;CAI5B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Vec2 } from '..';
|
|
2
|
+
export class Touch {
|
|
3
|
+
constructor(event) {
|
|
4
|
+
this.event = event;
|
|
5
|
+
}
|
|
6
|
+
getLocation() {
|
|
7
|
+
return this.event.global;
|
|
8
|
+
}
|
|
9
|
+
getLocationX() {
|
|
10
|
+
return this.event.globalX;
|
|
11
|
+
}
|
|
12
|
+
getLocationY() {
|
|
13
|
+
return this.event.globalY;
|
|
14
|
+
}
|
|
15
|
+
getDelta() {
|
|
16
|
+
return Vec2(this.event.movementX, this.event.movementY);
|
|
17
|
+
}
|
|
18
|
+
getDeltaX() {
|
|
19
|
+
return this.event.movementX;
|
|
20
|
+
}
|
|
21
|
+
getDeltaY() {
|
|
22
|
+
return this.event.movementY;
|
|
23
|
+
}
|
|
24
|
+
getLocationInView(view) {
|
|
25
|
+
const { x, y } = this.event.global;
|
|
26
|
+
return view.toLocal({ x, y });
|
|
27
|
+
}
|
|
28
|
+
getLocationInNode(node) {
|
|
29
|
+
const { x, y } = this.event.global;
|
|
30
|
+
return node.toLocal({ x, y });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Graphics,
|
|
1
|
+
import { Graphics, Sprite } from 'pixi.js';
|
|
2
2
|
import { Color4B, Vec2 } from '..';
|
|
3
3
|
import { ComponentX } from '../components/BaseComponent';
|
|
4
4
|
import { LoadingBarMode } from '../core/LoadingBar';
|
|
@@ -39,10 +39,10 @@ export declare class GraphicsRender extends ComponentX<GraphicsRenderProps & {
|
|
|
39
39
|
drawCubicBezier(origin: Vec2, destination: Vec2, color: Color4B): void;
|
|
40
40
|
drawCardinalSpline(points: Vec2[], color: Color4B): void;
|
|
41
41
|
drawCatmullRom(points: Vec2[], color: Color4B): void;
|
|
42
|
-
drawPoly(points: Vec2[],
|
|
42
|
+
drawPoly(points: Vec2[], color?: Color4B, thickness?: Float): void;
|
|
43
43
|
drawSolidPoly(points: Vec2[], color: Color4B): void;
|
|
44
44
|
drawDot(points: Vec2[], color: Color4B): void;
|
|
45
|
-
drawSegment(from:
|
|
45
|
+
drawSegment(from: Vec2, to: Vec2, thickness?: Float, color?: Color4B): void;
|
|
46
46
|
drawTriangle(p1: Vec2, p2: Vec2, p3: Vec2, color: Color4B): void;
|
|
47
47
|
clear(): void;
|
|
48
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderComponent.d.ts","sourceRoot":"","sources":["../../src/render/RenderComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"RenderComponent.d.ts","sourceRoot":"","sources":["../../src/render/RenderComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAW,MAAM,SAAS,CAAA;AAEnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAE5C,qBAAa,UAAW,SAAQ,UAAU;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,UAAU,iBAAiB;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,WAAW,CAAA;IAClB,QAAQ,CAAC,EAAE,cAAc,CAAA;CAI1B;AAED,qBAAa,YAAa,SAAQ,UAAU,CAAC,iBAAiB,GAAG;IAAE,IAAI,CAAC,EAAE,YAAY,CAAA;CAAE,EAAE,MAAM,CAAC;IAc/F,IAAI,WAAW,WAEd;IAED,IAAI,WAAW,CAAC,KAAK,QAAA,EAkBpB;CACF;AACD,aAAK,SAAS;IACZ,MAAM,IAAA;IACN,IAAI,IAAA;CACL;AACD,UAAU,mBAAmB;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AACD,qBAAa,cAAe,SAAQ,UAAU,CAAC,mBAAmB,GAAG;IAAE,IAAI,CAAC,EAAE,cAAc,CAAA;CAAE,EAAE,QAAQ,CAAC;IACvG,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,YAAiB;IAGtF,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK;IAC1E,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO;IAOxD,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO;IAC7D,UAAU,CACR,MAAM,EAAE,IAAI,EACZ,MAAM,EAAE,KAAK,EACb,KAAK,CAAC,EAAE,KAAK,EACb,QAAQ,CAAC,EAAE,OAAO,EAClB,gBAAgB,CAAC,EAAE,OAAO,EAC1B,MAAM,CAAC,EAAE,KAAK,EACd,MAAM,CAAC,EAAE,KAAK,EACd,KAAK,CAAC,EAAE,OAAO,EACf,SAAS,CAAC,EAAE,KAAK;IAMnB,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO;IAC/D,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO;IAC9D,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO;IAC/D,kBAAkB,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO;IACjD,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO;IAC7C,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,KAAK;IAI3D,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO;IAC5C,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO;IACtC,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,OAAO;IAWpE,YAAY,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO;IAIzD,KAAK;CAGN;AAED,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB;AACD,qBAAa,UAAW,SAAQ,UAAU,CAAC,eAAe,CAAC;CAAG"}
|
|
@@ -43,14 +43,11 @@ var PointType;
|
|
|
43
43
|
PointType[PointType["Circle"] = 0] = "Circle";
|
|
44
44
|
PointType[PointType["Rect"] = 1] = "Rect";
|
|
45
45
|
})(PointType || (PointType = {}));
|
|
46
|
-
;
|
|
47
46
|
export class GraphicsRender extends ComponentX {
|
|
48
|
-
drawPoint(position, pointSize, color, pointType = PointType.Rect) {
|
|
49
|
-
}
|
|
47
|
+
drawPoint(position, pointSize, color, pointType = PointType.Rect) { }
|
|
50
48
|
// drawPoints(points: Vec2[], color: Color4B) {
|
|
51
49
|
// }
|
|
52
|
-
drawLine(origin, destination, color, thickness) {
|
|
53
|
-
}
|
|
50
|
+
drawLine(origin, destination, color, thickness) { }
|
|
54
51
|
drawRect(origin, destination, color) {
|
|
55
52
|
const { x, y } = origin;
|
|
56
53
|
const width = destination.x - x;
|
|
@@ -58,37 +55,30 @@ export class GraphicsRender extends ComponentX {
|
|
|
58
55
|
this.node.instance.rect(x, y, width, height);
|
|
59
56
|
this.node.instance.fill(color);
|
|
60
57
|
}
|
|
61
|
-
drawSolidRect(origin, destination, color) {
|
|
62
|
-
}
|
|
58
|
+
drawSolidRect(origin, destination, color) { }
|
|
63
59
|
drawCircle(center, radius, angle, segments, drawLineToCenter, scaleX, scaleY, color, thickness) {
|
|
64
60
|
const { x, y } = center;
|
|
65
61
|
this.node.instance.circle(x, y, radius);
|
|
66
62
|
this.node.instance.fill(color);
|
|
67
63
|
}
|
|
68
|
-
drawSolidCircle(origin, destination, color) {
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this.node.instance.fill(color);
|
|
81
|
-
}
|
|
82
|
-
drawSolidPoly(points, color) {
|
|
83
|
-
}
|
|
84
|
-
drawDot(points, color) {
|
|
85
|
-
}
|
|
86
|
-
drawSegment(from, to, color) {
|
|
64
|
+
drawSolidCircle(origin, destination, color) { }
|
|
65
|
+
drawQuadBezier(origin, destination, color) { }
|
|
66
|
+
drawCubicBezier(origin, destination, color) { }
|
|
67
|
+
drawCardinalSpline(points, color) { }
|
|
68
|
+
drawCatmullRom(points, color) { }
|
|
69
|
+
drawPoly(points, color, thickness) {
|
|
70
|
+
this.node.instance.poly(points, true);
|
|
71
|
+
this.node.instance.fill(color || this.props.fillColor);
|
|
72
|
+
}
|
|
73
|
+
drawSolidPoly(points, color) { }
|
|
74
|
+
drawDot(points, color) { }
|
|
75
|
+
drawSegment(from, to, thickness, color) {
|
|
87
76
|
this.node.instance.moveTo(from.x, from.y);
|
|
88
77
|
this.node.instance.lineTo(to.x, to.y);
|
|
89
78
|
this.node.instance.strokeStyle = {
|
|
90
|
-
cap: 'round',
|
|
91
|
-
|
|
79
|
+
cap: 'round',
|
|
80
|
+
join: 'round',
|
|
81
|
+
width: thickness || this.props.lineWidth || 36,
|
|
92
82
|
color: color || this.props.strokeColor,
|
|
93
83
|
};
|
|
94
84
|
this.node.instance.stroke();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderSystem.d.ts","sourceRoot":"","sources":["../../src/render/RenderSystem.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"RenderSystem.d.ts","sourceRoot":"","sources":["../../src/render/RenderSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAc,MAAM,EAAE,MAAM,YAAY,CAAA;AAM7D,oBAAY,WAAW;IACrB,MAAM,IAAA;IACN,MAAM,IAAA;IACN,KAAK,IAAA;IACL,MAAM,IAAA;IACN,IAAI,IAAA;IACJ,SAAS,IAAA;CACV;AAED,qBAAa,YAAa,YAAW,MAAM;IACzC,SAAS,CAAC,aAAa,EAAE,YAAY;CA+CtC"}
|
|
@@ -20,7 +20,8 @@ export class RenderSystem {
|
|
|
20
20
|
});
|
|
21
21
|
event_manager.subscribe(EventTypes.ComponentAdded, SpriteRender, ({ entity, component }) => {
|
|
22
22
|
const { spriteFrame } = component.props;
|
|
23
|
-
//
|
|
23
|
+
// const texture = GameWorld.Instance.assetManager.get<Texture>(spriteFrame)
|
|
24
|
+
// console.log('SpriteRender ComponentAdded', component, texture)
|
|
24
25
|
const node = Sprite.from(spriteFrame);
|
|
25
26
|
// if (type === SpriteTypes.FILLED) {
|
|
26
27
|
// // console.log('fillType', fillType)
|
|
@@ -43,7 +44,7 @@ export class RenderSystem {
|
|
|
43
44
|
// maskComp.node = ett.assign(new NodeComp(node, ett))
|
|
44
45
|
});
|
|
45
46
|
event_manager.subscribe(EventTypes.ComponentAdded, GraphicsRender, ({ entity, component }) => {
|
|
46
|
-
// const { lineWidth, strokeColor, fillColor } = component
|
|
47
|
+
// const { lineWidth, strokeColor, fillColor } = component.props
|
|
47
48
|
// console.log('GraphicsRender', component);
|
|
48
49
|
const node = new Graphics();
|
|
49
50
|
component.node = entity.assign(new NodeComp(node, entity));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@safe-engine/pixi",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.3",
|
|
4
4
|
"description": "safex pixi plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"@esotericsoftware/spine-core": "^4.2.84",
|
|
20
20
|
"@pixi/ui": "^2.2.4",
|
|
21
21
|
"@types/node": "^24.0.10",
|
|
22
|
+
"box2d-wasm": "^7.0.0",
|
|
22
23
|
"copyfiles": "^2.4.1",
|
|
23
24
|
"dragonbones-pixijs": "^1.0.5",
|
|
24
25
|
"entityx-ts": "^2.2.1",
|
package/src/app.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { actionManager } from 'pixi-action-ease'
|
|
2
|
-
import { Application } from 'pixi.js'
|
|
2
|
+
import { Application, AssetsClass } from 'pixi.js'
|
|
3
3
|
|
|
4
4
|
import { GameWorld } from './base'
|
|
5
5
|
import { CollideSystem } from './collider'
|
|
@@ -7,7 +7,12 @@ import { GUISystem } from './gui/GUISystem'
|
|
|
7
7
|
import { NoRenderSystem } from './norender/NoRenderSystem'
|
|
8
8
|
import { RenderSystem } from './render/RenderSystem'
|
|
9
9
|
|
|
10
|
-
export async function startGame(
|
|
10
|
+
export async function startGame(
|
|
11
|
+
defaultFont,
|
|
12
|
+
designedResolution = { width: 720, height: 1280 },
|
|
13
|
+
assetManager: AssetsClass,
|
|
14
|
+
id = 'gameCanvas',
|
|
15
|
+
) {
|
|
11
16
|
const app = new Application()
|
|
12
17
|
await app.init({
|
|
13
18
|
antialias: true,
|
|
@@ -20,7 +25,7 @@ export async function startGame(defaultFont, designedResolution = { width: 720,
|
|
|
20
25
|
click: true,
|
|
21
26
|
wheel: false,
|
|
22
27
|
},
|
|
23
|
-
canvas: document.getElementById(id) as HTMLCanvasElement
|
|
28
|
+
canvas: document.getElementById(id) as HTMLCanvasElement,
|
|
24
29
|
})
|
|
25
30
|
// GameWorld.Instance.setup(NodeComp, app.stage)
|
|
26
31
|
Object.assign(app.canvas.style, {
|
|
@@ -33,6 +38,7 @@ export async function startGame(defaultFont, designedResolution = { width: 720,
|
|
|
33
38
|
// app.stage.position.y = app.renderer.height / app.renderer.resolution
|
|
34
39
|
// app.stage.scale.y = -1
|
|
35
40
|
GameWorld.Instance.app = app
|
|
41
|
+
GameWorld.Instance.assetManager = assetManager
|
|
36
42
|
initWorld(defaultFont)
|
|
37
43
|
startGameLoop(GameWorld.Instance)
|
|
38
44
|
return app
|
|
@@ -82,4 +88,4 @@ function initWorld(defaultFont?: string) {
|
|
|
82
88
|
guiSystem.defaultFont = defaultFont
|
|
83
89
|
}
|
|
84
90
|
// startGameLoop(world, app)
|
|
85
|
-
}
|
|
91
|
+
}
|
package/src/base/gworld.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Constructor, System, World } from 'entityx-ts'
|
|
2
|
-
import { Application } from 'pixi.js'
|
|
2
|
+
import { Application, AssetsClass } from 'pixi.js'
|
|
3
3
|
|
|
4
4
|
export class GameWorld extends World {
|
|
5
5
|
listUpdate: (System | Constructor<System>)[] = []
|
|
6
6
|
app: Application
|
|
7
|
+
assetManager: AssetsClass
|
|
7
8
|
update(dt: number) {
|
|
8
9
|
this.listUpdate.forEach((system: any) => {
|
|
9
10
|
this.systems.update(system, dt)
|
package/src/base/index.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
import { NodeComp } from '../components/NodeComp'
|
|
2
|
+
|
|
1
3
|
export * from './EnhancedComponent'
|
|
2
4
|
export * from './gworld'
|
|
3
5
|
export * from './utils'
|
|
6
|
+
|
|
7
|
+
export interface BaseComponentProps<T> {
|
|
8
|
+
$ref?: T
|
|
9
|
+
$push?: T[]
|
|
10
|
+
$refNode?: NodeComp
|
|
11
|
+
$pushNode?: NodeComp[]
|
|
12
|
+
node?: Partial<NodeComp>
|
|
13
|
+
// [$key: `$${string}`]: string
|
|
14
|
+
}
|
package/src/base/utils.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Constructor } from 'entityx-ts'
|
|
1
|
+
import { Constructor } from 'entityx-ts'
|
|
2
2
|
|
|
3
|
-
import { GameWorld } from '..'
|
|
4
|
-
import { ComponentX, NoRenderComponentX } from '../components/BaseComponent'
|
|
3
|
+
import { GameWorld } from '..'
|
|
4
|
+
import { ComponentX, NoRenderComponentX } from '../components/BaseComponent'
|
|
5
5
|
|
|
6
|
-
export type GetProps<T> = T extends ComponentX<infer P> ? P : T extends NoRenderComponentX<infer Q> ? Q : never
|
|
6
|
+
export type GetProps<T> = T extends ComponentX<infer P> ? P : T extends NoRenderComponentX<infer Q> ? Q : never
|
|
7
7
|
|
|
8
8
|
export function instantiate<T extends ComponentX>(ComponentType: Constructor<T>, data?: GetProps<T>): T {
|
|
9
9
|
const instance = new ComponentType()
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import Box2DFactory from 'box2d-wasm'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
EventManager,
|
|
5
|
-
EventTypes,
|
|
6
|
-
System
|
|
7
|
-
} from 'entityx-ts';
|
|
8
|
-
import { GameWorld, Graphics, instantiate, NodeComp, Vec2 } from '..';
|
|
1
|
+
import Box2DFactory from 'box2d-wasm'
|
|
2
|
+
import { EntityManager, EventManager, EventTypes, System } from 'entityx-ts'
|
|
3
|
+
import { Graphics } from 'pixi.js'
|
|
9
4
|
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
5
|
+
import { GameWorld, instantiate, NodeComp, Vec2 } from '..'
|
|
6
|
+
import { makeContactListener } from './ContactListener'
|
|
7
|
+
import { makeDebugDraw } from './debugDraw'
|
|
12
8
|
import {
|
|
13
9
|
BoxColliderPhysics,
|
|
14
10
|
CircleColliderPhysics,
|
|
@@ -16,8 +12,8 @@ import {
|
|
|
16
12
|
PhysicsMaterial,
|
|
17
13
|
PolygonColliderPhysics,
|
|
18
14
|
RigidBody,
|
|
19
|
-
} from './PhysicsComponent'
|
|
20
|
-
import { PhysicsSprite } from './PhysicsSprite'
|
|
15
|
+
} from './PhysicsComponent'
|
|
16
|
+
import { PhysicsSprite } from './PhysicsSprite'
|
|
21
17
|
|
|
22
18
|
// Box2D.b2Fixture.prototype.shouldCollide = function (other) {
|
|
23
19
|
// const nodeThis: NodeComp = this.getBody().getUserData()
|
|
@@ -27,18 +23,18 @@ import { PhysicsSprite } from './PhysicsSprite';
|
|
|
27
23
|
// }
|
|
28
24
|
export let box2D: typeof Box2D
|
|
29
25
|
export async function initBox2d() {
|
|
30
|
-
box2D = await Box2DFactory()
|
|
26
|
+
box2D = await Box2DFactory()
|
|
31
27
|
}
|
|
32
28
|
|
|
33
29
|
export function setColliderMatrix(colliderMatrix = [[true]]) {
|
|
34
30
|
const physicsSystem = GameWorld.Instance.systems.get(PhysicsSystem)
|
|
35
31
|
physicsSystem.colliderMatrix = colliderMatrix
|
|
36
32
|
}
|
|
37
|
-
const maxTimeStep = 1 / 60
|
|
38
|
-
const velocityIterations = 1
|
|
39
|
-
const positionIterations = 1
|
|
33
|
+
const maxTimeStep = 1 / 60
|
|
34
|
+
const velocityIterations = 1
|
|
35
|
+
const positionIterations = 1
|
|
40
36
|
const metadata: { [key: number]: NodeComp } = {}
|
|
41
|
-
const pixelsPerMeter = 1
|
|
37
|
+
const pixelsPerMeter = 1
|
|
42
38
|
|
|
43
39
|
export class PhysicsSystem implements System {
|
|
44
40
|
world: Box2D.b2World
|
|
@@ -53,15 +49,16 @@ export class PhysicsSystem implements System {
|
|
|
53
49
|
}
|
|
54
50
|
|
|
55
51
|
configure(event_manager: EventManager) {
|
|
56
|
-
const { b2BodyDef, b2_dynamicBody, b2_staticBody, b2FixtureDef, b2PolygonShape, b2Vec2, b2World, getPointer, b2ContactListener } =
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
const { b2BodyDef, b2_dynamicBody, b2_staticBody, b2FixtureDef, b2PolygonShape, b2Vec2, b2World, getPointer, b2ContactListener } =
|
|
53
|
+
box2D as typeof Box2D
|
|
54
|
+
const gravity = new b2Vec2(0, 10)
|
|
55
|
+
this.world = new b2World(gravity)
|
|
59
56
|
console.log('configure world', (event_manager.world as GameWorld).app)
|
|
60
57
|
// event_manager.world.physicsManager = this
|
|
61
|
-
const graphics = new Graphics()
|
|
58
|
+
const graphics = new Graphics()
|
|
62
59
|
this.graphics = graphics
|
|
63
60
|
graphics.zIndex = 1000
|
|
64
|
-
|
|
61
|
+
;(event_manager.world as GameWorld).app.stage.addChild(graphics)
|
|
65
62
|
// event_manager.subscribe(ComponentAddedEvent(RigidBody), this);
|
|
66
63
|
event_manager.subscribe(EventTypes.ComponentAdded, BoxColliderPhysics, ({ entity, component }) => {
|
|
67
64
|
console.log('ComponentAddedEvent BoxColliderPhysics', component)
|
|
@@ -70,7 +67,7 @@ export class PhysicsSystem implements System {
|
|
|
70
67
|
rigidBody = instantiate(RigidBody)
|
|
71
68
|
entity.assign(rigidBody)
|
|
72
69
|
}
|
|
73
|
-
const { type = 'static', gravityScale = 1
|
|
70
|
+
const { type = 'static', gravityScale = 1 } = rigidBody.props
|
|
74
71
|
const physicsMaterial = entity.getComponent(PhysicsMaterial)
|
|
75
72
|
const { density = 1, friction = 0.5, restitution = 0.3 } = physicsMaterial?.props || {}
|
|
76
73
|
const box = component
|
|
@@ -78,31 +75,31 @@ export class PhysicsSystem implements System {
|
|
|
78
75
|
const { width, height, ...colliderProps } = box.props
|
|
79
76
|
// ett.assign(instantiate(ColliderPhysics, { tag, offset }))
|
|
80
77
|
const { x = 0, y = 0 } = colliderProps.offset || {}
|
|
81
|
-
const zero = new b2Vec2(0, 0)
|
|
82
|
-
const position = new b2Vec2(node.posX, node.posY)
|
|
83
|
-
const offset = new b2Vec2(x, y)
|
|
78
|
+
const zero = new b2Vec2(0, 0)
|
|
79
|
+
const position = new b2Vec2(node.posX, node.posY)
|
|
80
|
+
const offset = new b2Vec2(x, y)
|
|
84
81
|
|
|
85
|
-
const bd = new b2BodyDef()
|
|
86
|
-
bd.set_type(type === 'dynamic' ? b2_dynamicBody : b2_staticBody)
|
|
87
|
-
bd.set_position(zero)
|
|
82
|
+
const bd = new b2BodyDef()
|
|
83
|
+
bd.set_type(type === 'dynamic' ? b2_dynamicBody : b2_staticBody)
|
|
84
|
+
bd.set_position(zero)
|
|
88
85
|
bd.set_gravityScale(gravityScale)
|
|
89
86
|
const body = this.world.CreateBody(bd)
|
|
90
87
|
rigidBody.body = body
|
|
91
88
|
// console.log('body', type, b2_dynamicBody, b2_staticBody, getPointer(body));
|
|
92
89
|
// body.setMassData({ mass: 1 } as any)
|
|
93
90
|
const physicsNode = new PhysicsSprite(node.instance, body)
|
|
94
|
-
const square = new b2PolygonShape()
|
|
95
|
-
square.SetAsBox(width / 2, height / 2)
|
|
96
|
-
const fixtureDef = new b2FixtureDef()
|
|
97
|
-
fixtureDef.set_shape(square)
|
|
98
|
-
fixtureDef.set_density(density)
|
|
99
|
-
fixtureDef.set_friction(friction)
|
|
100
|
-
fixtureDef.set_restitution(restitution)
|
|
101
|
-
body.CreateFixture(fixtureDef)
|
|
102
|
-
body.SetTransform(position, 0)
|
|
103
|
-
body.SetLinearVelocity(zero)
|
|
104
|
-
body.SetAwake(true)
|
|
105
|
-
body.SetEnabled(true)
|
|
91
|
+
const square = new b2PolygonShape()
|
|
92
|
+
square.SetAsBox(width / 2, height / 2)
|
|
93
|
+
const fixtureDef = new b2FixtureDef()
|
|
94
|
+
fixtureDef.set_shape(square)
|
|
95
|
+
fixtureDef.set_density(density)
|
|
96
|
+
fixtureDef.set_friction(friction)
|
|
97
|
+
fixtureDef.set_restitution(restitution)
|
|
98
|
+
body.CreateFixture(fixtureDef)
|
|
99
|
+
body.SetTransform(position, 0)
|
|
100
|
+
body.SetLinearVelocity(zero)
|
|
101
|
+
body.SetAwake(true)
|
|
102
|
+
body.SetEnabled(true)
|
|
106
103
|
metadata[getPointer(body)] = node
|
|
107
104
|
|
|
108
105
|
const physicsCollide = entity.assign(instantiate(ColliderPhysics, colliderProps))
|
|
@@ -110,9 +107,9 @@ export class PhysicsSystem implements System {
|
|
|
110
107
|
physicsCollide.node = node
|
|
111
108
|
box.node = node
|
|
112
109
|
})
|
|
113
|
-
event_manager.subscribe(EventTypes.ComponentAdded,
|
|
114
|
-
event_manager.subscribe(EventTypes.ComponentAdded,
|
|
115
|
-
event_manager.subscribe(EventTypes.ComponentRemoved,
|
|
110
|
+
event_manager.subscribe(EventTypes.ComponentAdded, CircleColliderPhysics, () => {})
|
|
111
|
+
event_manager.subscribe(EventTypes.ComponentAdded, PolygonColliderPhysics, () => {})
|
|
112
|
+
event_manager.subscribe(EventTypes.ComponentRemoved, NodeComp, () => {
|
|
116
113
|
// log('ComponentRemovedEvent NodeComp', event);
|
|
117
114
|
// const node = event.entity.getComponent(NodeComp)
|
|
118
115
|
// if (node.instance instanceof Sprite) {
|
|
@@ -127,11 +124,11 @@ export class PhysicsSystem implements System {
|
|
|
127
124
|
|
|
128
125
|
update(entities: EntityManager, events: EventManager, dt: number) {
|
|
129
126
|
if (this.world) {
|
|
130
|
-
const clampedDelta = Math.min(dt, maxTimeStep)
|
|
131
|
-
this.world.Step(clampedDelta, velocityIterations, positionIterations)
|
|
127
|
+
const clampedDelta = Math.min(dt, maxTimeStep)
|
|
128
|
+
this.world.Step(clampedDelta, velocityIterations, positionIterations)
|
|
132
129
|
this.graphics.clear()
|
|
133
|
-
this.world.DebugDraw()
|
|
134
|
-
this.graphics.fill()
|
|
130
|
+
this.world.DebugDraw()
|
|
131
|
+
this.graphics.fill()
|
|
135
132
|
// this.graphics.stroke();
|
|
136
133
|
// console.log('GetBodyCount', this.world.GetBodyCount());
|
|
137
134
|
}
|