@ignifx/2d 0.4.0 → 0.6.0
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/dist/index.d.ts +5 -5
- package/dist/index.js +21 -19
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/skills/2d/SKILL.md +10 -11
package/dist/index.d.ts
CHANGED
|
@@ -596,7 +596,7 @@ interface SpriteLayerKey {
|
|
|
596
596
|
* ```ts
|
|
597
597
|
* const hero = app.world.createEntity({ name: "hero" });
|
|
598
598
|
* const sprite = hero.addComponent(SpriteRenderer);
|
|
599
|
-
* sprite.sprite = app.assets.load<SpriteAtlasAsset>("2d/hero.atlas.json")
|
|
599
|
+
* sprite.sprite = app.assets.load<SpriteAtlasAsset>("2d/hero.atlas.json");
|
|
600
600
|
* sprite.sortingLayer = "Default";
|
|
601
601
|
* ```
|
|
602
602
|
*
|
|
@@ -2228,7 +2228,7 @@ interface PlayClipOptions {
|
|
|
2228
2228
|
* @example
|
|
2229
2229
|
* ```ts
|
|
2230
2230
|
* const animator = hero.addComponent(SpriteAnimator);
|
|
2231
|
-
* animator.animations = app.assets.load<SpriteAnimationAsset>("2d/hero.spriteanim.json")
|
|
2231
|
+
* animator.animations = app.assets.load<SpriteAnimationAsset>("2d/hero.spriteanim.json");
|
|
2232
2232
|
* animator.onEvent.connect((name) => { if (name === "footstep") playStep(); }, { owner: animator });
|
|
2233
2233
|
* animator.play("run");
|
|
2234
2234
|
* ```
|
|
@@ -4049,7 +4049,7 @@ interface TileChange {
|
|
|
4049
4049
|
* @example
|
|
4050
4050
|
* ```ts
|
|
4051
4051
|
* const level = app.world.createEntity({ name: "level" }).addComponent(Tilemap);
|
|
4052
|
-
* level.map = app.assets.load<TilemapAsset>("2d/level-1.tilemap.json")
|
|
4052
|
+
* level.map = app.assets.load<TilemapAsset>("2d/level-1.tilemap.json");
|
|
4053
4053
|
* level.setTile(0, 3, 2, 0); // carve a hole in the ground layer
|
|
4054
4054
|
* ```
|
|
4055
4055
|
*
|
|
@@ -4227,9 +4227,9 @@ export declare function spawnTilemapObjects(app: App, service: TwoDService, tile
|
|
|
4227
4227
|
* @example
|
|
4228
4228
|
* ```ts
|
|
4229
4229
|
* const level = app.world.createEntity({ name: "level" });
|
|
4230
|
-
* level.addComponent(Tilemap).map = app.assets.load<TilemapAsset>("2d/level-1.tilemap.json")
|
|
4230
|
+
* level.addComponent(Tilemap).map = app.assets.load<TilemapAsset>("2d/level-1.tilemap.json");
|
|
4231
4231
|
* const renderer = level.addComponent(TilemapRenderer);
|
|
4232
|
-
* renderer.atlas = app.assets.load<SpriteAtlasAsset>("2d/tiles.atlas.json")
|
|
4232
|
+
* renderer.atlas = app.assets.load<SpriteAtlasAsset>("2d/tiles.atlas.json");
|
|
4233
4233
|
* ```
|
|
4234
4234
|
*
|
|
4235
4235
|
* @public
|
package/dist/index.js
CHANGED
|
@@ -965,7 +965,7 @@ var SortingLayerTable = class {
|
|
|
965
965
|
* ```ts
|
|
966
966
|
* const hero = app.world.createEntity({ name: "hero" });
|
|
967
967
|
* const sprite = hero.addComponent(SpriteRenderer);
|
|
968
|
-
* sprite.sprite = app.assets.load<SpriteAtlasAsset>("2d/hero.atlas.json")
|
|
968
|
+
* sprite.sprite = app.assets.load<SpriteAtlasAsset>("2d/hero.atlas.json");
|
|
969
969
|
* sprite.sortingLayer = "Default";
|
|
970
970
|
* ```
|
|
971
971
|
*
|
|
@@ -1425,7 +1425,7 @@ const EMPTY_EVENTS = Object.freeze([]);
|
|
|
1425
1425
|
* @example
|
|
1426
1426
|
* ```ts
|
|
1427
1427
|
* const animator = hero.addComponent(SpriteAnimator);
|
|
1428
|
-
* animator.animations = app.assets.load<SpriteAnimationAsset>("2d/hero.spriteanim.json")
|
|
1428
|
+
* animator.animations = app.assets.load<SpriteAnimationAsset>("2d/hero.spriteanim.json");
|
|
1429
1429
|
* animator.onEvent.connect((name) => { if (name === "footstep") playStep(); }, { owner: animator });
|
|
1430
1430
|
* animator.play("run");
|
|
1431
1431
|
* ```
|
|
@@ -3471,7 +3471,9 @@ function beyond(desired, current, half) {
|
|
|
3471
3471
|
* @param surface - The surface to draw into; the engine, for a single-canvas app.
|
|
3472
3472
|
* @param clear - Whether the sprite pass clears first. `false` in `"mixed"` mode, so the 3D scene's
|
|
3473
3473
|
* colour survives underneath.
|
|
3474
|
-
* @param clearColor - The
|
|
3474
|
+
* @param clearColor - The sRGB colour the frame should present when `clear` is `true`, straight
|
|
3475
|
+
* RGBA in `0` to `1`. Lite stores the clear value as given, so it is passed through unchanged,
|
|
3476
|
+
* and decoded only for an `*-srgb` surface view, which encodes it again on write.
|
|
3475
3477
|
* @param clearColor.r - The red channel.
|
|
3476
3478
|
* @param clearColor.g - The green channel.
|
|
3477
3479
|
* @param clearColor.b - The blue channel.
|
|
@@ -3481,13 +3483,14 @@ function beyond(desired, current, half) {
|
|
|
3481
3483
|
* @internal
|
|
3482
3484
|
*/
|
|
3483
3485
|
function createRegisteredSpriteRenderer(surface, clear, clearColor) {
|
|
3486
|
+
const decode = surface.format.endsWith("-srgb");
|
|
3484
3487
|
const renderer = createSpriteRenderer(surface, {
|
|
3485
3488
|
layers: [],
|
|
3486
3489
|
clear,
|
|
3487
3490
|
clearValue: {
|
|
3488
|
-
r: clearColor.r,
|
|
3489
|
-
g: clearColor.g,
|
|
3490
|
-
b: clearColor.b,
|
|
3491
|
+
r: decode ? Color.srgbToLinear(clearColor.r) : clearColor.r,
|
|
3492
|
+
g: decode ? Color.srgbToLinear(clearColor.g) : clearColor.g,
|
|
3493
|
+
b: decode ? Color.srgbToLinear(clearColor.b) : clearColor.b,
|
|
3491
3494
|
a: clearColor.a
|
|
3492
3495
|
}
|
|
3493
3496
|
});
|
|
@@ -4097,9 +4100,9 @@ function tileCollisionInfo(map, tileId) {
|
|
|
4097
4100
|
* @example
|
|
4098
4101
|
* ```ts
|
|
4099
4102
|
* const level = app.world.createEntity({ name: "level" });
|
|
4100
|
-
* level.addComponent(Tilemap).map = app.assets.load<TilemapAsset>("2d/level-1.tilemap.json")
|
|
4103
|
+
* level.addComponent(Tilemap).map = app.assets.load<TilemapAsset>("2d/level-1.tilemap.json");
|
|
4101
4104
|
* const renderer = level.addComponent(TilemapRenderer);
|
|
4102
|
-
* renderer.atlas = app.assets.load<SpriteAtlasAsset>("2d/tiles.atlas.json")
|
|
4105
|
+
* renderer.atlas = app.assets.load<SpriteAtlasAsset>("2d/tiles.atlas.json");
|
|
4103
4106
|
* ```
|
|
4104
4107
|
*
|
|
4105
4108
|
* @public
|
|
@@ -5497,7 +5500,7 @@ const DEFAULT_CHUNK_SIZE = 32;
|
|
|
5497
5500
|
* @example
|
|
5498
5501
|
* ```ts
|
|
5499
5502
|
* const level = app.world.createEntity({ name: "level" }).addComponent(Tilemap);
|
|
5500
|
-
* level.map = app.assets.load<TilemapAsset>("2d/level-1.tilemap.json")
|
|
5503
|
+
* level.map = app.assets.load<TilemapAsset>("2d/level-1.tilemap.json");
|
|
5501
5504
|
* level.setTile(0, 3, 2, 0); // carve a hole in the ground layer
|
|
5502
5505
|
* ```
|
|
5503
5506
|
*
|
|
@@ -6722,8 +6725,8 @@ function twoDSettingsSchema() {
|
|
|
6722
6725
|
});
|
|
6723
6726
|
}
|
|
6724
6727
|
/**
|
|
6725
|
-
* The
|
|
6726
|
-
* setting
|
|
6728
|
+
* The sRGB colour a `"sprite"`-mode frame is cleared to, read from the **core**
|
|
6729
|
+
* `rendering.clearColor` setting.
|
|
6727
6730
|
*
|
|
6728
6731
|
* @remarks
|
|
6729
6732
|
* A `"sprite"`-mode sprite pass owns the frame: it clears the swapchain itself and nothing the
|
|
@@ -6733,22 +6736,21 @@ function twoDSettingsSchema() {
|
|
|
6733
6736
|
* (`docs/architecture/07-rendering.md` §2.1) — has only its last rung here: neither of those two
|
|
6734
6737
|
* components exists in a 2D scene, and `Camera2D` has no `clearColor` field of its own.
|
|
6735
6738
|
*
|
|
6736
|
-
*
|
|
6737
|
-
*
|
|
6738
|
-
*
|
|
6739
|
-
* and it is also why a literal `#14181F` presents darker than its hex suggests.
|
|
6739
|
+
* The colour is handed to the sprite pass as sRGB, and the adapter treats it exactly as
|
|
6740
|
+
* `RendererImpl.applyClearColor` does, so a `"sprite"` frame and a `"mixed"` frame with the same
|
|
6741
|
+
* setting present the same bytes: an sRGB `0.5` presents as `128`.
|
|
6740
6742
|
*
|
|
6741
6743
|
* @param app - The app whose settings are read.
|
|
6742
|
-
* @returns
|
|
6744
|
+
* @returns A copy of the setting, as straight sRGB RGBA in `0` to `1`.
|
|
6743
6745
|
*
|
|
6744
6746
|
* @internal
|
|
6745
6747
|
*/
|
|
6746
6748
|
function spriteClearColor(app) {
|
|
6747
6749
|
const { clearColor } = app.settings.section(RENDERING_SETTINGS_SECTION);
|
|
6748
6750
|
return {
|
|
6749
|
-
r:
|
|
6750
|
-
g:
|
|
6751
|
-
b:
|
|
6751
|
+
r: clearColor.r,
|
|
6752
|
+
g: clearColor.g,
|
|
6753
|
+
b: clearColor.b,
|
|
6752
6754
|
a: clearColor.a
|
|
6753
6755
|
};
|
|
6754
6756
|
}
|