@vworlds/vecs-phaser-client 1.0.25 → 1.0.26
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/index.d.ts +4 -0
- package/index.js +4 -0
- package/{dist/index.js.map → index.js.map} +1 -1
- package/markers.d.ts +45 -0
- package/markers.js +25 -0
- package/markers.js.map +1 -0
- package/modules/arc.d.ts +13 -0
- package/modules/arc.js +37 -0
- package/modules/arc.js.map +1 -0
- package/modules/ellipse.d.ts +13 -0
- package/modules/ellipse.js +24 -0
- package/modules/ellipse.js.map +1 -0
- package/modules/line.d.ts +13 -0
- package/modules/line.js +37 -0
- package/modules/line.js.map +1 -0
- package/modules/phaser_render.d.ts +10 -0
- package/modules/phaser_render.js +65 -0
- package/modules/phaser_render.js.map +1 -0
- package/modules/polygon.d.ts +13 -0
- package/modules/polygon.js +40 -0
- package/modules/polygon.js.map +1 -0
- package/modules/rectangle.d.ts +13 -0
- package/modules/rectangle.js +24 -0
- package/modules/rectangle.js.map +1 -0
- package/modules/star.d.ts +13 -0
- package/modules/star.js +34 -0
- package/modules/star.js.map +1 -0
- package/modules/sync.d.ts +9 -0
- package/modules/sync.js +49 -0
- package/modules/sync.js.map +1 -0
- package/modules/text.d.ts +10 -0
- package/modules/text.js +35 -0
- package/modules/text.js.map +1 -0
- package/modules/triangle.d.ts +13 -0
- package/modules/triangle.js +43 -0
- package/modules/triangle.js.map +1 -0
- package/modules/types.d.ts +6 -0
- package/modules/types.js +27 -0
- package/modules/types.js.map +1 -0
- package/package.json +10 -25
- package/{dist/sync.d.ts → sync.d.ts} +0 -3
- package/sync.js +53 -0
- package/sync.js.map +1 -0
- package/CHANGELOG.md +0 -14
- package/LICENSE +0 -21
- package/README.md +0 -35
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -4
- package/dist/render_context.d.ts +0 -16
- package/dist/render_context.js +0 -2
- package/dist/render_context.js.map +0 -1
- package/dist/renderers/arc.d.ts +0 -2
- package/dist/renderers/arc.js +0 -38
- package/dist/renderers/arc.js.map +0 -1
- package/dist/renderers/ellipse.d.ts +0 -2
- package/dist/renderers/ellipse.js +0 -19
- package/dist/renderers/ellipse.js.map +0 -1
- package/dist/renderers/index.d.ts +0 -2
- package/dist/renderers/index.js +0 -21
- package/dist/renderers/index.js.map +0 -1
- package/dist/renderers/line.d.ts +0 -2
- package/dist/renderers/line.js +0 -45
- package/dist/renderers/line.js.map +0 -1
- package/dist/renderers/polygon.d.ts +0 -2
- package/dist/renderers/polygon.js +0 -44
- package/dist/renderers/polygon.js.map +0 -1
- package/dist/renderers/rectangle.d.ts +0 -2
- package/dist/renderers/rectangle.js +0 -33
- package/dist/renderers/rectangle.js.map +0 -1
- package/dist/renderers/shared.d.ts +0 -33
- package/dist/renderers/shared.js +0 -63
- package/dist/renderers/shared.js.map +0 -1
- package/dist/renderers/star.d.ts +0 -2
- package/dist/renderers/star.js +0 -25
- package/dist/renderers/star.js.map +0 -1
- package/dist/renderers/text.d.ts +0 -2
- package/dist/renderers/text.js +0 -48
- package/dist/renderers/text.js.map +0 -1
- package/dist/renderers/triangle.d.ts +0 -2
- package/dist/renderers/triangle.js +0 -30
- package/dist/renderers/triangle.js.map +0 -1
- package/dist/runtime.d.ts +0 -30
- package/dist/runtime.js +0 -70
- package/dist/runtime.js.map +0 -1
- package/dist/sync.js +0 -130
- package/dist/sync.js.map +0 -1
- /package/{dist/coord_space.d.ts → coord_space.d.ts} +0 -0
- /package/{dist/coord_space.js → coord_space.js} +0 -0
- /package/{dist/coord_space.js.map → coord_space.js.map} +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Module, ON_STORE } from "@vworlds/vecs";
|
|
2
|
+
import Phaser from "phaser";
|
|
3
|
+
import { Triangle } from "@vworlds/vecs-phaser";
|
|
4
|
+
import * as m from "../markers.js";
|
|
5
|
+
function triangleCoordinates(coords, triangle) {
|
|
6
|
+
return [
|
|
7
|
+
coords.rx(triangle.x1),
|
|
8
|
+
coords.ry(triangle.y1),
|
|
9
|
+
coords.rx(triangle.x2),
|
|
10
|
+
coords.ry(triangle.y2),
|
|
11
|
+
coords.rx(triangle.x3),
|
|
12
|
+
coords.ry(triangle.y3),
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
export class TriangleModule extends Module {
|
|
16
|
+
init(config) {
|
|
17
|
+
const { scene, coords } = config;
|
|
18
|
+
const world = this.world;
|
|
19
|
+
world.component(Triangle).onRemove((entity) => {
|
|
20
|
+
if (entity.has(Phaser.GameObjects.Triangle)) {
|
|
21
|
+
entity.remove(Phaser.GameObjects.Triangle);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
world
|
|
25
|
+
.system("phaser.new.triangle")
|
|
26
|
+
.with(Triangle)
|
|
27
|
+
.without(Phaser.GameObjects.Triangle)
|
|
28
|
+
.phase(ON_STORE)
|
|
29
|
+
.enter([Triangle], (entity, [triangle]) => {
|
|
30
|
+
const obj = scene.add.triangle(0, 0, ...triangleCoordinates(coords, triangle));
|
|
31
|
+
obj.setOrigin(0, 0);
|
|
32
|
+
entity.attach(obj);
|
|
33
|
+
});
|
|
34
|
+
world
|
|
35
|
+
.system("phaser.render.triangle.geometry")
|
|
36
|
+
.with(Triangle, m.Vertices)
|
|
37
|
+
.phase(ON_STORE)
|
|
38
|
+
.update(Triangle, [m.Vertices], (_entity, triangle, [obj]) => {
|
|
39
|
+
obj.setTo(...triangleCoordinates(coords, triangle));
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=triangle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"triangle.js","sourceRoot":"","sources":["../../src/modules/triangle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,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EAAE,CAAC,EAAE,GAAG,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;YAC/E,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACpB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;QAEL,KAAK;aACF,MAAM,CAAC,iCAAiC,CAAC;aACzC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC;aAC1B,KAAK,CAAC,QAAQ,CAAC;aACf,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE;YAC3D,GAAG,CAAC,KAAK,CAAC,GAAG,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;IACP,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="./phaser" resolution-mode="require"/>
|
|
2
|
+
import { TextAlign, type Text as TextComponent } from "@vworlds/vecs-phaser";
|
|
3
|
+
import type Phaser from "phaser";
|
|
4
|
+
export declare function hexColor(color: number): string;
|
|
5
|
+
export declare function textAlign(value: TextAlign): "center" | "left" | "right";
|
|
6
|
+
export declare function textStyle(text: TextComponent): Phaser.Types.GameObjects.Text.TextStyle;
|
package/modules/types.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TextAlign } from "@vworlds/vecs-phaser";
|
|
2
|
+
export function hexColor(color) {
|
|
3
|
+
return `#${(color & 0xffffff).toString(16).padStart(6, "0")}`;
|
|
4
|
+
}
|
|
5
|
+
export function textAlign(value) {
|
|
6
|
+
switch (value) {
|
|
7
|
+
case TextAlign.Center:
|
|
8
|
+
return "center";
|
|
9
|
+
case TextAlign.Right:
|
|
10
|
+
return "right";
|
|
11
|
+
default:
|
|
12
|
+
return "left";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function textStyle(text) {
|
|
16
|
+
const style = {
|
|
17
|
+
align: textAlign(text.align),
|
|
18
|
+
color: hexColor(text.color),
|
|
19
|
+
fontFamily: text.fontFamily,
|
|
20
|
+
fontSize: text.fontSize,
|
|
21
|
+
};
|
|
22
|
+
if (text.backgroundAlpha > 0) {
|
|
23
|
+
style.backgroundColor = hexColor(text.backgroundColor);
|
|
24
|
+
}
|
|
25
|
+
return style;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/modules/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA8B,MAAM,sBAAsB,CAAC;AAG7E,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;AAED,MAAM,UAAU,SAAS,CAAC,IAAmB;IAC3C,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"}
|
package/package.json
CHANGED
|
@@ -1,40 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vworlds/vecs-phaser-client",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"private": false,
|
|
3
|
+
"version": "1.0.26",
|
|
5
4
|
"type": "module",
|
|
6
|
-
"main": "
|
|
7
|
-
"types": "
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"types": "./index.d.ts",
|
|
8
7
|
"exports": {
|
|
9
8
|
".": {
|
|
10
|
-
"types": "./
|
|
11
|
-
"import": "./
|
|
9
|
+
"types": "./index.d.ts",
|
|
10
|
+
"import": "./index.js"
|
|
12
11
|
}
|
|
13
12
|
},
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
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"
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/vworlds/vecs.git"
|
|
25
16
|
},
|
|
26
17
|
"dependencies": {
|
|
27
|
-
"@vworlds/vecs-client": "1.0.
|
|
28
|
-
"@vworlds/vecs-phaser": "1.0.
|
|
18
|
+
"@vworlds/vecs-client": "1.0.26",
|
|
19
|
+
"@vworlds/vecs-phaser": "1.0.26"
|
|
29
20
|
},
|
|
30
21
|
"peerDependencies": {
|
|
31
22
|
"phaser": "^4.1.0"
|
|
32
23
|
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"phaser": "^4.1.0"
|
|
35
|
-
},
|
|
36
|
-
"publishConfig": {
|
|
37
|
-
"access": "public"
|
|
38
|
-
},
|
|
39
24
|
"license": "MIT"
|
|
40
25
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ComponentInterpolator } from "@vworlds/vecs-client";
|
|
2
|
-
import type { RenderContext } from "./render_context.js";
|
|
3
2
|
/**
|
|
4
3
|
* Shortest-arc angular interpolator for raw `Rotation` components.
|
|
5
4
|
*
|
|
@@ -12,9 +11,7 @@ export declare const rotationInterpolator: ComponentInterpolator;
|
|
|
12
11
|
*
|
|
13
12
|
* Pass this at `ClientWorld` construction/connect time, for example:
|
|
14
13
|
* `ClientWorld.connectDgram({ networkComponents: phaserNetworkComponents, interpolators: phaserInterpolators() })`.
|
|
15
|
-
* Keep the runtime `interpolateRotation` option consistent with this setting.
|
|
16
14
|
*/
|
|
17
15
|
export declare function phaserInterpolators(options?: {
|
|
18
16
|
interpolateRotation?: boolean;
|
|
19
17
|
}): Array<readonly [number, ComponentInterpolator]>;
|
|
20
|
-
export declare function installSyncSystems(ctx: RenderContext): void;
|
package/sync.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { phaserNetworkComponents, Rotation } 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
|
+
*/
|
|
31
|
+
export function phaserInterpolators(options) {
|
|
32
|
+
if (options?.interpolateRotation === false) {
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
return [[rotationTypeId(), rotationInterpolator]];
|
|
36
|
+
}
|
|
37
|
+
function assertRotation(component, label) {
|
|
38
|
+
if (component instanceof Rotation) {
|
|
39
|
+
return component;
|
|
40
|
+
}
|
|
41
|
+
throw new Error(`Rotation interpolator expected ${label} to be Rotation`);
|
|
42
|
+
}
|
|
43
|
+
function normalizeAngle(angle) {
|
|
44
|
+
const normalized = angle % TWO_PI;
|
|
45
|
+
return normalized < 0 ? normalized + TWO_PI : normalized;
|
|
46
|
+
}
|
|
47
|
+
function rotationTypeId() {
|
|
48
|
+
return phaserNetworkComponents.indexOf(Rotation) + 1;
|
|
49
|
+
}
|
|
50
|
+
function shortestAngleDelta(source, target) {
|
|
51
|
+
return Math.atan2(Math.sin(target - source), Math.cos(target - source));
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=sync.js.map
|
package/sync.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;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KAAK,iBAAiB,CAAC,CAAC;AAC5E,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,MAAM,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/CHANGELOG.md
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
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.
|
package/dist/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
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
DELETED
package/dist/render_context.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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;
|
package/dist/render_context.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"render_context.js","sourceRoot":"","sources":["../src/render_context.ts"],"names":[],"mappings":""}
|
package/dist/renderers/arc.d.ts
DELETED
package/dist/renderers/arc.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
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(system);
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=arc.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arc.js","sourceRoot":"","sources":["../../src/renderers/arc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAI3C,OAAO,EAAE,sBAAsB,EAAqB,MAAM,aAAa,CAAC;AAIxE,MAAM,UAAU,kBAAkB,CAAC,GAAkB;IACnD,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK;SACrB,MAAM,CAAC,WAAW,CAAC;SACnB,IAAI,CAAC,GAAG,CAAC;SACT,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE;QAChB,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO;QACT,CAAC;QAED,MAAM,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAC3B,CAAC,EACD,CAAC,EACD,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAC1B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,EAC9B,G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AAC;AAC1B,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/renderers/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/renderers/line.d.ts
DELETED
package/dist/renderers/line.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,EACT,MAAM,CAAC,CAAC,CAAC,EACT,MAAM,CAAC,CAAC,CAAC,EACT,MAAM,CAAC,CAAC,CAAC,CACI,CAAC;QAChB,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;IAC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
|
-
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-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AC,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"}
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,33 +0,0 @@
|
|
|
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";
|