Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

test(render): the clip's cell is the one on screen

esengined1f12a7c46e4
diff --git a/fixtures/scenes/sprite-clip.esscene b/fixtures/scenes/sprite-clip.esscene
new file mode 100644
index 000000000..6ee32c421
--- /dev/null
+++ b/fixtures/scenes/sprite-clip.esscene
@@ -0,0 +1,29 @@
+{
+ "version": 4,
+ "name": "SpriteClip",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "components": [
+ { "type": "Transform", "data": { "position": { "x": 0, "y": 0, "z": 10 } } },
+ { "type": "Camera", "data": { "projectionType": 1, "orthoSize": 64, "isActive": true, "priority": 0 } }
+ ],
+ "visible": true
+ },
+ {
+ "id": 1,
+ "name": "Walker",
+ "parent": null,
+ "children": [],
+ "components": [
+ { "type": "Transform", "data": { "position": { "x": 0, "y": 0, "z": 0 } } },
+ { "type": "Sprite", "data": { "size": { "x": 64, "y": 64 }, "color": { "r": 1, "g": 1, "b": 1, "a": 1 }, "layer": 0, "order": 0, "enabled": true } },
+ { "type": "SpriteAnimator", "data": { "clip": "/scenes/sprite-clip/walk.esanim", "speed": 1, "playing": true, "loop": true, "enabled": true } }
+ ],
+ "visible": true
+ }
+ ]
+}
diff --git a/fixtures/scenes/sprite-clip/sheet.png b/fixtures/scenes/sprite-clip/sheet.png
new file mode 100644
index 000000000..e63a3bdd1
Binary files /dev/null and b/fixtures/scenes/sprite-clip/sheet.png differ
diff --git a/fixtures/scenes/sprite-clip/walk.esanim b/fixtures/scenes/sprite-clip/walk.esanim
new file mode 100644
index 000000000..a756fb63f
--- /dev/null
+++ b/fixtures/scenes/sprite-clip/walk.esanim
@@ -0,0 +1,21 @@
+{
+ "version": "1.5",
+ "type": "animation-clip",
+ "fps": 10,
+ "loop": true,
+ "sheet": {
+ "texture": "/scenes/sprite-clip/sheet.png",
+ "cellWidth": 16,
+ "cellHeight": 16,
+ "margin": 0,
+ "spacing": 0,
+ "pageWidth": 32,
+ "pageHeight": 32
+ },
+ "frames": [
+ { "cell": 0 },
+ { "cell": 1 },
+ { "cell": 2 },
+ { "cell": 3 }
+ ]
+}
diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjs
index 9cada54aa..9277bc543 100644
--- a/tools/renderScenes.mjs
+++ b/tools/renderScenes.mjs
@@ -79,6 +79,17 @@ export const SCENES = [
// no interaction and must survive, or masking is not opt-in.
{ id: "sprite-mask", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/sprite-mask.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.25,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":30},{\"x\":0.75,\"y\":0.5,\"rgb\":[255,0,0],\"tol\":30},{\"x\":0.25,\"y\":0.9375,\"rgb\":[0,0,255],\"tol\":30},{\"x\":0.75,\"y\":0.9375,\"rgb\":[0,0,255],\"tol\":30}]" } },
{ id: "parallax-shape", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/parallax-shape.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/parallax-shape.textures.json", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5,\"y\":0.5,\"rgb\":[0,255,0],\"tol\":40},{\"x\":0.25,\"y\":0.5,\"rgb\":[255,0,0],\"tol\":40}]" } },
+ // Frame N on screen is cell N — the clip's sheet window reaching Sprite UVs, which
+ // no pixel had ever read. Four probes INSIDE one sprite: a window that failed to
+ // narrow shows the whole page, so they come back four colours instead of one.
+ { id: "sprite-clip-cell0", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/sprite-clip.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_PLAY: "1", ESTELLA_VERIFY_STEPS: "3", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.375,\"y\":0.375,\"rgb\":[255,0,0],\"tol\":30},{\"x\":0.625,\"y\":0.375,\"rgb\":[255,0,0],\"tol\":30},{\"x\":0.375,\"y\":0.625,\"rgb\":[255,0,0],\"tol\":30},{\"x\":0.625,\"y\":0.625,\"rgb\":[255,0,0],\"tol\":30}]" } },
+ // Cells 1 and 2 are the two axes of the grid: a sheet cut transposed swaps them
+ // and cells 0 and 3 stay put, so a gate on either alone is half blind.
+ { id: "sprite-clip-cell1", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/sprite-clip.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_PLAY: "1", ESTELLA_VERIFY_STEPS: "9", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.375,\"y\":0.375,\"rgb\":[0,255,0],\"tol\":30},{\"x\":0.625,\"y\":0.375,\"rgb\":[0,255,0],\"tol\":30},{\"x\":0.375,\"y\":0.625,\"rgb\":[0,255,0],\"tol\":30},{\"x\":0.625,\"y\":0.625,\"rgb\":[0,255,0],\"tol\":30}]" } },
+ { id: "sprite-clip-cell2", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/sprite-clip.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_PLAY: "1", ESTELLA_VERIFY_STEPS: "15", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.375,\"y\":0.375,\"rgb\":[0,0,255],\"tol\":30},{\"x\":0.625,\"y\":0.375,\"rgb\":[0,0,255],\"tol\":30},{\"x\":0.375,\"y\":0.625,\"rgb\":[0,0,255],\"tol\":30},{\"x\":0.625,\"y\":0.625,\"rgb\":[0,0,255],\"tol\":30}]" } },
+ // Past the end and round again (t = 0.55s of a 0.4s clip). Cell 1 rather than 0:
+ // an animator that never advanced would answer cell 0 correctly.
+ { id: "sprite-clip-loop", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/sprite-clip.esscene", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_PLAY: "1", ESTELLA_VERIFY_STEPS: "33", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.375,\"y\":0.375,\"rgb\":[0,255,0],\"tol\":30},{\"x\":0.625,\"y\":0.375,\"rgb\":[0,255,0],\"tol\":30},{\"x\":0.375,\"y\":0.625,\"rgb\":[0,255,0],\"tol\":30},{\"x\":0.625,\"y\":0.625,\"rgb\":[0,255,0],\"tol\":30}]" } },
{ id: "tilemap-flip", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SCENE: "/scenes/tilemap-flip.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/tilemap-flip.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "2", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.40,\"y\":0.36,\"rgb\":[255,0,0]},{\"x\":0.60,\"y\":0.36,\"rgb\":[0,255,0]},{\"x\":0.40,\"y\":0.58,\"rgb\":[0,0,255]},{\"x\":0.60,\"y\":0.58,\"rgb\":[255,255,0]}]" } },
// A layer's own offset, set through the inspector's door: 16 world units is one
// cell here, so the whole grid steps right by one and the left column empties.