1681-engine 0.6.6 → 0.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/core/Group.js +12 -0
- package/dist/core/Stage.js +9 -8
- package/dist/core/depthSort.js +44 -0
- package/dist/types/core/Group.d.ts +8 -0
- package/dist/types/core/Group.d.ts.map +1 -1
- package/dist/types/core/Stage.d.ts.map +1 -1
- package/dist/types/core/depthSort.d.ts +6 -0
- package/dist/types/core/depthSort.d.ts.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this package are written here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
4
4
|
and versions follow [Semantic Versioning](https://semver.org/); before 1.0 a minor version may break the API.
|
|
5
5
|
|
|
6
|
+
## 0.6.7
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- `Group.keepAbove` / `keepBelow`: keep a child on one side of another, moved only when it is on the wrong side. Two
|
|
11
|
+
pieces each placed *directly* above one body with `moveAbove` (two blades, a fist on a hilt) pushed each other out
|
|
12
|
+
every frame, and every push rebuilt Pixi's draw instructions.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- The world layer sorts by depth once a frame (`deferDepthSort`, `flushDepthSorts`, run by `Stage.frame` after the
|
|
17
|
+
camera): a child's `zIndex` changing only notes the container, and the children are sorted — the render group's
|
|
18
|
+
structure marked changed — only when they are out of order. Pixi marked the structure changed at every `zIndex`
|
|
19
|
+
change, so a world sorted by its bodies' feet rebuilt every draw instruction every frame anything walked up or down
|
|
20
|
+
the screen. A container not handed over keeps Pixi's own behaviour.
|
|
21
|
+
|
|
6
22
|
## 0.6.6
|
|
7
23
|
|
|
8
24
|
### Added
|
package/dist/core/Group.js
CHANGED
|
@@ -22,6 +22,18 @@ class d extends r(i) {
|
|
|
22
22
|
moveBelow(t, e) {
|
|
23
23
|
return t.parent !== this || e.parent !== this || t === e ? this : this.getChildIndex(t) === this.getChildIndex(e) - 1 ? this : (this.removeChild(t), this.addChildAt(t, this.getChildIndex(e)), this);
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Keeps `child` drawn above `other`, anywhere above it: moved (directly above) only when it is below. What a weapon
|
|
27
|
+
* held over its body asks for. `moveAbove` from two pieces each wanting to sit *directly* above the same body (two
|
|
28
|
+
* blades, a fist on a hilt, a load) pushed the other out every frame, and every push rebuilt Pixi's instructions.
|
|
29
|
+
*/
|
|
30
|
+
keepAbove(t, e) {
|
|
31
|
+
return t.parent !== this || e.parent !== this || t === e ? this : this.getChildIndex(t) > this.getChildIndex(e) ? this : this.moveAbove(t, e);
|
|
32
|
+
}
|
|
33
|
+
/** Keeps `child` drawn below `other`, anywhere below it: moved (directly below) only when it is above (`keepAbove`). */
|
|
34
|
+
keepBelow(t, e) {
|
|
35
|
+
return t.parent !== this || e.parent !== this || t === e ? this : this.getChildIndex(t) < this.getChildIndex(e) ? this : this.moveBelow(t, e);
|
|
36
|
+
}
|
|
25
37
|
/** Puts `child` directly above `other` in the draw order; already there, it does nothing (see `moveBelow`). */
|
|
26
38
|
moveAbove(t, e) {
|
|
27
39
|
return t.parent !== this || e.parent !== this || t === e ? this : this.getChildIndex(t) === this.getChildIndex(e) + 1 ? this : (this.removeChild(t), this.addChildAt(t, this.getChildIndex(e) + 1), this);
|
package/dist/core/Stage.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Container as s } from "pixi.js";
|
|
2
2
|
import { Camera as n } from "./Camera.js";
|
|
3
3
|
import { Clock as a } from "./Clock.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { deferDepthSort as o, flushDepthSorts as d } from "./depthSort.js";
|
|
5
|
+
import { ObjectFactory as c } from "./ObjectFactory.js";
|
|
6
|
+
import { PixelGrid as m } from "./PixelGrid.js";
|
|
7
|
+
import { Pointer as p } from "./Pointer.js";
|
|
8
|
+
import { Tweener as u } from "./Tweener.js";
|
|
8
9
|
class h {
|
|
9
10
|
constructor(t, e) {
|
|
10
|
-
this.app = t, this.textures = e, t.stage.addChild(this.world, this.screen), this.cameras = { main: new n(this.world, this.screen) }, this.input = { activePointer: new
|
|
11
|
+
this.app = t, this.textures = e, t.stage.addChild(this.world, this.screen), o(this.world), this.cameras = { main: new n(this.world, this.screen) }, this.input = { activePointer: new p(t.canvas) }, this.grid = new m(t, this.world), this.time.onError = (i) => this.caught("timers", i), this.syncSize();
|
|
11
12
|
}
|
|
12
13
|
app;
|
|
13
14
|
textures;
|
|
@@ -15,8 +16,8 @@ class h {
|
|
|
15
16
|
static onCaught = null;
|
|
16
17
|
world = new s({ sortableChildren: !0 });
|
|
17
18
|
screen = new s();
|
|
18
|
-
add = new
|
|
19
|
-
tweens = new
|
|
19
|
+
add = new c(this);
|
|
20
|
+
tweens = new u();
|
|
20
21
|
time = new a();
|
|
21
22
|
cameras;
|
|
22
23
|
input;
|
|
@@ -61,7 +62,7 @@ class h {
|
|
|
61
62
|
*/
|
|
62
63
|
frame(t) {
|
|
63
64
|
const e = performance.now();
|
|
64
|
-
this.guard("resize", () => this.syncSize()), this.guard("update", () => this.update(e, t)), this.guard("tweens", () => this.tweens.update(t)), this.guard("timers", () => this.time.update(e)), this.guard("camera", () => this.cameras.main.apply(e)), (this.pixelPerfect || this.gridLive) && (this.gridLive = this.pixelPerfect, this.guard("pixel grid", () => this.grid.render(this.cameras.main, this.pixelPerfect, this.pixelDensity)));
|
|
65
|
+
this.guard("resize", () => this.syncSize()), this.guard("update", () => this.update(e, t)), this.guard("tweens", () => this.tweens.update(t)), this.guard("timers", () => this.time.update(e)), this.guard("camera", () => this.cameras.main.apply(e)), this.guard("depth", d), (this.pixelPerfect || this.gridLive) && (this.gridLive = this.pixelPerfect, this.guard("pixel grid", () => this.grid.render(this.cameras.main, this.pixelPerfect, this.pixelDensity)));
|
|
65
66
|
}
|
|
66
67
|
/**
|
|
67
68
|
* Keeps a piece of text made outside `add.text`/`add.label` (put on the world any way) at screen resolution while the
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Container as c } from "pixi.js";
|
|
2
|
+
const s = /* @__PURE__ */ new WeakSet(), d = /* @__PURE__ */ new Set();
|
|
3
|
+
let f = !1;
|
|
4
|
+
function p() {
|
|
5
|
+
if (f) return;
|
|
6
|
+
f = !0;
|
|
7
|
+
const e = c.prototype, r = e.depthOfChildModified;
|
|
8
|
+
e.depthOfChildModified = function() {
|
|
9
|
+
const t = this.parent;
|
|
10
|
+
if (t && s.has(t)) {
|
|
11
|
+
const n = t;
|
|
12
|
+
n.sortableChildren = !0, n.sortDirty = !0, d.add(t);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
r.call(this);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function h(e) {
|
|
19
|
+
p(), s.add(e);
|
|
20
|
+
}
|
|
21
|
+
function l() {
|
|
22
|
+
for (const e of d) {
|
|
23
|
+
if (e.destroyed) continue;
|
|
24
|
+
const r = e, o = e.children;
|
|
25
|
+
let t = !0;
|
|
26
|
+
for (let i = 1; i < o.length; i++)
|
|
27
|
+
if (o[i - 1].zIndex > o[i].zIndex) {
|
|
28
|
+
t = !1;
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
if (t) {
|
|
32
|
+
r.sortDirty = !1;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
r.sortChildren();
|
|
36
|
+
const n = r.renderGroup ?? r.parentRenderGroup;
|
|
37
|
+
n && (n.structureDidChange = !0);
|
|
38
|
+
}
|
|
39
|
+
d.clear();
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
h as deferDepthSort,
|
|
43
|
+
l as flushDepthSorts
|
|
44
|
+
};
|
|
@@ -12,6 +12,14 @@ export declare class Group extends Group_base {
|
|
|
12
12
|
* frame — a held weapon ordered against its body every frame did it every frame.
|
|
13
13
|
*/
|
|
14
14
|
moveBelow(child: PixiContainer, other: PixiContainer): this;
|
|
15
|
+
/**
|
|
16
|
+
* Keeps `child` drawn above `other`, anywhere above it: moved (directly above) only when it is below. What a weapon
|
|
17
|
+
* held over its body asks for. `moveAbove` from two pieces each wanting to sit *directly* above the same body (two
|
|
18
|
+
* blades, a fist on a hilt, a load) pushed the other out every frame, and every push rebuilt Pixi's instructions.
|
|
19
|
+
*/
|
|
20
|
+
keepAbove(child: PixiContainer, other: PixiContainer): this;
|
|
21
|
+
/** Keeps `child` drawn below `other`, anywhere below it: moved (directly below) only when it is above (`keepAbove`). */
|
|
22
|
+
keepBelow(child: PixiContainer, other: PixiContainer): this;
|
|
15
23
|
/** Puts `child` directly above `other` in the draw order; already there, it does nothing (see `moveBelow`). */
|
|
16
24
|
moveAbove(child: PixiContainer, other: PixiContainer): this;
|
|
17
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Group.d.ts","sourceRoot":"","sources":["../../../src/core/Group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;;AAGrE,yFAAyF;AACzF,qBAAa,KAAM,SAAQ,UAAqB;IAC9C,IAAI,IAAI,IAAI,aAAa,EAAE,CAE1B;IAED,GAAG,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,IAAI;IAKjD,KAAK,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAKhD,MAAM,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,UAAQ,GAAG,IAAI;IAMnD;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI;IAQ3D,+GAA+G;IAC/G,SAAS,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI;CAO5D"}
|
|
1
|
+
{"version":3,"file":"Group.d.ts","sourceRoot":"","sources":["../../../src/core/Group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;;AAGrE,yFAAyF;AACzF,qBAAa,KAAM,SAAQ,UAAqB;IAC9C,IAAI,IAAI,IAAI,aAAa,EAAE,CAE1B;IAED,GAAG,CAAC,KAAK,EAAE,aAAa,GAAG,aAAa,EAAE,GAAG,IAAI;IAKjD,KAAK,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAKhD,MAAM,CAAC,KAAK,EAAE,aAAa,EAAE,OAAO,UAAQ,GAAG,IAAI;IAMnD;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI;IAQ3D;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI;IAM3D,wHAAwH;IACxH,SAAS,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI;IAM3D,+GAA+G;IAC/G,SAAS,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,IAAI;CAO5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stage.d.ts","sourceRoot":"","sources":["../../../src/core/Stage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Stage.d.ts","sourceRoot":"","sources":["../../../src/core/Stage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK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IAAI,MAAM,CAElB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,GAAG,IAAI,MAAM,CAEhB;IAED,6GAA6G;IAC7G,QAAQ,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI;IAQpC,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAEjD;;;;OAIG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAe1B;;;OAGG;IACH,SAAS,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI;IAI/B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAE9C;;;;OAIG;IACH,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,IAAI;IAInD,2EAA2E;IAC3E,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC;IAS/D,iIAAiI;IACjI,SAAS,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,IAAI;IASlD,OAAO,IAAI,IAAI;IAUf,OAAO,CAAC,QAAQ;CAWjB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Container } from 'pixi.js';
|
|
2
|
+
/** Checks `container`'s depth order once a frame (`flushDepthSorts`) instead of at every child's `zIndex` change. */
|
|
3
|
+
export declare function deferDepthSort(container: Container): void;
|
|
4
|
+
/** Sorts each container whose children changed depth, marking its render group changed only if the order did. */
|
|
5
|
+
export declare function flushDepthSorts(): void;
|
|
6
|
+
//# sourceMappingURL=depthSort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"depthSort.d.ts","sourceRoot":"","sources":["../../../src/core/depthSort.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAyCpC,qHAAqH;AACrH,wBAAgB,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAGzD;AAED,iHAAiH;AACjH,wBAAgB,eAAe,IAAI,IAAI,CAqBtC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "1681-engine",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "A 2D game engine on PixiJS 8 for any art style: scenes and a fast ECS, a fixed-step loop, asset loading, Tiled maps, sprite animation, input actions, camera follow, audio and deterministic, server-replayable movement, plus Dither, an optional pixel-art module (pixel-perfect effects, dithered lighting).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|