1681-engine 0.6.2 → 0.6.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/CHANGELOG.md +8 -0
- package/dist/core/SharpText.js +27 -26
- package/dist/types/core/SharpText.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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.3
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
|
|
10
|
+
- `SharpText` lays a label's stand-in again only when its home moved, hid, faded or changed depth: `setFromMatrix`
|
|
11
|
+
(a decomposition with trigonometry that also marks the transform changed for Pixi) ran for every label every frame,
|
|
12
|
+
and a town's standing NPC names took ~9% of a frame on a CPU throttled 6x.
|
|
13
|
+
|
|
6
14
|
## 0.6.2
|
|
7
15
|
|
|
8
16
|
### Added
|
package/dist/core/SharpText.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { Container as
|
|
2
|
-
class
|
|
1
|
+
import { Container as p, Matrix as c } from "pixi.js";
|
|
2
|
+
class u {
|
|
3
3
|
constructor(e) {
|
|
4
4
|
this.world = e;
|
|
5
5
|
}
|
|
6
6
|
world;
|
|
7
|
-
layer = new
|
|
7
|
+
layer = new p({ sortableChildren: !0 });
|
|
8
8
|
labels = /* @__PURE__ */ new Set();
|
|
9
|
-
m = new
|
|
9
|
+
m = new c();
|
|
10
10
|
/** Labels tracked since the last sweep for destroyed ones: off, nothing else sweeps them. */
|
|
11
11
|
sinceSweep = 0;
|
|
12
12
|
track(e) {
|
|
13
|
-
this.labels.add({ obj: e, home: null, wrap: null }), ++this.sinceSweep >= 256 && this.prune();
|
|
13
|
+
this.labels.add({ obj: e, home: null, wrap: null, last: null }), ++this.sinceSweep >= 256 && this.prune();
|
|
14
14
|
}
|
|
15
15
|
/** Lays the layer over the world (`origin`: where the world's origin lands on screen) and every label on its home. */
|
|
16
|
-
sync(e,
|
|
17
|
-
this.layer.position.set(e.x, e.y), this.layer.scale.set(
|
|
16
|
+
sync(e, o) {
|
|
17
|
+
this.layer.position.set(e.x, e.y), this.layer.scale.set(o);
|
|
18
18
|
for (const t of this.labels) {
|
|
19
|
-
const
|
|
20
|
-
if (
|
|
19
|
+
const r = t.obj;
|
|
20
|
+
if (r.destroyed) {
|
|
21
21
|
this.drop(t);
|
|
22
22
|
continue;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
if (!(!
|
|
27
|
-
if (
|
|
28
|
-
|
|
24
|
+
r.parent && r.parent !== t.wrap && (t.home = r.parent, t.wrap ??= this.layer.addChild(new p()), t.wrap.addChild(r), t.last = null);
|
|
25
|
+
const s = t.home, a = t.wrap;
|
|
26
|
+
if (!(!s || !a)) {
|
|
27
|
+
if (s.destroyed) {
|
|
28
|
+
r.destroy(), this.drop(t);
|
|
29
29
|
continue;
|
|
30
30
|
}
|
|
31
|
-
this.place(
|
|
31
|
+
this.place(t, s, a, r);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
/** Every label back in its home (the grid switched off), the stand-ins gone. */
|
|
36
36
|
release() {
|
|
37
37
|
for (const e of this.labels) {
|
|
38
|
-
const { obj:
|
|
39
|
-
if (
|
|
38
|
+
const { obj: o, home: t, wrap: r } = e;
|
|
39
|
+
if (o.destroyed) {
|
|
40
40
|
this.drop(e);
|
|
41
41
|
continue;
|
|
42
42
|
}
|
|
43
|
-
t &&
|
|
43
|
+
t && r && o.parent === r && (t.destroyed ? o.destroy() : t.addChild(o)), r?.destroy(), e.wrap = null, e.home = null, e.last = null;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
/** Forgets labels the game destroyed while nothing synced (the grid off). */
|
|
@@ -51,22 +51,23 @@ class c {
|
|
|
51
51
|
destroy() {
|
|
52
52
|
this.release(), this.labels.clear(), this.layer.destroy({ children: !0 });
|
|
53
53
|
}
|
|
54
|
-
place(e,
|
|
54
|
+
place(e, o, t, r) {
|
|
55
55
|
const s = this.m.identity();
|
|
56
|
-
let
|
|
57
|
-
for (let
|
|
58
|
-
if (!
|
|
59
|
-
|
|
56
|
+
let a = !0, n = 1, h = o;
|
|
57
|
+
for (let i = o; i !== this.world; i = i.parent) {
|
|
58
|
+
if (!i) {
|
|
59
|
+
a = !1;
|
|
60
60
|
break;
|
|
61
61
|
}
|
|
62
|
-
(!
|
|
62
|
+
(!i.visible || !i.renderable) && (a = !1), n *= i.alpha, i.updateLocalTransform(), s.prepend(i.localTransform), h = i;
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
const d = o === this.world ? r.zIndex : h.zIndex, l = e.last ??= new Float64Array(9).fill(NaN);
|
|
65
|
+
a === (l[8] === 1) && (!a || l[0] === s.a && l[1] === s.b && l[2] === s.c && l[3] === s.d && l[4] === s.tx && l[5] === s.ty && l[6] === n && l[7] === d) || (l[8] = a ? 1 : 0, t.visible = a, a && (l[0] = s.a, l[1] = s.b, l[2] = s.c, l[3] = s.d, l[4] = s.tx, l[5] = s.ty, l[6] = n, l[7] = d, t.setFromMatrix(s), t.alpha = n, t.zIndex = d));
|
|
65
66
|
}
|
|
66
67
|
drop(e) {
|
|
67
68
|
e.wrap?.destroy(), this.labels.delete(e);
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
export {
|
|
71
|
-
|
|
72
|
+
u as SharpText
|
|
72
73
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SharpText.d.ts","sourceRoot":"","sources":["../../../src/core/SharpText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"SharpText.d.ts","sourceRoot":"","sources":["../../../src/core/SharpText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAU,MAAM,SAAS,CAAC;AAgB5C;;;;;;;GAOG;AACH,qBAAa,SAAS;IAOR,OAAO,CAAC,QAAQ,CAAC,KAAK;IANlC,QAAQ,CAAC,KAAK,8CAA6C;IAC3D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAgB;IAClC,6FAA6F;IAC7F,OAAO,CAAC,UAAU,CAAK;gBAEM,KAAK,EAAE,SAAS;IAE7C,KAAK,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI;IAK3B,sHAAsH;IACtH,IAAI,CAAC,MAAM,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IA6B1D,gFAAgF;IAChF,OAAO,IAAI,IAAI;IAkBf,6EAA6E;IAC7E,KAAK,IAAI,IAAI;IAKb,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,KAAK;IAqCb,OAAO,CAAC,IAAI;CAIb"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "1681-engine",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
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",
|