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.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(editor): a mesh is clickable where its geometry is
esengineb0a308da5081
diff --git a/desktop/scripts/headless-verify.mjs b/desktop/scripts/headless-verify.mjsindex 10818c008..49ba86e8b 100644--- a/desktop/scripts/headless-verify.mjs+++ b/desktop/scripts/headless-verify.mjs@@ -21,6 +21,7 @@* ESTELLA_VERIFY_DEPTH_LAYERS bitmask of layers resolved by depth (2.5D)* ESTELLA_VERIFY_PREFAB .esprefab instantiated into the scene after load* ESTELLA_VERIFY_SET_FIELD one inspector field written after load (JSON)+ * ESTELLA_VERIFY_PICK hit-test a viewport point, asserting the entity (JSON)*/import { app, BrowserWindow } from 'electron';import http from 'node:http';@@ -130,10 +131,13 @@ function finish(result, server) {&& (!result.meshAsset || result.meshAsset.pointed > 0)&& (!result.meshMaterial || result.meshMaterial.applied > 0)&& (!result.meshPrefab || result.meshPrefab.spawned > 0);+ // A hit test answering the wrong entity (or nothing) is the box being wrong,+ // which no pixel in the frame can show.+ const pickOk = !result.pick || result.pick.hit === result.pick.want;const renderedOk = result.capture?.rendered ?? false;const ok = result.ok && renderedOk && (result.expect?.ok ?? true) &&(result.resize?.ok ?? true) && (result.preview?.ok ?? true) && (result.grid?.ok ?? true) &&- deviceLossOk && meshOk;+ deviceLossOk && meshOk && pickOk;console.log(`\n[verify:render] ${ok ? 'PASS' : 'FAIL'} — ${SCENE} (${BACKEND})`);console.log('DRIVE_RESULT ' + JSON.stringify(result));try {@@ -171,6 +175,7 @@ app.whenReady().then(async () => {let meshMaterial = null;let meshPrefab = null;let setField = null;+ let pick = null;await exec('window.__estellaHeadless.ready');const entityCount = await exec(`window.__estellaHeadless.api.loadScene(${JSON.stringify(SCENE)}, ${JSON.stringify(MANIFEST)})`,@@ -283,6 +288,17 @@ app.whenReady().then(async () => {})()`);}+ // ESTELLA_VERIFY_PICK={"x","y","entity"} clicks a point (viewport fractions)+ // and asserts which entity answers — the editor's own hit test, whose box for+ // a mesh is its geometry rather than the icon square a shapeless entity gets.+ if (process.env.ESTELLA_VERIFY_PICK) {+ const spec = JSON.parse(process.env.ESTELLA_VERIFY_PICK);+ pick = await exec(`(() => ({+ hit: window.__estellaHeadless.api.pick(${spec.x * W}, ${spec.y * H}),+ want: ${JSON.stringify(spec.entity)},+ }))()`);+ }+// ESTELLA_VERIFY_PREFAB=<path> instantiates a prefab into the scene. For an// import's products this is the whole chain: the prefab names the geometry,// the image and the tint, and nothing here repeats what it should say.@@ -530,7 +546,7 @@ app.whenReady().then(async () => {return { differingPixels: differing, ok: differing > 300 };`);}- finish({ ok: true, entityCount, drawCalls, capture, expect, resize, preview, grid, deviceLoss, meshResident, meshAsset, meshMaterial, meshPrefab, setField }, server);+ finish({ ok: true, entityCount, drawCalls, capture, expect, resize, preview, grid, deviceLoss, meshResident, meshAsset, meshMaterial, meshPrefab, setField, pick }, server);} catch (e) {finish({ ok: false, error: String((e && e.stack) || e) }, server);}diff --git a/desktop/src/engine/ViewportController.ts b/desktop/src/engine/ViewportController.tsindex f02490ea9..b4309c3cc 100644--- a/desktop/src/engine/ViewportController.ts+++ b/desktop/src/engine/ViewportController.ts@@ -13,7 +13,7 @@ import {readColliderShapes, colliderShapeOutline, shapeCenter,layerOrderOf,editorViewHalfHeight, editorViewHalfExtent, setEditorViewHalfHeight, EDITOR_UI_ANCHOR,- entityWorldBox, uiNodeWorldBox,+ entityWorldBox, uiNodeWorldBox, meshWorldBox,type TilesetModel, type TileCollisionPiece, type TileGridParams,} from 'esengine';import type { EntityId } from '@/types';@@ -237,6 +237,10 @@ export const ViewportController = {entityBounds(id: EntityId): OBB | null {const world = EngineHost.world;if (!world) return null;+ // A mesh's extent is in its vertices, so it is asked for before the icon+ // fallback below would answer with a box the size of a camera gizmo.+ const mesh = meshWorldBox(world, id);+ if (mesh) return mesh;// The icon half-size is the editor's own: it is the size of the thing the// editor drew for an entity that draws nothing, so a camera is still// clickable. The running world has no icons and asks for no box.diff --git a/docs/astro/src/data/apiStability.generated.json b/docs/astro/src/data/apiStability.generated.jsonindex 6c33dd3de..4eba4d746 100644--- a/docs/astro/src/data/apiStability.generated.json+++ b/docs/astro/src/data/apiStability.generated.json@@ -3,10 +3,10 @@"counts": {"public": 113,"beta": 62,- "experimental": 1524,+ "experimental": 1525,"deprecated": 3},- "total": 1699,+ "total": 1700,"subsystems": [{"id": "ecs",diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex 359f20f9e..6720a13d8 100644--- a/sdk/etc/index.api.md+++ b/sdk/etc/index.api.md@@ -1,7 +1,7 @@# API surface — esengine/index<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 113 public · 55 beta · 1409 experimental · 3 deprecated+Symbols: 113 public · 55 beta · 1410 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```@@ -10309,6 +10309,11 @@ LoggerMesh2DPlugin```+## meshWorldBox — function @experimental+```+(world: LayoutWorld, entity: Entity): EntityBox | null+```+## messageOf — function @experimental```(error: unknown): stringdiff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex b2db9ce28..50c0285bc 100644--- a/sdk/etc/index.native.api.md+++ b/sdk/etc/index.native.api.md@@ -1,7 +1,7 @@# API surface — esengine/index.native<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 113 public · 60 beta · 1428 experimental · 3 deprecated+Symbols: 113 public · 60 beta · 1429 experimental · 3 deprecated## ABI_LAYOUT_HASH — const @experimental```@@ -10552,6 +10552,11 @@ LoggerMesh2DPlugin```+## meshWorldBox — function @experimental+```+(world: LayoutWorld, entity: Entity): EntityBox | null+```+## messageOf — function @experimental```(error: unknown): stringdiff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex 48650be6f..e6ef11d40 100644--- a/sdk/etc/index.node.api.md+++ b/sdk/etc/index.node.api.md@@ -1,7 +1,7 @@# API surface — esengine/index.node<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 113 public · 57 beta · 1408 experimental · 3 deprecated+Symbols: 113 public · 57 beta · 1409 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -10309,6 +10309,11 @@ LoggerMesh2DPlugin```+## meshWorldBox — function @experimental+```+(world: LayoutWorld, entity: Entity): EntityBox | null+```+## messageOf — function @experimental```(error: unknown): stringdiff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex 2af731f93..ce14d50f7 100644--- a/sdk/etc/minigame.api.md+++ b/sdk/etc/minigame.api.md@@ -1,7 +1,7 @@# API surface — esengine/minigame<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 113 public · 55 beta · 1429 experimental · 3 deprecated+Symbols: 113 public · 55 beta · 1430 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -10564,6 +10564,11 @@ LoggerMesh2DPlugin```+## meshWorldBox — function @experimental+```+(world: LayoutWorld, entity: Entity): EntityBox | null+```+## messageOf — function @experimental```(error: unknown): stringdiff --git a/sdk/etc/wasm.api.md b/sdk/etc/wasm.api.mdindex 5096252f2..4037f13ab 100644--- a/sdk/etc/wasm.api.md+++ b/sdk/etc/wasm.api.md@@ -258,6 +258,7 @@ material_define: (materialId: number, shaderHandle: number, blendMode: number, fmaterial_setTexture: (materialId: number, name: string, textureHandle: number) => voidmaterial_setUniform: (materialId: number, name: string, arity: number, v0: number, v1: number, v2: number, v3: number) => voidmaterial_undefine: (materialId: number) => void+mesh2d_localBounds: ((registry: CppRegistry, entity: number) => { minX: number; minY: number; maxX: number; maxY: number; } | null) | undefinedmesh2d_makeAllResident: ((registry: CppRegistry) => number) | undefinedmesh2d_makeResident: ((registry: CppRegistry, entity: number) => number) | undefinedmesh2d_setGeometry: ((registry: CppRegistry, entity: number, posUvPtr: number, vertexCount: number, colorsPtr: number, indicesPtr: number, indexCount: number) => void) | undefineddiff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex 956a7d050..1d6ce587a 100644--- a/sdk/etc/wechat.api.md+++ b/sdk/etc/wechat.api.md@@ -1,7 +1,7 @@# API surface — esengine/wechat<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->-Symbols: 113 public · 55 beta · 1419 experimental · 3 deprecated+Symbols: 113 public · 55 beta · 1420 experimental · 3 deprecated## ANCHOR_AXES — const @experimental```@@ -10336,6 +10336,11 @@ LoggerMesh2DPlugin```+## meshWorldBox — function @experimental+```+(world: LayoutWorld, entity: Entity): EntityBox | null+```+## messageOf — function @experimental```(error: unknown): stringdiff --git a/sdk/src/core-sys.ts b/sdk/src/core-sys.tsindex 1b68a4c89..25f1516f1 100644--- a/sdk/src/core-sys.ts+++ b/sdk/src/core-sys.ts@@ -61,7 +61,7 @@ export {export { setEntityVisible, isEntityVisible, hasVisibility, setEntityActive, isEntityActive } from './ecs/entityUtils';-export { entityWorldBox, uiNodeWorldBox, entityBoxCorners, type EntityBox, type EntityBoxOptions, type ReadableWorld, type LayoutWorld } from './ecs/entityBox';+export { entityWorldBox, uiNodeWorldBox, meshWorldBox, entityBoxCorners, type EntityBox, type EntityBoxOptions, type ReadableWorld, type LayoutWorld } from './ecs/entityBox';export { CacheBitmap, type BitmapCache } from './render/cacheBitmap';export {CacheAsBitmap,diff --git a/sdk/src/ecs/entityBox.ts b/sdk/src/ecs/entityBox.tsindex 17f87eda3..5ca5e26db 100644--- a/sdk/src/ecs/entityBox.ts+++ b/sdk/src/ecs/entityBox.ts@@ -11,7 +11,7 @@*/import type { Entity } from '../types';import type { World } from './world';-import { Transform, Sprite } from './component';+import { Transform, Sprite, Mesh2D } from './component';import { UINode } from '../ui/core/ui-node';import { quaternionToAngle2D } from '../ui/util/math';import { worldEngineApi } from './bridge/engineApi';@@ -128,6 +128,47 @@ export function uiNodeWorldBox(world: LayoutWorld, entity: Entity): EntityBox |};}+interface LocalBounds { minX: number; minY: number; maxX: number; maxY: number }++/**+ * The world box of a Mesh2D's geometry — {@link entityWorldBox} for a mesh,+ * whose extent is in its vertices rather than in a size field. The engine+ * answers: only it knows whether the live geometry is the resident one or the+ * inline payload. Null for anything else, and for a mesh that draws nothing.+ *+ * @experimental+ */+export function meshWorldBox(world: LayoutWorld, entity: Entity): EntityBox | null {+ if (!world.valid(entity) || !world.has(entity, Mesh2D) || !world.has(entity, Transform)) return null;+ if (world.has(entity, UINode)) return null;+ // The wasm module, not the shared engine api: this answer is a small object,+ // which is a shape only that binding surface carries.+ const module = world.getWasmModule() as {+ mesh2d_localBounds?(registry: unknown, entity: number): LocalBounds | null;+ } | null;+ const registry = world.getCppRegistry();+ if (!registry || !module?.mesh2d_localBounds) return null;+ const b = module.mesh2d_localBounds(registry, entity);+ if (!b) return null;++ const t = world.get(entity, Transform);+ const rot = quaternionToAngle2D((t.worldRotation as { z: number }).z,+ (t.worldRotation as { w: number }).w);+ // The geometry's centre is its own, not the transform's: a mesh authored+ // off-origin is drawn off-origin, and its box has to follow.+ const ox = (b.minX + b.maxX) / 2 * t.worldScale.x;+ const oy = (b.minY + b.maxY) / 2 * t.worldScale.y;+ const c = Math.cos(rot);+ const s = Math.sin(rot);+ return {+ cx: t.worldPosition.x + ox * c - oy * s,+ cy: t.worldPosition.y + ox * s + oy * c,+ hw: Math.abs((b.maxX - b.minX) * t.worldScale.x) / 2,+ hh: Math.abs((b.maxY - b.minY) * t.worldScale.y) / 2,+ rot,+ };+}+/*** The box's four corners in world units, counter-clockwise from its local* -x,-y — what an outline is drawn through.diff --git a/sdk/src/wasm.ts b/sdk/src/wasm.tsindex 80a617e43..5987a4ac1 100644--- a/sdk/src/wasm.ts+++ b/sdk/src/wasm.ts@@ -260,6 +260,10 @@ export interface ESEngineModule {* inline payloads. Returns how many were pointed.*/mesh2d_setMeshAll?(registry: CppRegistry, meshHandle: number): number;+ /** Local XY bounds of what a Mesh2D draws — resident geometry, else its+ * inline payload. Null when it draws nothing. */+ mesh2d_localBounds?(registry: CppRegistry, entity: number):+ { minX: number; minY: number; maxX: number; maxY: number } | null;/** Point every Mesh2D in the world at one material; returns how many. */mesh2d_setMaterialAll?(registry: CppRegistry, materialId: number): number;recoverDevice?(): boolean;diff --git a/sdk/tests/entity-box.test.ts b/sdk/tests/entity-box.test.tsindex 09f4d87c3..9ad4c224e 100644--- a/sdk/tests/entity-box.test.ts+++ b/sdk/tests/entity-box.test.ts@@ -8,8 +8,8 @@* sitting beside its sprite is made of. One definition, these claims.*/import { describe, expect, it } from 'vitest';-import { entityWorldBox, entityBoxCorners, uiNodeWorldBox } from '../src/ecs/entityBox';-import { Transform, Sprite } from '../src/ecs/component';+import { entityWorldBox, entityBoxCorners, uiNodeWorldBox, meshWorldBox } from '../src/ecs/entityBox';+import { Transform, Sprite, Mesh2D } from '../src/ecs/component';import { UINode } from '../src/ui/core/ui-node';import type { Entity } from '../src/types';@@ -31,6 +31,12 @@ const T = (x: number, y: number, sx = 1, sy = 1, angle = 0) => ({worldRotation: { x: 0, y: 0, z: Math.sin(angle / 2), w: Math.cos(angle / 2) },});+/** The engine side of a mesh box: the bounds of whichever geometry is live. */+const meshBounds = (b: { minX: number; minY: number; maxX: number; maxY: number } | null) => ({+ getCppRegistry: () => ({}),+ getWasmModule: () => ({ mesh2d_localBounds: () => b }),+});+/** The engine side of a UI box: a resolved layout size, in the core's own tables. */const layout = (w: number, h: number) => ({getCppRegistry: () => ({}),@@ -114,3 +120,36 @@ describe('an entity world box', () => {]);});});++describe('a mesh world box', () => {+ it('is the geometry the engine reports, through the world scale', () => {+ // A Mesh2D has no size field: the extent lives in its vertices, and for+ // resident geometry not even in the component. Only the engine can say.+ const world = {+ ...fakeWorld({ 1: { [name(Transform)]: T(10, 20, 2, 3), [name(Mesh2D)]: {} } }),+ ...meshBounds({ minX: -50, minY: -10, maxX: 50, maxY: 10 }),+ } as never;+ expect(meshWorldBox(world, ent(1))).toEqual({ cx: 10, cy: 20, hw: 100, hh: 30, rot: 0 });+ });++ it('follows geometry authored off the origin', () => {+ const world = {+ ...fakeWorld({ 1: { [name(Transform)]: T(0, 0), [name(Mesh2D)]: {} } }),+ ...meshBounds({ minX: 100, minY: 0, maxX: 300, maxY: 40 }),+ } as never;+ expect(meshWorldBox(world, ent(1))).toEqual({ cx: 200, cy: 20, hw: 100, hh: 20, rot: 0 });+ });++ it('has none when the mesh draws nothing, and none for a non-mesh', () => {+ const empty = {+ ...fakeWorld({ 1: { [name(Transform)]: T(0, 0), [name(Mesh2D)]: {} } }),+ ...meshBounds(null),+ } as never;+ expect(meshWorldBox(empty, ent(1))).toBeNull();+ const sprite = {+ ...fakeWorld({ 1: { [name(Transform)]: T(0, 0), [name(Sprite)]: { size: { x: 4, y: 4 } } } }),+ ...meshBounds({ minX: -1, minY: -1, maxX: 1, maxY: 1 }),+ } as never;+ expect(meshWorldBox(sprite, ent(1))).toBeNull();+ });+});diff --git a/sdk/tests/mesh-box-integration.test.ts b/sdk/tests/mesh-box-integration.test.tsnew file mode 100644index 000000000..4bd08c055--- /dev/null+++ b/sdk/tests/mesh-box-integration.test.ts@@ -0,0 +1,85 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file A mesh's world box, against the real engine.+ *+ * The extent of a Mesh2D lives in its vertices — and for GPU-resident geometry+ * not in the component at all — so the engine is what answers. An editor that+ * boxes a mesh by its component alone gets nothing to click.+ *+ * Requires pre-built WASM at desktop/public/wasm/esengine.wasm.+ */+import { describe, it, expect, beforeAll } from 'vitest';+import { App } from '../src/app/app';+import { Transform, Mesh2D } from '../src/ecs/component';+import { Mesh2DAPI } from '../src/render/mesh2d';+import { meshWorldBox } from '../src/ecs/entityBox';+import type { ESEngineModule, CppRegistry } from '../src/wasm';+import { loadWasmModule, HAS_WASM } from './helpers/loadWasm';++// The world triple is written directly: what a box reads is the RESOLVED+// transform, and this test is about the geometry rather than the hierarchy.+const transform = (x = 0, y = 0, sx = 1, sy = 1) => ({+ position: { x, y, z: 0 },+ rotation: { x: 0, y: 0, z: 0, w: 1 },+ scale: { x: sx, y: sy, z: 1 },+ worldPosition: { x, y, z: 0 },+ worldRotation: { x: 0, y: 0, z: 0, w: 1 },+ worldScale: { x: sx, y: sy, z: 1 },+});++describe.skipIf(!HAS_WASM)('a mesh world box (WASM integration)', () => {+ let module: ESEngineModule;++ beforeAll(async () => {+ module = await loadWasmModule();+ });++ function createApp(): { app: App; registry: CppRegistry } {+ const app = App.new();+ const registry = new module.Registry() as unknown as CppRegistry;+ app.connectCpp(registry, module);+ return { app, registry };+ }++ function dispose(app: App, registry: CppRegistry): void {+ for (const e of app.world.getAllEntities()) {+ try { app.world.despawn(e); } catch { /* already gone */ }+ }+ app.world.disconnectCpp();+ (registry as unknown as { delete(): void }).delete();+ }++ it('is the uploaded geometry, taken through the world scale', () => {+ const { app, registry } = createApp();+ try {+ const mesh = new Mesh2DAPI(module as never, registry);+ const e = app.world.spawn();+ app.world.insert(e, Transform, transform(10, 20, 2, 3));+ app.world.insert(e, Mesh2D, {});+ mesh.setGeometry(e, {+ positions: [-50, -10, 50, -10, 50, 10, -50, 10],+ indices: [0, 1, 2, 0, 2, 3],+ });+ app.tick(1 / 60);++ expect(meshWorldBox(app.world, e))+ .toEqual({ cx: 10, cy: 20, hw: 100, hh: 30, rot: 0 });+ } finally {+ dispose(app, registry);+ }+ });++ it('has no box before geometry is uploaded', () => {+ const { app, registry } = createApp();+ try {+ const e = app.world.spawn();+ app.world.insert(e, Transform, transform());+ app.world.insert(e, Mesh2D, {});+ app.tick(1 / 60);+ expect(meshWorldBox(app.world, e)).toBeNull();+ } finally {+ dispose(app, registry);+ }+ });+});diff --git a/src/esengine/bindings/RendererBindings.cpp b/src/esengine/bindings/RendererBindings.cppindex 95ce7b603..08ddae310 100644--- a/src/esengine/bindings/RendererBindings.cpp+++ b/src/esengine/bindings/RendererBindings.cpp@@ -692,6 +692,37 @@ u32 renderer_getDrawCalls() {}#ifdef __EMSCRIPTEN__+/**+ * The local-space XY box of what a Mesh2D DRAWS — resident geometry when it has+ * some, else the inline payload. Which of the two is live is the engine's to+ * know: an editor asking the component alone boxes a resident mesh at zero, and+ * then it cannot be clicked.+ */+emscripten::val mesh2d_localBounds(ecs::Registry& registry, u32 entity) {+ const Entity ent = Entity::fromRaw(entity);+ const auto* mesh = registry.tryGet<ecs::Mesh2D>(ent);+ if (!mesh) return emscripten::val::null();++ glm::vec2 mn = mesh->localMin;+ glm::vec2 mx = mesh->localMax;+ if (mesh->mesh.isValid()) {+ if (auto* rm = ctx().tryGet<resource::ResourceManager>()) {+ if (const Mesh* res = rm->getMesh(mesh->mesh)) {+ mn = glm::vec2(res->localMin);+ mx = glm::vec2(res->localMax);+ }+ }+ }+ if (!(mx.x > mn.x) && !(mx.y > mn.y)) return emscripten::val::null();++ auto out = emscripten::val::object();+ out.set("minX", mn.x);+ out.set("minY", mn.y);+ out.set("maxX", mx.x);+ out.set("maxY", mx.y);+ return out;+}+emscripten::val renderer_getLiveObjects() {auto* device = g_device;// Null rather than zeros: with no device there is nothing to report, and adiff --git a/src/esengine/bindings/RendererBindings.hpp b/src/esengine/bindings/RendererBindings.hppindex 4b6dcbda9..bb0e2d847 100644--- a/src/esengine/bindings/RendererBindings.hpp+++ b/src/esengine/bindings/RendererBindings.hpp@@ -117,6 +117,9 @@ u32 renderer_getDrawCalls();/// GPU objects the device has not destroyed, for the resource census. Null when/// no device is initialized — absent counters, not zeroed ones.emscripten::val renderer_getLiveObjects();+/// Local XY bounds of what a Mesh2D draws (resident geometry, else the inline+/// payload). Null when it draws nothing — an editor boxes it by its icon then.+emscripten::val mesh2d_localBounds(ecs::Registry& registry, u32 entity);#endifu32 renderer_getTriangles();u32 renderer_getSprites();diff --git a/src/esengine/bindings/WebSDKEntry.cpp b/src/esengine/bindings/WebSDKEntry.cppindex dab06c93f..348f00de3 100644--- a/src/esengine/bindings/WebSDKEntry.cpp+++ b/src/esengine/bindings/WebSDKEntry.cpp@@ -527,6 +527,7 @@ EMSCRIPTEN_BINDINGS(esengine_renderer) {emscripten::function("mesh_createFromChannels", &esengine::mesh_createFromChannels);emscripten::function("mesh_release", &esengine::mesh_release);emscripten::function("mesh2d_setMesh", &esengine::mesh2d_setMesh);+ emscripten::function("mesh2d_localBounds", &esengine::mesh2d_localBounds);emscripten::function("mesh2d_makeResident", &esengine::mesh2d_makeResident);emscripten::function("mesh2d_makeAllResident", &esengine::mesh2d_makeAllResident);emscripten::function("mesh2d_setMeshAll", &esengine::mesh2d_setMeshAll);diff --git a/tools/renderScenes.mjs b/tools/renderScenes.mjsindex 2ab261818..17fb1aa12 100644--- a/tools/renderScenes.mjs+++ b/tools/renderScenes.mjs@@ -142,8 +142,9 @@ export const SCENES = [{ id: "mesh-material-lit", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_MESH_ASSET: "/scenes/lit-triangles.esmesh", ESTELLA_VERIFY_MESH_MATERIAL: "/scenes/mesh-material-lit/litmat.esmaterial", ESTELLA_VERIFY_SCENE: "/scenes/mesh-lit.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mesh-lit.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.30,\"y\":0.556,\"rgb\":[255,0,0],\"tol\":40},{\"x\":0.70,\"y\":0.556,\"rgb\":[0,0,0],\"tol\":40}]" } },// A mesh assigned IN THE EDITOR: a cold ref reaches the World only through the// live loader + re-projection. The quad covers the gap between the scene's own- // two triangles, so the frame says which geometry is drawn.- { id: "mesh-assign", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SET_FIELD: "{\"entity\":1,\"component\":\"Mesh2D\",\"key\":\"mesh\",\"value\":\"/scenes/textured-quad.esmesh\"}", ESTELLA_VERIFY_SCENE: "/scenes/mesh2d.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mesh2d.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5,\"y\":0.5,\"rgb\":[255,255,255],\"tol\":40},{\"x\":0.30,\"y\":0.556,\"rgb\":[255,255,255],\"tol\":40}]" } },+ // two triangles, so the frame says which geometry is drawn — and the hit test+ // lands 120 world units out, where only the mesh's own box reaches.+ { id: "mesh-assign", tier: "pr", webgpu: true, env: { ESTELLA_VERIFY_SET_FIELD: "{\"entity\":1,\"component\":\"Mesh2D\",\"key\":\"mesh\",\"value\":\"/scenes/textured-quad.esmesh\"}", ESTELLA_VERIFY_PICK: "{\"x\":0.7,\"y\":0.3833,\"entity\":1}", ESTELLA_VERIFY_SCENE: "/scenes/mesh2d.esscene", ESTELLA_VERIFY_MANIFEST: "/scenes/mesh2d.textures.json", ESTELLA_VERIFY_W: "256", ESTELLA_VERIFY_H: "256", ESTELLA_VERIFY_STEPS: "4", ESTELLA_VERIFY_EXPECT: "[{\"x\":0.5,\"y\":0.5,\"rgb\":[255,255,255],\"tol\":40},{\"x\":0.30,\"y\":0.556,\"rgb\":[255,255,255],\"tol\":40}]" } },// A normal map over FLAT normals: the quad faces the viewer, so without the map// both halves take the same light. Its texels point -X and +X, so the lit half// and the unlit one are the tangent frame, derived per pixel from derivatives.