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.

fix: resolve CI test failures for v0.9.0

esengine98c3d895e1ed
diff --git a/sdk/src/timeline/TimelinePlugin.ts b/sdk/src/timeline/TimelinePlugin.ts
index ffdc5b22e..64ea9971d 100644
--- a/sdk/src/timeline/TimelinePlugin.ts
+++ b/sdk/src/timeline/TimelinePlugin.ts
@@ -42,7 +42,7 @@ const WRAP_MODE_MAP: Record<string, number> = {
pingPong: WrapMode.PingPong,
};
-function setNestedProperty(obj: Record<string, any>, path: string, value: number): boolean {
+export function setNestedProperty(obj: Record<string, any>, path: string, value: number): boolean {
const parts = path.split('.');
let target = obj;
for (let i = 0; i < parts.length - 1; i++) {
diff --git a/sdk/tests/dropdown-interaction.test.ts b/sdk/tests/dropdown-interaction.test.ts
index fb6c658d2..51f6fe9d5 100644
--- a/sdk/tests/dropdown-interaction.test.ts
+++ b/sdk/tests/dropdown-interaction.test.ts
@@ -45,8 +45,10 @@ describe.skipIf(!HAS_WASM)('Dropdown Interaction (WASM integration)', () => {
const registry = new module.Registry() as unknown as CppRegistry;
app.connectCpp(registry, module);
+ const vp = new Float32Array(16);
+ vp[0] = 2 / 800; vp[5] = 2 / 600; vp[10] = -1; vp[15] = 1;
app.insertResource(UICameraInfo, {
- viewProjection: new Float32Array(16),
+ viewProjection: vp,
vpX: 0, vpY: 0, vpW: 800, vpH: 600,
screenW: 800, screenH: 600,
worldLeft: -400, worldBottom: -300, worldRight: 400, worldTop: 300,
@@ -164,13 +166,13 @@ describe.skipIf(!HAS_WASM)('Dropdown Interaction (WASM integration)', () => {
return { root, ddEntity, listEntity, labelEntity };
}
- it('should propagate justPressed through C++ UIInteraction component', () => {
+ it('should propagate justPressed through C++ UIInteraction component', async () => {
const { app, registry } = createApp();
const { ddEntity } = createDropdownHierarchy(app);
const world = app.world;
// First tick to let layout compute positions
- app.tick(1 / 60);
+ await app.tick(1 / 60);
// The ddEntity should now have UIInteraction from the hit test system (getOrEmplace)
// Verify UIInteraction round-trip: read from C++, modify, write back
@@ -195,13 +197,13 @@ describe.skipIf(!HAS_WASM)('Dropdown Interaction (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should detect click on dropdown via C++ hit test and open it', () => {
+ it('should detect click on dropdown via C++ hit test and open it', async () => {
const { app, registry } = createApp();
const { ddEntity, listEntity } = createDropdownHierarchy(app);
const world = app.world;
// Initial tick to compute layout
- app.tick(1 / 60);
+ await app.tick(1 / 60);
// Verify dropdown is closed
let dd = world.get(ddEntity, Dropdown) as DropdownData;
@@ -216,14 +218,18 @@ describe.skipIf(!HAS_WASM)('Dropdown Interaction (WASM integration)', () => {
// The hit test should detect the dropdown entity
expect(hitEntity).toBe(ddEntity);
- // Now simulate a full click by setting UIInteraction with plain object
- // (bypassing the UIInteractionPlugin's Emscripten wrapper issue)
- world.insert(ddEntity, UIInteraction, {
- hovered: true, pressed: true,
- justPressed: true, justReleased: false,
- });
+ // Simulate a mouse click through the Input resource so UIInteractionPlugin
+ // naturally sets justPressed on the hit entity
+ const input = app.getResource(Input) as InputState;
+ input.mouseX = 400;
+ input.mouseY = 300;
+ input.mouseButtons.add(0);
+ input.mouseButtonsPressed.add(0);
+
+ await app.tick(1 / 60);
- app.tick(1 / 60);
+ // Clear mouse state after the press frame
+ input.mouseButtonsPressed.clear();
dd = world.get(ddEntity, Dropdown) as DropdownData;
expect(dd.isOpen).toBe(true);
@@ -231,12 +237,12 @@ describe.skipIf(!HAS_WASM)('Dropdown Interaction (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should correctly round-trip UIInteraction through Emscripten wrapper', () => {
+ it('should correctly round-trip UIInteraction through Emscripten wrapper', async () => {
const { app, registry } = createApp();
const { ddEntity } = createDropdownHierarchy(app);
const world = app.world;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
// Set known values via plain object
world.insert(ddEntity, UIInteraction, {
@@ -316,7 +322,7 @@ describe.skipIf(!HAS_WASM)('Dropdown Interaction (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should fix white label text to black after initialization', () => {
+ it('should fix white label text to black after initialization', async () => {
const { app, registry } = createApp();
const { labelEntity } = createDropdownHierarchy(app);
const world = app.world;
@@ -328,7 +334,7 @@ describe.skipIf(!HAS_WASM)('Dropdown Interaction (WASM integration)', () => {
expect(text.color.b).toBe(1);
// After tick, syncLabel should fix to black
- app.tick(1 / 60);
+ await app.tick(1 / 60);
text = world.get(labelEntity, Text) as TextData;
const isWhite = text.color.r === 1 && text.color.g === 1 && text.color.b === 1;
diff --git a/sdk/tests/dropdown-layout.test.ts b/sdk/tests/dropdown-layout.test.ts
index 4c641999e..6fc7a6cf4 100644
--- a/sdk/tests/dropdown-layout.test.ts
+++ b/sdk/tests/dropdown-layout.test.ts
@@ -47,10 +47,12 @@ describe.skipIf(!HAS_WASM)('Dropdown Layout (WASM integration)', () => {
const registry = new module.Registry() as unknown as CppRegistry;
app.connectCpp(registry, module);
+ const vp = new Float32Array(16);
+ vp[0] = 2 / 800; vp[5] = 2 / 600; vp[10] = -1; vp[15] = 1;
app.insertResource(UICameraInfo, {
- viewProjection: new Float32Array(16),
- vpX: 0, vpY: 0, vpW: 0, vpH: 0,
- screenW: 0, screenH: 0,
+ viewProjection: vp,
+ vpX: 0, vpY: 0, vpW: 800, vpH: 600,
+ screenW: 800, screenH: 600,
worldLeft: -400, worldBottom: -300, worldRight: 400, worldTop: 300,
worldMouseX: 0, worldMouseY: 0,
valid: true,
@@ -163,26 +165,24 @@ describe.skipIf(!HAS_WASM)('Dropdown Layout (WASM integration)', () => {
return { root, ddEntity, listEntity, labelEntity };
}
- it('should create option entities with distinct Y positions after opening', () => {
+ it('should create option entities with distinct Y positions after opening', async () => {
const { app, registry } = createDropdownApp();
const { ddEntity, listEntity } = createDropdownHierarchy(app);
// Initial tick to set up layout
- app.tick(1 / 60);
+ await app.tick(1 / 60);
- // Simulate click on dropdown to open it:
- // Force isOpen via component update and tick
+ // Open dropdown by setting isOpen directly and simulating click via Input
const world = app.world;
- const dd = world.get(ddEntity, Dropdown) as any;
- dd.isOpen = false;
+ const input = app.getResource(Input) as InputState;
+ input.mouseX = 400;
+ input.mouseY = 300;
+ input.mouseButtons.add(0);
+ input.mouseButtonsPressed.add(0);
- // Simulate UIInteraction justPressed on the dropdown
- world.insert(ddEntity, UIInteraction, {
- hovered: true, pressed: true,
- justPressed: true, justReleased: false,
- });
+ await app.tick(1 / 60);
- app.tick(1 / 60);
+ input.mouseButtonsPressed.clear();
// After tick, the dropdown should be open and options should exist
const ddData = world.get(ddEntity, Dropdown) as any;
@@ -207,7 +207,7 @@ describe.skipIf(!HAS_WASM)('Dropdown Layout (WASM integration)', () => {
expect(optionEntities.length).toBe(3);
// Run another tick so layout computes positions
- app.tick(1 / 60);
+ await app.tick(1 / 60);
// Each option should have a DISTINCT Y position
const yPositions = optionEntities.map(e => {
@@ -231,20 +231,22 @@ describe.skipIf(!HAS_WASM)('Dropdown Layout (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should have option sprites with non-zero size after layout', () => {
+ it('should have option sprites with non-zero size after layout', async () => {
const { app, registry } = createDropdownApp();
const { ddEntity, listEntity } = createDropdownHierarchy(app);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const world = app.world;
- world.insert(ddEntity, UIInteraction, {
- hovered: true, pressed: true,
- justPressed: true, justReleased: false,
- });
+ const input = app.getResource(Input) as InputState;
+ input.mouseX = 400;
+ input.mouseY = 300;
+ input.mouseButtons.add(0);
+ input.mouseButtonsPressed.add(0);
+ await app.tick(1 / 60);
+ input.mouseButtonsPressed.clear();
- app.tick(1 / 60);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const allEntities = world.getAllEntities();
const optionEntities: number[] = [];
@@ -268,7 +270,7 @@ describe.skipIf(!HAS_WASM)('Dropdown Layout (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should hide list entity on initialization when dropdown is closed', () => {
+ it('should hide list entity on initialization when dropdown is closed', async () => {
const { app, registry } = createDropdownApp();
const { listEntity } = createDropdownHierarchy(app);
const world = app.world;
@@ -282,7 +284,7 @@ describe.skipIf(!HAS_WASM)('Dropdown Layout (WASM integration)', () => {
});
world.insert(listEntity, Interactable, { enabled: true, blockRaycast: true, raycastTarget: true });
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const sprite = registry.getSprite(listEntity);
expect(sprite.enabled).toBe(false);
@@ -293,12 +295,12 @@ describe.skipIf(!HAS_WASM)('Dropdown Layout (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should set label text color to non-white after sync', () => {
+ it('should set label text color to non-white after sync', async () => {
const { app, registry } = createDropdownApp();
const { labelEntity } = createDropdownHierarchy(app);
const world = app.world;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const text = world.get(labelEntity, Text) as TextData;
const isWhite = text.color.r === 1 && text.color.g === 1 && text.color.b === 1;
@@ -308,7 +310,7 @@ describe.skipIf(!HAS_WASM)('Dropdown Layout (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should preserve label placeholder text when selectedIndex is -1', () => {
+ it('should preserve label placeholder text when selectedIndex is -1', async () => {
const { app, registry } = createDropdownApp();
const { ddEntity, labelEntity } = createDropdownHierarchy(app);
const world = app.world;
@@ -327,7 +329,7 @@ describe.skipIf(!HAS_WASM)('Dropdown Layout (WASM integration)', () => {
dd.selectedIndex = -1;
world.insert(ddEntity, Dropdown, dd);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const text = world.get(labelEntity, Text) as TextData;
expect(text.content).toBe('Select...');
@@ -335,7 +337,7 @@ describe.skipIf(!HAS_WASM)('Dropdown Layout (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should fix white label text even when selectedIndex is -1', () => {
+ it('should fix white label text even when selectedIndex is -1', async () => {
const { app, registry } = createDropdownApp();
const { ddEntity, labelEntity } = createDropdownHierarchy(app);
const world = app.world;
@@ -354,7 +356,7 @@ describe.skipIf(!HAS_WASM)('Dropdown Layout (WASM integration)', () => {
dd.selectedIndex = -1;
world.insert(ddEntity, Dropdown, dd);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const text = world.get(labelEntity, Text) as TextData;
// White text should be fixed to black even without valid selection
@@ -366,24 +368,25 @@ describe.skipIf(!HAS_WASM)('Dropdown Layout (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should open dropdown and show list entity on click', () => {
+ it('should open dropdown and show list entity on click', async () => {
const { app, registry } = createDropdownApp();
const { ddEntity, listEntity } = createDropdownHierarchy(app);
const world = app.world;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
// Verify list is hidden initially
let sprite = registry.getSprite(listEntity);
expect(sprite.enabled).toBe(false);
- // Simulate click
- world.insert(ddEntity, UIInteraction, {
- hovered: true, pressed: true,
- justPressed: true, justReleased: false,
- });
-
- app.tick(1 / 60);
+ // Simulate click via Input resource
+ const input = app.getResource(Input) as InputState;
+ input.mouseX = 400;
+ input.mouseY = 300;
+ input.mouseButtons.add(0);
+ input.mouseButtonsPressed.add(0);
+ await app.tick(1 / 60);
+ input.mouseButtonsPressed.clear();
const dd = world.get(ddEntity, Dropdown) as any;
expect(dd.isOpen).toBe(true);
diff --git a/sdk/tests/dropdown-list-text.test.ts b/sdk/tests/dropdown-list-text.test.ts
index ac88287c6..dba0dab8a 100644
--- a/sdk/tests/dropdown-list-text.test.ts
+++ b/sdk/tests/dropdown-list-text.test.ts
@@ -43,8 +43,10 @@ describe.skipIf(!HAS_WASM)('Dropdown list child text visibility (WASM)', () => {
const registry = new module.Registry() as unknown as CppRegistry;
app.connectCpp(registry, module);
+ const vp = new Float32Array(16);
+ vp[0] = 2 / 800; vp[5] = 2 / 600; vp[10] = -1; vp[15] = 1;
app.insertResource(UICameraInfo, {
- viewProjection: new Float32Array(16),
+ viewProjection: vp,
vpX: 0, vpY: 0, vpW: 800, vpH: 600,
screenW: 800, screenH: 600,
worldLeft: -400, worldBottom: -300, worldRight: 400, worldTop: 300,
@@ -189,7 +191,7 @@ describe.skipIf(!HAS_WASM)('Dropdown list child text visibility (WASM)', () => {
return { root, ddEntity, listEntity, labelEntity, userTextEntity };
}
- it('list entity scale should be normalized from (0,0,0) to (1,1,1) on init', () => {
+ it('list entity scale should be normalized from (0,0,0) to (1,1,1) on init', async () => {
const { app, registry } = createApp();
const { ddEntity, listEntity, userTextEntity } = buildDropdownWithUserText(app);
const world = app.world;
@@ -200,7 +202,7 @@ describe.skipIf(!HAS_WASM)('Dropdown list child text visibility (WASM)', () => {
expect(beforeTick.scale.y).toBe(0);
// First tick initializes the dropdown (closed state)
- app.tick(1 / 60);
+ await app.tick(1 / 60);
// DropdownPlugin should normalize list scale to (1,1,1) so children are visible
const listTransform = world.get(listEntity, Transform) as TransformData;
@@ -219,12 +221,12 @@ describe.skipIf(!HAS_WASM)('Dropdown list child text visibility (WASM)', () => {
disposeApp(app, registry);
});
- it('user text entity should have non-zero sprite size after layout', () => {
+ it('user text entity should have non-zero sprite size after layout', async () => {
const { app, registry } = createApp();
const { userTextEntity } = buildDropdownWithUserText(app);
const world = app.world;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const sprite = world.get(userTextEntity, Sprite) as SpriteData;
expect(sprite.size.x).toBeGreaterThan(0);
@@ -233,12 +235,12 @@ describe.skipIf(!HAS_WASM)('Dropdown list child text visibility (WASM)', () => {
disposeApp(app, registry);
});
- it('user text entity should get layer from UIRenderOrderSystem', () => {
+ it('user text entity should get layer from UIRenderOrderSystem', async () => {
const { app, registry } = createApp();
const { ddEntity, listEntity, userTextEntity } = buildDropdownWithUserText(app);
const world = app.world;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const ddSprite = world.get(ddEntity, Sprite) as SpriteData;
const listSprite = world.get(listEntity, Sprite) as SpriteData;
@@ -252,20 +254,22 @@ describe.skipIf(!HAS_WASM)('Dropdown list child text visibility (WASM)', () => {
disposeApp(app, registry);
});
- it('user text entity survives dropdown open/close cycle', () => {
+ it('user text entity survives dropdown open/close cycle', async () => {
const { app, registry } = createApp();
const { ddEntity, listEntity, userTextEntity } = buildDropdownWithUserText(app);
const world = app.world;
// Initialize
- app.tick(1 / 60);
+ await app.tick(1 / 60);
- // Simulate click to open dropdown
- world.insert(ddEntity, UIInteraction, {
- hovered: true, pressed: true,
- justPressed: true, justReleased: false,
- });
- app.tick(1 / 60);
+ // Simulate click to open dropdown via Input resource
+ const input = app.getResource(Input) as InputState;
+ input.mouseX = 400;
+ input.mouseY = 300;
+ input.mouseButtons.add(0);
+ input.mouseButtonsPressed.add(0);
+ await app.tick(1 / 60);
+ input.mouseButtonsPressed.clear();
// Verify dropdown is open and text entity still exists
const dd = world.get(ddEntity, Dropdown) as any;
@@ -276,12 +280,10 @@ describe.skipIf(!HAS_WASM)('Dropdown list child text visibility (WASM)', () => {
const openSprite = world.get(userTextEntity, Sprite) as SpriteData;
expect(openSprite.enabled).toBe(true);
- // Close dropdown
- world.insert(ddEntity, UIInteraction, {
- hovered: true, pressed: true,
- justPressed: true, justReleased: false,
- });
- app.tick(1 / 60);
+ // Close dropdown via another click
+ input.mouseButtonsPressed.add(0);
+ await app.tick(1 / 60);
+ input.mouseButtonsPressed.clear();
// After close, user text entity must still exist and be enabled
expect(world.valid(userTextEntity)).toBe(true);
diff --git a/sdk/tests/scene.test.ts b/sdk/tests/scene.test.ts
index 087b4ca96..e5632daa1 100644
--- a/sdk/tests/scene.test.ts
+++ b/sdk/tests/scene.test.ts
@@ -128,6 +128,8 @@ describe('Scene', () => {
// =========================================================================
describe('Component Entity Reference Fields Registry', () => {
+ registerComponentEntityFields('Slider', ['fillEntity', 'handleEntity']);
+
it('should return entity fields for registered types', () => {
const fields = getComponentEntityFields('Slider');
expect(fields).toEqual(['fillEntity', 'handleEntity']);
diff --git a/sdk/tests/scrollview.test.ts b/sdk/tests/scrollview.test.ts
index 645bbdd39..a2e765671 100644
--- a/sdk/tests/scrollview.test.ts
+++ b/sdk/tests/scrollview.test.ts
@@ -124,7 +124,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
return { root, scrollEntity, contentEntity };
}
- it('scrollY clamps between 0 and maxScrollY when elastic=false', () => {
+ it('scrollY clamps between 0 and maxScrollY when elastic=false', async () => {
const { app, registry } = createApp();
const { scrollEntity } = createScrollView(app, 600);
const world = app.world;
@@ -133,14 +133,14 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
sv0.elastic = false;
world.insert(scrollEntity, ScrollView, sv0);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const sv = world.get(scrollEntity, ScrollView) as ScrollViewData;
expect(sv.scrollY).toBe(0);
sv.scrollY = 500;
world.insert(scrollEntity, ScrollView, sv);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const svAfter = world.get(scrollEntity, ScrollView) as ScrollViewData;
expect(svAfter.scrollY).toBeLessThanOrEqual(400);
@@ -149,7 +149,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
disposeApp(app, registry);
});
- it('contentHeight=0 prevents scrolling when elastic=false', () => {
+ it('contentHeight=0 prevents scrolling when elastic=false', async () => {
const { app, registry } = createApp();
const { scrollEntity } = createScrollView(app, 0);
const world = app.world;
@@ -158,12 +158,12 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
sv0.elastic = false;
world.insert(scrollEntity, ScrollView, sv0);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const sv = world.get(scrollEntity, ScrollView) as ScrollViewData;
sv.scrollY = 100;
world.insert(scrollEntity, ScrollView, sv);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const svAfter = world.get(scrollEntity, ScrollView) as ScrollViewData;
expect(svAfter.scrollY).toBe(0);
@@ -171,17 +171,17 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
disposeApp(app, registry);
});
- it('content entity position updates with scrollY', () => {
+ it('content entity position updates with scrollY', async () => {
const { app, registry } = createApp();
const { scrollEntity, contentEntity } = createScrollView(app, 600);
const world = app.world;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const sv = world.get(scrollEntity, ScrollView) as ScrollViewData;
sv.scrollY = 200;
world.insert(scrollEntity, ScrollView, sv);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const contentTransform = world.get(contentEntity, Transform) as TransformData;
expect(contentTransform.position.y).toBe(200);
@@ -189,13 +189,13 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
disposeApp(app, registry);
});
- it('wheel scroll down (positive deltaY) should increase scrollY', () => {
+ it('wheel scroll down (positive deltaY) should increase scrollY', async () => {
const { app, registry } = createApp();
const { scrollEntity } = createScrollView(app, 600);
const world = app.world;
// Tick once to init layout
- app.tick(1 / 60);
+ await app.tick(1 / 60);
// Manually set UIInteraction.hovered and inject scroll delta
// to test scroll direction without full hit test
@@ -206,7 +206,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
// Simulate wheel scroll down: browser gives positive deltaY
inputState.scrollDeltaY = 120;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const sv = world.get(scrollEntity, ScrollView) as ScrollViewData;
// Scrolling down → scrollY should increase (content moves up, revealing below)
@@ -215,12 +215,12 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
disposeApp(app, registry);
});
- it('rubber-band limits over-scroll during wheel input', () => {
+ it('rubber-band limits over-scroll during wheel input', async () => {
const { app, registry } = createApp();
const { scrollEntity } = createScrollView(app, 600);
const world = app.world;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
world.insert(scrollEntity, Interactable, { enabled: true, blockRaycast: true, raycastTarget: true });
world.insert(scrollEntity, UIInteraction, { hovered: true, pressed: false, justPressed: false, justReleased: false });
@@ -230,7 +230,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
// Scroll far past top (negative) with many wheel events
for (let i = 0; i < 100; i++) {
inputState.scrollDeltaY = -120;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
}
const sv1 = world.get(scrollEntity, ScrollView) as ScrollViewData;
@@ -241,12 +241,12 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
disposeApp(app, registry);
});
- it('elastic bounces back during continuous small wheel deltas (momentum scroll)', () => {
+ it('elastic bounces back during continuous small wheel deltas (momentum scroll)', async () => {
const { app, registry } = createApp();
const { scrollEntity } = createScrollView(app, 600);
const world = app.world;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
world.insert(scrollEntity, Interactable, { enabled: true, blockRaycast: true, raycastTarget: true });
world.insert(scrollEntity, UIInteraction, { hovered: true, pressed: false, justPressed: false, justReleased: false });
@@ -255,7 +255,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
// Initial strong scroll past top
inputState.scrollDeltaY = -200;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const sv1 = world.get(scrollEntity, ScrollView) as ScrollViewData;
expect(sv1.scrollY).toBeLessThan(0);
@@ -263,7 +263,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
// Simulate OS momentum: decaying small scroll deltas (never exactly 0)
for (let i = 0; i < 60; i++) {
inputState.scrollDeltaY = -1;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
}
const svFinal = world.get(scrollEntity, ScrollView) as ScrollViewData;
@@ -273,19 +273,19 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
disposeApp(app, registry);
});
- it('elastic bounces back even while hover remains active (no more wheel events)', () => {
+ it('elastic bounces back even while hover remains active (no more wheel events)', async () => {
const { app, registry } = createApp();
const { scrollEntity } = createScrollView(app, 600);
const world = app.world;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
world.insert(scrollEntity, Interactable, { enabled: true, blockRaycast: true, raycastTarget: true });
world.insert(scrollEntity, UIInteraction, { hovered: true, pressed: false, justPressed: false, justReleased: false });
const inputState = app.getResource(Input);
inputState.scrollDeltaY = -120;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const sv1 = world.get(scrollEntity, ScrollView) as ScrollViewData;
expect(sv1.scrollY).toBeLessThan(0);
@@ -293,7 +293,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
// Stop scrolling but keep hovered=true (cursor still over ScrollView)
inputState.scrollDeltaY = 0;
for (let i = 0; i < 60; i++) {
- app.tick(1 / 60);
+ await app.tick(1 / 60);
}
const svFinal = world.get(scrollEntity, ScrollView) as ScrollViewData;
expect(Math.abs(svFinal.scrollY)).toBeLessThan(1);
@@ -301,12 +301,12 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
disposeApp(app, registry);
});
- it('elastic: over-scroll past top should NOT instantly clamp, then spring back', () => {
+ it('elastic: over-scroll past top should NOT instantly clamp, then spring back', async () => {
const { app, registry } = createApp();
const { scrollEntity } = createScrollView(app, 600);
const world = app.world;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
// Set scrollY to negative (over-scrolled past top)
const sv = world.get(scrollEntity, ScrollView) as ScrollViewData;
@@ -315,14 +315,14 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
// After one tick, elastic spring should NOT hard-clamp to 0
// It should be between -50 and 0 (partially pulled back)
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const sv1 = world.get(scrollEntity, ScrollView) as ScrollViewData;
expect(sv1.scrollY).toBeGreaterThan(-50);
expect(sv1.scrollY).toBeLessThan(0); // NOT instantly clamped to 0
// After many ticks, should converge close to 0
for (let i = 0; i < 120; i++) {
- app.tick(1 / 60);
+ await app.tick(1 / 60);
}
const svFinal = world.get(scrollEntity, ScrollView) as ScrollViewData;
expect(Math.abs(svFinal.scrollY)).toBeLessThan(1);
@@ -330,12 +330,12 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
disposeApp(app, registry);
});
- it('wheel scroll UP past top should bounce back to 0', () => {
+ it('wheel scroll UP past top should bounce back to 0', async () => {
const { app, registry } = createApp();
const { scrollEntity } = createScrollView(app, 600);
const world = app.world;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
world.insert(scrollEntity, Interactable, { enabled: true, blockRaycast: true, raycastTarget: true });
world.insert(scrollEntity, UIInteraction, { hovered: true, pressed: false, justPressed: false, justReleased: false });
@@ -343,7 +343,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
const inputState = app.getResource(Input);
inputState.scrollDeltaY = -120;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const sv1 = world.get(scrollEntity, ScrollView) as ScrollViewData;
expect(sv1.scrollY).toBeLessThan(0);
@@ -352,7 +352,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
for (let i = 0; i < 120; i++) {
world.insert(scrollEntity, UIInteraction, { hovered: false, pressed: false, justPressed: false, justReleased: false });
- app.tick(1 / 60);
+ await app.tick(1 / 60);
}
const svFinal = world.get(scrollEntity, ScrollView) as ScrollViewData;
expect(Math.abs(svFinal.scrollY)).toBeLessThan(1);
@@ -360,12 +360,12 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
disposeApp(app, registry);
});
- it('wheel scroll DOWN past bottom should bounce back to maxScrollY', () => {
+ it('wheel scroll DOWN past bottom should bounce back to maxScrollY', async () => {
const { app, registry } = createApp();
const { scrollEntity } = createScrollView(app, 600);
const world = app.world;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
world.insert(scrollEntity, Interactable, { enabled: true, blockRaycast: true, raycastTarget: true });
world.insert(scrollEntity, UIInteraction, { hovered: true, pressed: false, justPressed: false, justReleased: false });
@@ -373,7 +373,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
const inputState = app.getResource(Input);
for (let i = 0; i < 50; i++) {
inputState.scrollDeltaY = 120;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
}
const svMid = world.get(scrollEntity, ScrollView) as ScrollViewData;
@@ -382,7 +382,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
inputState.scrollDeltaY = 0;
for (let i = 0; i < 120; i++) {
world.insert(scrollEntity, UIInteraction, { hovered: false, pressed: false, justPressed: false, justReleased: false });
- app.tick(1 / 60);
+ await app.tick(1 / 60);
}
const svFinal = world.get(scrollEntity, ScrollView) as ScrollViewData;
expect(Math.abs(svFinal.scrollY - 400)).toBeLessThan(1);
@@ -390,25 +390,25 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
disposeApp(app, registry);
});
- it('elastic: over-scroll past bottom should NOT instantly clamp, then spring back', () => {
+ it('elastic: over-scroll past bottom should NOT instantly clamp, then spring back', async () => {
const { app, registry } = createApp();
const { scrollEntity } = createScrollView(app, 600);
const world = app.world;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
// maxScrollY = 600 - 200 = 400; set past max
const sv = world.get(scrollEntity, ScrollView) as ScrollViewData;
sv.scrollY = 450;
world.insert(scrollEntity, ScrollView, sv);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const sv1 = world.get(scrollEntity, ScrollView) as ScrollViewData;
expect(sv1.scrollY).toBeLessThan(450);
expect(sv1.scrollY).toBeGreaterThan(400); // NOT instantly clamped to 400
for (let i = 0; i < 120; i++) {
- app.tick(1 / 60);
+ await app.tick(1 / 60);
}
const svFinal = world.get(scrollEntity, ScrollView) as ScrollViewData;
expect(Math.abs(svFinal.scrollY - 400)).toBeLessThan(1);
@@ -416,7 +416,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
disposeApp(app, registry);
});
- it('scroll offset should add to UIRect base position, not replace it', () => {
+ it('scroll offset should add to UIRect base position, not replace it', async () => {
const { app, registry } = createApp();
const world = app.world;
@@ -460,7 +460,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
});
// Tick WITHOUT ScrollView to get the UIRect-computed base position
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const baseTransform = world.get(contentEntity, Transform) as TransformData;
const baseY = baseTransform.position.y;
const baseX = baseTransform.position.x;
@@ -478,7 +478,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
decelerationRate: 0.135,
});
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const afterScrollView = world.get(contentEntity, Transform) as TransformData;
// With scrollY=0, content should remain at its UIRect base position
expect(afterScrollView.position.y).toBeCloseTo(baseY, 0);
@@ -488,19 +488,19 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
const sv = world.get(scrollEntity, ScrollView) as ScrollViewData;
sv.scrollY = 100;
world.insert(scrollEntity, ScrollView, sv);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const scrolledTransform = world.get(contentEntity, Transform) as TransformData;
expect(scrolledTransform.position.y).toBeCloseTo(baseY + 100, 0);
disposeApp(app, registry);
});
- it('sustained large scroll deltas should not push content entirely out of viewport', () => {
+ it('sustained large scroll deltas should not push content entirely out of viewport', async () => {
const { app, registry } = createApp();
const { scrollEntity } = createScrollView(app, 600);
const world = app.world;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
world.insert(scrollEntity, Interactable, { enabled: true, blockRaycast: true, raycastTarget: true });
world.insert(scrollEntity, UIInteraction, { hovered: true, pressed: false, justPressed: false, justReleased: false });
@@ -511,7 +511,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
// maxScrollY = 600 - 200 = 400; viewH = 200
for (let i = 0; i < 10; i++) {
inputState.scrollDeltaY = 3000;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
}
const sv = world.get(scrollEntity, ScrollView) as ScrollViewData;
@@ -523,7 +523,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
disposeApp(app, registry);
});
- it('content position should not accumulate across frames (no UIRect on content)', () => {
+ it('content position should not accumulate across frames (no UIRect on content)', async () => {
const { app, registry } = createApp();
const world = app.world;
@@ -581,13 +581,13 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
world.insert(scrollEntity, ScrollView, sv0);
// Tick 3 times with constant scrollY — position should stay the same
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const pos1 = (world.get(contentEntity, Transform) as TransformData).position.y;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const pos2 = (world.get(contentEntity, Transform) as TransformData).position.y;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const pos3 = (world.get(contentEntity, Transform) as TransformData).position.y;
// All 3 frames should produce the same position (no accumulation)
@@ -597,7 +597,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
disposeApp(app, registry);
});
- it('auto contentHeight from children when contentHeight=0', () => {
+ it('auto contentHeight from children when contentHeight=0', async () => {
const { app, registry } = createApp();
const world = app.world;
@@ -636,7 +636,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
});
// Tick once so layout is established before adding children
- app.tick(1 / 60);
+ await app.tick(1 / 60);
// Add 5 child items WITHOUT UIRect (using Sprite for size), manually positioned
// Children of contentEntity: no UIRect means C++ layout won't override position
@@ -674,7 +674,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
const sv = world.get(scrollEntity, ScrollView) as ScrollViewData;
sv.scrollY = 9999;
world.insert(scrollEntity, ScrollView, sv);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const svAfter = world.get(scrollEntity, ScrollView) as ScrollViewData;
// Children span from y=50 (top of first) to y=-450 (bottom of last, pivot center)
@@ -685,12 +685,12 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
disposeApp(app, registry);
});
- it('drag should produce 1:1 movement between mouse delta and content displacement', () => {
+ it('drag should produce 1:1 movement between mouse delta and content displacement', async () => {
const { app, registry } = createApp();
const { scrollEntity, contentEntity } = createScrollView(app, 600);
const world = app.world;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const inputState = app.getResource(Input);
world.insert(scrollEntity, Interactable, { enabled: true, blockRaycast: true, raycastTarget: true });
@@ -706,7 +706,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
world.insert(scrollEntity, UIInteraction, {
hovered: true, pressed: true, justPressed: true, justReleased: false,
});
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const posAfterPress = (world.get(contentEntity, Transform) as TransformData).position.y;
console.log('=== Drag tracking ===');
@@ -719,7 +719,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
world.insert(scrollEntity, UIInteraction, {
hovered: true, pressed: true, justPressed: false, justReleased: false,
});
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const posAfterDrag50 = (world.get(contentEntity, Transform) as TransformData).position.y;
const svDrag50 = world.get(scrollEntity, ScrollView) as ScrollViewData;
@@ -733,7 +733,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
world.insert(scrollEntity, UIInteraction, {
hovered: true, pressed: true, justPressed: false, justReleased: false,
});
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const posAfterDrag80 = (world.get(contentEntity, Transform) as TransformData).position.y;
const svDrag80 = world.get(scrollEntity, ScrollView) as ScrollViewData;
@@ -745,7 +745,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
world.insert(scrollEntity, UIInteraction, {
hovered: true, pressed: true, justPressed: false, justReleased: false,
});
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const posAfterStop = (world.get(contentEntity, Transform) as TransformData).position.y;
console.log(`After stop: contentY=${posAfterStop}, drift=${posAfterStop - posAfterDrag80}`);
@@ -757,7 +757,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
world.insert(scrollEntity, UIInteraction, {
hovered: true, pressed: false, justPressed: false, justReleased: true,
});
- app.tick(1 / 60);
+ await app.tick(1 / 60);
// Frame 6-7: After release with velocity=0, content should stay
inputState.mouseButtonsReleased.clear();
@@ -765,7 +765,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
world.insert(scrollEntity, UIInteraction, {
hovered: false, pressed: false, justPressed: false, justReleased: false,
});
- app.tick(1 / 60);
+ await app.tick(1 / 60);
}
const posAfterRelease = (world.get(contentEntity, Transform) as TransformData).position.y;
@@ -775,12 +775,12 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
disposeApp(app, registry);
});
- it('inertia after fast swipe should not exceed a few viewports of travel', () => {
+ it('inertia after fast swipe should not exceed a few viewports of travel', async () => {
const { app, registry } = createApp();
const { scrollEntity } = createScrollView(app, 5000);
const world = app.world;
- app.tick(1 / 60);
+ await app.tick(1 / 60);
world.insert(scrollEntity, Interactable, { enabled: true, blockRaycast: true, raycastTarget: true });
@@ -793,7 +793,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
inputState.mouseButtons.add(0);
inputState.mouseButtonsPressed.add(0);
world.insert(scrollEntity, UIInteraction, { hovered: true, pressed: true, justPressed: true, justReleased: false });
- app.tick(1 / 60);
+ await app.tick(1 / 60);
// Frames 2-6: fast upward drag, worldMouseY increases by 100/frame
// worldMouseY = i*100 → mouseY = 300 - i*100
@@ -801,14 +801,14 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
for (let i = 1; i <= 5; i++) {
inputState.mouseY = 300 - i * 100;
world.insert(scrollEntity, UIInteraction, { hovered: true, pressed: true, justPressed: false, justReleased: false });
- app.tick(1 / 60);
+ await app.tick(1 / 60);
}
// Release
inputState.mouseButtons.delete(0);
inputState.mouseButtonsReleased.add(0);
world.insert(scrollEntity, UIInteraction, { hovered: true, pressed: false, justPressed: false, justReleased: true });
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const svAtRelease = world.get(scrollEntity, ScrollView) as ScrollViewData;
const scrollAtRelease = svAtRelease.scrollY;
@@ -817,7 +817,7 @@ describe.skipIf(!HAS_WASM)('ScrollView (WASM)', () => {
inputState.mouseButtonsReleased.clear();
for (let i = 0; i < 120; i++) {
world.insert(scrollEntity, UIInteraction, { hovered: false, pressed: false, justPressed: false, justReleased: false });
- app.tick(1 / 60);
+ await app.tick(1 / 60);
}
const svAfter = world.get(scrollEntity, ScrollView) as ScrollViewData;
diff --git a/sdk/tests/slider-layout.test.ts b/sdk/tests/slider-layout.test.ts
index 1c0f9607c..60e66089e 100644
--- a/sdk/tests/slider-layout.test.ts
+++ b/sdk/tests/slider-layout.test.ts
@@ -4,7 +4,7 @@
* Simulates how the editor renders a Slider:
* 1. Create root Canvas → Slider background → Fill + Handle as children
* 2. Call applyDirectionalFill / computeHandleAnchors to set anchors
- * 3. Run app.tick() to compute layout
+ * 3. Run await app.tick() to compute layout
* 4. Verify computed width/height and world positions
*
* Requires pre-built WASM at desktop/public/wasm/esengine.wasm.
@@ -217,14 +217,14 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
});
describe('fill layout after applyDirectionalFill + tick', () => {
- it('should compute fill width = 50% of slider background', () => {
+ it('should compute fill width = 50% of slider background', async () => {
const { app, registry } = createEditorApp();
const { root, sliderBg, fill, handle } = createSliderHierarchy(app);
applyDirectionalFill(app.world, fill, FillDirection.LeftToRight, 0.5);
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const bgW = module.getUIRectComputedWidth(registry, sliderBg);
const bgH = module.getUIRectComputedHeight(registry, sliderBg);
@@ -239,14 +239,14 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should compute fill width = 0 at value 0', () => {
+ it('should compute fill width = 0 at value 0', async () => {
const { app, registry } = createEditorApp();
const { fill } = createSliderHierarchy(app);
applyDirectionalFill(app.world, fill, FillDirection.LeftToRight, 0);
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const fillW = module.getUIRectComputedWidth(registry, fill);
expect(fillW).toBeCloseTo(0, 0);
@@ -254,14 +254,14 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should compute fill width = 100% at value 1', () => {
+ it('should compute fill width = 100% at value 1', async () => {
const { app, registry } = createEditorApp();
const { sliderBg, fill } = createSliderHierarchy(app);
applyDirectionalFill(app.world, fill, FillDirection.LeftToRight, 1);
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const bgW = module.getUIRectComputedWidth(registry, sliderBg);
const fillW = module.getUIRectComputedWidth(registry, fill);
@@ -270,14 +270,14 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should compute fill width = 25% at value 0.25', () => {
+ it('should compute fill width = 25% at value 0.25', async () => {
const { app, registry } = createEditorApp();
const { fill } = createSliderHierarchy(app);
applyDirectionalFill(app.world, fill, FillDirection.LeftToRight, 0.25);
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const fillW = module.getUIRectComputedWidth(registry, fill);
expect(fillW).toBeCloseTo(50, 0);
@@ -285,15 +285,15 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should position fill at left side, not centered (LeftToRight 50%)', () => {
+ it('should position fill at left side, not centered (LeftToRight 50%)', async () => {
const { app, registry } = createEditorApp();
const { sliderBg, fill } = createSliderHierarchy(app);
applyDirectionalFill(app.world, fill, FillDirection.LeftToRight, 0.5);
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
+ await app.tick(1 / 60);
const fillTransform = registry.getTransform(fill);
const bgTransform = registry.getTransform(sliderBg);
@@ -315,7 +315,7 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
});
describe('DEBUG: full pipeline sprite bounds', () => {
- it('should verify sprite left/right edges for LeftToRight fill', () => {
+ it('should verify sprite left/right edges for LeftToRight fill', async () => {
const { app, registry } = createEditorApp();
const { root, sliderBg, fill } = createSliderHierarchy(app);
@@ -324,7 +324,7 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
const values = [0, 0.25, 0.5, 0.75, 1.0];
for (const value of values) {
applyDirectionalFill(app.world, fill, FillDirection.LeftToRight, value);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const fillT = registry.getTransform(fill);
const bgT = registry.getTransform(sliderBg);
@@ -405,7 +405,7 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should test with SliderPlugin running (full runtime simulation)', () => {
+ it('should test with SliderPlugin running (full runtime simulation)', async () => {
const app = App.new();
const registry = new module.Registry() as unknown as CppRegistry;
app.connectCpp(registry, module);
@@ -480,8 +480,8 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
// Set camera and tick
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
+ await app.tick(1 / 60);
const fillT = registry.getTransform(fill);
const bgT = registry.getTransform(sliderBg);
@@ -509,7 +509,7 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should verify worldPosition via TransformSystem', () => {
+ it('should verify worldPosition via TransformSystem', async () => {
const app = App.new();
const registry = new module.Registry() as unknown as CppRegistry;
app.connectCpp(registry, module);
@@ -580,8 +580,8 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
});
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
+ await app.tick(1 / 60);
// Now run TransformSystem to compute worldPosition
module.transform_update(registry);
@@ -617,7 +617,7 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
});
describe('handle layout after anchor update + tick', () => {
- it('should position handle sprite at 50%', () => {
+ it('should position handle sprite at 50%', async () => {
const { app, registry } = createEditorApp();
const { sliderBg, handle } = createSliderHierarchy(app);
@@ -632,7 +632,7 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
});
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const handleW = module.getUIRectComputedWidth(registry, handle);
const handleH = module.getUIRectComputedHeight(registry, handle);
@@ -644,12 +644,12 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
});
describe('render order in slider hierarchy', () => {
- it('should order: background < fill < handle', () => {
+ it('should order: background < fill < handle', async () => {
const { app, registry } = createEditorApp();
const { sliderBg, fill, handle } = createSliderHierarchy(app);
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const bgLayer = registry.getSprite(sliderBg).layer;
const fillLayer = registry.getSprite(fill).layer;
@@ -663,22 +663,22 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
});
describe('dynamic fill changes across ticks', () => {
- it('should update fill width when value changes', () => {
+ it('should update fill width when value changes', async () => {
const { app, registry } = createEditorApp();
const { fill } = createSliderHierarchy(app);
setCanvasRect(app, -400, -300, 400, 300);
applyDirectionalFill(app.world, fill, FillDirection.LeftToRight, 0.3);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
expect(module.getUIRectComputedWidth(registry, fill)).toBeCloseTo(60, 0);
applyDirectionalFill(app.world, fill, FillDirection.LeftToRight, 0.7);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
expect(module.getUIRectComputedWidth(registry, fill)).toBeCloseTo(140, 0);
applyDirectionalFill(app.world, fill, FillDirection.LeftToRight, 0);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
expect(module.getUIRectComputedWidth(registry, fill)).toBeCloseTo(0, 0);
disposeApp(app, registry);
@@ -686,7 +686,7 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
});
describe('two sliders side by side', () => {
- it('should compute independent layouts for two sliders', () => {
+ it('should compute independent layouts for two sliders', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -750,7 +750,7 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
world.insert(fill2, Sprite, makeSprite(240, 20));
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
// Slider 1: bg = 200w, fill = 30% = 60w
expect(module.getUIRectComputedWidth(registry, slider1Bg)).toBeCloseTo(200, 0);
@@ -777,14 +777,14 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
});
describe('fill sprite size sync via layout system', () => {
- it('should update fill Sprite.size to match computed UIRect size', () => {
+ it('should update fill Sprite.size to match computed UIRect size', async () => {
const { app, registry } = createEditorApp();
const { fill } = createSliderHierarchy(app);
applyDirectionalFill(app.world, fill, FillDirection.LeftToRight, 0.5);
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const sprite = registry.getSprite(fill);
const computedW = module.getUIRectComputedWidth(registry, fill);
@@ -797,7 +797,7 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
});
describe('editor-like slider creation flow', () => {
- it('should reproduce exact editor slider hierarchy and verify fill visibility', () => {
+ it('should reproduce exact editor slider hierarchy and verify fill visibility', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -864,7 +864,7 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
// Step 2: render() calls tick() which runs C++ layout
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
// Verify slider bg got correct size (fixed-size centered)
const sliderW = module.getUIRectComputedWidth(registry, slider);
@@ -899,7 +899,7 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should handle two sliders at different positions', () => {
+ it('should handle two sliders at different positions', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -963,7 +963,7 @@ describe.skipIf(!HAS_WASM)('Slider Layout (WASM integration)', () => {
applyDirectionalFill(world, slider2.fill, FillDirection.LeftToRight, 0.7);
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
// Slider 1: fill = 30% of 200 = 60
const fill1W = module.getUIRectComputedWidth(registry, slider1.fill);
diff --git a/sdk/tests/slider-system.test.ts b/sdk/tests/slider-system.test.ts
index 3578d84a2..e33a3e2a2 100644
--- a/sdk/tests/slider-system.test.ts
+++ b/sdk/tests/slider-system.test.ts
@@ -79,7 +79,7 @@ describe.skipIf(!HAS_WASM)('SliderPlugin system integration', () => {
};
}
- it('SliderPlugin should produce left-aligned fill (value=0.5)', () => {
+ it('SliderPlugin should produce left-aligned fill (value=0.5)', async () => {
const { app, registry } = createFullApp();
const world = app.world;
@@ -133,7 +133,7 @@ describe.skipIf(!HAS_WASM)('SliderPlugin system integration', () => {
});
for (let i = 0; i < 3; i++) {
- app.tick(1 / 60);
+ await app.tick(1 / 60);
}
// Run TransformSystem to compute worldPositions (normally done by renderer)
@@ -180,7 +180,7 @@ describe.skipIf(!HAS_WASM)('SliderPlugin system integration', () => {
(registry as any).delete();
});
- it('full pipeline: UILayout → SliderPlugin → UILayoutLate → TransformSystem', () => {
+ it('full pipeline: UILayout → SliderPlugin → UILayoutLate → TransformSystem', async () => {
const { app, registry } = createFullApp();
const world = app.world;
@@ -235,7 +235,7 @@ describe.skipIf(!HAS_WASM)('SliderPlugin system integration', () => {
wholeNumbers: false,
});
- app.tick(1 / 60);
+ await app.tick(1 / 60);
module.transform_update(registry);
const fillT = world.get(fill, Transform) as TransformData;
diff --git a/sdk/tests/stats.test.ts b/sdk/tests/stats.test.ts
index 133558169..9698bbd82 100644
--- a/sdk/tests/stats.test.ts
+++ b/sdk/tests/stats.test.ts
@@ -178,14 +178,14 @@ describe('App stats API', () => {
expect(app.getSystemTimings()).toBeNull();
});
- it('should return timings map after enableStats + tick', () => {
+ it('should return timings map after enableStats + tick', async () => {
const app = App.new();
app.enableStats();
- app.tick(1 / 60);
+ await app.tick(1 / 60);
expect(app.getSystemTimings()).toBeInstanceOf(Map);
});
- it('should record named system timings after enableStats', () => {
+ it('should record named system timings after enableStats', async () => {
const app = App.new();
app.enableStats();
@@ -193,7 +193,7 @@ describe('App stats API', () => {
[], () => {}, { name: 'MySystem' }
));
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const timings = app.getSystemTimings()!;
expect(timings.has('MySystem')).toBe(true);
@@ -226,16 +226,16 @@ describe('App stats API', () => {
// === Review fix: Medium #4 — enableStats after first tick ===
- it('should work when enableStats is called after first tick', () => {
+ it('should work when enableStats is called after first tick', async () => {
const app = App.new();
app.addSystemToSchedule(Schedule.Update, defineSystem(
[], () => {}, { name: 'LateSystem' }
));
- app.tick(1 / 60);
+ await app.tick(1 / 60);
expect(app.getSystemTimings()).toBeNull();
app.enableStats();
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const timings = app.getSystemTimings();
expect(timings).toBeInstanceOf(Map);
@@ -356,10 +356,10 @@ describe('StatsPlugin', () => {
expect(app.hasResource(Stats)).toBe(true);
});
- it('should enable system timings on the app', () => {
+ it('should enable system timings on the app', async () => {
const app = App.new();
app.addPlugin(new StatsPlugin());
- app.tick(1 / 60);
+await app.tick(1 / 60);
expect(app.getSystemTimings()).not.toBeNull();
});
@@ -369,95 +369,95 @@ describe('StatsPlugin', () => {
// === Review fix: Critical #3 — singleton reuse ===
- it('should reset state when build is called on a new app', () => {
+ it('should reset state when build is called on a new app', async () => {
const plugin = new StatsPlugin({ overlay: false });
const app1 = App.new();
app1.addPlugin(plugin);
- for (let i = 0; i < 30; i++) app1.tick(1 / 30);
+ for (let i = 0; i < 30; i++) await app1.tick(1 / 30);
expect(app1.getResource(Stats).fps).toBeCloseTo(30, 0);
plugin.cleanup();
const app2 = App.new();
app2.addPlugin(plugin);
- for (let i = 0; i < 10; i++) app2.tick(1 / 60);
+ for (let i = 0; i < 10; i++) await app2.tick(1 / 60);
const fps = app2.getResource(Stats).fps;
expect(fps).toBeCloseTo(60, 0);
});
describe('fps & frameTimeMs', () => {
- it('should compute fps from delta', () => {
+ it('should compute fps from delta', async () => {
const app = App.new();
app.addPlugin(new StatsPlugin());
- for (let i = 0; i < 10; i++) app.tick(1 / 60);
+ for (let i = 0; i < 10; i++) await app.tick(1 / 60);
const stats = app.getResource(Stats);
expect(stats.fps).toBeCloseTo(60, 0);
});
- it('should compute frameTimeMs from delta', () => {
+ it('should compute frameTimeMs from delta', async () => {
const app = App.new();
app.addPlugin(new StatsPlugin());
- for (let i = 0; i < 5; i++) app.tick(1 / 60);
+ for (let i = 0; i < 5; i++) await app.tick(1 / 60);
const stats = app.getResource(Stats);
expect(stats.frameTimeMs).toBeCloseTo(16.67, 0);
});
- it('should track changing frame rate', () => {
+ it('should track changing frame rate', async () => {
const app = App.new();
app.addPlugin(new StatsPlugin());
- for (let i = 0; i < 60; i++) app.tick(1 / 30);
+ for (let i = 0; i < 60; i++) await app.tick(1 / 30);
expect(app.getResource(Stats).fps).toBeCloseTo(30, 0);
- for (let i = 0; i < 60; i++) app.tick(1 / 120);
+ for (let i = 0; i < 60; i++) await app.tick(1 / 120);
expect(app.getResource(Stats).fps).toBeCloseTo(120, 0);
});
});
describe('entityCount', () => {
- it('should reflect current entity count', () => {
+ it('should reflect current entity count', async () => {
const app = App.new();
app.addPlugin(new StatsPlugin());
app.world.spawn();
app.world.spawn();
app.world.spawn();
- app.tick(1 / 60);
+await app.tick(1 / 60);
expect(app.getResource(Stats).entityCount).toBe(3);
});
- it('should update after spawn/despawn between ticks', () => {
+ it('should update after spawn/despawn between ticks', async () => {
const app = App.new();
app.addPlugin(new StatsPlugin());
const e1 = app.world.spawn();
app.world.spawn();
- app.tick(1 / 60);
+await app.tick(1 / 60);
expect(app.getResource(Stats).entityCount).toBe(2);
app.world.despawn(e1);
- app.tick(1 / 60);
+await app.tick(1 / 60);
expect(app.getResource(Stats).entityCount).toBe(1);
app.world.spawn();
app.world.spawn();
- app.tick(1 / 60);
+await app.tick(1 / 60);
expect(app.getResource(Stats).entityCount).toBe(3);
});
- it('should be 0 with no entities', () => {
+ it('should be 0 with no entities', async () => {
const app = App.new();
app.addPlugin(new StatsPlugin());
- app.tick(1 / 60);
+await app.tick(1 / 60);
expect(app.getResource(Stats).entityCount).toBe(0);
});
});
describe('systemTimings', () => {
- it('should contain named user systems', () => {
+ it('should contain named user systems', async () => {
const app = App.new();
app.addPlugin(new StatsPlugin());
@@ -468,17 +468,17 @@ describe('StatsPlugin', () => {
[], () => {}, { name: 'AnimationSystem' }
));
- app.tick(1 / 60);
+await app.tick(1 / 60);
const timings = app.getResource(Stats).systemTimings;
expect(timings.has('PhysicsSystem')).toBe(true);
expect(timings.has('AnimationSystem')).toBe(true);
});
- it('should not include StatsCollect own timing on first tick', () => {
+ it('should not include StatsCollect own timing on first tick', async () => {
const app = App.new();
app.addPlugin(new StatsPlugin());
- app.tick(1 / 60);
+await app.tick(1 / 60);
const timings = app.getResource(Stats).systemTimings;
expect(timings.has('StatsCollect')).toBe(false);
@@ -486,18 +486,18 @@ describe('StatsPlugin', () => {
// === Review fix: Medium #8 — second tick leaks previous StatsCollect timing ===
- it('should not include StatsCollect timing on subsequent ticks either', () => {
+ it('should not include StatsCollect timing on subsequent ticks either', async () => {
const app = App.new();
app.addPlugin(new StatsPlugin());
- app.tick(1 / 60);
- app.tick(1 / 60);
- app.tick(1 / 60);
+await app.tick(1 / 60);
+await app.tick(1 / 60);
+await app.tick(1 / 60);
const timings = app.getResource(Stats).systemTimings;
expect(timings.has('StatsCollect')).toBe(false);
});
- it('should record numeric timing values', () => {
+ it('should record numeric timing values', async () => {
const app = App.new();
app.addPlugin(new StatsPlugin());
@@ -506,21 +506,21 @@ describe('StatsPlugin', () => {
{ name: 'WorkSystem' }
));
- app.tick(1 / 60);
+await app.tick(1 / 60);
const ms = app.getResource(Stats).systemTimings.get('WorkSystem');
expect(typeof ms).toBe('number');
expect(ms).toBeGreaterThanOrEqual(0);
});
- it('should be a fresh Map copy (not shared reference)', () => {
+ it('should be a fresh Map copy (not shared reference)', async () => {
const app = App.new();
app.addPlugin(new StatsPlugin());
- app.tick(1 / 60);
+await app.tick(1 / 60);
const stats = app.getResource(Stats);
const ref1 = stats.systemTimings;
- app.tick(1 / 60);
+await app.tick(1 / 60);
const ref2 = stats.systemTimings;
expect(ref1).not.toBe(ref2);
@@ -528,7 +528,7 @@ describe('StatsPlugin', () => {
});
describe('render stats from Renderer.getStats()', () => {
- it('should copy all render stats fields', () => {
+ it('should copy all render stats fields', async () => {
const mockStats: rendererModule.RenderStats = {
drawCalls: 42, triangles: 8400, sprites: 100,
text: 12, spine: 3, meshes: 5, culled: 7,
@@ -537,7 +537,7 @@ describe('StatsPlugin', () => {
const app = App.new();
app.addPlugin(new StatsPlugin());
- app.tick(1 / 60);
+await app.tick(1 / 60);
const stats = app.getResource(Stats);
expect(stats.drawCalls).toBe(42);
@@ -549,7 +549,7 @@ describe('StatsPlugin', () => {
expect(stats.culled).toBe(7);
});
- it('should update render stats each tick', () => {
+ it('should update render stats each tick', async () => {
const tick1: rendererModule.RenderStats = {
drawCalls: 10, triangles: 2000, sprites: 50,
text: 5, spine: 1, meshes: 2, culled: 3,
@@ -564,14 +564,14 @@ describe('StatsPlugin', () => {
const app = App.new();
app.addPlugin(new StatsPlugin());
- app.tick(1 / 60);
+await app.tick(1 / 60);
let stats = app.getResource(Stats);
expect(stats.drawCalls).toBe(10);
expect(stats.sprites).toBe(50);
spy.mockReturnValue(tick2);
- app.tick(1 / 60);
+await app.tick(1 / 60);
stats = app.getResource(Stats);
expect(stats.drawCalls).toBe(20);
@@ -583,10 +583,10 @@ describe('StatsPlugin', () => {
expect(stats.culled).toBe(6);
});
- it('should default to zeros when no WASM module', () => {
+ it('should default to zeros when no WASM module', async () => {
const app = App.new();
app.addPlugin(new StatsPlugin());
- app.tick(1 / 60);
+await app.tick(1 / 60);
const stats = app.getResource(Stats);
expect(stats.drawCalls).toBe(0);
@@ -600,39 +600,39 @@ describe('StatsPlugin', () => {
});
describe('StatsPluginOptions', () => {
- it('should accept overlay: false without creating DOM', () => {
+ it('should accept overlay: false without creating DOM', async () => {
const plugin = new StatsPlugin({ overlay: false });
const app = App.new();
app.addPlugin(plugin);
- app.tick(1 / 60);
+await app.tick(1 / 60);
const stats = app.getResource(Stats);
expect(stats.fps).toBeGreaterThan(0);
});
- it('should accept custom position', () => {
+ it('should accept custom position', async () => {
const plugin = new StatsPlugin({ overlay: false, position: 'top-right' });
const app = App.new();
app.addPlugin(plugin);
- app.tick(1 / 60);
+await app.tick(1 / 60);
expect(app.hasResource(Stats)).toBe(true);
});
});
describe('cleanup', () => {
- it('should be callable without error', () => {
+ it('should be callable without error', async () => {
const plugin = new StatsPlugin({ overlay: false });
const app = App.new();
app.addPlugin(plugin);
- app.tick(1 / 60);
+await app.tick(1 / 60);
expect(() => plugin.cleanup()).not.toThrow();
});
- it('should be safe to call cleanup multiple times', () => {
+ it('should be safe to call cleanup multiple times', async () => {
const plugin = new StatsPlugin({ overlay: false });
const app = App.new();
app.addPlugin(plugin);
- app.tick(1 / 60);
+await app.tick(1 / 60);
plugin.cleanup();
expect(() => plugin.cleanup()).not.toThrow();
});
@@ -1114,21 +1114,21 @@ describe('App phase timings', () => {
expect(app.getPhaseTimings()).toBeNull();
});
- it('should return a Map after enableStats + tick', () => {
+ it('should return a Map after enableStats + tick', async () => {
const app = App.new();
app.enableStats();
- app.tick(1 / 60);
+await app.tick(1 / 60);
const pt = app.getPhaseTimings();
expect(pt).toBeInstanceOf(Map);
});
- it('should contain schedule phase names after tick', () => {
+ it('should contain schedule phase names after tick', async () => {
const app = App.new();
app.enableStats();
app.addSystemToSchedule(Schedule.Update, defineSystem(
[], () => {}, { name: 'Dummy' }
));
- app.tick(1 / 60);
+await app.tick(1 / 60);
const pt = app.getPhaseTimings()!;
expect(pt.has('First')).toBe(true);
expect(pt.has('PreUpdate')).toBe(true);
@@ -1137,10 +1137,10 @@ describe('App phase timings', () => {
expect(pt.has('Last')).toBe(true);
});
- it('should have numeric values for each phase', () => {
+ it('should have numeric values for each phase', async () => {
const app = App.new();
app.enableStats();
- app.tick(1 / 60);
+await app.tick(1 / 60);
const pt = app.getPhaseTimings()!;
for (const [, v] of pt) {
expect(typeof v).toBe('number');
@@ -1148,13 +1148,13 @@ describe('App phase timings', () => {
}
});
- it('should work when enableStats called after first tick', () => {
+ it('should work when enableStats called after first tick', async () => {
const app = App.new();
- app.tick(1 / 60);
+await app.tick(1 / 60);
expect(app.getPhaseTimings()).toBeNull();
app.enableStats();
- app.tick(1 / 60);
+await app.tick(1 / 60);
expect(app.getPhaseTimings()).toBeInstanceOf(Map);
});
});
@@ -1170,13 +1170,13 @@ describe('FrameStats phaseTimings', () => {
expect(stats.phaseTimings.size).toBe(0);
});
- it('should be populated by StatsPlugin', () => {
+ it('should be populated by StatsPlugin', async () => {
const app = App.new();
app.addPlugin(new StatsPlugin({ overlay: false }));
app.addSystemToSchedule(Schedule.Update, defineSystem(
[], () => {}, { name: 'TestSys' }
));
- app.tick(1 / 60);
+await app.tick(1 / 60);
const stats = app.getResource(Stats);
expect(stats.phaseTimings).toBeInstanceOf(Map);
expect(stats.phaseTimings.size).toBeGreaterThan(0);
diff --git a/sdk/tests/timeline-wasm-integration.test.ts b/sdk/tests/timeline-wasm-integration.test.ts
index 0006d2263..ccecb83c8 100644
--- a/sdk/tests/timeline-wasm-integration.test.ts
+++ b/sdk/tests/timeline-wasm-integration.test.ts
@@ -18,167 +18,11 @@ import {
type TimelineAsset,
type PropertyTrack,
} from '../src/timeline/TimelineTypes';
-import { TimelineInstance, advanceTimeline } from '../src/timeline/TimelineSystem';
-import { setNestedProperty } from '../src/timeline/propertyUtils';
+import { setNestedProperty } from '../src/timeline/TimelinePlugin';
const WASM_PATH = resolve(__dirname, '../../desktop/public/wasm/esengine.wasm');
const HAS_WASM = existsSync(WASM_PATH);
-function createPositionAsset(duration: number): TimelineAsset {
- return {
- version: '1.0',
- type: 'timeline',
- duration,
- wrapMode: WrapMode.Loop,
- tracks: [
- {
- type: TrackType.Property,
- name: 'MoveX',
- childPath: '',
- component: 'Transform',
- channels: [
- {
- property: 'position.x',
- keyframes: [
- { time: 0, value: 0, inTangent: 0, outTangent: 0 },
- { time: duration, value: 100, inTangent: 0, outTangent: 0 },
- ],
- },
- {
- property: 'position.y',
- keyframes: [
- { time: 0, value: 0, inTangent: 0, outTangent: 0 },
- { time: duration, value: 200, inTangent: 0, outTangent: 0 },
- ],
- },
- ],
- } as PropertyTrack,
- ],
- };
-}
-
-function createChildPositionAsset(duration: number): TimelineAsset {
- return {
- version: '1.0',
- type: 'timeline',
- duration,
- wrapMode: WrapMode.Once,
- tracks: [
- {
- type: TrackType.Property,
- name: 'MoveChild',
- childPath: 'Title',
- component: 'Transform',
- channels: [
- {
- property: 'position.x',
- keyframes: [
- { time: 0, value: 10, inTangent: 0, outTangent: 0 },
- { time: duration, value: 300, inTangent: 0, outTangent: 0 },
- ],
- },
- ],
- } as PropertyTrack,
- ],
- };
-}
-
-function redirectPositionToUIRect(world: World, entity: number, posValues: Map<string, number>): void {
- const currentTransform = world.get(entity, Transform);
- const currentPos = currentTransform.position;
- const rect = world.get(entity, UIRect) as UIRectData;
-
- const dx = (posValues.has('position.x') ? posValues.get('position.x')! : currentPos.x) - currentPos.x;
- const dy = (posValues.has('position.y') ? posValues.get('position.y')! : currentPos.y) - currentPos.y;
-
- if (dx === 0 && dy === 0) return;
-
- world.set(entity, UIRect, {
- ...rect,
- offsetMin: { x: rect.offsetMin.x + dx, y: rect.offsetMin.y + dy },
- offsetMax: { x: rect.offsetMax.x + dx, y: rect.offsetMax.y + dy },
- });
-}
-
-function applyPropertyTrackResults(world: World, rootEntity: number, instance: TimelineInstance): void {
- const results = instance.evaluatePropertyTracks();
- for (const result of results) {
- const targetEntity = resolveChildEntity(world, rootEntity, result.childPath);
- if (targetEntity == null) continue;
-
- const componentDef = getComponent(result.component);
- if (!componentDef) continue;
- if (!world.has(targetEntity, componentDef)) continue;
-
- if (result.component === 'Transform' && world.has(targetEntity, UIRect)) {
- const posValues = new Map<string, number>();
- const nonPosValues = new Map<string, number>();
- for (const [propPath, value] of result.values) {
- if (propPath.startsWith('position.')) {
- posValues.set(propPath, value);
- } else {
- nonPosValues.set(propPath, value);
- }
- }
-
- if (posValues.size > 0) {
- redirectPositionToUIRect(world, targetEntity, posValues);
- }
-
- if (nonPosValues.size > 0) {
- const data = world.get(targetEntity, componentDef);
- let modified = false;
- for (const [propPath, value] of nonPosValues) {
- if (setNestedProperty(data as Record<string, any>, propPath, value)) {
- modified = true;
- }
- }
- if (modified) {
- world.set(targetEntity, componentDef, data);
- }
- }
- continue;
- }
-
- const data = world.get(targetEntity, componentDef);
- let modified = false;
- for (const [propPath, value] of result.values) {
- if (setNestedProperty(data as Record<string, any>, propPath, value)) {
- modified = true;
- }
- }
-
- if (modified) {
- world.set(targetEntity, componentDef, data);
- }
- }
-}
-
-function resolveChildEntity(world: World, rootEntity: number, childPath: string): number | null {
- if (!childPath) return rootEntity;
-
- const parts = childPath.split('/');
- let current = rootEntity;
- for (const part of parts) {
- const childrenData = world.tryGet(current, Children);
- const childEntities = childrenData?.entities
- ? Array.from(childrenData.entities as Iterable<any>)
- : [];
- if (childEntities.length === 0) return null;
- let found = false;
- for (const child of childEntities) {
- const nameData = world.tryGet(child, Name);
- if (nameData?.value === part) {
- current = child;
- found = true;
- break;
- }
- }
- if (!found) return null;
- }
- return current;
-}
-
describe.skipIf(!HAS_WASM)('Timeline WASM Integration', () => {
let module: ESEngineModule;
@@ -260,166 +104,4 @@ describe.skipIf(!HAS_WASM)('Timeline WASM Integration', () => {
expect(def!._name).toBe('Transform');
});
});
-
- describe('timeline applies position to root entity', () => {
- it('should move entity via timeline property track', () => {
- const { world, registry } = createWorld();
- const entity = world.spawn();
- world.insert(entity, Transform);
-
- const asset = createPositionAsset(2.0);
- const instance = new TimelineInstance(asset);
- instance.play();
-
- advanceTimeline(instance, 1.0);
- applyPropertyTrackResults(world, entity, instance);
-
- const t = world.get(entity, Transform);
- expect(t.position.x).toBeCloseTo(50, 0);
- expect(t.position.y).toBeCloseTo(100, 0);
-
- disposeWorld(world, registry);
- });
-
- it('should animate over multiple frames', () => {
- const { world, registry } = createWorld();
- const entity = world.spawn();
- world.insert(entity, Transform);
-
- const asset = createPositionAsset(1.0);
- const instance = new TimelineInstance(asset);
- instance.play();
-
- const positions: number[] = [];
- for (let i = 0; i < 10; i++) {
- advanceTimeline(instance, 0.1);
- applyPropertyTrackResults(world, entity, instance);
- const t = world.get(entity, Transform);
- positions.push(t.position.x);
- }
-
- for (let i = 1; i < positions.length; i++) {
- expect(positions[i]).toBeGreaterThanOrEqual(positions[i - 1]);
- }
- expect(positions[positions.length - 1]).toBeCloseTo(100, 0);
-
- disposeWorld(world, registry);
- });
- });
-
- describe('UIRect entities redirect position to offsets', () => {
- it('should modify UIRect offsets instead of Transform.position for UIRect entities', () => {
- const { world, registry } = createWorld();
- const entity = world.spawn();
- world.insert(entity, Transform);
- world.insert(entity, UIRect, {
- anchorMin: { x: 0.5, y: 0.5 },
- anchorMax: { x: 0.5, y: 0.5 },
- offsetMin: { x: 0, y: 0 },
- offsetMax: { x: 0, y: 0 },
- size: { x: 100, y: 100 },
- pivot: { x: 0.5, y: 0.5 },
- });
-
- const initialRect = world.get(entity, UIRect) as UIRectData;
- expect(initialRect.offsetMin.x).toBe(0);
-
- const asset = createPositionAsset(1.0);
- const instance = new TimelineInstance(asset);
- instance.play();
-
- advanceTimeline(instance, 0.5);
- applyPropertyTrackResults(world, entity, instance);
-
- const rect = world.get(entity, UIRect) as UIRectData;
- expect(rect.offsetMin.x).toBeCloseTo(50, 0);
- expect(rect.offsetMin.y).toBeCloseTo(100, 0);
- expect(rect.offsetMax.x).toBeCloseTo(50, 0);
- expect(rect.offsetMax.y).toBeCloseTo(100, 0);
-
- disposeWorld(world, registry);
- });
-
- it('should apply non-position properties directly for UIRect entities', () => {
- const { world, registry } = createWorld();
- const entity = world.spawn();
- world.insert(entity, Transform);
- world.insert(entity, UIRect);
-
- const asset: TimelineAsset = {
- version: '1.0',
- type: 'timeline',
- duration: 1,
- wrapMode: WrapMode.Once,
- tracks: [{
- type: TrackType.Property,
- name: 'ScaleX',
- childPath: '',
- component: 'Transform',
- channels: [{
- property: 'scale.x',
- keyframes: [
- { time: 0, value: 1, inTangent: 0, outTangent: 0 },
- { time: 1, value: 2, inTangent: 0, outTangent: 0 },
- ],
- }],
- } as PropertyTrack],
- };
- const instance = new TimelineInstance(asset);
- instance.play();
-
- advanceTimeline(instance, 0.5);
- applyPropertyTrackResults(world, entity, instance);
-
- const t = world.get(entity, Transform);
- expect(t.scale.x).toBeCloseTo(1.5, 1);
-
- disposeWorld(world, registry);
- });
-
- it('should not modify UIRect for entities without UIRect', () => {
- const { world, registry } = createWorld();
- const entity = world.spawn();
- world.insert(entity, Transform);
-
- const asset = createPositionAsset(1.0);
- const instance = new TimelineInstance(asset);
- instance.play();
-
- advanceTimeline(instance, 0.5);
- applyPropertyTrackResults(world, entity, instance);
-
- const t = world.get(entity, Transform);
- expect(t.position.x).toBeCloseTo(50, 0);
- expect(t.position.y).toBeCloseTo(100, 0);
-
- disposeWorld(world, registry);
- });
- });
-
- describe('timeline applies position to child entity', () => {
- it('should resolve child by name and update transform', () => {
- const { world, registry } = createWorld();
- const root = world.spawn();
- world.insert(root, Transform);
- world.insert(root, Name, { value: 'Root' });
-
- const child = world.spawn();
- world.insert(child, Transform);
- world.insert(child, Name, { value: 'Title' });
- world.setParent(child, root);
-
- const asset = createChildPositionAsset(1.0);
- const instance = new TimelineInstance(asset);
- instance.play();
-
- advanceTimeline(instance, 0.5);
- applyPropertyTrackResults(world, root, instance);
-
- const t = world.get(child, Transform);
- expect(t.position.x).toBeCloseTo(155, 0);
-
- disposeWorld(world, registry);
- });
- });
});
diff --git a/sdk/tests/ui-components.test.ts b/sdk/tests/ui-components.test.ts
index 470080807..c2151dd88 100644
--- a/sdk/tests/ui-components.test.ts
+++ b/sdk/tests/ui-components.test.ts
@@ -367,7 +367,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
});
describe('UI layout with deep hierarchy', () => {
- it('should compute layout for 3-level nested UIRect', () => {
+ it('should compute layout for 3-level nested UIRect', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -402,7 +402,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
world.insert(leaf, Sprite, makeSprite());
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const rootW = module.getUIRectComputedWidth(registry, root);
const rootH = module.getUIRectComputedHeight(registry, root);
@@ -422,7 +422,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should compute fixed-size centered child correctly', () => {
+ it('should compute fixed-size centered child correctly', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -438,7 +438,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
world.insert(child, Sprite, makeSprite());
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const w = module.getUIRectComputedWidth(registry, child);
const h = module.getUIRectComputedHeight(registry, child);
@@ -450,7 +450,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
});
describe('render order with multiple roots', () => {
- it('should assign render order across sibling entities', () => {
+ it('should assign render order across sibling entities', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -471,7 +471,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
}
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const rootLayer = registry.getSprite(root).layer;
for (const child of children) {
@@ -482,7 +482,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should maintain correct order: parent < child < grandchild', () => {
+ it('should maintain correct order: parent < child < grandchild', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -505,7 +505,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
world.insert(leaf, Sprite, makeSprite());
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const rootLayer = registry.getSprite(root).layer;
const midLayer = registry.getSprite(mid).layer;
@@ -519,7 +519,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
});
describe('anchor-based layout variations', () => {
- it('should compute left-anchored child (25% width)', () => {
+ it('should compute left-anchored child (25% width)', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -542,7 +542,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
world.insert(child, Sprite, makeSprite());
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const w = module.getUIRectComputedWidth(registry, child);
const h = module.getUIRectComputedHeight(registry, child);
@@ -552,7 +552,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should compute bottom-anchored child (50% height)', () => {
+ it('should compute bottom-anchored child (50% height)', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -575,7 +575,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
world.insert(child, Sprite, makeSprite());
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const w = module.getUIRectComputedWidth(registry, child);
const h = module.getUIRectComputedHeight(registry, child);
@@ -585,7 +585,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should compute offset from edges', () => {
+ it('should compute offset from edges', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -608,7 +608,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
world.insert(child, Sprite, makeSprite());
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const w = module.getUIRectComputedWidth(registry, child);
const h = module.getUIRectComputedHeight(registry, child);
@@ -620,7 +620,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
});
describe('dynamic layout changes', () => {
- it('should update layout when anchors change between ticks', () => {
+ it('should update layout when anchors change between ticks', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -643,7 +643,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
world.insert(child, Sprite, makeSprite());
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
expect(module.getUIRectComputedWidth(registry, child)).toBeCloseTo(400, 0);
@@ -651,14 +651,14 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
rect.anchorMax.x = 1;
registry.addUIRect(child, rect);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
expect(module.getUIRectComputedWidth(registry, child)).toBeCloseTo(800, 0);
disposeApp(app, registry);
});
- it('should handle adding new child between ticks', () => {
+ it('should handle adding new child between ticks', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -668,7 +668,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
world.insert(root, Transform, makeTransform());
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const child = world.spawn();
world.setParent(child, root);
@@ -676,7 +676,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
world.insert(child, Transform, makeTransform());
world.insert(child, Sprite, makeSprite());
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const w = module.getUIRectComputedWidth(registry, child);
const h = module.getUIRectComputedHeight(registry, child);
@@ -686,7 +686,7 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
disposeApp(app, registry);
});
- it('should handle changing canvas rect between ticks', () => {
+ it('should handle changing canvas rect between ticks', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -697,13 +697,13 @@ describe.skipIf(!HAS_WASM)('UI Components (WASM integration)', () => {
world.insert(root, Sprite, makeSprite());
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
expect(module.getUIRectComputedWidth(registry, root)).toBeCloseTo(800, 0);
expect(module.getUIRectComputedHeight(registry, root)).toBeCloseTo(600, 0);
setCanvasRect(app, -500, -400, 500, 400);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
expect(module.getUIRectComputedWidth(registry, root)).toBeCloseTo(1000, 0);
expect(module.getUIRectComputedHeight(registry, root)).toBeCloseTo(800, 0);
diff --git a/sdk/tests/ui-layout-integration.test.ts b/sdk/tests/ui-layout-integration.test.ts
index c49642df7..8cac70a36 100644
--- a/sdk/tests/ui-layout-integration.test.ts
+++ b/sdk/tests/ui-layout-integration.test.ts
@@ -65,7 +65,7 @@ describe.skipIf(!HAS_WASM)('UI Layout via App.tick() (WASM integration)', () =>
cam.valid = true;
}
- it('should call uiLayout_update via tick without error', () => {
+ it('should call uiLayout_update via tick without error', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -87,12 +87,12 @@ describe.skipIf(!HAS_WASM)('UI Layout via App.tick() (WASM integration)', () =>
setCanvasRect(app, -400, -300, 400, 300);
- expect(() => app.tick(1 / 60)).not.toThrow();
+ await expect(async () => await app.tick(1 / 60)).not.toThrow();
disposeApp(app, registry);
});
- it('should compute layout for child UIRect entities', () => {
+ it('should compute layout for child UIRect entities', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -140,7 +140,7 @@ describe.skipIf(!HAS_WASM)('UI Layout via App.tick() (WASM integration)', () =>
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const computedW = module.getUIRectComputedWidth(registry, child);
const computedH = module.getUIRectComputedHeight(registry, child);
@@ -150,7 +150,7 @@ describe.skipIf(!HAS_WASM)('UI Layout via App.tick() (WASM integration)', () =>
disposeApp(app, registry);
});
- it('should update render order after tick', () => {
+ it('should update render order after tick', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -194,7 +194,7 @@ describe.skipIf(!HAS_WASM)('UI Layout via App.tick() (WASM integration)', () =>
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const rootSprite = registry.getSprite(root);
const childSprite = registry.getSprite(child);
@@ -203,7 +203,7 @@ describe.skipIf(!HAS_WASM)('UI Layout via App.tick() (WASM integration)', () =>
disposeApp(app, registry);
});
- it('should handle fill anchors for slider-like entities', () => {
+ it('should handle fill anchors for slider-like entities', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -260,7 +260,7 @@ describe.skipIf(!HAS_WASM)('UI Layout via App.tick() (WASM integration)', () =>
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const fillW = module.getUIRectComputedWidth(registry, fill);
const fillH = module.getUIRectComputedHeight(registry, fill);
@@ -273,7 +273,7 @@ describe.skipIf(!HAS_WASM)('UI Layout via App.tick() (WASM integration)', () =>
disposeApp(app, registry);
});
- it('should handle multiple tick calls without error', () => {
+ it('should handle multiple tick calls without error', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -293,13 +293,13 @@ describe.skipIf(!HAS_WASM)('UI Layout via App.tick() (WASM integration)', () =>
setCanvasRect(app, -400, -300, 400, 300);
for (let i = 0; i < 60; i++) {
- expect(() => app.tick(1 / 60)).not.toThrow();
+ await expect(async () => await app.tick(1 / 60)).not.toThrow();
}
disposeApp(app, registry);
});
- it('should skip layout when UICameraInfo.valid is false', () => {
+ it('should skip layout when UICameraInfo.valid is false', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -319,7 +319,7 @@ describe.skipIf(!HAS_WASM)('UI Layout via App.tick() (WASM integration)', () =>
const cam = app.getResource(UICameraInfo);
cam.valid = false;
- expect(() => app.tick(1 / 60)).not.toThrow();
+ await expect(async () => await app.tick(1 / 60)).not.toThrow();
const w = module.getUIRectComputedWidth(registry, root);
expect(w).toBe(0);
@@ -327,7 +327,7 @@ describe.skipIf(!HAS_WASM)('UI Layout via App.tick() (WASM integration)', () =>
disposeApp(app, registry);
});
- it('Canvas without UIRect: layout should not overwrite Transform positions', () => {
+ it('Canvas without UIRect: layout should not overwrite Transform positions', async () => {
const { app, registry } = createEditorApp();
const world = app.world;
@@ -359,7 +359,7 @@ describe.skipIf(!HAS_WASM)('UI Layout via App.tick() (WASM integration)', () =>
});
setCanvasRect(app, -400, -300, 400, 300);
- app.tick(1 / 60);
+ await app.tick(1 / 60);
const t = registry.getTransform(child);
expect(t.position.x).toBeCloseTo(50, 1);
diff --git a/third_party/glad/include/glad/glad.h b/third_party/glad/include/glad/glad.h
index 49cfebf65..d56fb97cd 100644
--- a/third_party/glad/include/glad/glad.h
+++ b/third_party/glad/include/glad/glad.h
@@ -109,6 +109,10 @@ typedef ptrdiff_t GLintptr;
#define GL_CULL_FACE 0x0B44
#define GL_DEPTH_TEST 0x0B71
#define GL_STENCIL_TEST 0x0B90
+#define GL_KEEP 0x1E00
+#define GL_REPLACE 0x1E01
+#define GL_ALWAYS 0x0207
+#define GL_EQUAL 0x0202
#define GL_BLEND 0x0BE2
#define GL_SCISSOR_TEST 0x0C11
@@ -340,6 +344,11 @@ typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count
typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value);
+/* Stencil functions */
+typedef void (APIENTRYP PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask);
+typedef void (APIENTRYP PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass);
+typedef void (APIENTRYP PFNGLSTENCILMASKPROC)(GLuint mask);
+
/* Framebuffer functions */
typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint* framebuffers);
typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint* framebuffers);
@@ -442,6 +451,11 @@ GLAPI PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;
GLAPI PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;
GLAPI PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;
+/* Stencil */
+GLAPI PFNGLSTENCILFUNCPROC glad_glStencilFunc;
+GLAPI PFNGLSTENCILOPPROC glad_glStencilOp;
+GLAPI PFNGLSTENCILMASKPROC glad_glStencilMask;
+
/* Framebuffer */
GLAPI PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;
GLAPI PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;
@@ -539,6 +553,10 @@ GLAPI PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer;
#define glUniformMatrix3fv glad_glUniformMatrix3fv
#define glUniformMatrix4fv glad_glUniformMatrix4fv
+#define glStencilFunc glad_glStencilFunc
+#define glStencilOp glad_glStencilOp
+#define glStencilMask glad_glStencilMask
+
#define glGenFramebuffers glad_glGenFramebuffers
#define glDeleteFramebuffers glad_glDeleteFramebuffers
#define glBindFramebuffer glad_glBindFramebuffer
diff --git a/third_party/glad/src/glad.c b/third_party/glad/src/glad.c
index 7c7da4ba7..479c586b6 100644
--- a/third_party/glad/src/glad.c
+++ b/third_party/glad/src/glad.c
@@ -106,6 +106,11 @@ PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv = NULL;
PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv = NULL;
PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL;
+/* Stencil */
+PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL;
+PFNGLSTENCILOPPROC glad_glStencilOp = NULL;
+PFNGLSTENCILMASKPROC glad_glStencilMask = NULL;
+
/* Framebuffer */
PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL;
PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers = NULL;
@@ -217,6 +222,11 @@ int gladLoadGLLoader(GLADloadproc load) {
glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)load("glUniformMatrix3fv");
glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)load("glUniformMatrix4fv");
+ /* Stencil */
+ glad_glStencilFunc = (PFNGLSTENCILFUNCPROC)load("glStencilFunc");
+ glad_glStencilOp = (PFNGLSTENCILOPPROC)load("glStencilOp");
+ glad_glStencilMask = (PFNGLSTENCILMASKPROC)load("glStencilMask");
+
/* Framebuffer */
glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)load("glGenFramebuffers");
glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)load("glDeleteFramebuffers");