@safe-engine/pixi 8.1.4 → 8.2.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/README.md +9 -3
- package/dist/@types/index.d.ts +2 -0
- package/dist/@types/safex.d.ts +168 -0
- package/dist/app.d.ts +1 -2
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +25 -24
- package/dist/base/EnhancedComponent.d.ts +25 -0
- package/dist/base/EnhancedComponent.d.ts.map +1 -0
- package/dist/base/EnhancedComponent.js +26 -0
- package/dist/base/gworld.d.ts +8 -0
- package/dist/base/gworld.d.ts.map +1 -0
- package/dist/base/gworld.js +16 -0
- package/dist/base/index.d.ts +4 -0
- package/dist/base/index.d.ts.map +1 -0
- package/dist/base/index.js +3 -0
- package/dist/base/utils.d.ts +6 -0
- package/dist/base/utils.d.ts.map +1 -0
- package/dist/base/utils.js +3 -0
- package/dist/collider/CollideComponent.d.ts +63 -0
- package/dist/collider/CollideComponent.d.ts.map +1 -0
- package/dist/collider/CollideComponent.js +236 -0
- package/dist/collider/CollideSystem.d.ts +26 -0
- package/dist/collider/CollideSystem.d.ts.map +1 -0
- package/dist/collider/CollideSystem.js +159 -0
- package/dist/collider/helper/Intersection.d.ts +7 -0
- package/dist/collider/helper/Intersection.d.ts.map +1 -0
- package/dist/collider/helper/Intersection.js +111 -0
- package/dist/collider/helper/utils.d.ts +3 -0
- package/dist/collider/helper/utils.d.ts.map +1 -0
- package/dist/collider/helper/utils.js +11 -0
- package/dist/collider/index.d.ts +3 -0
- package/dist/collider/index.d.ts.map +1 -0
- package/dist/collider/index.js +2 -0
- package/dist/components/BaseComponent.d.ts +6 -5
- package/dist/components/BaseComponent.d.ts.map +1 -1
- package/dist/components/BaseComponent.js +7 -9
- package/dist/components/GUIComponent.d.ts +22 -19
- package/dist/components/GUIComponent.d.ts.map +1 -1
- package/dist/components/GUIComponent.js +27 -44
- package/dist/components/NoRenderComponent.d.ts +33 -0
- package/dist/components/NodeComp.d.ts +13 -13
- package/dist/components/NodeComp.d.ts.map +1 -1
- package/dist/components/NodeComp.js +32 -28
- package/dist/components/RenderComponent.d.ts +7 -6
- package/dist/components/Scene.d.ts +2 -3
- package/dist/components/Scene.d.ts.map +1 -1
- package/dist/components/Scene.js +6 -10
- package/dist/core/Color.d.ts +1 -0
- package/dist/core/Color.d.ts.map +1 -1
- package/dist/core/Color.js +3 -6
- package/dist/core/LoadingBar.js +10 -15
- package/dist/core/NodePool.d.ts +9 -0
- package/dist/core/NodePool.d.ts.map +1 -0
- package/dist/core/NodePool.js +24 -0
- package/dist/core/Size.js +1 -4
- package/dist/core/director.d.ts +3 -0
- package/dist/core/director.d.ts.map +1 -0
- package/dist/core/director.js +7 -0
- package/dist/core/math.d.ts +4 -0
- package/dist/core/math.d.ts.map +1 -0
- package/dist/core/math.js +10 -0
- package/dist/dragonbones/DragonBonesComponent.d.ts +17 -0
- package/dist/dragonbones/DragonBonesComponent.d.ts.map +1 -0
- package/dist/dragonbones/DragonBonesComponent.js +18 -0
- package/dist/dragonbones/DragonBonesSystem.d.ts +6 -0
- package/dist/dragonbones/DragonBonesSystem.d.ts.map +1 -0
- package/dist/dragonbones/DragonBonesSystem.js +29 -0
- package/dist/dragonbones/index.d.ts +3 -0
- package/dist/dragonbones/index.d.ts.map +1 -0
- package/dist/dragonbones/index.js +2 -0
- package/dist/gui/GUIComponent.d.ts +99 -0
- package/dist/gui/GUIComponent.d.ts.map +1 -0
- package/dist/gui/GUIComponent.js +123 -0
- package/dist/{systems → gui}/GUISystem.d.ts +1 -1
- package/dist/gui/GUISystem.d.ts.map +1 -0
- package/dist/gui/GUISystem.js +100 -0
- package/dist/helper/html-text-parser.d.ts +19 -29
- package/dist/helper/html-text-parser.d.ts.map +1 -1
- package/dist/helper/html-text-parser.js +57 -346
- package/dist/helper/utils.d.ts +2 -3
- package/dist/helper/utils.d.ts.map +1 -1
- package/dist/helper/utils.js +18 -23
- package/dist/index.d.ts +16 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -28
- package/dist/norender/NoRenderComponent.d.ts +33 -0
- package/dist/norender/NoRenderComponent.d.ts.map +1 -0
- package/dist/norender/NoRenderComponent.js +50 -0
- package/dist/norender/NoRenderSystem.d.ts +5 -0
- package/dist/norender/NoRenderSystem.d.ts.map +1 -0
- package/dist/norender/NoRenderSystem.js +57 -0
- package/dist/planck/PhysicsComponent.d.ts +37 -0
- package/dist/planck/PhysicsComponent.d.ts.map +1 -0
- package/dist/planck/PhysicsComponent.js +52 -0
- package/dist/planck/PhysicsSprite.d.ts +16 -0
- package/dist/planck/PhysicsSprite.d.ts.map +1 -0
- package/dist/planck/PhysicsSprite.js +31 -0
- package/dist/planck/PhysicsSystem.d.ts +20 -0
- package/dist/planck/PhysicsSystem.d.ts.map +1 -0
- package/dist/planck/PhysicsSystem.js +187 -0
- package/dist/planck/index.d.ts +4 -0
- package/dist/planck/index.d.ts.map +1 -0
- package/dist/planck/index.js +3 -0
- package/dist/render/RenderComponent.d.ts +52 -0
- package/dist/render/RenderComponent.d.ts.map +1 -0
- package/dist/render/RenderComponent.js +104 -0
- package/dist/render/RenderSystem.d.ts.map +1 -0
- package/dist/render/RenderSystem.js +65 -0
- package/dist/spine/SpineComponent.d.ts +10 -0
- package/dist/spine/SpineComponent.d.ts.map +1 -0
- package/dist/spine/SpineComponent.js +3 -0
- package/dist/spine/SpineSystem.d.ts +5 -0
- package/dist/spine/SpineSystem.d.ts.map +1 -0
- package/dist/spine/SpineSystem.js +25 -0
- package/dist/spine/index.d.ts +3 -0
- package/dist/spine/index.d.ts.map +1 -0
- package/dist/spine/index.js +2 -0
- package/dist/spine/lib/BatchableSpineSlot.d.ts +59 -0
- package/dist/spine/lib/BatchableSpineSlot.d.ts.map +1 -0
- package/dist/spine/lib/BatchableSpineSlot.js +86 -0
- package/dist/spine/lib/Spine.d.ts +239 -0
- package/dist/spine/lib/Spine.d.ts.map +1 -0
- package/dist/spine/lib/Spine.js +628 -0
- package/dist/spine/lib/SpineDebugRenderer.d.ts +109 -0
- package/dist/spine/lib/SpineDebugRenderer.d.ts.map +1 -0
- package/dist/spine/lib/SpineDebugRenderer.js +474 -0
- package/dist/spine/lib/SpinePipe.d.ts +49 -0
- package/dist/spine/lib/SpinePipe.d.ts.map +1 -0
- package/dist/spine/lib/SpinePipe.js +148 -0
- package/dist/spine/lib/SpineTexture.d.ts +45 -0
- package/dist/spine/lib/SpineTexture.d.ts.map +1 -0
- package/dist/spine/lib/SpineTexture.js +114 -0
- package/dist/spine/lib/assets/atlasLoader.d.ts +34 -0
- package/dist/spine/lib/assets/atlasLoader.d.ts.map +1 -0
- package/dist/spine/lib/assets/atlasLoader.js +122 -0
- package/dist/spine/lib/assets/skeletonLoader.d.ts +30 -0
- package/dist/spine/lib/assets/skeletonLoader.d.ts.map +1 -0
- package/dist/spine/lib/assets/skeletonLoader.js +70 -0
- package/dist/spine/lib/darktint/DarkTintBatchGeometry.d.ts +33 -0
- package/dist/spine/lib/darktint/DarkTintBatchGeometry.d.ts.map +1 -0
- package/dist/spine/lib/darktint/DarkTintBatchGeometry.js +84 -0
- package/dist/spine/lib/darktint/DarkTintBatcher.d.ts +50 -0
- package/dist/spine/lib/darktint/DarkTintBatcher.d.ts.map +1 -0
- package/dist/spine/lib/darktint/DarkTintBatcher.js +131 -0
- package/dist/spine/lib/darktint/DarkTintShader.d.ts +33 -0
- package/dist/spine/lib/darktint/DarkTintShader.d.ts.map +1 -0
- package/dist/spine/lib/darktint/DarkTintShader.js +59 -0
- package/dist/spine/lib/darktint/darkTintBit.d.ts +51 -0
- package/dist/spine/lib/darktint/darkTintBit.d.ts.map +1 -0
- package/dist/spine/lib/darktint/darkTintBit.js +75 -0
- package/dist/spine/lib/index.d.ts +42 -0
- package/dist/spine/lib/index.d.ts.map +1 -0
- package/dist/spine/lib/index.js +41 -0
- package/dist/spine/lib/require-shim.d.ts +33 -0
- package/dist/spine/lib/require-shim.d.ts.map +1 -0
- package/dist/spine/lib/require-shim.js +38 -0
- package/package.json +13 -9
- package/dist/components/RenderComponent.d.ts.map +0 -1
- package/dist/components/RenderComponent.js +0 -58
- package/dist/systems/GUISystem.d.ts.map +0 -1
- package/dist/systems/GUISystem.js +0 -90
- package/dist/systems/RenderSystem.d.ts.map +0 -1
- package/dist/systems/RenderSystem.js +0 -67
- /package/dist/{systems → render}/RenderSystem.d.ts +0 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { NoRenderComponentX } from '../components/BaseComponent';
|
|
2
|
+
export class EventRegister extends NoRenderComponentX {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(...arguments);
|
|
5
|
+
this.events = {};
|
|
6
|
+
}
|
|
7
|
+
on(name, callback, target) {
|
|
8
|
+
const bound = target ? callback.bind(target) : callback;
|
|
9
|
+
if (this.events[name]) {
|
|
10
|
+
this.events[name].push(bound);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
this.events[name] = [bound];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
off(name) {
|
|
17
|
+
this.events[name] = undefined;
|
|
18
|
+
}
|
|
19
|
+
emit(name, ...params) {
|
|
20
|
+
if (this.events[name]) {
|
|
21
|
+
this.events[name].forEach((fc) => fc(...params));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class TouchEventRegister extends NoRenderComponentX {
|
|
26
|
+
setOnTouchStart(cb) {
|
|
27
|
+
this.onTouchStart = cb;
|
|
28
|
+
}
|
|
29
|
+
setOnTouchMove(cb) {
|
|
30
|
+
this.onTouchMove = cb;
|
|
31
|
+
}
|
|
32
|
+
setOnTouchEnd(cb) {
|
|
33
|
+
this.onTouchEnd = cb;
|
|
34
|
+
}
|
|
35
|
+
setOnTouchCancel(cb) {
|
|
36
|
+
this.onTouchCancel = cb;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export class ExtraDataComp extends NoRenderComponentX {
|
|
40
|
+
constructor() {
|
|
41
|
+
super(...arguments);
|
|
42
|
+
this.data = {};
|
|
43
|
+
}
|
|
44
|
+
getData(key) {
|
|
45
|
+
return this.data[key];
|
|
46
|
+
}
|
|
47
|
+
setData(key, val) {
|
|
48
|
+
this.data[key] = val;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +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;AAO7D,qBAAa,cAAe,YAAW,MAAM;IAC3C,SAAS,CAAC,aAAa,EAAE,YAAY;CAyDtC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { EventTypes } from 'entityx-ts';
|
|
2
|
+
import { NodeComp } from '../components/NodeComp';
|
|
3
|
+
import { ExtraDataComp, TouchEventRegister } from './NoRenderComponent';
|
|
4
|
+
export class NoRenderSystem {
|
|
5
|
+
configure(event_manager) {
|
|
6
|
+
event_manager.subscribe(EventTypes.ComponentAdded, ExtraDataComp, ({ entity, component }) => {
|
|
7
|
+
const { key, value } = component;
|
|
8
|
+
component.data[key] = value;
|
|
9
|
+
});
|
|
10
|
+
event_manager.subscribe(EventTypes.ComponentAdded, TouchEventRegister, ({ entity, component }) => {
|
|
11
|
+
const ett = entity;
|
|
12
|
+
const touchComp = component;
|
|
13
|
+
const nodeComp = ett.getComponent(NodeComp);
|
|
14
|
+
touchComp.node = nodeComp;
|
|
15
|
+
const container = nodeComp.instance;
|
|
16
|
+
if (touchComp.onTouchStart) {
|
|
17
|
+
container.on('touchstart', (event) => {
|
|
18
|
+
touchComp.onTouchStart(event, nodeComp);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
if (touchComp.onTouchMove) {
|
|
22
|
+
container.on('touchmove', (event) => {
|
|
23
|
+
touchComp.onTouchMove(event, nodeComp);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (touchComp.onTouchEnd) {
|
|
27
|
+
container.on('touchend', (event) => {
|
|
28
|
+
touchComp.onTouchEnd(event, nodeComp);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (touchComp.onTouchEnd) {
|
|
32
|
+
container.on('touchcancel', (event) => {
|
|
33
|
+
touchComp.onTouchEnd(event, nodeComp);
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
event_manager.subscribe(EventTypes.ComponentRemoved, TouchEventRegister, ({ entity, component }) => {
|
|
38
|
+
console.log('ComponentRemovedEvent TouchEventRegister', event);
|
|
39
|
+
// const ett = event.entity
|
|
40
|
+
// const nodeComp = ett.getComponent(NodeComp)
|
|
41
|
+
const touchComp = component;
|
|
42
|
+
const container = touchComp.node.instance;
|
|
43
|
+
if (touchComp.onTouchStart) {
|
|
44
|
+
container.removeListener('touchstart');
|
|
45
|
+
}
|
|
46
|
+
if (touchComp.onTouchMove) {
|
|
47
|
+
container.removeListener('touchmove');
|
|
48
|
+
}
|
|
49
|
+
if (touchComp.onTouchEnd) {
|
|
50
|
+
container.removeListener('touchend');
|
|
51
|
+
}
|
|
52
|
+
if (touchComp.onTouchEnd) {
|
|
53
|
+
container.removeListener('touchcancel');
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Body, BodyType, Vec2 } from 'planck';
|
|
2
|
+
import { BoxColliderPhysicsProps, CircleColliderPhysicsProps, ColliderPhysicsProps, PhysicsMaterialProps, PolygonColliderPhysicsProps, RigidBodyProps } from '../@types/safex';
|
|
3
|
+
import { NoRenderComponentX } from '../components/BaseComponent';
|
|
4
|
+
import { PhysicsSprite } from './PhysicsSprite';
|
|
5
|
+
export declare class RigidBody extends NoRenderComponentX<RigidBodyProps> {
|
|
6
|
+
type: BodyType;
|
|
7
|
+
density: number;
|
|
8
|
+
restitution: number;
|
|
9
|
+
friction: number;
|
|
10
|
+
body: Body;
|
|
11
|
+
gravityScale: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class PhysicsMaterial extends NoRenderComponentX<PhysicsMaterialProps> {
|
|
14
|
+
density: number;
|
|
15
|
+
restitution: number;
|
|
16
|
+
friction: number;
|
|
17
|
+
}
|
|
18
|
+
export declare class ColliderPhysics<T extends ColliderPhysicsProps = ColliderPhysicsProps> extends NoRenderComponentX<T, PhysicsSprite['node']> {
|
|
19
|
+
tag: number;
|
|
20
|
+
group: number;
|
|
21
|
+
offset: Vec2;
|
|
22
|
+
onCollisionEnter: (other: ColliderPhysics) => void;
|
|
23
|
+
onCollisionExit: (other: ColliderPhysics) => void;
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
instance: PhysicsSprite;
|
|
26
|
+
}
|
|
27
|
+
export declare class BoxColliderPhysics extends ColliderPhysics<BoxColliderPhysicsProps> {
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
}
|
|
31
|
+
export declare class CircleColliderPhysics extends ColliderPhysics<CircleColliderPhysicsProps> {
|
|
32
|
+
radius: number;
|
|
33
|
+
}
|
|
34
|
+
export declare class PolygonColliderPhysics extends ColliderPhysics<PolygonColliderPhysicsProps> {
|
|
35
|
+
points: number[];
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=PhysicsComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PhysicsComponent.d.ts","sourceRoot":"","sources":["../../src/planck/PhysicsComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,uBAAuB,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC9K,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAG/C,qBAAa,SAAU,SAAQ,kBAAkB,CAAC,cAAc,CAAC;IAC/D,IAAI,EAAE,QAAQ,CAAY;IAC1B,OAAO,SAAI;IACX,WAAW,SAAM;IACjB,QAAQ,SAAM;IACd,IAAI,EAAE,IAAI,CAAA;IACV,YAAY,SAAI;CAmBjB;AAED,qBAAa,eAAgB,SAAQ,kBAAkB,CAAC,oBAAoB,CAAC;IAC3E,OAAO,SAAI;IACX,WAAW,SAAI;IACf,QAAQ,SAAI;CACb;AAED,qBAAa,eAAe,CAAC,CAAC,SAAS,oBAAoB,GAAG,oBAAoB,CAAE,SAAQ,kBAAkB,CAAC,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACtI,GAAG,SAAI;IACP,KAAK,SAAI;IACT,MAAM,EAAE,IAAI,CAAc;IAC1B,gBAAgB,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAA;IAClD,eAAe,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAA;IACjD,OAAO,UAAO;IACd,QAAQ,EAAE,aAAa,CAAA;CACxB;AAED,qBAAa,kBAAmB,SAAQ,eAAe,CAAC,uBAAuB,CAAC;IAC9E,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CAWf;AAED,qBAAa,qBAAsB,SAAQ,eAAe,CAAC,0BAA0B,CAAC;IACpF,MAAM,EAAE,MAAM,CAAA;CACf;AAED,qBAAa,sBAAuB,SAAQ,eAAe,CAAC,2BAA2B,CAAC;IACtF,MAAM,EAAE,MAAM,EAAE,CAAA;CACjB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Vec2 } from 'planck';
|
|
2
|
+
import { NoRenderComponentX } from '../components/BaseComponent';
|
|
3
|
+
export class RigidBody extends NoRenderComponentX {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.type = 'dynamic';
|
|
7
|
+
this.density = 1;
|
|
8
|
+
this.restitution = 0.5;
|
|
9
|
+
this.friction = 0.3;
|
|
10
|
+
this.gravityScale = 1;
|
|
11
|
+
// set linearVelocity(vel: Vec2) {
|
|
12
|
+
// if (!this.node) {
|
|
13
|
+
// return
|
|
14
|
+
// }
|
|
15
|
+
// const physics = this.node.instance
|
|
16
|
+
// if (physics instanceof Sprite) {
|
|
17
|
+
// physics.getBody().setVel(vel)
|
|
18
|
+
// }
|
|
19
|
+
// }
|
|
20
|
+
// get linearVelocity() {
|
|
21
|
+
// if (!this.node) {
|
|
22
|
+
// return Vec2.ZERO
|
|
23
|
+
// }
|
|
24
|
+
// const physics = this.node.instance
|
|
25
|
+
// const vel = (physics as Sprite).getBody().getVel()
|
|
26
|
+
// return v2(vel)
|
|
27
|
+
// }
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class PhysicsMaterial extends NoRenderComponentX {
|
|
31
|
+
constructor() {
|
|
32
|
+
super(...arguments);
|
|
33
|
+
this.density = 1;
|
|
34
|
+
this.restitution = 0;
|
|
35
|
+
this.friction = 0;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class ColliderPhysics extends NoRenderComponentX {
|
|
39
|
+
constructor() {
|
|
40
|
+
super(...arguments);
|
|
41
|
+
this.tag = 0;
|
|
42
|
+
this.group = 0;
|
|
43
|
+
this.offset = Vec2.zero();
|
|
44
|
+
this.enabled = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export class BoxColliderPhysics extends ColliderPhysics {
|
|
48
|
+
}
|
|
49
|
+
export class CircleColliderPhysics extends ColliderPhysics {
|
|
50
|
+
}
|
|
51
|
+
export class PolygonColliderPhysics extends ColliderPhysics {
|
|
52
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Container } from 'pixi.js';
|
|
2
|
+
import { Body, Vec2 } from 'planck';
|
|
3
|
+
export declare class PhysicsSprite {
|
|
4
|
+
node: Container;
|
|
5
|
+
physicsBody: Body;
|
|
6
|
+
constructor(node: Container, body: Body);
|
|
7
|
+
set position(val: Vec2);
|
|
8
|
+
set x(val: number);
|
|
9
|
+
set y(val: number);
|
|
10
|
+
get x(): number;
|
|
11
|
+
get y(): number;
|
|
12
|
+
set angle(val: number);
|
|
13
|
+
get angle(): number;
|
|
14
|
+
addChild(child: Container): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=PhysicsSprite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PhysicsSprite.d.ts","sourceRoot":"","sources":["../../src/planck/PhysicsSprite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAEnC,qBAAa,aAAa;IACxB,IAAI,EAAE,SAAS,CAAA;IACf,WAAW,EAAE,IAAI,CAAA;gBAEL,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI;IAKvC,IAAI,QAAQ,CAAC,GAAG,EAAE,IAAI,EAErB;IAED,IAAI,CAAC,CAAC,GAAG,QAAA,EAER;IACD,IAAI,CAAC,CAAC,GAAG,QAAA,EAER;IAED,IAAI,CAAC,WAEJ;IAED,IAAI,CAAC,WAEJ;IAED,IAAI,KAAK,CAAC,GAAG,EAAE,MAAM,EAEpB;IAED,IAAI,KAAK,IAJM,MAAM,CAMpB;IAED,QAAQ,CAAC,KAAK,EAAE,SAAS;CAG1B"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Vec2 } from 'planck';
|
|
2
|
+
export class PhysicsSprite {
|
|
3
|
+
constructor(node, body) {
|
|
4
|
+
this.node = node;
|
|
5
|
+
this.physicsBody = body;
|
|
6
|
+
}
|
|
7
|
+
set position(val) {
|
|
8
|
+
this.physicsBody.setPosition(val);
|
|
9
|
+
}
|
|
10
|
+
set x(val) {
|
|
11
|
+
this.physicsBody.setPosition(Vec2(val, this.y));
|
|
12
|
+
}
|
|
13
|
+
set y(val) {
|
|
14
|
+
this.physicsBody.setPosition(Vec2(this.x, val));
|
|
15
|
+
}
|
|
16
|
+
get x() {
|
|
17
|
+
return this.physicsBody.getPosition().x;
|
|
18
|
+
}
|
|
19
|
+
get y() {
|
|
20
|
+
return this.physicsBody.getPosition().x;
|
|
21
|
+
}
|
|
22
|
+
set angle(val) {
|
|
23
|
+
this.physicsBody.setAngle(val);
|
|
24
|
+
}
|
|
25
|
+
get angle() {
|
|
26
|
+
return this.physicsBody.getAngle();
|
|
27
|
+
}
|
|
28
|
+
addChild(child) {
|
|
29
|
+
this.node.addChild(child);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EntityManager, EventManager, System } from 'entityx-ts';
|
|
2
|
+
import { Body, Contact, Fixture, Manifold, Shape, World } from 'planck';
|
|
3
|
+
export declare function setColliderMatrix(colliderMatrix?: boolean[][]): void;
|
|
4
|
+
export declare class PhysicsSystem implements System {
|
|
5
|
+
world: World;
|
|
6
|
+
listRemoveBody: Body[];
|
|
7
|
+
listRemoveShape: Shape[];
|
|
8
|
+
colliderMatrix: boolean[][];
|
|
9
|
+
configure(event_manager: EventManager): void;
|
|
10
|
+
update(entities: EntityManager, events: EventManager, dt: number): void;
|
|
11
|
+
renderBody(body: Body): void;
|
|
12
|
+
renderFixture(fixture: Fixture): void;
|
|
13
|
+
renderJoint(joint: any): void;
|
|
14
|
+
contactBegin(contact: Contact): void;
|
|
15
|
+
preSolve(contact: Contact, oldManifold: Manifold): void;
|
|
16
|
+
postSolve(contact: Contact, contactImpulse: any): void;
|
|
17
|
+
contactEnd(contact: Contact): void;
|
|
18
|
+
set enabled(val: any);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=PhysicsSystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PhysicsSystem.d.ts","sourceRoot":"","sources":["../../src/planck/PhysicsSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,YAAY,EAEZ,MAAM,EACP,MAAM,YAAY,CAAA;AACnB,OAAO,EAAE,IAAI,EAAO,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAQ,KAAK,EAAE,MAAM,QAAQ,CAAA;AAqBlF,wBAAgB,iBAAiB,CAAC,cAAc,cAAW,QAG1D;AAED,qBAAa,aAAc,YAAW,MAAM;IAC1C,KAAK,EAAE,KAAK,CAAA;IACZ,cAAc,EAAE,IAAI,EAAE,CAAK;IAC3B,eAAe,EAAE,KAAK,EAAE,CAAK;IAC7B,cAAc,cAAW;IAEzB,SAAS,CAAC,aAAa,EAAE,YAAY;IAgErC,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM;IAoBhE,UAAU,CAAC,IAAI,EAAE,IAAI;IAWrB,aAAa,CAAC,OAAO,EAAE,OAAO;IAM9B,WAAW,CAAC,KAAK,KAAA;IAIjB,YAAY,CAAC,OAAO,EAAE,OAAO;IAsB7B,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ;IAIhD,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,KAAA;IAI1C,UAAU,CAAC,OAAO,EAAE,OAAO;IAkB3B,IAAI,OAAO,CAAC,GAAG,KAAA,EAMd;CACF"}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { EventTypes } from 'entityx-ts';
|
|
13
|
+
import { Box, Fixture, Vec2, World } from 'planck';
|
|
14
|
+
import { Graphics } from 'pixi.js';
|
|
15
|
+
import { GameWorld, instantiate } from '../base';
|
|
16
|
+
import { NodeComp } from '../components/NodeComp';
|
|
17
|
+
import { BoxColliderPhysics, CircleColliderPhysics, ColliderPhysics, PolygonColliderPhysics, RigidBody, } from './PhysicsComponent';
|
|
18
|
+
import { PhysicsSprite } from './PhysicsSprite';
|
|
19
|
+
Fixture.prototype.shouldCollide = function (other) {
|
|
20
|
+
const nodeThis = this.getBody().getUserData();
|
|
21
|
+
const nodeOther = other.getBody().getUserData();
|
|
22
|
+
const { colliderMatrix } = GameWorld.Instance.systems.get(PhysicsSystem);
|
|
23
|
+
return colliderMatrix[nodeOther.group][nodeThis.group];
|
|
24
|
+
};
|
|
25
|
+
export function setColliderMatrix(colliderMatrix = [[true]]) {
|
|
26
|
+
const physicsSystem = GameWorld.Instance.systems.get(PhysicsSystem);
|
|
27
|
+
physicsSystem.colliderMatrix = colliderMatrix;
|
|
28
|
+
}
|
|
29
|
+
export class PhysicsSystem {
|
|
30
|
+
constructor() {
|
|
31
|
+
this.listRemoveBody = [];
|
|
32
|
+
this.listRemoveShape = [];
|
|
33
|
+
this.colliderMatrix = [[true]];
|
|
34
|
+
}
|
|
35
|
+
configure(event_manager) {
|
|
36
|
+
// Settings.lengthUnitsPerMeter = 100
|
|
37
|
+
this.world = new World({
|
|
38
|
+
gravity: Vec2(0, -10.0),
|
|
39
|
+
});
|
|
40
|
+
// event_manager.world.physicsManager = this
|
|
41
|
+
// event_manager.subscribe(ComponentAddedEvent(RigidBody), this);
|
|
42
|
+
event_manager.subscribe(EventTypes.ComponentAdded, BoxColliderPhysics, ({ entity, component }) => {
|
|
43
|
+
console.log('ComponentAddedEvent BoxColliderPhysics', component);
|
|
44
|
+
let rigidBody = entity.getComponent(RigidBody);
|
|
45
|
+
if (!rigidBody) {
|
|
46
|
+
rigidBody = instantiate(RigidBody);
|
|
47
|
+
entity.assign(rigidBody);
|
|
48
|
+
}
|
|
49
|
+
// const physicsMaterial = entity.getComponent(PhysicsMaterial)
|
|
50
|
+
const box = component;
|
|
51
|
+
const node = entity.getComponent(NodeComp);
|
|
52
|
+
const { width, height } = box, colliderProps = __rest(box
|
|
53
|
+
// ett.assign(instantiate(ColliderPhysics, { tag, offset }))
|
|
54
|
+
// const { density, restitution, friction } = physicsMaterial
|
|
55
|
+
, ["width", "height"]);
|
|
56
|
+
// ett.assign(instantiate(ColliderPhysics, { tag, offset }))
|
|
57
|
+
// const { density, restitution, friction } = physicsMaterial
|
|
58
|
+
const body = this.world.createBody({
|
|
59
|
+
position: node.position, // the body's origin position.
|
|
60
|
+
angle: 0.25 * Math.PI, // the body's angle in radians.
|
|
61
|
+
userData: node,
|
|
62
|
+
type: rigidBody.type,
|
|
63
|
+
gravityScale: rigidBody.gravityScale,
|
|
64
|
+
});
|
|
65
|
+
rigidBody.body = body;
|
|
66
|
+
// console.log('body', body);
|
|
67
|
+
// body.setMassData({ mass: 1 } as any)
|
|
68
|
+
const physicsNode = new PhysicsSprite(node.instance, body);
|
|
69
|
+
const shape = new Box(width, height);
|
|
70
|
+
body.createFixture({
|
|
71
|
+
shape,
|
|
72
|
+
density: 1,
|
|
73
|
+
isSensor: true,
|
|
74
|
+
});
|
|
75
|
+
const debugBox = new Graphics();
|
|
76
|
+
const { x, y } = colliderProps.offset;
|
|
77
|
+
debugBox.rect(x, y, width, height);
|
|
78
|
+
debugBox.fill({ color: 0xff0000, alpha: 0.3 });
|
|
79
|
+
node.instance.addChild(debugBox);
|
|
80
|
+
const physicsCollide = entity.assign(instantiate(ColliderPhysics, colliderProps));
|
|
81
|
+
physicsCollide.instance = physicsNode;
|
|
82
|
+
physicsCollide.node = node;
|
|
83
|
+
box.node = node;
|
|
84
|
+
});
|
|
85
|
+
event_manager.subscribe(EventTypes.ComponentAdded, (CircleColliderPhysics), () => { });
|
|
86
|
+
event_manager.subscribe(EventTypes.ComponentAdded, (PolygonColliderPhysics), () => { });
|
|
87
|
+
event_manager.subscribe(EventTypes.ComponentRemoved, (NodeComp), () => {
|
|
88
|
+
// log('ComponentRemovedEvent NodeComp', event);
|
|
89
|
+
// const node = event.entity.getComponent(NodeComp)
|
|
90
|
+
// if (node.instance instanceof Sprite) {
|
|
91
|
+
// const body = node.instance.getBody()
|
|
92
|
+
// this.listRemoveShape.push(...body.shapeList)
|
|
93
|
+
// this.listRemoveBody.push(body)
|
|
94
|
+
// }
|
|
95
|
+
});
|
|
96
|
+
this.world.on('begin-contact', this.contactBegin.bind(this));
|
|
97
|
+
this.world.on('end-contact', this.contactEnd.bind(this));
|
|
98
|
+
this.world.on('pre-solve', this.preSolve.bind(this));
|
|
99
|
+
this.world.on('post-solve', this.postSolve.bind(this));
|
|
100
|
+
}
|
|
101
|
+
update(entities, events, dt) {
|
|
102
|
+
if (this.world) {
|
|
103
|
+
this.world.step(dt);
|
|
104
|
+
// Iterate over bodies
|
|
105
|
+
for (let body = this.world.getBodyList(); body; body = body.getNext()) {
|
|
106
|
+
this.renderBody(body);
|
|
107
|
+
// ... and fixtures
|
|
108
|
+
for (let fixture = body.getFixtureList(); fixture; fixture = fixture.getNext()) {
|
|
109
|
+
this.renderFixture(fixture);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Iterate over joints
|
|
113
|
+
for (let joint = this.world.getJointList(); joint; joint = joint.getNext()) {
|
|
114
|
+
this.renderJoint(joint);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
renderBody(body) {
|
|
119
|
+
// Render or update body rendering
|
|
120
|
+
const ett = body.getUserData();
|
|
121
|
+
const collider = ett.getComponent(ColliderPhysics);
|
|
122
|
+
if (collider) {
|
|
123
|
+
collider.instance.node.position = body.getPosition();
|
|
124
|
+
collider.instance.angle = body.getAngle();
|
|
125
|
+
// console.log('renderBody body', body.getPosition())
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
renderFixture(fixture) {
|
|
129
|
+
// Render or update fixture rendering
|
|
130
|
+
// const shape = fixture.getShape()
|
|
131
|
+
// console.log('renderFixture shape', shape.m_type)
|
|
132
|
+
}
|
|
133
|
+
renderJoint(joint) {
|
|
134
|
+
// Render or update joint rendering
|
|
135
|
+
}
|
|
136
|
+
contactBegin(contact) {
|
|
137
|
+
const ett1 = contact.getFixtureA().getBody().getUserData();
|
|
138
|
+
const ett2 = contact.getFixtureB().getBody().getUserData();
|
|
139
|
+
// this.world.addPostStepCallback(() => {
|
|
140
|
+
// // log('addPostStepCallback');
|
|
141
|
+
// this.listRemoveShape.forEach((s) => this.world.removeShape(s))
|
|
142
|
+
// this.listRemoveBody.forEach((b) => this.world.removeBody(b))
|
|
143
|
+
// this.listRemoveBody = []
|
|
144
|
+
// this.listRemoveShape = []
|
|
145
|
+
// })
|
|
146
|
+
const phys1 = ett1.getComponent(ColliderPhysics);
|
|
147
|
+
const phys2 = ett2.getComponent(ColliderPhysics);
|
|
148
|
+
if (phys1 && phys2) {
|
|
149
|
+
if (Object.prototype.hasOwnProperty.call(phys1, 'onCollisionEnter')) {
|
|
150
|
+
phys1.onCollisionEnter(phys2);
|
|
151
|
+
}
|
|
152
|
+
if (Object.prototype.hasOwnProperty.call(phys2, 'onCollisionEnter')) {
|
|
153
|
+
phys2.onCollisionEnter(phys1);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
preSolve(contact, oldManifold) {
|
|
158
|
+
// log('preSolve');
|
|
159
|
+
}
|
|
160
|
+
postSolve(contact, contactImpulse) {
|
|
161
|
+
// log('collisionPost');
|
|
162
|
+
}
|
|
163
|
+
contactEnd(contact) {
|
|
164
|
+
// log('collisionSeparate');
|
|
165
|
+
const ett1 = contact.getFixtureA().getBody().getUserData();
|
|
166
|
+
const ett2 = contact.getFixtureB().getBody().getUserData();
|
|
167
|
+
// const event1 = ett1.getComponent(NodeComp)
|
|
168
|
+
const phys1 = ett1.getComponent(ColliderPhysics);
|
|
169
|
+
const phys2 = ett2.getComponent(ColliderPhysics);
|
|
170
|
+
// const event2 = ett2.getComponent(NodeComp)
|
|
171
|
+
if (phys1 && phys2) {
|
|
172
|
+
if (Object.prototype.hasOwnProperty.call(phys1, 'onCollisionExit')) {
|
|
173
|
+
phys1.onCollisionExit(phys2);
|
|
174
|
+
}
|
|
175
|
+
if (Object.prototype.hasOwnProperty.call(phys2, 'onCollisionExit')) {
|
|
176
|
+
phys2.onCollisionExit(phys1);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
set enabled(val) {
|
|
181
|
+
if (val) {
|
|
182
|
+
this.world.setGravity(Vec2(0, -1));
|
|
183
|
+
// this.world.iterations = 60
|
|
184
|
+
// this.world.collisionSlop = 0.5
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/planck/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Graphics, Point, Sprite } from 'pixi.js';
|
|
2
|
+
import { Color4B, Vec2 } from '..';
|
|
3
|
+
import { GraphicsRenderProps, MaskRenderProps, SpriteRenderProps } from '../@types/safex';
|
|
4
|
+
import { ComponentX } from '../components/BaseComponent';
|
|
5
|
+
import { LoadingBar, LoadingBarMode } from '../core/LoadingBar';
|
|
6
|
+
import { SpriteTypes } from './RenderSystem';
|
|
7
|
+
export declare class NodeRender extends ComponentX {
|
|
8
|
+
nodeName?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class SpriteRender extends ComponentX<SpriteRenderProps, Sprite> {
|
|
11
|
+
spriteFrame: string;
|
|
12
|
+
type: SpriteTypes;
|
|
13
|
+
fillType: LoadingBarMode;
|
|
14
|
+
fillRange: number;
|
|
15
|
+
fillCenter: Point;
|
|
16
|
+
loadingBar: LoadingBar;
|
|
17
|
+
setFillRange(val: number): void;
|
|
18
|
+
getSpriteFrame(): string;
|
|
19
|
+
setSpriteFrame(frame: any): void;
|
|
20
|
+
}
|
|
21
|
+
declare enum PointType {
|
|
22
|
+
Circle = 0,
|
|
23
|
+
Rect = 1
|
|
24
|
+
}
|
|
25
|
+
export declare class GraphicsRender extends ComponentX<GraphicsRenderProps, Graphics> {
|
|
26
|
+
lineWidth: number;
|
|
27
|
+
strokeColor: Color4B;
|
|
28
|
+
fillColor: Color4B;
|
|
29
|
+
drawPoint(position: Vec2, pointSize: Float, color: Color4B, pointType?: PointType): void;
|
|
30
|
+
drawLine(origin: Vec2, destination: Vec2, color: Color4B, thickness: Float): void;
|
|
31
|
+
drawRect(origin: Vec2, destination: Vec2, color: Color4B): void;
|
|
32
|
+
drawSolidRect(origin: Vec2, destination: Vec2, color: Color4B): void;
|
|
33
|
+
drawCircle(center: Vec2, radius: Float, angle?: Float, segments?: Integer, drawLineToCenter?: boolean, scaleX?: Float, scaleY?: Float, color?: Color4B, thickness?: Float): void;
|
|
34
|
+
drawSolidCircle(origin: Vec2, destination: Vec2, color: Color4B): void;
|
|
35
|
+
drawQuadBezier(origin: Vec2, destination: Vec2, color: Color4B): void;
|
|
36
|
+
drawCubicBezier(origin: Vec2, destination: Vec2, color: Color4B): void;
|
|
37
|
+
drawCardinalSpline(points: Vec2[], color: Color4B): void;
|
|
38
|
+
drawCatmullRom(points: Vec2[], color: Color4B): void;
|
|
39
|
+
drawPoly(points: Vec2[], closedPolygon: boolean, color: Color4B, thickness?: Float): void;
|
|
40
|
+
drawSolidPoly(points: Vec2[], color: Color4B): void;
|
|
41
|
+
drawDot(points: Vec2[], color: Color4B): void;
|
|
42
|
+
drawSegment(from: Vec2, to: Vec2, color: Color4B): void;
|
|
43
|
+
drawTriangle(p1: Vec2, p2: Vec2, p3: Vec2, color: Color4B): void;
|
|
44
|
+
clear(): void;
|
|
45
|
+
}
|
|
46
|
+
export declare class MaskRender extends ComponentX<MaskRenderProps> {
|
|
47
|
+
type: number;
|
|
48
|
+
segments: number;
|
|
49
|
+
inverted: boolean;
|
|
50
|
+
}
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=RenderComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderComponent.d.ts","sourceRoot":"","sources":["../../src/render/RenderComponent.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Texture } from 'pixi.js';
|
|
2
|
+
import { ComponentX } from '../components/BaseComponent';
|
|
3
|
+
import { LoadingBarMode } from '../core/LoadingBar';
|
|
4
|
+
export class NodeRender extends ComponentX {
|
|
5
|
+
}
|
|
6
|
+
export class SpriteRender extends ComponentX {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.fillType = LoadingBarMode.BAR;
|
|
10
|
+
this.fillRange = 1;
|
|
11
|
+
}
|
|
12
|
+
// set fillStart(val: number) {
|
|
13
|
+
// if (this.node.instance instanceof cc.ProgressTimer) {
|
|
14
|
+
// this.node.instance.setMidpoint(cc.v2(val, val));
|
|
15
|
+
// }
|
|
16
|
+
// }
|
|
17
|
+
setFillRange(val) {
|
|
18
|
+
if (this.loadingBar) {
|
|
19
|
+
this.loadingBar.progress = val;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
getSpriteFrame() {
|
|
23
|
+
return this.spriteFrame;
|
|
24
|
+
}
|
|
25
|
+
setSpriteFrame(frame) {
|
|
26
|
+
this.spriteFrame = frame;
|
|
27
|
+
const sprite = this.node.instance;
|
|
28
|
+
// if (this.node.instance instanceof cc.Sprite) {
|
|
29
|
+
sprite.texture = Texture.from(frame);
|
|
30
|
+
// sprite.texture.rotate = 8
|
|
31
|
+
// } else if (this.node.instance instanceof ccui.ImageView) {
|
|
32
|
+
// if (this.texType) {
|
|
33
|
+
// this.node.instance.loadTexture(frame, this.texType);
|
|
34
|
+
// } else {
|
|
35
|
+
// this.node.instance.loadTexture(frame);
|
|
36
|
+
// }
|
|
37
|
+
// const sprite = new cc.Sprite(frame);
|
|
38
|
+
// this.node.setContentSize(sprite.getContentSize());
|
|
39
|
+
// } else if (this.node.instance instanceof ccui.Button) {
|
|
40
|
+
// this.node.instance.loadTextureNormal(frame);
|
|
41
|
+
// }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
var PointType;
|
|
45
|
+
(function (PointType) {
|
|
46
|
+
PointType[PointType["Circle"] = 0] = "Circle";
|
|
47
|
+
PointType[PointType["Rect"] = 1] = "Rect";
|
|
48
|
+
})(PointType || (PointType = {}));
|
|
49
|
+
;
|
|
50
|
+
export class GraphicsRender extends ComponentX {
|
|
51
|
+
constructor() {
|
|
52
|
+
super(...arguments);
|
|
53
|
+
this.lineWidth = 2;
|
|
54
|
+
}
|
|
55
|
+
drawPoint(position, pointSize, color, pointType = PointType.Rect) {
|
|
56
|
+
}
|
|
57
|
+
// drawPoints(points: Vec2[], color: Color4B) {
|
|
58
|
+
// }
|
|
59
|
+
drawLine(origin, destination, color, thickness) {
|
|
60
|
+
}
|
|
61
|
+
drawRect(origin, destination, color) {
|
|
62
|
+
const { x, y } = origin;
|
|
63
|
+
const width = destination.x - x;
|
|
64
|
+
const height = destination.y - y;
|
|
65
|
+
this.node.instance.rect(x, y, width, height);
|
|
66
|
+
this.node.instance.fill(color);
|
|
67
|
+
}
|
|
68
|
+
drawSolidRect(origin, destination, color) {
|
|
69
|
+
}
|
|
70
|
+
drawCircle(center, radius, angle, segments, drawLineToCenter, scaleX, scaleY, color, thickness) {
|
|
71
|
+
const { x, y } = center;
|
|
72
|
+
this.node.instance.circle(x, y, radius);
|
|
73
|
+
this.node.instance.fill(color);
|
|
74
|
+
}
|
|
75
|
+
drawSolidCircle(origin, destination, color) {
|
|
76
|
+
}
|
|
77
|
+
drawQuadBezier(origin, destination, color) {
|
|
78
|
+
}
|
|
79
|
+
drawCubicBezier(origin, destination, color) {
|
|
80
|
+
}
|
|
81
|
+
drawCardinalSpline(points, color) {
|
|
82
|
+
}
|
|
83
|
+
drawCatmullRom(points, color) {
|
|
84
|
+
}
|
|
85
|
+
drawPoly(points, closedPolygon, color, thickness) {
|
|
86
|
+
this.node.instance.poly(points, closedPolygon);
|
|
87
|
+
this.node.instance.fill(color);
|
|
88
|
+
}
|
|
89
|
+
drawSolidPoly(points, color) {
|
|
90
|
+
}
|
|
91
|
+
drawDot(points, color) {
|
|
92
|
+
}
|
|
93
|
+
drawSegment(from, to, color) {
|
|
94
|
+
}
|
|
95
|
+
drawTriangle(p1, p2, p3, color) {
|
|
96
|
+
this.node.instance.poly([p1, p2, p3], true);
|
|
97
|
+
this.node.instance.fill(color);
|
|
98
|
+
}
|
|
99
|
+
clear() {
|
|
100
|
+
this.node.instance.clear();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export class MaskRender extends ComponentX {
|
|
104
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RenderSystem.d.ts","sourceRoot":"","sources":["../../src/render/RenderSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,MAAM,EACP,MAAM,YAAY,CAAA;AAOnB,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;CAmDtC"}
|