@vworlds/vecs-phaser-client 1.0.25

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/LICENSE +21 -0
  3. package/README.md +35 -0
  4. package/dist/coord_space.d.ts +35 -0
  5. package/dist/coord_space.js +49 -0
  6. package/dist/coord_space.js.map +1 -0
  7. package/dist/index.d.ts +5 -0
  8. package/dist/index.js +4 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/render_context.d.ts +16 -0
  11. package/dist/render_context.js +2 -0
  12. package/dist/render_context.js.map +1 -0
  13. package/dist/renderers/arc.d.ts +2 -0
  14. package/dist/renderers/arc.js +38 -0
  15. package/dist/renderers/arc.js.map +1 -0
  16. package/dist/renderers/ellipse.d.ts +2 -0
  17. package/dist/renderers/ellipse.js +19 -0
  18. package/dist/renderers/ellipse.js.map +1 -0
  19. package/dist/renderers/index.d.ts +2 -0
  20. package/dist/renderers/index.js +21 -0
  21. package/dist/renderers/index.js.map +1 -0
  22. package/dist/renderers/line.d.ts +2 -0
  23. package/dist/renderers/line.js +45 -0
  24. package/dist/renderers/line.js.map +1 -0
  25. package/dist/renderers/polygon.d.ts +2 -0
  26. package/dist/renderers/polygon.js +44 -0
  27. package/dist/renderers/polygon.js.map +1 -0
  28. package/dist/renderers/rectangle.d.ts +2 -0
  29. package/dist/renderers/rectangle.js +33 -0
  30. package/dist/renderers/rectangle.js.map +1 -0
  31. package/dist/renderers/shared.d.ts +33 -0
  32. package/dist/renderers/shared.js +63 -0
  33. package/dist/renderers/shared.js.map +1 -0
  34. package/dist/renderers/star.d.ts +2 -0
  35. package/dist/renderers/star.js +25 -0
  36. package/dist/renderers/star.js.map +1 -0
  37. package/dist/renderers/text.d.ts +2 -0
  38. package/dist/renderers/text.js +48 -0
  39. package/dist/renderers/text.js.map +1 -0
  40. package/dist/renderers/triangle.d.ts +2 -0
  41. package/dist/renderers/triangle.js +30 -0
  42. package/dist/renderers/triangle.js.map +1 -0
  43. package/dist/runtime.d.ts +30 -0
  44. package/dist/runtime.js +70 -0
  45. package/dist/runtime.js.map +1 -0
  46. package/dist/sync.d.ts +20 -0
  47. package/dist/sync.js +130 -0
  48. package/dist/sync.js.map +1 -0
  49. package/package.json +40 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@vworlds/vecs-phaser-client` will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ### Added
10
+
11
+ - Added `CoordSpace` for meter-to-pixel conversion with center-origin, +Y-up world coordinates at the Phaser boundary.
12
+ - Added `PhaserVecsRuntime` for mapping networked vecs entities to Phaser `GameObject`s, lifecycle cleanup, and reset rebuilds.
13
+ - Added per-shape renderers for arcs, rectangles, polygons, lines, text, ellipses, triangles, and stars, including shared transform and style initialization/sync.
14
+ - Added `phaserInterpolators` and `rotationInterpolator` for shortest-arc rotation interpolation.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 vworlds
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # @vworlds/vecs-phaser-client
2
+
3
+ Browser runtime adapter: observes a replicated `ClientWorld` and automatically creates,
4
+ updates, and destroys Phaser GameObjects (`PhaserVecsRuntime`, `CoordSpace`). All pixel,
5
+ PPM, and Y-flip conversion lives here at the Phaser frontier.
6
+
7
+ Depends on `@vworlds/vecs-phaser` and `@vworlds/vecs-client`. Requires `phaser@^4.1.0` as
8
+ a peer dependency (provided by the application).
9
+
10
+ ## Rotation Interpolation
11
+
12
+ `ClientWorld` interpolation is configured at construction/connect time. To smooth Phaser
13
+ `Rotation` components with shortest-arc angular interpolation, pass `phaserInterpolators()`
14
+ when connecting the world:
15
+
16
+ ```ts
17
+ import { ClientWorld } from "@vworlds/vecs-client";
18
+ import { phaserNetworkComponents } from "@vworlds/vecs-phaser";
19
+ import { phaserInterpolators, PhaserVecsRuntime } from "@vworlds/vecs-phaser-client";
20
+
21
+ const world = await ClientWorld.connectDgram({
22
+ host: "localhost",
23
+ port: 8080,
24
+ worldName: "main",
25
+ networkComponents: phaserNetworkComponents,
26
+ interpolators: phaserInterpolators(),
27
+ });
28
+
29
+ new PhaserVecsRuntime({ world, scene, interpolateRotation: true }).start();
30
+ ```
31
+
32
+ Keep `PhaserVecsRuntimeOptions.interpolateRotation` consistent with the
33
+ `phaserInterpolators({ interpolateRotation })` argument. Pass
34
+ `phaserInterpolators({ interpolateRotation: false })` and runtime
35
+ `interpolateRotation: false` to snap rotation updates instead.
@@ -0,0 +1,35 @@
1
+ /// <reference types="./phaser" resolution-mode="require"/>
2
+ import type Phaser from "phaser";
3
+ /**
4
+ * Converts between server-side meter coordinates (+y up, origin at center)
5
+ * and Phaser screen-pixel coordinates (+y down, origin at top-left).
6
+ *
7
+ * The server origin (0, 0) maps to the scene center. All coordinate reads
8
+ * happen on every call so that canvas resizes are reflected immediately.
9
+ *
10
+ * See architecture/README.md §4 for the full coordinate model and formulas.
11
+ */
12
+ export declare class CoordSpace {
13
+ private readonly _scene;
14
+ private readonly _ppm;
15
+ constructor(scene: Phaser.Scene, ppm?: number);
16
+ /** Absolute X pixel: scene center + ppm * meter-x. */
17
+ x(mx: number): number;
18
+ /** Absolute Y pixel: scene center - ppm * meter-y (Y flip). */
19
+ y(my: number): number;
20
+ /** Length in pixels: ppm * meters. */
21
+ len(m: number): number;
22
+ /** Relative X pixel (no center offset): ppm * meter-x. */
23
+ rx(mx: number): number;
24
+ /** Relative Y pixel (no center offset, Y flip): -ppm * meter-y. */
25
+ ry(my: number): number;
26
+ /**
27
+ * Rotation in radians for Phaser: negated to account for Y-axis flip
28
+ * inverting handedness (math CCW+ → Phaser CW+).
29
+ */
30
+ rot(rad: number): number;
31
+ /**
32
+ * Rotation in degrees for Phaser arc angles: (-rad) * 180 / PI.
33
+ */
34
+ deg(rad: number): number;
35
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Converts between server-side meter coordinates (+y up, origin at center)
3
+ * and Phaser screen-pixel coordinates (+y down, origin at top-left).
4
+ *
5
+ * The server origin (0, 0) maps to the scene center. All coordinate reads
6
+ * happen on every call so that canvas resizes are reflected immediately.
7
+ *
8
+ * See architecture/README.md §4 for the full coordinate model and formulas.
9
+ */
10
+ export class CoordSpace {
11
+ constructor(scene, ppm = 64) {
12
+ this._scene = scene;
13
+ this._ppm = ppm;
14
+ }
15
+ /** Absolute X pixel: scene center + ppm * meter-x. */
16
+ x(mx) {
17
+ return this._scene.scale.width / 2 + this._ppm * mx;
18
+ }
19
+ /** Absolute Y pixel: scene center - ppm * meter-y (Y flip). */
20
+ y(my) {
21
+ return this._scene.scale.height / 2 - this._ppm * my;
22
+ }
23
+ /** Length in pixels: ppm * meters. */
24
+ len(m) {
25
+ return this._ppm * m;
26
+ }
27
+ /** Relative X pixel (no center offset): ppm * meter-x. */
28
+ rx(mx) {
29
+ return this._ppm * mx;
30
+ }
31
+ /** Relative Y pixel (no center offset, Y flip): -ppm * meter-y. */
32
+ ry(my) {
33
+ return -this._ppm * my;
34
+ }
35
+ /**
36
+ * Rotation in radians for Phaser: negated to account for Y-axis flip
37
+ * inverting handedness (math CCW+ → Phaser CW+).
38
+ */
39
+ rot(rad) {
40
+ return -rad;
41
+ }
42
+ /**
43
+ * Rotation in degrees for Phaser arc angles: (-rad) * 180 / PI.
44
+ */
45
+ deg(rad) {
46
+ return (-rad * 180) / Math.PI;
47
+ }
48
+ }
49
+ //# sourceMappingURL=coord_space.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coord_space.js","sourceRoot":"","sources":["../src/coord_space.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,OAAO,UAAU;IAIrB,YAAY,KAAmB,EAAE,MAAc,EAAE;QAC/C,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IAED,sDAAsD;IACtD,CAAC,CAAC,EAAU;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;IACtD,CAAC;IAED,+DAA+D;IAC/D,CAAC,CAAC,EAAU;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;IACvD,CAAC;IAED,sCAAsC;IACtC,GAAG,CAAC,CAAS;QACX,OAAO,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,0DAA0D;IAC1D,EAAE,CAAC,EAAU;QACX,OAAO,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;IACxB,CAAC;IAED,mEAAmE;IACnE,EAAE,CAAC,EAAU;QACX,OAAO,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,GAAG,CAAC,GAAW;QACb,OAAO,CAAC,GAAG,CAAC;IACd,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,GAAW;QACb,OAAO,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ export { CoordSpace } from "./coord_space.js";
2
+ export { PhaserVecsRuntime } from "./runtime.js";
3
+ export { installSyncSystems, phaserInterpolators, rotationInterpolator } from "./sync.js";
4
+ export type { PhaserVecsRuntimeOptions } from "./runtime.js";
5
+ export type { RenderContext, RenderSystemInstaller } from "./render_context.js";
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { CoordSpace } from "./coord_space.js";
2
+ export { PhaserVecsRuntime } from "./runtime.js";
3
+ export { installSyncSystems, phaserInterpolators, rotationInterpolator } from "./sync.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,16 @@
1
+ /// <reference types="./phaser" resolution-mode="require"/>
2
+ import type { ClientWorld } from "@vworlds/vecs-client";
3
+ import type { EID, System } from "@vworlds/vecs";
4
+ import type Phaser from "phaser";
5
+ import type { CoordSpace } from "./coord_space.js";
6
+ export interface RenderContext {
7
+ readonly world: ClientWorld;
8
+ readonly scene: Phaser.Scene;
9
+ readonly coords: CoordSpace;
10
+ readonly interpolateRotation: boolean;
11
+ getGameObject(eid: EID): Phaser.GameObjects.GameObject | undefined;
12
+ setGameObject(eid: EID, obj: Phaser.GameObjects.GameObject): void;
13
+ deleteGameObject(eid: EID): void;
14
+ trackSystem(system: System): void;
15
+ }
16
+ export type RenderSystemInstaller = (ctx: RenderContext) => void;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=render_context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render_context.js","sourceRoot":"","sources":["../src/render_context.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ import type { RenderContext } from "../render_context.js";
2
+ export declare function installArcRenderer(ctx: RenderContext): void;
@@ -0,0 +1,38 @@
1
+ import { Arc } from "@vworlds/vecs-phaser";
2
+ import { applyInitialComponents } from "./shared.js";
3
+ export function installArcRenderer(ctx) {
4
+ const system = ctx.world
5
+ .system("RenderArc")
6
+ .with(Arc)
7
+ .enter((entity) => {
8
+ const arc = entity.get(Arc);
9
+ if (!arc) {
10
+ return;
11
+ }
12
+ const obj = ctx.scene.add.arc(0, 0, ctx.coords.len(arc.radius), ctx.coords.deg(arc.startAngle), ctx.coords.deg(arc.endAngle), arc.anticlockwise);
13
+ obj.setIterations(arc.iterations);
14
+ ctx.setGameObject(entity.eid, obj);
15
+ applyInitialComponents(ctx, entity, obj);
16
+ })
17
+ .update(Arc, (entity, arc) => {
18
+ const obj = ctx.getGameObject(entity.eid);
19
+ if (!obj) {
20
+ return;
21
+ }
22
+ obj
23
+ .setRadius(ctx.coords.len(arc.radius))
24
+ .setStartAngle(ctx.coords.deg(arc.startAngle), arc.anticlockwise)
25
+ .setEndAngle(ctx.coords.deg(arc.endAngle), arc.anticlockwise)
26
+ .setIterations(arc.iterations);
27
+ })
28
+ .exit((entity) => {
29
+ const obj = ctx.getGameObject(entity.eid);
30
+ if (!obj) {
31
+ return;
32
+ }
33
+ obj.destroy();
34
+ ctx.deleteGameObject(entity.eid);
35
+ });
36
+ ctx.trackSystem(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,CAAC,GAAG,EAAE,CAAC;YACT,OAAO;QACT,CAAC;QACD,GAAG;aACA,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;aACrC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC;aAChE,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,aAAa,CAAC;aAC5D,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACnC,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACf,MAAM,GAAG,GAAG,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1C,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO;QACT,CAAC;QACD,GAAG,CAAC,OAAO,EAAE,CAAC;QACd,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEL,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { RenderSystemInstaller } from "../render_context.js";
2
+ export declare const installEllipseRenderer: RenderSystemInstaller;
@@ -0,0 +1,19 @@
1
+ import { Ellipse } from "@vworlds/vecs-phaser";
2
+ import { applyInitialComponents, destroyMappedGameObject, getMappedGameObject, initialPosition, } from "./shared.js";
3
+ export const installEllipseRenderer = (ctx) => {
4
+ const system = ctx.world
5
+ .system("phaser.render.ellipse")
6
+ .with(Ellipse)
7
+ .enter([Ellipse], (entity, [ellipse]) => {
8
+ const [x, y] = initialPosition(ctx, entity);
9
+ const obj = ctx.scene.add.ellipse(x, y, ctx.coords.len(ellipse.width), ctx.coords.len(ellipse.height));
10
+ ctx.setGameObject(entity.eid, obj);
11
+ applyInitialComponents(ctx, entity, obj);
12
+ })
13
+ .update(Ellipse, (entity, ellipse) => {
14
+ getMappedGameObject(ctx, entity.eid)?.setSize(ctx.coords.len(ellipse.width), ctx.coords.len(ellipse.height));
15
+ })
16
+ .exit((entity) => destroyMappedGameObject(ctx, entity.eid));
17
+ ctx.trackSystem(system);
18
+ };
19
+ //# sourceMappingURL=ellipse.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ellipse.js","sourceRoot":"","sources":["../../src/renderers/ellipse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAG/C,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,GAEhB,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,sBAAsB,GAA0B,CAAC,GAAkB,EAAQ,EAAE;IACxF,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK;SACrB,MAAM,CAAC,uBAAuB,CAAC;SAC/B,IAAI,CAAC,OAAO,CAAC;SACb,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE;QACtC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC5C,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAC/B,CAAC,EACD,CAAC,EACD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,EAC7B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CACF,CAAC;QAC/B,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACnC,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC,CAAC;SACD,MAAM,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;QACnC,mBAAmB,CAAiB,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,OAAO,CAC3D,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,EAC7B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAC/B,CAAC;IACJ,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAE9D,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { RenderContext } from "../render_context.js";
2
+ export declare function installRenderSystems(ctx: RenderContext): void;
@@ -0,0 +1,21 @@
1
+ import { installSyncSystems } from "../sync.js";
2
+ import { installArcRenderer } from "./arc.js";
3
+ import { installEllipseRenderer } from "./ellipse.js";
4
+ import { installLineRenderer } from "./line.js";
5
+ import { installPolygonRenderer } from "./polygon.js";
6
+ import { installRectangleRenderer } from "./rectangle.js";
7
+ import { installStarRenderer } from "./star.js";
8
+ import { installTextRenderer } from "./text.js";
9
+ import { installTriangleRenderer } from "./triangle.js";
10
+ export function installRenderSystems(ctx) {
11
+ installArcRenderer(ctx);
12
+ installEllipseRenderer(ctx);
13
+ installLineRenderer(ctx);
14
+ installPolygonRenderer(ctx);
15
+ installRectangleRenderer(ctx);
16
+ installStarRenderer(ctx);
17
+ installTextRenderer(ctx);
18
+ installTriangleRenderer(ctx);
19
+ installSyncSystems(ctx);
20
+ }
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/renderers/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,MAAM,UAAU,oBAAoB,CAAC,GAAkB;IACrD,kBAAkB,CAAC,GAAG,CAAC,CAAC;IACxB,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAC5B,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACzB,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAC5B,wBAAwB,CAAC,GAAG,CAAC,CAAC;IAC9B,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACzB,mBAAmB,CAAC,GAAG,CAAC,CAAC;IACzB,uBAAuB,CAAC,GAAG,CAAC,CAAC;IAC7B,kBAAkB,CAAC,GAAG,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { RenderContext } from "../render_context.js";
2
+ export declare function installLineRenderer(ctx: RenderContext): void;
@@ -0,0 +1,45 @@
1
+ import { Line } from "@vworlds/vecs-phaser";
2
+ import { applyInitialComponents, applyVertexOrigin } from "./shared.js";
3
+ export function installLineRenderer(ctx) {
4
+ const system = ctx.world
5
+ .system("RenderLine")
6
+ .with(Line)
7
+ .enter((entity) => {
8
+ const line = entity.get(Line);
9
+ if (!line) {
10
+ return;
11
+ }
12
+ const points = linePoints(ctx, line);
13
+ const obj = ctx.scene.add.line(0, 0, points[0], points[1], points[2], points[3]);
14
+ applyVertexOrigin(obj);
15
+ ctx.setGameObject(entity.eid, obj);
16
+ applyInitialComponents(ctx, entity, obj);
17
+ })
18
+ .update(Line, (entity, line) => {
19
+ const obj = ctx.getGameObject(entity.eid);
20
+ if (!obj) {
21
+ return;
22
+ }
23
+ const points = linePoints(ctx, line);
24
+ obj.setTo(points[0], points[1], points[2], points[3]);
25
+ applyVertexOrigin(obj);
26
+ })
27
+ .exit((entity) => {
28
+ const obj = ctx.getGameObject(entity.eid);
29
+ if (!obj) {
30
+ return;
31
+ }
32
+ obj.destroy();
33
+ ctx.deleteGameObject(entity.eid);
34
+ });
35
+ ctx.trackSystem(system);
36
+ }
37
+ function linePoints(ctx, line) {
38
+ return [
39
+ ctx.coords.rx(line.x1),
40
+ ctx.coords.ry(line.y1),
41
+ ctx.coords.rx(line.x2),
42
+ ctx.coords.ry(line.y2),
43
+ ];
44
+ }
45
+ //# sourceMappingURL=line.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"line.js","sourceRoot":"","sources":["../../src/renderers/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAI5C,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAqB,MAAM,aAAa,CAAC;AAI3F,MAAM,UAAU,mBAAmB,CAAC,GAAkB;IACpD,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK;SACrB,MAAM,CAAC,YAAY,CAAC;SACpB,IAAI,CAAC,IAAI,CAAC;SACV,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE;QAChB,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACrC,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAC5B,CAAC,EACD,CAAC,EACD,MAAM,CAAC,CAAC,CAAC,E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AC,EAAE,CAAC;QACtB,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;KACvB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { RenderContext } from "../render_context.js";
2
+ export declare function installPolygonRenderer(ctx: RenderContext): void;
@@ -0,0 +1,44 @@
1
+ import { Polygon } from "@vworlds/vecs-phaser";
2
+ import { applyInitialComponents, applyVertexOrigin } from "./shared.js";
3
+ export function installPolygonRenderer(ctx) {
4
+ const system = ctx.world
5
+ .system("RenderPolygon")
6
+ .with(Polygon)
7
+ .enter((entity) => {
8
+ const polygon = entity.get(Polygon);
9
+ if (!polygon) {
10
+ return;
11
+ }
12
+ const points = polygonPoints(ctx, polygon);
13
+ const obj = ctx.scene.add.polygon(0, 0, points);
14
+ applyVertexOrigin(obj);
15
+ ctx.setGameObject(entity.eid, obj);
16
+ applyInitialComponents(ctx, entity, obj);
17
+ })
18
+ .update(Polygon, (entity, polygon) => {
19
+ const obj = ctx.getGameObject(entity.eid);
20
+ if (!obj) {
21
+ return;
22
+ }
23
+ const points = polygonPoints(ctx, polygon);
24
+ obj.setTo(points);
25
+ applyVertexOrigin(obj);
26
+ })
27
+ .exit((entity) => {
28
+ const obj = ctx.getGameObject(entity.eid);
29
+ if (!obj) {
30
+ return;
31
+ }
32
+ obj.destroy();
33
+ ctx.deleteGameObject(entity.eid);
34
+ });
35
+ ctx.trackSystem(system);
36
+ }
37
+ function polygonPoints(ctx, polygon) {
38
+ const points = [];
39
+ for (let i = 0; i < polygon.points.length; i += 2) {
40
+ points.push(ctx.coords.rx(polygon.points[i] ?? 0), ctx.coords.ry(polygon.points[i + 1] ?? 0));
41
+ }
42
+ return points;
43
+ }
44
+ //# sourceMappingURL=polygon.js.map
@@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AC,CAAC;IACzB,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACf,MAAM,GAAG,GAAG,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1C,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO;QACT,CAAC;QACD,GAAG,CAAC,OAAO,EAAE,CAAC;QACd,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEL,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,aAAa,CAAC,GAAkB,EAAE,OAAgB;IACzD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAClD,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChG,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { RenderContext } from "../render_context.js";
2
+ export declare function installRectangleRenderer(ctx: RenderContext): void;
@@ -0,0 +1,33 @@
1
+ import { Rectangle } from "@vworlds/vecs-phaser";
2
+ import { applyInitialComponents } from "./shared.js";
3
+ export function installRectangleRenderer(ctx) {
4
+ const system = ctx.world
5
+ .system("RenderRectangle")
6
+ .with(Rectangle)
7
+ .enter((entity) => {
8
+ const rectangle = entity.get(Rectangle);
9
+ if (!rectangle) {
10
+ return;
11
+ }
12
+ const obj = ctx.scene.add.rectangle(0, 0, ctx.coords.len(rectangle.width), ctx.coords.len(rectangle.height));
13
+ ctx.setGameObject(entity.eid, obj);
14
+ applyInitialComponents(ctx, entity, obj);
15
+ })
16
+ .update(Rectangle, (entity, rectangle) => {
17
+ const obj = ctx.getGameObject(entity.eid);
18
+ if (!obj) {
19
+ return;
20
+ }
21
+ obj.setSize(ctx.coords.len(rectangle.width), ctx.coords.len(rectangle.height));
22
+ })
23
+ .exit((entity) => {
24
+ const obj = ctx.getGameObject(entity.eid);
25
+ if (!obj) {
26
+ return;
27
+ }
28
+ obj.destroy();
29
+ ctx.deleteGameObject(entity.eid);
30
+ });
31
+ ctx.trackSystem(system);
32
+ }
33
+ //# sourceMappingURL=rectangle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rectangle.js","sourceRoot":"","sources":["../../src/renderers/rectangle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAIjD,OAAO,EAAE,sBAAsB,EAAqB,MAAM,aAAa,CAAC;AAIxE,MAAM,UAAU,wBAAwB,CAAC,GAAkB;IACzD,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK;SACrB,MAAM,CAAC,iBAAiB,CAAC;SACzB,IAAI,CAAC,SAAS,CAAC;SACf,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE;QAChB,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxC,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO;QACT,CAAC;QAED,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CACjC,CAAC,EACD,CAAC,EACD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,EAC/B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CACd,CAAC;QACrB,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACnC,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC,CAAC;SACD,MAAM,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE;QACvC,MAAM,GAAG,GAAG,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAgC,CAAC;QACzE,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO;QACT,CAAC;QACD,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IACjF,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;QACf,MAAM,GAAG,GAAG,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1C,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO;QACT,CAAC;QACD,GAAG,CAAC,OAAO,EAAE,CAAC;QACd,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEL,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,33 @@
1
+ /// <reference types="./phaser" resolution-mode="require"/>
2
+ import type { EID, Entity } from "@vworlds/vecs";
3
+ import { TextAlign } from "@vworlds/vecs-phaser";
4
+ import type Phaser from "phaser";
5
+ import type { RenderContext } from "../render_context.js";
6
+ export interface RenderObject extends Phaser.GameObjects.GameObject {
7
+ setAlpha(value: number): this;
8
+ setDepth(value: number): this;
9
+ setFillStyle(color: number, alpha?: number): this;
10
+ setOrigin(x: number, y?: number): this;
11
+ setPosition(x: number, y: number): this;
12
+ setRotation(radians: number): this;
13
+ setScale(x: number, y?: number): this;
14
+ setStrokeStyle(lineWidth: number, color: number, alpha?: number): this;
15
+ }
16
+ export interface SizeGameObject extends RenderObject {
17
+ setSize(width: number, height: number): this;
18
+ }
19
+ export interface StarGameObject extends RenderObject {
20
+ setInnerRadius(value: number): this;
21
+ setOuterRadius(value: number): this;
22
+ setPoints(points: number): this;
23
+ }
24
+ export interface VertexGameObject extends RenderObject {
25
+ setTo(...coordinates: readonly number[]): this;
26
+ }
27
+ export declare function applyInitialComponents(ctx: RenderContext, entity: Entity, obj: RenderObject): void;
28
+ export declare function applyVertexOrigin(obj: RenderObject): void;
29
+ export declare function destroyMappedGameObject(ctx: RenderContext, eid: EID): void;
30
+ export declare function getMappedGameObject<T extends RenderObject>(ctx: RenderContext, eid: EID): T | undefined;
31
+ export declare function initialPosition(ctx: RenderContext, entity: Entity): readonly [number, number];
32
+ export declare function hexColor(color: number): string;
33
+ export declare function textAlign(value: TextAlign): "center" | "left" | "right";
@@ -0,0 +1,63 @@
1
+ import { Alpha, Depth, FillStyle, Position, Rotation, Scale, StrokeStyle, TextAlign, } from "@vworlds/vecs-phaser";
2
+ export function applyInitialComponents(ctx, entity, obj) {
3
+ const position = entity.get(Position);
4
+ if (position) {
5
+ obj.setPosition(ctx.coords.x(position.x), ctx.coords.y(position.y));
6
+ }
7
+ const rotation = entity.get(Rotation);
8
+ if (rotation) {
9
+ obj.setRotation(ctx.coords.rot(rotation.angle));
10
+ }
11
+ const scale = entity.get(Scale);
12
+ if (scale) {
13
+ obj.setScale(scale.x, scale.y);
14
+ }
15
+ const alpha = entity.get(Alpha);
16
+ if (alpha) {
17
+ obj.setAlpha(alpha.value);
18
+ }
19
+ const depth = entity.get(Depth);
20
+ if (depth) {
21
+ obj.setDepth(depth.value);
22
+ }
23
+ const fill = entity.get(FillStyle);
24
+ if (fill) {
25
+ obj.setFillStyle(fill.color, fill.alpha);
26
+ }
27
+ const stroke = entity.get(StrokeStyle);
28
+ if (stroke) {
29
+ obj.setStrokeStyle(stroke.width, stroke.color, stroke.alpha);
30
+ }
31
+ }
32
+ export function applyVertexOrigin(obj) {
33
+ obj.setOrigin(0, 0);
34
+ }
35
+ export function destroyMappedGameObject(ctx, eid) {
36
+ const obj = ctx.getGameObject(eid);
37
+ if (obj === undefined) {
38
+ return;
39
+ }
40
+ obj.destroy();
41
+ ctx.deleteGameObject(eid);
42
+ }
43
+ export function getMappedGameObject(ctx, eid) {
44
+ return ctx.getGameObject(eid);
45
+ }
46
+ export function initialPosition(ctx, entity) {
47
+ const position = entity.get(Position);
48
+ return [ctx.coords.x(position?.x ?? 0), ctx.coords.y(position?.y ?? 0)];
49
+ }
50
+ export function hexColor(color) {
51
+ return `#${(color & 0xffffff).toString(16).padStart(6, "0")}`;
52
+ }
53
+ export function textAlign(value) {
54
+ switch (value) {
55
+ case TextAlign.Center:
56
+ return "center";
57
+ case TextAlign.Right:
58
+ return "right";
59
+ default:
60
+ return "left";
61
+ }
62
+ }
63
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/renderers/shared.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,WAAW,EACX,SAAS,GACV,MAAM,sBAAsB,CAAC;AA8B9B,MAAM,UAAU,sBAAsB,CACpC,GAAkB,EAClB,MAAc,EACd,GAAiB;IAEjB,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtC,IAAI,QAAQ,EAAE,CAAC;QACb,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtC,IAAI,QAAQ,EA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IAClE,MAAM,GAAG,GAAG,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;QACtB,OAAO;IACT,CAAC;IACD,GAAG,CAAC,OAAO,EAAE,CAAC;IACd,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,GAAkB,EAClB,GAAQ;IAER,OAAO,GAAG,CAAC,aAAa,CAAC,GAAG,CAAkB,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAkB,EAAE,MAAc;IAChE,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAC1E,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,KAAa;IACpC,OAAO,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,KAAgB;IACxC,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,SAAS,CAAC,MAAM;YACnB,OAAO,QAAQ,CAAC;QAClB,KAAK,SAAS,CAAC,KAAK;YAClB,OAAO,OAAO,CAAC;QACjB;YACE,OAAO,MAAM,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { RenderSystemInstaller } from "../render_context.js";
2
+ export declare const installStarRenderer: RenderSystemInstaller;
@@ -0,0 +1,25 @@
1
+ import { Star } from "@vworlds/vecs-phaser";
2
+ import { applyInitialComponents, destroyMappedGameObject, getMappedGameObject, initialPosition, } from "./shared.js";
3
+ export const installStarRenderer = (ctx) => {
4
+ const system = ctx.world
5
+ .system("phaser.render.star")
6
+ .with(Star)
7
+ .enter([Star], (entity, [star]) => {
8
+ const [x, y] = initialPosition(ctx, entity);
9
+ const obj = ctx.scene.add.star(x, y, star.points, ctx.coords.len(star.innerRadius), ctx.coords.len(star.outerRadius));
10
+ ctx.setGameObject(entity.eid, obj);
11
+ applyInitialComponents(ctx, entity, obj);
12
+ })
13
+ .update(Star, (entity, star) => {
14
+ const obj = getMappedGameObject(ctx, entity.eid);
15
+ if (obj === undefined) {
16
+ return;
17
+ }
18
+ obj.setPoints(star.points);
19
+ obj.setInnerRadius(ctx.coords.len(star.innerRadius));
20
+ obj.setOuterRadius(ctx.coords.len(star.outerRadius));
21
+ })
22
+ .exit((entity) => destroyMappedGameObject(ctx, entity.eid));
23
+ ctx.trackSystem(system);
24
+ };
25
+ //# sourceMappingURL=star.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"star.js","sourceRoot":"","sources":["../../src/renderers/star.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAG5C,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,GAEhB,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,mBAAmB,GAA0B,CAAC,GAAkB,EAAQ,EAAE;IACrF,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK;SACrB,MAAM,CAAC,oBAAoB,CAAC;SAC5B,IAAI,CAAC,IAAI,CAAC;SACV,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE;QAChC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC5C,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAC5B,CAAC,EACD,CAAC,EACD,IAAI,CAAC,MAAM,EACX,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,EAChC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CACJ,CAAC;QAC/B,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACnC,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC,CAAC;SACD,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE;QAC7B,MAAM,GAAG,GAAG,mBAAmB,CAAiB,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,OAAO;QACT,CAAC;QACD,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3B,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QACrD,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAE9D,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { RenderContext } from "../render_context.js";
2
+ export declare function installTextRenderer(ctx: RenderContext): void;
@@ -0,0 +1,48 @@
1
+ import { Text as TextComponent } from "@vworlds/vecs-phaser";
2
+ import { applyInitialComponents, hexColor, textAlign } from "./shared.js";
3
+ export function installTextRenderer(ctx) {
4
+ const system = ctx.world
5
+ .system("RenderText")
6
+ .with(TextComponent)
7
+ .enter((entity) => {
8
+ const text = entity.get(TextComponent);
9
+ if (!text) {
10
+ return;
11
+ }
12
+ const obj = ctx.scene.add.text(0, 0, text.value, textStyle(text));
13
+ obj.setOrigin(0.5);
14
+ ctx.setGameObject(entity.eid, obj);
15
+ applyInitialComponents(ctx, entity, obj);
16
+ })
17
+ .update(TextComponent, (entity, text) => {
18
+ const obj = ctx.getGameObject(entity.eid);
19
+ if (!obj) {
20
+ return;
21
+ }
22
+ obj.setText(text.value);
23
+ obj.setStyle(textStyle(text));
24
+ obj.setOrigin(0.5);
25
+ })
26
+ .exit((entity) => {
27
+ const obj = ctx.getGameObject(entity.eid);
28
+ if (!obj) {
29
+ return;
30
+ }
31
+ obj.destroy();
32
+ ctx.deleteGameObject(entity.eid);
33
+ });
34
+ ctx.trackSystem(system);
35
+ }
36
+ function textStyle(text) {
37
+ const style = {
38
+ align: textAlign(text.align),
39
+ color: hexColor(text.color),
40
+ fontFamily: text.fontFamily,
41
+ fontSize: text.fontSize,
42
+ };
43
+ if (text.backgroundAlpha > 0) {
44
+ style.backgroundColor = hexColor(text.backgroundColor);
45
+ }
46
+ return style;
47
+ }
48
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/renderers/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAI7D,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,SAAS,EAAqB,MAAM,aAAa,CAAC;AAI7F,MAAM,UAAU,mBAAmB,CAAC,GAAkB;IACpD,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK;SACrB,MAAM,CAAC,YAAY,CAAC;SACpB,IAAI,CAAC,aAAa,CAAC;SACnB,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE;QAChB,MAAM,IAAI,GAAG,MAA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AAmB;IACpC,MAAM,KAAK,GAA4C;QACrD,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;QAC5B,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;QAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,QAAQ,EAAE,IAAI,CAAC,QAAQ;KACxB,CAAC;IACF,IAAI,IAAI,CAAC,eAAe,GAAG,CAAC,EAAE,CAAC;QAC7B,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { RenderSystemInstaller } from "../render_context.js";
2
+ export declare const installTriangleRenderer: RenderSystemInstaller;
@@ -0,0 +1,30 @@
1
+ import { Triangle } from "@vworlds/vecs-phaser";
2
+ import { applyInitialComponents, applyVertexOrigin, destroyMappedGameObject, getMappedGameObject, initialPosition, } from "./shared.js";
3
+ export const installTriangleRenderer = (ctx) => {
4
+ const system = ctx.world
5
+ .system("phaser.render.triangle")
6
+ .with(Triangle)
7
+ .enter([Triangle], (entity, [triangle]) => {
8
+ const [x, y] = initialPosition(ctx, entity);
9
+ const obj = ctx.scene.add.triangle(x, y, ...triangleCoordinates(ctx, triangle));
10
+ applyVertexOrigin(obj);
11
+ ctx.setGameObject(entity.eid, obj);
12
+ applyInitialComponents(ctx, entity, obj);
13
+ })
14
+ .update(Triangle, (entity, triangle) => {
15
+ getMappedGameObject(ctx, entity.eid)?.setTo(...triangleCoordinates(ctx, triangle));
16
+ })
17
+ .exit((entity) => destroyMappedGameObject(ctx, entity.eid));
18
+ ctx.trackSystem(system);
19
+ };
20
+ function triangleCoordinates(ctx, triangle) {
21
+ return [
22
+ ctx.coords.rx(triangle.x1),
23
+ ctx.coords.ry(triangle.y1),
24
+ ctx.coords.rx(triangle.x2),
25
+ ctx.coords.ry(triangle.y2),
26
+ ctx.coords.rx(triangle.x3),
27
+ ctx.coords.ry(triangle.y3),
28
+ ];
29
+ }
30
+ //# sourceMappingURL=triangle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"triangle.js","sourceRoot":"","sources":["../../src/renderers/triangle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,GAEhB,MAAM,aAAa,CAAC;AAErB,MAAM,CAAC,MAAM,uBAAuB,GAA0B,CAAC,GAAkB,EAAQ,EAAE;IACzF,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK;SACrB,MAAM,CAAC,wBAAwB,CAAC;SAChC,IAAI,CAAC,QAAQ,CAAC;SACd,KAAK,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE;QACxC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,eAAe,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QAC5C,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAChC,CAAC,EACD,CAAC,EACD,GAAG,mBAAmB,CAAC,GAAG,EAAE,QAAQ,CAAC,CACP,CAAC;QACjC,iBAAiB,CAAC,GAAG,CAAC,CAAC;QACvB,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACnC,sBAAsB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3C,CAAC,CAAC;SACD,MAAM,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;QACrC,mBAAmB,CAAmB,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,KAAK,CAC3D,GAAG,mBAAmB,CAAC,GAAG,EAAE,QAAQ,CAAC,CACtC,CAAC;IACJ,CAAC,CAAC;SACD,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,uBAAuB,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IAE9D,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAC1B,CAAC,CAAC;AAEF,SAAS,mBAAmB,CAC1B,GAAkB,EAClB,QAAkB;IAElB,OAAO;QACL,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC;KAC3B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,30 @@
1
+ /// <reference types="./phaser" resolution-mode="require"/>
2
+ import type { ClientWorld } from "@vworlds/vecs-client";
3
+ import type { EID } from "@vworlds/vecs";
4
+ import type Phaser from "phaser";
5
+ export interface PhaserVecsRuntimeOptions {
6
+ world: ClientWorld;
7
+ scene: Phaser.Scene;
8
+ pixelsPerMeter?: number;
9
+ interpolateRotation?: boolean;
10
+ }
11
+ export declare class PhaserVecsRuntime {
12
+ private readonly _world;
13
+ private readonly _scene;
14
+ private readonly _coords;
15
+ private readonly _interpolateRotation;
16
+ private readonly _gameObjects;
17
+ private readonly _systems;
18
+ private readonly _resetHandler;
19
+ private _started;
20
+ private _systemsInstalled;
21
+ constructor(options: PhaserVecsRuntimeOptions);
22
+ start(): void;
23
+ stop(): void;
24
+ getGameObject(eid: EID): Phaser.GameObjects.GameObject | undefined;
25
+ private _createRenderContext;
26
+ private _destroyGameObjects;
27
+ private _disableSystems;
28
+ private _enableSystems;
29
+ private _handleReset;
30
+ }
@@ -0,0 +1,70 @@
1
+ import { CoordSpace } from "./coord_space.js";
2
+ import { installRenderSystems } from "./renderers/index.js";
3
+ export class PhaserVecsRuntime {
4
+ constructor(options) {
5
+ this._gameObjects = new Map();
6
+ this._systems = [];
7
+ this._resetHandler = () => this._handleReset();
8
+ this._started = false;
9
+ this._systemsInstalled = false;
10
+ this._world = options.world;
11
+ this._scene = options.scene;
12
+ this._coords = new CoordSpace(options.scene, options.pixelsPerMeter);
13
+ this._interpolateRotation = options.interpolateRotation ?? true;
14
+ }
15
+ start() {
16
+ if (this._started) {
17
+ return;
18
+ }
19
+ this._enableSystems();
20
+ this._world.events.on("reset", this._resetHandler);
21
+ this._started = true;
22
+ }
23
+ stop() {
24
+ if (!this._started) {
25
+ return;
26
+ }
27
+ this._world.events.off("reset", this._resetHandler);
28
+ this._disableSystems();
29
+ this._destroyGameObjects();
30
+ this._started = false;
31
+ }
32
+ getGameObject(eid) {
33
+ return this._gameObjects.get(eid);
34
+ }
35
+ _createRenderContext() {
36
+ return {
37
+ world: this._world,
38
+ scene: this._scene,
39
+ coords: this._coords,
40
+ interpolateRotation: this._interpolateRotation,
41
+ getGameObject: (eid) => this.getGameObject(eid),
42
+ setGameObject: (eid, obj) => this._gameObjects.set(eid, obj),
43
+ deleteGameObject: (eid) => {
44
+ this._gameObjects.delete(eid);
45
+ },
46
+ trackSystem: (system) => this._systems.push(system),
47
+ };
48
+ }
49
+ _destroyGameObjects() {
50
+ this._gameObjects.forEach((obj) => obj.destroy());
51
+ this._gameObjects.clear();
52
+ }
53
+ _disableSystems() {
54
+ this._systems.forEach((system) => system.disable());
55
+ }
56
+ _enableSystems() {
57
+ if (!this._systemsInstalled) {
58
+ installRenderSystems(this._createRenderContext());
59
+ this._systemsInstalled = true;
60
+ return;
61
+ }
62
+ this._systems.forEach((system) => system.enable());
63
+ }
64
+ _handleReset() {
65
+ // Baseline reset should route renderer exits, but destroy any object still
66
+ // mapped here so queued or missing exits cannot leak Phaser objects.
67
+ this._destroyGameObjects();
68
+ }
69
+ }
70
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAS5D,MAAM,OAAO,iBAAiB;IAW5B,YAAY,OAAiC;QAN5B,iBAAY,GAAG,IAAI,GAAG,EAAsC,CAAC;QAC7D,aAAQ,GAAa,EAAE,CAAC;QACxB,kBAAa,GAAG,GAAS,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC;QACzD,aAAQ,GAAG,KAAK,CAAC;QACjB,sBAAiB,GAAG,KAAK,CAAC;QAGhC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;QACrE,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC,mBAAmB,IAAI,IAAI,CAAC;IAClE,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QACnD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;IAED,IAAI;QACF,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QACD,IAAI,CAAC,MAA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AC;IACtD,CAAC;IAEO,cAAc;QACpB,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC5B,oBAAoB,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAC;YAClD,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC;YAC9B,OAAO;QACT,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IACrD,CAAC;IAEO,YAAY;QAClB,2EAA2E;QAC3E,qEAAqE;QACrE,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC7B,CAAC;CACF"}
package/dist/sync.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import type { ComponentInterpolator } from "@vworlds/vecs-client";
2
+ import type { RenderContext } from "./render_context.js";
3
+ /**
4
+ * Shortest-arc angular interpolator for raw `Rotation` components.
5
+ *
6
+ * The returned angle stays in component/math space (radians, CCW-positive); the
7
+ * Phaser Y-flip is still applied later by `CoordSpace.rot()` at render time.
8
+ */
9
+ export declare const rotationInterpolator: ComponentInterpolator;
10
+ /**
11
+ * Returns vecs-client interpolator entries for Phaser render components.
12
+ *
13
+ * Pass this at `ClientWorld` construction/connect time, for example:
14
+ * `ClientWorld.connectDgram({ networkComponents: phaserNetworkComponents, interpolators: phaserInterpolators() })`.
15
+ * Keep the runtime `interpolateRotation` option consistent with this setting.
16
+ */
17
+ export declare function phaserInterpolators(options?: {
18
+ interpolateRotation?: boolean;
19
+ }): Array<readonly [number, ComponentInterpolator]>;
20
+ export declare function installSyncSystems(ctx: RenderContext): void;
package/dist/sync.js ADDED
@@ -0,0 +1,130 @@
1
+ import { Alpha, Depth, FillStyle, phaserNetworkComponents, Position, Rotation, Scale, StrokeStyle, } from "@vworlds/vecs-phaser";
2
+ const TWO_PI = Math.PI * 2;
3
+ /**
4
+ * Shortest-arc angular interpolator for raw `Rotation` components.
5
+ *
6
+ * The returned angle stays in component/math space (radians, CCW-positive); the
7
+ * Phaser Y-flip is still applied later by `CoordSpace.rot()` at render time.
8
+ */
9
+ export const rotationInterpolator = (source, target, alpha) => {
10
+ const sourceRotation = assertRotation(source, "source");
11
+ const targetRotation = assertRotation(target, "target");
12
+ const result = new Rotation();
13
+ if (alpha === 0) {
14
+ result.angle = sourceRotation.angle;
15
+ return result;
16
+ }
17
+ if (alpha === 1) {
18
+ result.angle = targetRotation.angle;
19
+ return result;
20
+ }
21
+ const delta = shortestAngleDelta(sourceRotation.angle, targetRotation.angle);
22
+ result.angle = normalizeAngle(sourceRotation.angle + delta * alpha);
23
+ return result;
24
+ };
25
+ /**
26
+ * Returns vecs-client interpolator entries for Phaser render components.
27
+ *
28
+ * Pass this at `ClientWorld` construction/connect time, for example:
29
+ * `ClientWorld.connectDgram({ networkComponents: phaserNetworkComponents, interpolators: phaserInterpolators() })`.
30
+ * Keep the runtime `interpolateRotation` option consistent with this setting.
31
+ */
32
+ export function phaserInterpolators(options) {
33
+ if (options?.interpolateRotation === false) {
34
+ return [];
35
+ }
36
+ return [[rotationTypeId(), rotationInterpolator]];
37
+ }
38
+ export function installSyncSystems(ctx) {
39
+ ctx.trackSystem(ctx.world
40
+ .system("PhaserSync:Position")
41
+ .with(Position)
42
+ .update(Position, (entity, position) => {
43
+ const obj = getSyncGameObject(ctx, entity.eid);
44
+ if (!obj) {
45
+ return;
46
+ }
47
+ obj.setPosition(ctx.coords.x(position.x), ctx.coords.y(position.y));
48
+ }));
49
+ ctx.trackSystem(ctx.world
50
+ .system("PhaserSync:Rotation")
51
+ .with(Rotation)
52
+ .update(Rotation, (entity, rotation) => {
53
+ const obj = getSyncGameObject(ctx, entity.eid);
54
+ if (!obj) {
55
+ return;
56
+ }
57
+ obj.setRotation(ctx.coords.rot(rotation.angle));
58
+ }));
59
+ ctx.trackSystem(ctx.world
60
+ .system("PhaserSync:Scale")
61
+ .with(Scale)
62
+ .update(Scale, (entity, scale) => {
63
+ const obj = getSyncGameObject(ctx, entity.eid);
64
+ if (!obj) {
65
+ return;
66
+ }
67
+ obj.setScale(scale.x, scale.y);
68
+ }));
69
+ ctx.trackSystem(ctx.world
70
+ .system("PhaserSync:Alpha")
71
+ .with(Alpha)
72
+ .update(Alpha, (entity, alpha) => {
73
+ const obj = getSyncGameObject(ctx, entity.eid);
74
+ if (!obj) {
75
+ return;
76
+ }
77
+ obj.setAlpha(alpha.value);
78
+ }));
79
+ ctx.trackSystem(ctx.world
80
+ .system("PhaserSync:Depth")
81
+ .with(Depth)
82
+ .update(Depth, (entity, depth) => {
83
+ const obj = getSyncGameObject(ctx, entity.eid);
84
+ if (!obj) {
85
+ return;
86
+ }
87
+ obj.setDepth(depth.value);
88
+ }));
89
+ ctx.trackSystem(ctx.world
90
+ .system("PhaserSync:FillStyle")
91
+ .with(FillStyle)
92
+ .update(FillStyle, (entity, fill) => {
93
+ const obj = getSyncGameObject(ctx, entity.eid);
94
+ if (!obj) {
95
+ return;
96
+ }
97
+ obj.setFillStyle(fill.color, fill.alpha);
98
+ }));
99
+ ctx.trackSystem(ctx.world
100
+ .system("PhaserSync:StrokeStyle")
101
+ .with(StrokeStyle)
102
+ .update(StrokeStyle, (entity, stroke) => {
103
+ const obj = getSyncGameObject(ctx, entity.eid);
104
+ if (!obj) {
105
+ return;
106
+ }
107
+ obj.setStrokeStyle(stroke.width, stroke.color, stroke.alpha);
108
+ }));
109
+ }
110
+ function assertRotation(component, label) {
111
+ if (component instanceof Rotation) {
112
+ return component;
113
+ }
114
+ throw new Error(`Rotation interpolator expected ${label} to be Rotation`);
115
+ }
116
+ function getSyncGameObject(ctx, eid) {
117
+ const obj = ctx.getGameObject(eid);
118
+ return obj ? obj : undefined;
119
+ }
120
+ function normalizeAngle(angle) {
121
+ const normalized = angle % TWO_PI;
122
+ return normalized < 0 ? normalized + TWO_PI : normalized;
123
+ }
124
+ function rotationTypeId() {
125
+ return phaserNetworkComponents.indexOf(Rotation) + 1;
126
+ }
127
+ function shortestAngleDelta(source, target) {
128
+ return Math.atan2(Math.sin(target - source), Math.cos(target - source));
129
+ }
130
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.js","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,EACL,KAAK,EACL,SAAS,EACT,uBAAuB,EACvB,QAAQ,EACR,QAAQ,EACR,KAAK,EACL,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAK9B,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;AAY3B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE;IACnF,MAAM,cAAc,GAAG,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACxD,MAAM,cAAc,GAAG,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACxD,MAAM,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;IAC9B,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QAChB,MAAM,CAAC,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC;QACpC,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QAChB,MAAM,CAAC,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC;QACpC,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,MAAM,KAAK,GAAG,kBAAkB,CAAC,cAAc,CAAC,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;IAC7E,MAAM,CAAC,KAAK,GAAG,cAAc,CAAC,cAAc,CAAC,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC,CAAC;IACpE,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAEnC;IACC,IAAI,OAAO,EAAE,mBAAmB,KAAK,KA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AAM,UAAU,GAAG,KAAK,GAAG,MAAM,CAAC;IAClC,OAAO,UAAU,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC;AAC3D,CAAC;AAED,SAAS,cAAc;IACrB,OAAO,uBAAuB,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAc,EAAE,MAAc;IACxD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;AAC1E,CAAC"}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@vworlds/vecs-phaser-client",
3
+ "version": "1.0.25",
4
+ "private": false,
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE",
18
+ "CHANGELOG.md"
19
+ ],
20
+ "scripts": {
21
+ "build": "rimraf dist && tsc -p tsconfig.build.json",
22
+ "typecheck": "tsc --noEmit",
23
+ "lint": "eslint \"src/**/*.ts\" \"tests/**/*.ts\" --no-error-on-unmatched-pattern",
24
+ "test": "vitest run --passWithNoTests"
25
+ },
26
+ "dependencies": {
27
+ "@vworlds/vecs-client": "1.0.25",
28
+ "@vworlds/vecs-phaser": "1.0.25"
29
+ },
30
+ "peerDependencies": {
31
+ "phaser": "^4.1.0"
32
+ },
33
+ "devDependencies": {
34
+ "phaser": "^4.1.0"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "license": "MIT"
40
+ }