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
feat(ui): group opacity, a pointer gate, mask shapes, and object-fit
yhh699087007970
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.mdindex 28cd1ca23..230cf11a4 100644--- a/sdk/etc/index.api.md+++ b/sdk/etc/index.api.md@@ -5,7 +5,7 @@ Symbols: 1369 stable · 17 beta · 1 deprecated## ABI_LAYOUT_HASH — const```-"9219dd764c94a81e"+"52526b76662ebd4a"```## ANCHOR_AXES — const@@ -2318,9 +2318,11 @@ getResourceManager: () => CppResourceManagergetRigidBodyPtr: (registry: CppRegistry, entity: number) => numbergetSpritePtr: (registry: CppRegistry, entity: number) => numbergetTransformPtr: (registry: CppRegistry, entity: number) => number+getUINodeAlphaInTree: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeComputedHeight: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeComputedWidth: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeHiddenInTree: ((registry: CppRegistry, entity: number) => boolean) | undefined+getUINodePointerBlockedInTree: ((registry: CppRegistry, entity: number) => boolean) | undefinedgetVelocityPtr: (registry: CppRegistry, entity: number) => numbergl_checkErrors: (context: string) => numbergl_enableErrorCheck: (enabled: boolean) => void@@ -7669,6 +7671,7 @@ BuiltinComponentDef<UIMaskData>## UIMaskData — interface```+alphaCutoff: numberenabled: booleanmode: MaskMode```@@ -7700,6 +7703,8 @@ marginBottom: Dimension | undefinedmarginLeft: Dimension | undefinedmarginRight: Dimension | undefinedmarginTop: Dimension | undefined+opacity: number | undefined+pointerEvents: number | undefinedposition: number | undefinedwidth: Dimension | undefined```@@ -7772,6 +7777,7 @@ enabled: booleanfillAmount: numberfillMethod: FillMethodfillOrigin: FillOrigin+fit: UIVisualFitmaterial: numbersliceBorder: Vec4texture: number@@ -7788,6 +7794,7 @@ enabled: boolean | undefinedfillAmount: number | undefinedfillMethod: FillMethod | undefinedfillOrigin: FillOrigin | undefined+fit: UIVisualFit | undefinedmaterial: number | undefinedsliceBorder: { x: number; y: number; z: number; w: number; } | undefinedtexture: number | undefineddiff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.mdindex c1beaf04b..524b3c010 100644--- a/sdk/etc/index.native.api.md+++ b/sdk/etc/index.native.api.md@@ -5,7 +5,7 @@ Symbols: 1388 stable · 22 beta · 1 deprecated## ABI_LAYOUT_HASH — const```-"9219dd764c94a81e"+"52526b76662ebd4a"```## ANCHOR_AXES — const@@ -2326,9 +2326,11 @@ getResourceManager: () => CppResourceManagergetRigidBodyPtr: (registry: CppRegistry, entity: number) => numbergetSpritePtr: (registry: CppRegistry, entity: number) => numbergetTransformPtr: (registry: CppRegistry, entity: number) => number+getUINodeAlphaInTree: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeComputedHeight: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeComputedWidth: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeHiddenInTree: ((registry: CppRegistry, entity: number) => boolean) | undefined+getUINodePointerBlockedInTree: ((registry: CppRegistry, entity: number) => boolean) | undefinedgetVelocityPtr: (registry: CppRegistry, entity: number) => numbergl_checkErrors: (context: string) => numbergl_enableErrorCheck: (enabled: boolean) => void@@ -7833,6 +7835,7 @@ BuiltinComponentDef<UIMaskData>## UIMaskData — interface```+alphaCutoff: numberenabled: booleanmode: MaskMode```@@ -7864,6 +7867,8 @@ marginBottom: Dimension | undefinedmarginLeft: Dimension | undefinedmarginRight: Dimension | undefinedmarginTop: Dimension | undefined+opacity: number | undefined+pointerEvents: number | undefinedposition: number | undefinedwidth: Dimension | undefined```@@ -7936,6 +7941,7 @@ enabled: booleanfillAmount: numberfillMethod: FillMethodfillOrigin: FillOrigin+fit: UIVisualFitmaterial: numbersliceBorder: Vec4texture: number@@ -7952,6 +7958,7 @@ enabled: boolean | undefinedfillAmount: number | undefinedfillMethod: FillMethod | undefinedfillOrigin: FillOrigin | undefined+fit: UIVisualFit | undefinedmaterial: number | undefinedsliceBorder: { x: number; y: number; z: number; w: number; } | undefinedtexture: number | undefineddiff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.mdindex ed5f07567..96867b4bc 100644--- a/sdk/etc/index.node.api.md+++ b/sdk/etc/index.node.api.md@@ -2313,9 +2313,11 @@ getResourceManager: () => CppResourceManagergetRigidBodyPtr: (registry: CppRegistry, entity: number) => numbergetSpritePtr: (registry: CppRegistry, entity: number) => numbergetTransformPtr: (registry: CppRegistry, entity: number) => number+getUINodeAlphaInTree: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeComputedHeight: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeComputedWidth: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeHiddenInTree: ((registry: CppRegistry, entity: number) => boolean) | undefined+getUINodePointerBlockedInTree: ((registry: CppRegistry, entity: number) => boolean) | undefinedgetVelocityPtr: (registry: CppRegistry, entity: number) => numbergl_checkErrors: (context: string) => numbergl_enableErrorCheck: (enabled: boolean) => void@@ -7664,6 +7666,7 @@ BuiltinComponentDef<UIMaskData>## UIMaskData — interface```+alphaCutoff: numberenabled: booleanmode: MaskMode```@@ -7695,6 +7698,8 @@ marginBottom: Dimension | undefinedmarginLeft: Dimension | undefinedmarginRight: Dimension | undefinedmarginTop: Dimension | undefined+opacity: number | undefined+pointerEvents: number | undefinedposition: number | undefinedwidth: Dimension | undefined```@@ -7767,6 +7772,7 @@ enabled: booleanfillAmount: numberfillMethod: FillMethodfillOrigin: FillOrigin+fit: UIVisualFitmaterial: numbersliceBorder: Vec4texture: number@@ -7783,6 +7789,7 @@ enabled: boolean | undefinedfillAmount: number | undefinedfillMethod: FillMethod | undefinedfillOrigin: FillOrigin | undefined+fit: UIVisualFit | undefinedmaterial: number | undefinedsliceBorder: { x: number; y: number; z: number; w: number; } | undefinedtexture: number | undefineddiff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.mdindex e524ef8e8..eb4085e9e 100644--- a/sdk/etc/minigame.api.md+++ b/sdk/etc/minigame.api.md@@ -2313,9 +2313,11 @@ getResourceManager: () => CppResourceManagergetRigidBodyPtr: (registry: CppRegistry, entity: number) => numbergetSpritePtr: (registry: CppRegistry, entity: number) => numbergetTransformPtr: (registry: CppRegistry, entity: number) => number+getUINodeAlphaInTree: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeComputedHeight: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeComputedWidth: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeHiddenInTree: ((registry: CppRegistry, entity: number) => boolean) | undefined+getUINodePointerBlockedInTree: ((registry: CppRegistry, entity: number) => boolean) | undefinedgetVelocityPtr: (registry: CppRegistry, entity: number) => numbergl_checkErrors: (context: string) => numbergl_enableErrorCheck: (enabled: boolean) => void@@ -7879,6 +7881,7 @@ BuiltinComponentDef<UIMaskData>## UIMaskData — interface```+alphaCutoff: numberenabled: booleanmode: MaskMode```@@ -7910,6 +7913,8 @@ marginBottom: Dimension | undefinedmarginLeft: Dimension | undefinedmarginRight: Dimension | undefinedmarginTop: Dimension | undefined+opacity: number | undefined+pointerEvents: number | undefinedposition: number | undefinedwidth: Dimension | undefined```@@ -7982,6 +7987,7 @@ enabled: booleanfillAmount: numberfillMethod: FillMethodfillOrigin: FillOrigin+fit: UIVisualFitmaterial: numbersliceBorder: Vec4texture: number@@ -7998,6 +8004,7 @@ enabled: boolean | undefinedfillAmount: number | undefinedfillMethod: FillMethod | undefinedfillOrigin: FillOrigin | undefined+fit: UIVisualFit | undefinedmaterial: number | undefinedsliceBorder: { x: number; y: number; z: number; w: number; } | undefinedtexture: number | undefineddiff --git a/sdk/etc/wasm.api.md b/sdk/etc/wasm.api.mdindex 5fd100c66..0e45d04ef 100644--- a/sdk/etc/wasm.api.md+++ b/sdk/etc/wasm.api.md@@ -226,9 +226,11 @@ getResourceManager: () => CppResourceManagergetRigidBodyPtr: (registry: CppRegistry, entity: number) => numbergetSpritePtr: (registry: CppRegistry, entity: number) => numbergetTransformPtr: (registry: CppRegistry, entity: number) => number+getUINodeAlphaInTree: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeComputedHeight: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeComputedWidth: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeHiddenInTree: ((registry: CppRegistry, entity: number) => boolean) | undefined+getUINodePointerBlockedInTree: ((registry: CppRegistry, entity: number) => boolean) | undefinedgetVelocityPtr: (registry: CppRegistry, entity: number) => numbergl_checkErrors: (context: string) => numbergl_enableErrorCheck: (enabled: boolean) => voiddiff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.mdindex 833cccbd4..014876a97 100644--- a/sdk/etc/wechat.api.md+++ b/sdk/etc/wechat.api.md@@ -2313,9 +2313,11 @@ getResourceManager: () => CppResourceManagergetRigidBodyPtr: (registry: CppRegistry, entity: number) => numbergetSpritePtr: (registry: CppRegistry, entity: number) => numbergetTransformPtr: (registry: CppRegistry, entity: number) => number+getUINodeAlphaInTree: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeComputedHeight: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeComputedWidth: ((registry: CppRegistry, entity: number) => number) | undefinedgetUINodeHiddenInTree: ((registry: CppRegistry, entity: number) => boolean) | undefined+getUINodePointerBlockedInTree: ((registry: CppRegistry, entity: number) => boolean) | undefinedgetVelocityPtr: (registry: CppRegistry, entity: number) => numbergl_checkErrors: (context: string) => numbergl_enableErrorCheck: (enabled: boolean) => void@@ -7671,6 +7673,7 @@ BuiltinComponentDef<UIMaskData>## UIMaskData — interface```+alphaCutoff: numberenabled: booleanmode: MaskMode```@@ -7702,6 +7705,8 @@ marginBottom: Dimension | undefinedmarginLeft: Dimension | undefinedmarginRight: Dimension | undefinedmarginTop: Dimension | undefined+opacity: number | undefined+pointerEvents: number | undefinedposition: number | undefinedwidth: Dimension | undefined```@@ -7774,6 +7779,7 @@ enabled: booleanfillAmount: numberfillMethod: FillMethodfillOrigin: FillOrigin+fit: UIVisualFitmaterial: numbersliceBorder: Vec4texture: number@@ -7790,6 +7796,7 @@ enabled: boolean | undefinedfillAmount: number | undefinedfillMethod: FillMethod | undefinedfillOrigin: FillOrigin | undefined+fit: UIVisualFit | undefinedmaterial: number | undefinedsliceBorder: { x: number; y: number; z: number; w: number; } | undefinedtexture: number | undefineddiff --git a/sdk/src/component.generated.ts b/sdk/src/component.generated.tsindex 100950d29..d8d9d2f6f 100644--- a/sdk/src/component.generated.ts+++ b/sdk/src/component.generated.ts@@ -15,7 +15,7 @@ import type { Dimension, Padding } from './wasm.generated';* getAbiLayoutHash(); BuiltinBridge.connect() compares them and refuses to* run on mismatch, because mismatched offsets read the wrong heap bytes.*/-export const ABI_LAYOUT_HASH = '9219dd764c94a81e';+export const ABI_LAYOUT_HASH = '52526b76662ebd4a';export interface AssetFieldMeta {field: string;@@ -709,6 +709,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {defaults: {enabled: true,mode: 0,+ alphaCutoff: 0,},assetFields: [],entityFields: [],@@ -716,12 +717,15 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {animatableFields: [],fields: {mode: { enum: [{ label: 'Scissor', value: 0 }, { label: 'Stencil', value: 1 }] },+ alphaCutoff: { tooltip: "Stencil only: above 0, clip to the mask sprite's shape instead of its box." },},},UINode: {defaults: {position: 0,display: 0,+ opacity: 1,+ pointerEvents: 0,width: { value: 0, unit: 2 },height: { value: 0, unit: 2 },minWidth: { value: 0, unit: 2 },@@ -748,6 +752,8 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {fields: {position: { enum: [{ label: 'Relative', value: 0 }, { label: 'Absolute', value: 1 }] },display: { enum: [{ label: 'Flex', value: 0 }, { label: 'None', value: 1 }], tooltip: "None removes this node and its whole subtree from layout, rendering and input." },+ opacity: { min: 0, max: 1, tooltip: "Subtree opacity, multiplied down the tree. Fades this node and everything under it." },+ pointerEvents: { enum: [{ label: 'Auto', value: 0 }, { label: 'None', value: 1 }], tooltip: "None makes this node and its subtree transparent to the pointer — hits pass through to what is behind." },alignSelf: { enum: [{ label: 'Auto', value: 0 }, { label: 'Start', value: 1 }, { label: 'Center', value: 2 }, { label: 'End', value: 3 }, { label: 'Stretch', value: 4 }] },},},@@ -756,6 +762,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {visualType: 0,texture: 0,color: { r: 1, g: 1, b: 1, a: 1 },+ fit: 0,uvOffset: { x: 0, y: 0 },uvScale: { x: 1, y: 1 },sliceBorder: { x: 0, y: 0, z: 0, w: 0 },@@ -772,6 +779,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {animatableFields: ['color.r', 'color.g', 'color.b', 'color.a', 'fillAmount'],fields: {visualType: { enum: [{ label: 'None', value: 0 }, { label: 'SolidColor', value: 1 }, { label: 'Image', value: 2 }, { label: 'NineSlice', value: 3 }, { label: 'Tiled', value: 4 }, { label: 'Filled', value: 5 }] },+ fit: { enum: [{ label: 'Fill', value: 0 }, { label: 'Contain', value: 1 }, { label: 'Cover', value: 2 }], tooltip: "How the image fits its box: Fill stretches, Contain letterboxes it whole, Cover fills and crops." },fillMethod: { enum: [{ label: 'Horizontal', value: 0 }, { label: 'Vertical', value: 1 }, { label: 'Radial360', value: 2 }, { label: 'Radial90', value: 3 }, { label: 'Radial180', value: 4 }] },fillOrigin: { enum: [{ label: 'Left', value: 0 }, { label: 'Right', value: 1 }, { label: 'Bottom', value: 2 }, { label: 'Top', value: 3 }] },},@@ -1122,11 +1130,14 @@ export interface UIInteractionData {export interface UIMaskData {enabled: boolean;mode: number;+ alphaCutoff: number;}export interface UINodeData {position: number;display: number;+ opacity: number;+ pointerEvents: number;width: Dimension;height: Dimension;minWidth: Dimension;@@ -1151,6 +1162,7 @@ export interface UIVisualData {visualType: number;texture: number;color: Color;+ fit: number;uvOffset: Vec2;uvScale: Vec2;sliceBorder: Vec4;diff --git a/sdk/src/ecs/nativeEngineApi.generated.ts b/sdk/src/ecs/nativeEngineApi.generated.tsindex 7ba641648..ac76610b5 100644--- a/sdk/src/ecs/nativeEngineApi.generated.ts+++ b/sdk/src/ecs/nativeEngineApi.generated.ts@@ -52,9 +52,11 @@ export interface NativeEngineApi {geometry_setIndices16?(handle: number, indicesPtr: number, indexCount: number): void;geometry_setIndices32?(handle: number, indicesPtr: number, indexCount: number): void;geometry_updateVertices?(handle: number, verticesPtr: number, vertexCount: number, offset: number): void;+ getUINodeAlphaInTree?(registry: unknown, entity: number): number;getUINodeComputedHeight?(registry: unknown, entity: number): number;getUINodeComputedWidth?(registry: unknown, entity: number): number;getUINodeHiddenInTree?(registry: unknown, entity: number): boolean;+ getUINodePointerBlockedInTree?(registry: unknown, entity: number): boolean;gl_checkErrors?(context: string): number;gl_enableErrorCheck?(enabled: boolean): void;material_compileEsshader?(source: string, featuresCsv: string): number;@@ -283,9 +285,11 @@ export function createNativeEngineApi(bind('geometry_setIndices16', 'es_geometry_setIndices16', false);bind('geometry_setIndices32', 'es_geometry_setIndices32', false);bind('geometry_updateVertices', 'es_geometry_updateVertices', false);+ bind('getUINodeAlphaInTree', 'es_getUINodeAlphaInTree', true);bind('getUINodeComputedHeight', 'es_getUINodeComputedHeight', true);bind('getUINodeComputedWidth', 'es_getUINodeComputedWidth', true);bind('getUINodeHiddenInTree', 'es_getUINodeHiddenInTree', true);+ bind('getUINodePointerBlockedInTree', 'es_getUINodePointerBlockedInTree', true);bind('gl_checkErrors', 'es_gl_checkErrors', false);bind('gl_enableErrorCheck', 'es_gl_enableErrorCheck', false);bind('material_compileEsshader', 'es_material_compileEsshader', false);diff --git a/sdk/src/ecs/ptrAccessors.generated.ts b/sdk/src/ecs/ptrAccessors.generated.tsindex 348ae4b7f..af367bda1 100644--- a/sdk/src/ecs/ptrAccessors.generated.ts+++ b/sdk/src/ecs/ptrAccessors.generated.ts@@ -1432,6 +1432,7 @@ export function createUIInteractionData(): UIInteractionPtrData {export interface UIMaskPtrData {enabled: boolean;mode: number;+ alphaCutoff: number;}export function fillUIMask(@@ -1440,6 +1441,7 @@ export function fillUIMask(): void {out.enabled = u8[ptr] !== 0;out.mode = u8[ptr + 1];+ out.alphaCutoff = f32[(ptr + 4) >> 2];}export function writeUIMask(@@ -1448,18 +1450,22 @@ export function writeUIMask(): void {u8[ptr] = data.enabled ? 1 : 0;u8[ptr + 1] = data.mode;+ f32[(ptr + 4) >> 2] = data.alphaCutoff;}export function createUIMaskData(): UIMaskPtrData {return {enabled: false,mode: 0,+ alphaCutoff: 0,};}export interface UINodePtrData {position: number;display: number;+ opacity: number;+ pointerEvents: number;width: { value: number; unit: number; };height: { value: number; unit: number; };minWidth: { value: number; unit: number; };@@ -1486,24 +1492,26 @@ export function fillUINode(): void {out.position = u8[ptr];out.display = u8[ptr + 1];- const width_ = out.width; width_.value = f32[(ptr + 4) >> 2]; width_.unit = u8[ptr + 8];- const height_ = out.height; height_.value = f32[(ptr + 12) >> 2]; height_.unit = u8[ptr + 16];- const minWidth_ = out.minWidth; minWidth_.value = f32[(ptr + 20) >> 2]; minWidth_.unit = u8[ptr + 24];- const minHeight_ = out.minHeight; minHeight_.value = f32[(ptr + 28) >> 2]; minHeight_.unit = u8[ptr + 32];- const maxWidth_ = out.maxWidth; maxWidth_.value = f32[(ptr + 36) >> 2]; maxWidth_.unit = u8[ptr + 40];- const maxHeight_ = out.maxHeight; maxHeight_.value = f32[(ptr + 44) >> 2]; maxHeight_.unit = u8[ptr + 48];- out.flexGrow = f32[(ptr + 52) >> 2];- out.flexShrink = f32[(ptr + 56) >> 2];- const flexBasis_ = out.flexBasis; flexBasis_.value = f32[(ptr + 60) >> 2]; flexBasis_.unit = u8[ptr + 64];- out.alignSelf = u8[ptr + 68];- const marginLeft_ = out.marginLeft; marginLeft_.value = f32[(ptr + 72) >> 2]; marginLeft_.unit = u8[ptr + 76];- const marginTop_ = out.marginTop; marginTop_.value = f32[(ptr + 80) >> 2]; marginTop_.unit = u8[ptr + 84];- const marginRight_ = out.marginRight; marginRight_.value = f32[(ptr + 88) >> 2]; marginRight_.unit = u8[ptr + 92];- const marginBottom_ = out.marginBottom; marginBottom_.value = f32[(ptr + 96) >> 2]; marginBottom_.unit = u8[ptr + 100];- const insetLeft_ = out.insetLeft; insetLeft_.value = f32[(ptr + 104) >> 2]; insetLeft_.unit = u8[ptr + 108];- const insetTop_ = out.insetTop; insetTop_.value = f32[(ptr + 112) >> 2]; insetTop_.unit = u8[ptr + 116];- const insetRight_ = out.insetRight; insetRight_.value = f32[(ptr + 120) >> 2]; insetRight_.unit = u8[ptr + 124];- const insetBottom_ = out.insetBottom; insetBottom_.value = f32[(ptr + 128) >> 2]; insetBottom_.unit = u8[ptr + 132];+ out.opacity = f32[(ptr + 4) >> 2];+ out.pointerEvents = u8[ptr + 8];+ const width_ = out.width; width_.value = f32[(ptr + 12) >> 2]; width_.unit = u8[ptr + 16];+ const height_ = out.height; height_.value = f32[(ptr + 20) >> 2]; height_.unit = u8[ptr + 24];+ const minWidth_ = out.minWidth; minWidth_.value = f32[(ptr + 28) >> 2]; minWidth_.unit = u8[ptr + 32];+ const minHeight_ = out.minHeight; minHeight_.value = f32[(ptr + 36) >> 2]; minHeight_.unit = u8[ptr + 40];+ const maxWidth_ = out.maxWidth; maxWidth_.value = f32[(ptr + 44) >> 2]; maxWidth_.unit = u8[ptr + 48];+ const maxHeight_ = out.maxHeight; maxHeight_.value = f32[(ptr + 52) >> 2]; maxHeight_.unit = u8[ptr + 56];+ out.flexGrow = f32[(ptr + 60) >> 2];+ out.flexShrink = f32[(ptr + 64) >> 2];+ const flexBasis_ = out.flexBasis; flexBasis_.value = f32[(ptr + 68) >> 2]; flexBasis_.unit = u8[ptr + 72];+ out.alignSelf = u8[ptr + 76];+ const marginLeft_ = out.marginLeft; marginLeft_.value = f32[(ptr + 80) >> 2]; marginLeft_.unit = u8[ptr + 84];+ const marginTop_ = out.marginTop; marginTop_.value = f32[(ptr + 88) >> 2]; marginTop_.unit = u8[ptr + 92];+ const marginRight_ = out.marginRight; marginRight_.value = f32[(ptr + 96) >> 2]; marginRight_.unit = u8[ptr + 100];+ const marginBottom_ = out.marginBottom; marginBottom_.value = f32[(ptr + 104) >> 2]; marginBottom_.unit = u8[ptr + 108];+ const insetLeft_ = out.insetLeft; insetLeft_.value = f32[(ptr + 112) >> 2]; insetLeft_.unit = u8[ptr + 116];+ const insetTop_ = out.insetTop; insetTop_.value = f32[(ptr + 120) >> 2]; insetTop_.unit = u8[ptr + 124];+ const insetRight_ = out.insetRight; insetRight_.value = f32[(ptr + 128) >> 2]; insetRight_.unit = u8[ptr + 132];+ const insetBottom_ = out.insetBottom; insetBottom_.value = f32[(ptr + 136) >> 2]; insetBottom_.unit = u8[ptr + 140];}export function writeUINode(@@ -1512,30 +1520,34 @@ export function writeUINode(): void {u8[ptr] = data.position;u8[ptr + 1] = data.display;- f32[(ptr + 4) >> 2] = data.width.value; u8[ptr + 8] = data.width.unit;- f32[(ptr + 12) >> 2] = data.height.value; u8[ptr + 16] = data.height.unit;- f32[(ptr + 20) >> 2] = data.minWidth.value; u8[ptr + 24] = data.minWidth.unit;- f32[(ptr + 28) >> 2] = data.minHeight.value; u8[ptr + 32] = data.minHeight.unit;- f32[(ptr + 36) >> 2] = data.maxWidth.value; u8[ptr + 40] = data.maxWidth.unit;- f32[(ptr + 44) >> 2] = data.maxHeight.value; u8[ptr + 48] = data.maxHeight.unit;- f32[(ptr + 52) >> 2] = data.flexGrow;- f32[(ptr + 56) >> 2] = data.flexShrink;- f32[(ptr + 60) >> 2] = data.flexBasis.value; u8[ptr + 64] = data.flexBasis.unit;- u8[ptr + 68] = data.alignSelf;- f32[(ptr + 72) >> 2] = data.marginLeft.value; u8[ptr + 76] = data.marginLeft.unit;- f32[(ptr + 80) >> 2] = data.marginTop.value; u8[ptr + 84] = data.marginTop.unit;- f32[(ptr + 88) >> 2] = data.marginRight.value; u8[ptr + 92] = data.marginRight.unit;- f32[(ptr + 96) >> 2] = data.marginBottom.value; u8[ptr + 100] = data.marginBottom.unit;- f32[(ptr + 104) >> 2] = data.insetLeft.value; u8[ptr + 108] = data.insetLeft.unit;- f32[(ptr + 112) >> 2] = data.insetTop.value; u8[ptr + 116] = data.insetTop.unit;- f32[(ptr + 120) >> 2] = data.insetRight.value; u8[ptr + 124] = data.insetRight.unit;- f32[(ptr + 128) >> 2] = data.insetBottom.value; u8[ptr + 132] = data.insetBottom.unit;+ f32[(ptr + 4) >> 2] = data.opacity;+ u8[ptr + 8] = data.pointerEvents;+ f32[(ptr + 12) >> 2] = data.width.value; u8[ptr + 16] = data.width.unit;+ f32[(ptr + 20) >> 2] = data.height.value; u8[ptr + 24] = data.height.unit;+ f32[(ptr + 28) >> 2] = data.minWidth.value; u8[ptr + 32] = data.minWidth.unit;+ f32[(ptr + 36) >> 2] = data.minHeight.value; u8[ptr + 40] = data.minHeight.unit;+ f32[(ptr + 44) >> 2] = data.maxWidth.value; u8[ptr + 48] = data.maxWidth.unit;+ f32[(ptr + 52) >> 2] = data.maxHeight.value; u8[ptr + 56] = data.maxHeight.unit;+ f32[(ptr + 60) >> 2] = data.flexGrow;+ f32[(ptr + 64) >> 2] = data.flexShrink;+ f32[(ptr + 68) >> 2] = data.flexBasis.value; u8[ptr + 72] = data.flexBasis.unit;+ u8[ptr + 76] = data.alignSelf;+ f32[(ptr + 80) >> 2] = data.marginLeft.value; u8[ptr + 84] = data.marginLeft.unit;+ f32[(ptr + 88) >> 2] = data.marginTop.value; u8[ptr + 92] = data.marginTop.unit;+ f32[(ptr + 96) >> 2] = data.marginRight.value; u8[ptr + 100] = data.marginRight.unit;+ f32[(ptr + 104) >> 2] = data.marginBottom.value; u8[ptr + 108] = data.marginBottom.unit;+ f32[(ptr + 112) >> 2] = data.insetLeft.value; u8[ptr + 116] = data.insetLeft.unit;+ f32[(ptr + 120) >> 2] = data.insetTop.value; u8[ptr + 124] = data.insetTop.unit;+ f32[(ptr + 128) >> 2] = data.insetRight.value; u8[ptr + 132] = data.insetRight.unit;+ f32[(ptr + 136) >> 2] = data.insetBottom.value; u8[ptr + 140] = data.insetBottom.unit;}export function createUINodeData(): UINodePtrData {return {position: 0,display: 0,+ opacity: 0,+ pointerEvents: 0,width: { value: 0, unit: 0 },height: { value: 0, unit: 0 },minWidth: { value: 0, unit: 0 },@@ -1561,6 +1573,7 @@ export interface UIVisualPtrData {visualType: number;texture: number;color: Color;+ fit: number;uvOffset: Vec2;uvScale: Vec2;sliceBorder: Vec4;@@ -1579,15 +1592,16 @@ export function fillUIVisual(out.visualType = u8[ptr];out.texture = u32[(ptr + 4) >> 2];const color_ = out.color; color_.r = f32[(ptr + 8) >> 2]; color_.g = f32[((ptr + 8) >> 2) + 1]; color_.b = f32[((ptr + 8) >> 2) + 2]; color_.a = f32[((ptr + 8) >> 2) + 3];- const uvOffset_ = out.uvOffset; uvOffset_.x = f32[(ptr + 24) >> 2]; uvOffset_.y = f32[((ptr + 24) >> 2) + 1];- const uvScale_ = out.uvScale; uvScale_.x = f32[(ptr + 32) >> 2]; uvScale_.y = f32[((ptr + 32) >> 2) + 1];- const sliceBorder_ = out.sliceBorder; sliceBorder_.x = f32[(ptr + 40) >> 2]; sliceBorder_.y = f32[((ptr + 40) >> 2) + 1]; sliceBorder_.z = f32[((ptr + 40) >> 2) + 2]; sliceBorder_.w = f32[((ptr + 40) >> 2) + 3];- const tileSize_ = out.tileSize; tileSize_.x = f32[(ptr + 56) >> 2]; tileSize_.y = f32[((ptr + 56) >> 2) + 1];- out.fillMethod = u8[ptr + 64];- out.fillOrigin = u8[ptr + 65];- out.fillAmount = f32[(ptr + 68) >> 2];- out.material = u32[(ptr + 72) >> 2];- out.enabled = u8[ptr + 76] !== 0;+ out.fit = u8[ptr + 24];+ const uvOffset_ = out.uvOffset; uvOffset_.x = f32[(ptr + 28) >> 2]; uvOffset_.y = f32[((ptr + 28) >> 2) + 1];+ const uvScale_ = out.uvScale; uvScale_.x = f32[(ptr + 36) >> 2]; uvScale_.y = f32[((ptr + 36) >> 2) + 1];+ const sliceBorder_ = out.sliceBorder; sliceBorder_.x = f32[(ptr + 44) >> 2]; sliceBorder_.y = f32[((ptr + 44) >> 2) + 1]; sliceBorder_.z = f32[((ptr + 44) >> 2) + 2]; sliceBorder_.w = f32[((ptr + 44) >> 2) + 3];+ const tileSize_ = out.tileSize; tileSize_.x = f32[(ptr + 60) >> 2]; tileSize_.y = f32[((ptr + 60) >> 2) + 1];+ out.fillMethod = u8[ptr + 68];+ out.fillOrigin = u8[ptr + 69];+ out.fillAmount = f32[(ptr + 72) >> 2];+ out.material = u32[(ptr + 76) >> 2];+ out.enabled = u8[ptr + 80] !== 0;}export function writeUIVisual(@@ -1597,15 +1611,16 @@ export function writeUIVisual(u8[ptr] = data.visualType;u32[(ptr + 4) >> 2] = data.texture;f32[(ptr + 8) >> 2] = data.color.r; f32[((ptr + 8) >> 2) + 1] = data.color.g; f32[((ptr + 8) >> 2) + 2] = data.color.b; f32[((ptr + 8) >> 2) + 3] = data.color.a;- f32[(ptr + 24) >> 2] = data.uvOffset.x; f32[((ptr + 24) >> 2) + 1] = data.uvOffset.y;- f32[(ptr + 32) >> 2] = data.uvScale.x; f32[((ptr + 32) >> 2) + 1] = data.uvScale.y;- f32[(ptr + 40) >> 2] = data.sliceBorder.x; f32[((ptr + 40) >> 2) + 1] = data.sliceBorder.y; f32[((ptr + 40) >> 2) + 2] = data.sliceBorder.z; f32[((ptr + 40) >> 2) + 3] = data.sliceBorder.w;- f32[(ptr + 56) >> 2] = data.tileSize.x; f32[((ptr + 56) >> 2) + 1] = data.tileSize.y;- u8[ptr + 64] = data.fillMethod;- u8[ptr + 65] = data.fillOrigin;- f32[(ptr + 68) >> 2] = data.fillAmount;- u32[(ptr + 72) >> 2] = data.material;- u8[ptr + 76] = data.enabled ? 1 : 0;+ u8[ptr + 24] = data.fit;+ f32[(ptr + 28) >> 2] = data.uvOffset.x; f32[((ptr + 28) >> 2) + 1] = data.uvOffset.y;+ f32[(ptr + 36) >> 2] = data.uvScale.x; f32[((ptr + 36) >> 2) + 1] = data.uvScale.y;+ f32[(ptr + 44) >> 2] = data.sliceBorder.x; f32[((ptr + 44) >> 2) + 1] = data.sliceBorder.y; f32[((ptr + 44) >> 2) + 2] = data.sliceBorder.z; f32[((ptr + 44) >> 2) + 3] = data.sliceBorder.w;+ f32[(ptr + 60) >> 2] = data.tileSize.x; f32[((ptr + 60) >> 2) + 1] = data.tileSize.y;+ u8[ptr + 68] = data.fillMethod;+ u8[ptr + 69] = data.fillOrigin;+ f32[(ptr + 72) >> 2] = data.fillAmount;+ u32[(ptr + 76) >> 2] = data.material;+ u8[ptr + 80] = data.enabled ? 1 : 0;}export function createUIVisualData(): UIVisualPtrData {@@ -1613,6 +1628,7 @@ export function createUIVisualData(): UIVisualPtrData {visualType: 0,texture: 0,color: { r: 0, g: 0, b: 0, a: 0 },+ fit: 0,uvOffset: { x: 0, y: 0 },uvScale: { x: 0, y: 0 },sliceBorder: { x: 0, y: 0, z: 0, w: 0 },diff --git a/sdk/src/ptrLayouts.generated.ts b/sdk/src/ptrLayouts.generated.tsindex 746747b2a..c05896d11 100644--- a/sdk/src/ptrLayouts.generated.ts+++ b/sdk/src/ptrLayouts.generated.ts@@ -387,6 +387,7 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {fields: [{ name: 'enabled', type: 'bool', offset: 0 },{ name: 'mode', type: 'u8', offset: 1 },+ { name: 'alphaCutoff', type: 'f32', offset: 4 },],},UINode: {@@ -394,24 +395,26 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {fields: [{ name: 'position', type: 'u8', offset: 0 },{ name: 'display', type: 'u8', offset: 1 },- { name: 'width', type: 'struct', offset: 4, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },- { name: 'height', type: 'struct', offset: 12, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },- { name: 'minWidth', type: 'struct', offset: 20, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },- { name: 'minHeight', type: 'struct', offset: 28, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },- { name: 'maxWidth', type: 'struct', offset: 36, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },- { name: 'maxHeight', type: 'struct', offset: 44, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },- { name: 'flexGrow', type: 'f32', offset: 52 },- { name: 'flexShrink', type: 'f32', offset: 56 },- { name: 'flexBasis', type: 'struct', offset: 60, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },- { name: 'alignSelf', type: 'u8', offset: 68 },- { name: 'marginLeft', type: 'struct', offset: 72, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },- { name: 'marginTop', type: 'struct', offset: 80, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },- { name: 'marginRight', type: 'struct', offset: 88, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },- { name: 'marginBottom', type: 'struct', offset: 96, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },- { name: 'insetLeft', type: 'struct', offset: 104, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },- { name: 'insetTop', type: 'struct', offset: 112, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },- { name: 'insetRight', type: 'struct', offset: 120, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },- { name: 'insetBottom', type: 'struct', offset: 128, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },+ { name: 'opacity', type: 'f32', offset: 4 },+ { name: 'pointerEvents', type: 'u8', offset: 8 },+ { name: 'width', type: 'struct', offset: 12, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },+ { name: 'height', type: 'struct', offset: 20, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },+ { name: 'minWidth', type: 'struct', offset: 28, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },+ { name: 'minHeight', type: 'struct', offset: 36, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },+ { name: 'maxWidth', type: 'struct', offset: 44, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },+ { name: 'maxHeight', type: 'struct', offset: 52, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },+ { name: 'flexGrow', type: 'f32', offset: 60 },+ { name: 'flexShrink', type: 'f32', offset: 64 },+ { name: 'flexBasis', type: 'struct', offset: 68, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },+ { name: 'alignSelf', type: 'u8', offset: 76 },+ { name: 'marginLeft', type: 'struct', offset: 80, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },+ { name: 'marginTop', type: 'struct', offset: 88, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },+ { name: 'marginRight', type: 'struct', offset: 96, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },+ { name: 'marginBottom', type: 'struct', offset: 104, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },+ { name: 'insetLeft', type: 'struct', offset: 112, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },+ { name: 'insetTop', type: 'struct', offset: 120, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },+ { name: 'insetRight', type: 'struct', offset: 128, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },+ { name: 'insetBottom', type: 'struct', offset: 136, members: [{ name: 'value', type: 'f32', offset: 0 }, { name: 'unit', type: 'u8', offset: 4 }] },],},UIVisual: {@@ -420,15 +423,16 @@ export const PTR_LAYOUTS: Record<string, PtrLayout> = {{ name: 'visualType', type: 'u8', offset: 0 },{ name: 'texture', type: 'u32', offset: 4 },{ name: 'color', type: 'color', offset: 8 },- { name: 'uvOffset', type: 'vec2', offset: 24 },- { name: 'uvScale', type: 'vec2', offset: 32 },- { name: 'sliceBorder', type: 'vec4', offset: 40 },- { name: 'tileSize', type: 'vec2', offset: 56 },- { name: 'fillMethod', type: 'u8', offset: 64 },- { name: 'fillOrigin', type: 'u8', offset: 65 },- { name: 'fillAmount', type: 'f32', offset: 68 },- { name: 'material', type: 'u32', offset: 72 },- { name: 'enabled', type: 'bool', offset: 76 },+ { name: 'fit', type: 'u8', offset: 24 },+ { name: 'uvOffset', type: 'vec2', offset: 28 },+ { name: 'uvScale', type: 'vec2', offset: 36 },+ { name: 'sliceBorder', type: 'vec4', offset: 44 },+ { name: 'tileSize', type: 'vec2', offset: 60 },+ { name: 'fillMethod', type: 'u8', offset: 68 },+ { name: 'fillOrigin', type: 'u8', offset: 69 },+ { name: 'fillAmount', type: 'f32', offset: 72 },+ { name: 'material', type: 'u32', offset: 76 },+ { name: 'enabled', type: 'bool', offset: 80 },],},Velocity: {diff --git a/sdk/src/ui/core/compose.ts b/sdk/src/ui/core/compose.tsindex 1af68c43f..ac585a750 100644--- a/sdk/src/ui/core/compose.ts+++ b/sdk/src/ui/core/compose.ts@@ -16,9 +16,9 @@ import {import type { Entity, Vec2 } from '../../types';import type { World } from '../../world';-import { UINode, UIPositionType, UIDisplay, type UINodeData } from './ui-node';+import { UINode, UIPositionType, UIDisplay, UIPointerEvents, type UINodeData } from './ui-node';import { px, auto, type Dimension } from './dimension';-import { UIVisual, UIVisualType, FillMethod, FillOrigin, type UIVisualData } from './ui-visual';+import { UIVisual, UIVisualType, UIVisualFit, FillMethod, FillOrigin, type UIVisualData } from './ui-visual';import { Text, TextAlign, TextVerticalAlign, TextRenderMode, type TextData } from './text';/** Identity Transform. Fresh object per call — safe to insert into ECS. */@@ -38,6 +38,10 @@ export interface UINodeInit {fill?: boolean;/** UIPositionType: Relative (flex flow) or Absolute (placed by inset). */position?: number;+ /** Subtree opacity (CSS `opacity`), multiplied down the tree. */+ opacity?: number;+ /** UIPointerEvents: None makes this node and its subtree click-through. */+ pointerEvents?: number;width?: Dimension;height?: Dimension;insetLeft?: Dimension;@@ -62,6 +66,8 @@ export function buildUINode(init: UINodeInit = {}): UINodeData {return {position: init.position ?? (fill ? UIPositionType.Absolute : UIPositionType.Relative),display: UIDisplay.Flex,+ opacity: init.opacity ?? 1,+ pointerEvents: init.pointerEvents ?? UIPointerEvents.Auto,width: init.width ?? auto(),height: init.height ?? auto(),minWidth: auto(),@@ -87,6 +93,8 @@ export interface UIVisualInit {visualType?: UIVisualType;texture?: number;color?: { r: number; g: number; b: number; a: number };+ /** CSS `object-fit` (UIVisualFit). Default Fill. */+ fit?: UIVisualFit;uvOffset?: Vec2;uvScale?: Vec2;sliceBorder?: { x: number; y: number; z: number; w: number };@@ -103,6 +111,7 @@ export function buildUIVisual(init: UIVisualInit = {}): UIVisualData {visualType: init.visualType ?? UIVisualType.SolidColor,texture: init.texture ?? 0,color: init.color ?? { r: 1, g: 1, b: 1, a: 1 },+ fit: init.fit ?? UIVisualFit.Fill,uvOffset: init.uvOffset ?? { x: 0, y: 0 },uvScale: init.uvScale ?? { x: 1, y: 1 },sliceBorder: init.sliceBorder ?? { x: 0, y: 0, z: 0, w: 0 },diff --git a/sdk/src/ui/core/ui-mask.ts b/sdk/src/ui/core/ui-mask.tsindex bc01f2037..662e154c3 100644--- a/sdk/src/ui/core/ui-mask.ts+++ b/sdk/src/ui/core/ui-mask.ts@@ -11,9 +11,13 @@ export type MaskMode = (typeof MaskMode)[keyof typeof MaskMode];export interface UIMaskData {enabled: boolean;mode: MaskMode;+ /** Stencil mode only: above 0, clip to the SHAPE the mask sprite draws+ * instead of to its box (0, the default, keeps the box). */+ alphaCutoff: number;}export const UIMask = defineBuiltin<UIMaskData>('UIMask', {enabled: true,mode: MaskMode.Scissor,+ alphaCutoff: 0,});diff --git a/sdk/src/ui/core/ui-node.ts b/sdk/src/ui/core/ui-node.tsindex c871d4318..0ac1052f1 100644--- a/sdk/src/ui/core/ui-node.ts+++ b/sdk/src/ui/core/ui-node.ts@@ -18,7 +18,7 @@ import { auto, px, type Dimension } from './dimension';// `inset` against the parent box — covers the old RectTransform anchor/stretch// cases) and per-item cross-axis alignment override. Both single-sourced from// the C++ ES_ENUMs via the generated module.-export { UIPositionType, UIDisplay, AlignSelf } from '../../wasm.generated';+export { UIPositionType, UIDisplay, UIPointerEvents, AlignSelf } from '../../wasm.generated';export interface UINodeData {/** Relative (flex flow) or Absolute (placed by inset). */@@ -27,6 +27,13 @@ export interface UINodeData {* from layout, rendering and hit-testing — the hierarchical show/hide.* Contrast with UIVisual.enabled, which hides only this entity's visual. */display: number;+ /** Subtree opacity, multiplied down the tree like CSS `opacity` — the knob+ * that fades a whole panel. Multiplies into each descendant's own alpha+ * rather than compositing the subtree offscreen. */+ opacity: number;+ /** CSS `pointer-events` (UIPointerEvents). None makes this node AND its+ * subtree transparent to the pointer: still drawn, hits pass through. */+ pointerEvents: number;/** Box size; `auto()` = content-/flex-driven. */width: Dimension;height: Dimension;@@ -57,6 +64,8 @@ export interface UINodeData {export const UINode = defineBuiltin<UINodeData>('UINode', {position: 0,display: 0,+ opacity: 1,+ pointerEvents: 0,width: auto(),height: auto(),minWidth: auto(),diff --git a/sdk/src/ui/core/ui-visual.ts b/sdk/src/ui/core/ui-visual.tsindex 11994eba4..14671b49d 100644--- a/sdk/src/ui/core/ui-visual.ts+++ b/sdk/src/ui/core/ui-visual.ts@@ -24,15 +24,20 @@ import type { Color, Vec2, Vec4 } from '../../types';// UIFillMethod/UIFillOrigin.import {UIVisualType,+ UIVisualFit,UIFillMethod as FillMethod,UIFillOrigin as FillOrigin,} from '../../wasm.generated';-export { UIVisualType, FillMethod, FillOrigin };+export { UIVisualType, UIVisualFit, FillMethod, FillOrigin };export interface UIVisualData {visualType: UIVisualType;texture: number;color: Color;+ /** CSS `object-fit`: Fill stretches to the box (default), Contain+ * letterboxes the whole image inside it, Cover fills the box and crops.+ * Ignored by NineSlice and Tiled, which exist to adapt to the box. */+ fit: UIVisualFit;/** Base UV sub-region offset (identity = whole texture). */uvOffset: Vec2;/** Base UV sub-region scale (identity = whole texture). */@@ -55,6 +60,7 @@ export const UIVisual = defineBuiltin<UIVisualData>('UIVisual', {visualType: UIVisualType.None,texture: 0,color: { r: 1, g: 1, b: 1, a: 1 },+ fit: UIVisualFit.Fill,uvOffset: { x: 0, y: 0 },uvScale: { x: 1, y: 1 },sliceBorder: { x: 0, y: 0, z: 0, w: 0 },diff --git a/sdk/src/ui/text/plugin.ts b/sdk/src/ui/text/plugin.tsindex b32bb072c..4f785011b 100644--- a/sdk/src/ui/text/plugin.ts+++ b/sdk/src/ui/text/plugin.ts@@ -112,6 +112,7 @@ export class TextPlugin implements Plugin {if (!t.content || t.enabled === false) continue;// display:none anywhere up the UI tree hides this text too.if (api?.getUINodeHiddenInTree?.(registry, entity)) continue;+ const groupAlpha = api?.getUINodeAlphaInTree?.(registry, entity) ?? 1;seen.add(entity as number);const tr = world.get(entity, Transform) as TransformData;@@ -173,7 +174,10 @@ export class TextPlugin implements Plugin {text: t.content,fontFamily: resolveTextFamily(t.font, t.fontFamily),fontSizePx: t.fontSize,- color: [t.color.r, t.color.g, t.color.b, t.color.a],+ // Subtree opacity (UINode.opacity) is resolved in C++ by the+ // layout pass; text is drawn here, so it multiplies the same+ // inherited alpha in and fades with its panel like visuals do.+ color: [t.color.r, t.color.g, t.color.b, t.color.a * groupAlpha],style,richText: t.richText,align: t.align,diff --git a/sdk/src/ui/widgets/prefabs/Button.esprefab b/sdk/src/ui/widgets/prefabs/Button.esprefabindex 89f271fd9..f64c45361 100644--- a/sdk/src/ui/widgets/prefabs/Button.esprefab+++ b/sdk/src/ui/widgets/prefabs/Button.esprefab@@ -53,6 +53,8 @@"data": {"position": 0,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 140,"unit": 0@@ -129,6 +131,7 @@"b": 1,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -294,6 +297,8 @@"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 0,"unit": 2diff --git a/sdk/src/ui/widgets/prefabs/Dialog.esprefab b/sdk/src/ui/widgets/prefabs/Dialog.esprefabindex d554151a5..a2922b06e 100644--- a/sdk/src/ui/widgets/prefabs/Dialog.esprefab+++ b/sdk/src/ui/widgets/prefabs/Dialog.esprefab@@ -53,6 +53,8 @@"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 0,"unit": 2@@ -129,6 +131,7 @@"b": 0,"a": 0.5},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -226,6 +229,8 @@"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 400,"unit": 0@@ -302,6 +307,7 @@"b": 0.18,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0diff --git a/sdk/src/ui/widgets/prefabs/Dropdown.esprefab b/sdk/src/ui/widgets/prefabs/Dropdown.esprefabindex 918d0f0d0..70d3b058f 100644--- a/sdk/src/ui/widgets/prefabs/Dropdown.esprefab+++ b/sdk/src/ui/widgets/prefabs/Dropdown.esprefab@@ -53,6 +53,8 @@"data": {"position": 0,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 150,"unit": 0@@ -129,6 +131,7 @@"b": 0.26,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -291,6 +294,8 @@"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 0,"unit": 2diff --git a/sdk/src/ui/widgets/prefabs/ListView.esprefab b/sdk/src/ui/widgets/prefabs/ListView.esprefabindex b48a805f5..250e34456 100644--- a/sdk/src/ui/widgets/prefabs/ListView.esprefab+++ b/sdk/src/ui/widgets/prefabs/ListView.esprefab@@ -53,6 +53,8 @@"data": {"position": 0,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 240,"unit": 0@@ -129,6 +131,7 @@"b": 0.26,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -226,6 +229,8 @@"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 0,"unit": 2diff --git a/sdk/src/ui/widgets/prefabs/Progress.esprefab b/sdk/src/ui/widgets/prefabs/Progress.esprefabindex 9a8441f54..f3ec29244 100644--- a/sdk/src/ui/widgets/prefabs/Progress.esprefab+++ b/sdk/src/ui/widgets/prefabs/Progress.esprefab@@ -53,6 +53,8 @@"data": {"position": 0,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 200,"unit": 0@@ -129,6 +131,7 @@"b": 0.15,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -211,6 +214,8 @@"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 0,"unit": 2@@ -287,6 +292,7 @@"b": 0.96,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0diff --git a/sdk/src/ui/widgets/prefabs/ScrollView.esprefab b/sdk/src/ui/widgets/prefabs/ScrollView.esprefabindex 6803a68ea..058efa45b 100644--- a/sdk/src/ui/widgets/prefabs/ScrollView.esprefab+++ b/sdk/src/ui/widgets/prefabs/ScrollView.esprefab@@ -53,6 +53,8 @@"data": {"position": 0,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 240,"unit": 0@@ -129,6 +131,7 @@"b": 0.26,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -226,6 +229,8 @@"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 240,"unit": 0diff --git a/sdk/src/ui/widgets/prefabs/Slider.esprefab b/sdk/src/ui/widgets/prefabs/Slider.esprefabindex f15fa8f4c..98f19dc79 100644--- a/sdk/src/ui/widgets/prefabs/Slider.esprefab+++ b/sdk/src/ui/widgets/prefabs/Slider.esprefab@@ -54,6 +54,8 @@"data": {"position": 0,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 200,"unit": 0@@ -130,6 +132,7 @@"b": 0.15,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -238,6 +241,8 @@"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 14,"unit": 0@@ -314,6 +319,7 @@"b": 1,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -396,6 +402,8 @@"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 0,"unit": 2@@ -472,6 +480,7 @@"b": 0.96,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0diff --git a/sdk/src/ui/widgets/prefabs/TextInput.esprefab b/sdk/src/ui/widgets/prefabs/TextInput.esprefabindex 2752bf2cd..2ded4a11e 100644--- a/sdk/src/ui/widgets/prefabs/TextInput.esprefab+++ b/sdk/src/ui/widgets/prefabs/TextInput.esprefab@@ -51,6 +51,8 @@"data": {"position": 0,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 220,"unit": 0diff --git a/sdk/src/ui/widgets/prefabs/Toggle.esprefab b/sdk/src/ui/widgets/prefabs/Toggle.esprefabindex 027eb29b5..9a18bbfd5 100644--- a/sdk/src/ui/widgets/prefabs/Toggle.esprefab+++ b/sdk/src/ui/widgets/prefabs/Toggle.esprefab@@ -53,6 +53,8 @@"data": {"position": 0,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 28,"unit": 0@@ -129,6 +131,7 @@"b": 1,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -301,6 +304,8 @@"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 0,"unit": 2@@ -377,6 +382,7 @@"b": 0.96,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0diff --git a/sdk/src/ui/widgets/prefabs/generated.ts b/sdk/src/ui/widgets/prefabs/generated.tsindex 00794679d..78660d20f 100644--- a/sdk/src/ui/widgets/prefabs/generated.ts+++ b/sdk/src/ui/widgets/prefabs/generated.ts@@ -57,6 +57,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 0,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 140,"unit": 0@@ -133,6 +135,7 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"b": 1,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -298,6 +301,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 0,"unit": 2@@ -471,6 +476,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 0,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 28,"unit": 0@@ -547,6 +554,7 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"b": 1,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -719,6 +727,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 0,"unit": 2@@ -795,6 +805,7 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"b": 0.96,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -887,6 +898,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 0,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 200,"unit": 0@@ -963,6 +976,7 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"b": 0.15,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -1071,6 +1085,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 14,"unit": 0@@ -1147,6 +1163,7 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"b": 1,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -1229,6 +1246,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 0,"unit": 2@@ -1305,6 +1324,7 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"b": 0.96,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -1396,6 +1416,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 0,"unit": 2@@ -1472,6 +1494,7 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"b": 0,"a": 0.5},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -1569,6 +1592,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 400,"unit": 0@@ -1645,6 +1670,7 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"b": 0.18,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -1742,6 +1768,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 0,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 220,"unit": 0@@ -1928,6 +1956,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 0,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 200,"unit": 0@@ -2004,6 +2034,7 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"b": 0.15,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -2086,6 +2117,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 0,"unit": 2@@ -2162,6 +2195,7 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"b": 0.96,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -2253,6 +2287,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 0,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 150,"unit": 0@@ -2329,6 +2365,7 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"b": 0.26,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -2491,6 +2528,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 0,"unit": 2@@ -2664,6 +2703,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 0,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 240,"unit": 0@@ -2740,6 +2781,7 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"b": 0.26,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -2837,6 +2879,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 0,"unit": 2@@ -3010,6 +3054,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 0,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 240,"unit": 0@@ -3086,6 +3132,7 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"b": 0.26,"a": 1},+ "fit": 0,"uvOffset": {"x": 0,"y": 0@@ -3183,6 +3230,8 @@ export const BUILTIN_UI_PREFABS: Record<string, PrefabData> = {"data": {"position": 1,"display": 0,+ "opacity": 1,+ "pointerEvents": 0,"width": {"value": 240,"unit": 0diff --git a/sdk/src/wasm.generated.ts b/sdk/src/wasm.generated.tsindex 39dc84743..7ca9a5dc2 100644--- a/sdk/src/wasm.generated.ts+++ b/sdk/src/wasm.generated.ts@@ -186,11 +186,22 @@ export enum UIFillOrigin {Top = 3,}+export enum UIPointerEvents {+ Auto = 0,+ None = 1,+}+export enum UIPositionType {Relative = 0,Absolute = 1,}+export enum UIVisualFit {+ Fill = 0,+ Contain = 1,+ Cover = 2,+}+export enum UIVisualType {None = 0,SolidColor = 1,@@ -531,11 +542,14 @@ export interface UIInteraction {export interface UIMask {enabled: boolean;mode: number;+ alphaCutoff: number;}export interface UINode {position: number;display: number;+ opacity: number;+ pointerEvents: number;width: Dimension;height: Dimension;minWidth: Dimension;@@ -560,6 +574,7 @@ export interface UIVisual {visualType: number;texture: number;color: Vec4;+ fit: number;uvOffset: Vec2;uvScale: Vec2;sliceBorder: Vec4;diff --git a/sdk/src/wasm.ts b/sdk/src/wasm.tsindex 13d0e6d9a..6133ff323 100644--- a/sdk/src/wasm.ts+++ b/sdk/src/wasm.ts@@ -435,6 +435,10 @@ export interface ESEngineModule {getUINodeComputedWidth?(registry: CppRegistry, entity: number): number;getUINodeComputedHeight?(registry: CppRegistry, entity: number): number;getUINodeHiddenInTree?(registry: CppRegistry, entity: number): boolean;+ /** Subtree opacity resolved by the layout pass (UINode.opacity multiplied down). */+ getUINodeAlphaInTree?(registry: CppRegistry, entity: number): number;+ /** True when this node or an ancestor set pointerEvents = None. */+ getUINodePointerBlockedInTree?(registry: CppRegistry, entity: number): boolean;uiTree_markStructureDirty(): void;uiTree_markDirty(entity: number): void;uiTree_markAllDirty(): void;diff --git a/sdk/tests/emscripten-wrapper.test.ts b/sdk/tests/emscripten-wrapper.test.tsindex 66016b2db..213902d75 100644--- a/sdk/tests/emscripten-wrapper.test.ts+++ b/sdk/tests/emscripten-wrapper.test.ts@@ -22,6 +22,8 @@ function fullNode(over: Partial<UINodeData> = {}): UINodeData {return {position: 0,display: 0,+ opacity: 1,+ pointerEvents: 0,width: auto(), height: auto(),minWidth: auto(), minHeight: auto(),maxWidth: auto(), maxHeight: auto(),diff --git a/src/esengine/bindings/EditorAPI.generated.cpp b/src/esengine/bindings/EditorAPI.generated.cppindex bcccfae5c..b3417fdfb 100644--- a/src/esengine/bindings/EditorAPI.generated.cpp+++ b/src/esengine/bindings/EditorAPI.generated.cpp@@ -2,10 +2,10 @@* @file EditorAPI.generated.cpp* @brief Auto-generated editor API with string-dispatched component access* @details Generated by EHT - DO NOT EDIT- * @schema_hash 56250acd973c90d3+ * @schema_hash ddbf982e6824a31b*/-#define ES_EDITOR_API_SCHEMA_HASH "56250acd973c90d3"+#define ES_EDITOR_API_SCHEMA_HASH "ddbf982e6824a31b"#include <emscripten/bind.h>#include <string>@@ -494,12 +494,15 @@ std::string editor_getComponentSchema(const std::string& name) {} else if (name == "UIMask") {return R"JSON([{"key":"enabled","type":"bool","group":"UIMask"},- {"key":"mode","type":"enum","group":"UIMask","values":["Scissor","Stencil"]}+ {"key":"mode","type":"enum","group":"UIMask","values":["Scissor","Stencil"]},+ {"key":"alphaCutoff","type":"float","group":"UIMask"}])JSON";} else if (name == "UINode") {return R"JSON([{"key":"position","type":"enum","group":"UINode","values":["Relative","Absolute"]},{"key":"display","type":"enum","group":"UINode","values":["Flex","None"]},+ {"key":"opacity","type":"float","group":"UINode"},+ {"key":"pointerEvents","type":"enum","group":"UINode","values":["Auto","None"]},{"key":"width.value","type":"float","group":"UINode"},{"key":"width.unit","type":"float","group":"UINode"},{"key":"height.value","type":"float","group":"UINode"},@@ -542,6 +545,7 @@ std::string editor_getComponentSchema(const std::string& name) {{"key":"color.g","type":"color","group":"UIVisual"},{"key":"color.b","type":"color","group":"UIVisual"},{"key":"color.a","type":"color","group":"UIVisual"},+ {"key":"fit","type":"enum","group":"UIVisual","values":["Fill","Contain","Cover"]},{"key":"uvOffset.x","type":"float","group":"UIVisual"},{"key":"uvOffset.y","type":"float","group":"UIVisual"},{"key":"uvScale.x","type":"float","group":"UIVisual"},@@ -1127,10 +1131,17 @@ bool editor_setFloat(Registry& reg, u32 e, const std::string& comp, const std::s}else { return false; }return true;+ } else if (comp == "UIMask") {+ if (!reg.has<esengine::ecs::UIMask>(entity)) return false;+ auto& c = reg.get<esengine::ecs::UIMask>(entity);+ if (field == "alphaCutoff") { c.alphaCutoff = value; }+ else { return false; }+ return true;} else if (comp == "UINode") {if (!reg.has<esengine::ecs::UINode>(entity)) return false;auto& c = reg.get<esengine::ecs::UINode>(entity);- if (field == "width.value") { c.width.value = value; }+ if (field == "opacity") { c.opacity = value; }+ else if (field == "width.value") { c.width.value = value; }else if (field == "width.unit") { c.width.unit = value; }else if (field == "height.value") { c.height.value = value; }else if (field == "height.unit") { c.height.unit = value; }@@ -1467,10 +1478,15 @@ f32 editor_getFloat(Registry& reg, u32 e, const std::string& comp, const std::stelse if (field == "rotation.x") { return quatToEulerDeg(c.rotation).x; }else if (field == "rotation.y") { return quatToEulerDeg(c.rotation).y; }else if (field == "rotation.z") { return quatToEulerDeg(c.rotation).z; }+ } else if (comp == "UIMask") {+ if (!reg.has<esengine::ecs::UIMask>(entity)) return 0.0f;+ const auto& c = reg.get<esengine::ecs::UIMask>(entity);+ if (field == "alphaCutoff") { return c.alphaCutoff; }} else if (comp == "UINode") {if (!reg.has<esengine::ecs::UINode>(entity)) return 0.0f;const auto& c = reg.get<esengine::ecs::UINode>(entity);- if (field == "width.value") { return c.width.value; }+ if (field == "opacity") { return c.opacity; }+ else if (field == "width.value") { return c.width.value; }else if (field == "width.unit") { return c.width.unit; }else if (field == "height.value") { return c.height.value; }else if (field == "height.unit") { return c.height.unit; }@@ -1712,6 +1728,7 @@ bool editor_setInt(Registry& reg, u32 e, const std::string& comp, const std::strauto& c = reg.get<esengine::ecs::UINode>(entity);if (field == "position") { c.position = static_cast<UIPositionType>(value); }else if (field == "display") { c.display = static_cast<UIDisplay>(value); }+ else if (field == "pointerEvents") { c.pointerEvents = static_cast<UIPointerEvents>(value); }else if (field == "alignSelf") { c.alignSelf = static_cast<AlignSelf>(value); }else { return false; }return true;@@ -1720,6 +1737,7 @@ bool editor_setInt(Registry& reg, u32 e, const std::string& comp, const std::strauto& c = reg.get<esengine::ecs::UIVisual>(entity);if (field == "visualType") { c.visualType = static_cast<UIVisualType>(value); }else if (field == "texture") { c.texture = resource::TextureHandle(static_cast<u32>(value)); }+ else if (field == "fit") { c.fit = static_cast<UIVisualFit>(value); }else if (field == "fillMethod") { c.fillMethod = static_cast<UIFillMethod>(value); }else if (field == "fillOrigin") { c.fillOrigin = static_cast<UIFillOrigin>(value); }else if (field == "material") { c.material = static_cast<u32>(value); }@@ -1866,12 +1884,14 @@ i32 editor_getInt(Registry& reg, u32 e, const std::string& comp, const std::striconst auto& c = reg.get<esengine::ecs::UINode>(entity);if (field == "position") { return static_cast<i32>(c.position); }else if (field == "display") { return static_cast<i32>(c.display); }+ else if (field == "pointerEvents") { return static_cast<i32>(c.pointerEvents); }else if (field == "alignSelf") { return static_cast<i32>(c.alignSelf); }} else if (comp == "UIVisual") {if (!reg.has<esengine::ecs::UIVisual>(entity)) return 0;const auto& c = reg.get<esengine::ecs::UIVisual>(entity);if (field == "visualType") { return static_cast<i32>(c.visualType); }else if (field == "texture") { return static_cast<i32>(c.texture.id()); }+ else if (field == "fit") { return static_cast<i32>(c.fit); }else if (field == "fillMethod") { return static_cast<i32>(c.fillMethod); }else if (field == "fillOrigin") { return static_cast<i32>(c.fillOrigin); }else if (field == "material") { return static_cast<i32>(c.material); }diff --git a/src/esengine/bindings/UIBindings.cpp b/src/esengine/bindings/UIBindings.cppindex 118cac364..0029b3c69 100644--- a/src/esengine/bindings/UIBindings.cpp+++ b/src/esengine/bindings/UIBindings.cpp@@ -108,6 +108,19 @@ bool getUINodeHiddenInTree(ecs::Registry& registry, u32 entity) {return node && node->hidden_in_tree_;}+// Subtree opacity / pointer gate, resolved by the layout pass. Same reason as+// the hidden bit: computed state is not embind-readable, and the TS text+// renderer + input router need it to behave like the C++ visuals do.+f32 getUINodeAlphaInTree(ecs::Registry& registry, u32 entity) {+ auto* node = registry.tryGet<ecs::UINode>(Entity::fromRaw(entity));+ return node ? node->alpha_in_tree_ : 1.0f;+}++bool getUINodePointerBlockedInTree(ecs::Registry& registry, u32 entity) {+ auto* node = registry.tryGet<ecs::UINode>(Entity::fromRaw(entity));+ return node && node->pointer_blocked_in_tree_;+}+f32 getUINodeComputedWidth(ecs::Registry& registry, u32 entity) {auto* node = registry.tryGet<ecs::UINode>(Entity::fromRaw(entity));if (!node) return 0.0f;diff --git a/src/esengine/bindings/UIBindings.hpp b/src/esengine/bindings/UIBindings.hppindex cb92ab84a..1262abf12 100644--- a/src/esengine/bindings/UIBindings.hpp+++ b/src/esengine/bindings/UIBindings.hpp@@ -54,6 +54,10 @@ void uiTree_markAllDirty();/** UINode computed state that is not embind-readable off the component. */bool getUINodeHiddenInTree(ecs::Registry& registry, u32 entity);+/** Subtree opacity resolved by the layout pass (UINode.opacity multiplied down). */+f32 getUINodeAlphaInTree(ecs::Registry& registry, u32 entity);+/** True when this node or an ancestor set pointerEvents = None. */+bool getUINodePointerBlockedInTree(ecs::Registry& registry, u32 entity);f32 getUINodeComputedWidth(ecs::Registry& registry, u32 entity);f32 getUINodeComputedHeight(ecs::Registry& registry, u32 entity);diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cppindex 4528c7879..e2a7321bd 100644--- a/src/esengine/bindings/WebBindings.generated.cpp+++ b/src/esengine/bindings/WebBindings.generated.cpp@@ -225,10 +225,19 @@ EMSCRIPTEN_BINDINGS(esengine_enums) {.value("Bottom", esengine::ecs::UIFillOrigin::Bottom).value("Top", esengine::ecs::UIFillOrigin::Top);+ enum_<esengine::ecs::UIPointerEvents>("UIPointerEvents")+ .value("Auto", esengine::ecs::UIPointerEvents::Auto)+ .value("None", esengine::ecs::UIPointerEvents::None);+enum_<esengine::ecs::UIPositionType>("UIPositionType").value("Relative", esengine::ecs::UIPositionType::Relative).value("Absolute", esengine::ecs::UIPositionType::Absolute);+ enum_<esengine::ecs::UIVisualFit>("UIVisualFit")+ .value("Fill", esengine::ecs::UIVisualFit::Fill)+ .value("Contain", esengine::ecs::UIVisualFit::Contain)+ .value("Cover", esengine::ecs::UIVisualFit::Cover);+enum_<esengine::ecs::UIVisualType>("UIVisualType").value("None", esengine::ecs::UIVisualType::None).value("SolidColor", esengine::ecs::UIVisualType::SolidColor)@@ -845,12 +854,14 @@ TrailRendererJS trailrendererToJS(const esengine::ecs::TrailRenderer& c) {struct UIMaskJS {bool enabled;i32 mode;+ f32 alphaCutoff;};esengine::ecs::UIMask uimaskFromJS(const UIMaskJS& js) {esengine::ecs::UIMask c;c.enabled = js.enabled;c.mode = static_cast<MaskMode>(js.mode);+ c.alphaCutoff = js.alphaCutoff;return c;}@@ -858,12 +869,15 @@ UIMaskJS uimaskToJS(const esengine::ecs::UIMask& c) {UIMaskJS js;js.enabled = c.enabled;js.mode = static_cast<i32>(c.mode);+ js.alphaCutoff = c.alphaCutoff;return js;}struct UINodeJS {i32 position;i32 display;+ f32 opacity;+ i32 pointerEvents;Dimension width;Dimension height;Dimension minWidth;@@ -888,6 +902,8 @@ esengine::ecs::UINode uinodeFromJS(const UINodeJS& js) {esengine::ecs::UINode c;c.position = static_cast<UIPositionType>(js.position);c.display = static_cast<UIDisplay>(js.display);+ c.opacity = js.opacity;+ c.pointerEvents = static_cast<UIPointerEvents>(js.pointerEvents);c.width = js.width;c.height = js.height;c.minWidth = js.minWidth;@@ -913,6 +929,8 @@ UINodeJS uinodeToJS(const esengine::ecs::UINode& c) {UINodeJS js;js.position = static_cast<i32>(c.position);js.display = static_cast<i32>(c.display);+ js.opacity = c.opacity;+ js.pointerEvents = static_cast<i32>(c.pointerEvents);js.width = c.width;js.height = c.height;js.minWidth = c.minWidth;@@ -938,6 +956,7 @@ struct UIVisualJS {i32 visualType;u32 texture;glm::vec4 color;+ i32 fit;glm::vec2 uvOffset;glm::vec2 uvScale;glm::vec4 sliceBorder;@@ -954,6 +973,7 @@ esengine::ecs::UIVisual uivisualFromJS(const UIVisualJS& js) {c.visualType = static_cast<UIVisualType>(js.visualType);c.texture = resource::TextureHandle(js.texture);c.color = js.color;+ c.fit = static_cast<UIVisualFit>(js.fit);c.uvOffset = js.uvOffset;c.uvScale = js.uvScale;c.sliceBorder = js.sliceBorder;@@ -971,6 +991,7 @@ UIVisualJS uivisualToJS(const esengine::ecs::UIVisual& c) {js.visualType = static_cast<i32>(c.visualType);js.texture = c.texture.id();js.color = c.color;+ js.fit = static_cast<i32>(c.fit);js.uvOffset = c.uvOffset;js.uvScale = c.uvScale;js.sliceBorder = c.sliceBorder;@@ -1289,11 +1310,14 @@ EMSCRIPTEN_BINDINGS(esengine_components) {value_object<UIMaskJS>("UIMask").field("enabled", &UIMaskJS::enabled)- .field("mode", &UIMaskJS::mode);+ .field("mode", &UIMaskJS::mode)+ .field("alphaCutoff", &UIMaskJS::alphaCutoff);value_object<UINodeJS>("UINode").field("position", &UINodeJS::position).field("display", &UINodeJS::display)+ .field("opacity", &UINodeJS::opacity)+ .field("pointerEvents", &UINodeJS::pointerEvents).field("width", &UINodeJS::width).field("height", &UINodeJS::height).field("minWidth", &UINodeJS::minWidth)@@ -1317,6 +1341,7 @@ EMSCRIPTEN_BINDINGS(esengine_components) {.field("visualType", &UIVisualJS::visualType).field("texture", &UIVisualJS::texture).field("color", &UIVisualJS::color)+ .field("fit", &UIVisualJS::fit).field("uvOffset", &UIVisualJS::uvOffset).field("uvScale", &UIVisualJS::uvScale).field("sliceBorder", &UIVisualJS::sliceBorder)@@ -2248,38 +2273,42 @@ static_assert(offsetof(esengine::ecs::UIInteraction, justPressed) == 2, "ABI offstatic_assert(offsetof(esengine::ecs::UIInteraction, justReleased) == 3, "ABI offset drift: esengine::ecs::UIInteraction.justReleased (EHT expected 3)");static_assert(offsetof(esengine::ecs::UIMask, enabled) == 0, "ABI offset drift: esengine::ecs::UIMask.enabled (EHT expected 0)");static_assert(offsetof(esengine::ecs::UIMask, mode) == 1, "ABI offset drift: esengine::ecs::UIMask.mode (EHT expected 1)");+static_assert(offsetof(esengine::ecs::UIMask, alphaCutoff) == 4, "ABI offset drift: esengine::ecs::UIMask.alphaCutoff (EHT expected 4)");static_assert(offsetof(esengine::ecs::UINode, position) == 0, "ABI offset drift: esengine::ecs::UINode.position (EHT expected 0)");static_assert(offsetof(esengine::ecs::UINode, display) == 1, "ABI offset drift: esengine::ecs::UINode.display (EHT expected 1)");-static_assert(offsetof(esengine::ecs::UINode, width) == 4, "ABI offset drift: esengine::ecs::UINode.width (EHT expected 4)");-static_assert(offsetof(esengine::ecs::UINode, height) == 12, "ABI offset drift: esengine::ecs::UINode.height (EHT expected 12)");-static_assert(offsetof(esengine::ecs::UINode, minWidth) == 20, "ABI offset drift: esengine::ecs::UINode.minWidth (EHT expected 20)");-static_assert(offsetof(esengine::ecs::UINode, minHeight) == 28, "ABI offset drift: esengine::ecs::UINode.minHeight (EHT expected 28)");-static_assert(offsetof(esengine::ecs::UINode, maxWidth) == 36, "ABI offset drift: esengine::ecs::UINode.maxWidth (EHT expected 36)");-static_assert(offsetof(esengine::ecs::UINode, maxHeight) == 44, "ABI offset drift: esengine::ecs::UINode.maxHeight (EHT expected 44)");-static_assert(offsetof(esengine::ecs::UINode, flexGrow) == 52, "ABI offset drift: esengine::ecs::UINode.flexGrow (EHT expected 52)");-static_assert(offsetof(esengine::ecs::UINode, flexShrink) == 56, "ABI offset drift: esengine::ecs::UINode.flexShrink (EHT expected 56)");-static_assert(offsetof(esengine::ecs::UINode, flexBasis) == 60, "ABI offset drift: esengine::ecs::UINode.flexBasis (EHT expected 60)");-static_assert(offsetof(esengine::ecs::UINode, alignSelf) == 68, "ABI offset drift: esengine::ecs::UINode.alignSelf (EHT expected 68)");-static_assert(offsetof(esengine::ecs::UINode, marginLeft) == 72, "ABI offset drift: esengine::ecs::UINode.marginLeft (EHT expected 72)");-static_assert(offsetof(esengine::ecs::UINode, marginTop) == 80, "ABI offset drift: esengine::ecs::UINode.marginTop (EHT expected 80)");-static_assert(offsetof(esengine::ecs::UINode, marginRight) == 88, "ABI offset drift: esengine::ecs::UINode.marginRight (EHT expected 88)");-static_assert(offsetof(esengine::ecs::UINode, marginBottom) == 96, "ABI offset drift: esengine::ecs::UINode.marginBottom (EHT expected 96)");-static_assert(offsetof(esengine::ecs::UINode, insetLeft) == 104, "ABI offset drift: esengine::ecs::UINode.insetLeft (EHT expected 104)");-static_assert(offsetof(esengine::ecs::UINode, insetTop) == 112, "ABI offset drift: esengine::ecs::UINode.insetTop (EHT expected 112)");-static_assert(offsetof(esengine::ecs::UINode, insetRight) == 120, "ABI offset drift: esengine::ecs::UINode.insetRight (EHT expected 120)");-static_assert(offsetof(esengine::ecs::UINode, insetBottom) == 128, "ABI offset drift: esengine::ecs::UINode.insetBottom (EHT expected 128)");+static_assert(offsetof(esengine::ecs::UINode, opacity) == 4, "ABI offset drift: esengine::ecs::UINode.opacity (EHT expected 4)");+static_assert(offsetof(esengine::ecs::UINode, pointerEvents) == 8, "ABI offset drift: esengine::ecs::UINode.pointerEvents (EHT expected 8)");+static_assert(offsetof(esengine::ecs::UINode, width) == 12, "ABI offset drift: esengine::ecs::UINode.width (EHT expected 12)");+static_assert(offsetof(esengine::ecs::UINode, height) == 20, "ABI offset drift: esengine::ecs::UINode.height (EHT expected 20)");+static_assert(offsetof(esengine::ecs::UINode, minWidth) == 28, "ABI offset drift: esengine::ecs::UINode.minWidth (EHT expected 28)");+static_assert(offsetof(esengine::ecs::UINode, minHeight) == 36, "ABI offset drift: esengine::ecs::UINode.minHeight (EHT expected 36)");+static_assert(offsetof(esengine::ecs::UINode, maxWidth) == 44, "ABI offset drift: esengine::ecs::UINode.maxWidth (EHT expected 44)");+static_assert(offsetof(esengine::ecs::UINode, maxHeight) == 52, "ABI offset drift: esengine::ecs::UINode.maxHeight (EHT expected 52)");+static_assert(offsetof(esengine::ecs::UINode, flexGrow) == 60, "ABI offset drift: esengine::ecs::UINode.flexGrow (EHT expected 60)");+static_assert(offsetof(esengine::ecs::UINode, flexShrink) == 64, "ABI offset drift: esengine::ecs::UINode.flexShrink (EHT expected 64)");+static_assert(offsetof(esengine::ecs::UINode, flexBasis) == 68, "ABI offset drift: esengine::ecs::UINode.flexBasis (EHT expected 68)");+static_assert(offsetof(esengine::ecs::UINode, alignSelf) == 76, "ABI offset drift: esengine::ecs::UINode.alignSelf (EHT expected 76)");+static_assert(offsetof(esengine::ecs::UINode, marginLeft) == 80, "ABI offset drift: esengine::ecs::UINode.marginLeft (EHT expected 80)");+static_assert(offsetof(esengine::ecs::UINode, marginTop) == 88, "ABI offset drift: esengine::ecs::UINode.marginTop (EHT expected 88)");+static_assert(offsetof(esengine::ecs::UINode, marginRight) == 96, "ABI offset drift: esengine::ecs::UINode.marginRight (EHT expected 96)");+static_assert(offsetof(esengine::ecs::UINode, marginBottom) == 104, "ABI offset drift: esengine::ecs::UINode.marginBottom (EHT expected 104)");+static_assert(offsetof(esengine::ecs::UINode, insetLeft) == 112, "ABI offset drift: esengine::ecs::UINode.insetLeft (EHT expected 112)");+static_assert(offsetof(esengine::ecs::UINode, insetTop) == 120, "ABI offset drift: esengine::ecs::UINode.insetTop (EHT expected 120)");+static_assert(offsetof(esengine::ecs::UINode, insetRight) == 128, "ABI offset drift: esengine::ecs::UINode.insetRight (EHT expected 128)");+static_assert(offsetof(esengine::ecs::UINode, insetBottom) == 136, "ABI offset drift: esengine::ecs::UINode.insetBottom (EHT expected 136)");static_assert(offsetof(esengine::ecs::UIVisual, visualType) == 0, "ABI offset drift: esengine::ecs::UIVisual.visualType (EHT expected 0)");static_assert(offsetof(esengine::ecs::UIVisual, texture) == 4, "ABI offset drift: esengine::ecs::UIVisual.texture (EHT expected 4)");static_assert(offsetof(esengine::ecs::UIVisual, color) == 8, "ABI offset drift: esengine::ecs::UIVisual.color (EHT expected 8)");-static_assert(offsetof(esengine::ecs::UIVisual, uvOffset) == 24, "ABI offset drift: esengine::ecs::UIVisual.uvOffset (EHT expected 24)");-static_assert(offsetof(esengine::ecs::UIVisual, uvScale) == 32, "ABI offset drift: esengine::ecs::UIVisual.uvScale (EHT expected 32)");-static_assert(offsetof(esengine::ecs::UIVisual, sliceBorder) == 40, "ABI offset drift: esengine::ecs::UIVisual.sliceBorder (EHT expected 40)");-static_assert(offsetof(esengine::ecs::UIVisual, tileSize) == 56, "ABI offset drift: esengine::ecs::UIVisual.tileSize (EHT expected 56)");-static_assert(offsetof(esengine::ecs::UIVisual, fillMethod) == 64, "ABI offset drift: esengine::ecs::UIVisual.fillMethod (EHT expected 64)");-static_assert(offsetof(esengine::ecs::UIVisual, fillOrigin) == 65, "ABI offset drift: esengine::ecs::UIVisual.fillOrigin (EHT expected 65)");-static_assert(offsetof(esengine::ecs::UIVisual, fillAmount) == 68, "ABI offset drift: esengine::ecs::UIVisual.fillAmount (EHT expected 68)");-static_assert(offsetof(esengine::ecs::UIVisual, material) == 72, "ABI offset drift: esengine::ecs::UIVisual.material (EHT expected 72)");-static_assert(offsetof(esengine::ecs::UIVisual, enabled) == 76, "ABI offset drift: esengine::ecs::UIVisual.enabled (EHT expected 76)");+static_assert(offsetof(esengine::ecs::UIVisual, fit) == 24, "ABI offset drift: esengine::ecs::UIVisual.fit (EHT expected 24)");+static_assert(offsetof(esengine::ecs::UIVisual, uvOffset) == 28, "ABI offset drift: esengine::ecs::UIVisual.uvOffset (EHT expected 28)");+static_assert(offsetof(esengine::ecs::UIVisual, uvScale) == 36, "ABI offset drift: esengine::ecs::UIVisual.uvScale (EHT expected 36)");+static_assert(offsetof(esengine::ecs::UIVisual, sliceBorder) == 44, "ABI offset drift: esengine::ecs::UIVisual.sliceBorder (EHT expected 44)");+static_assert(offsetof(esengine::ecs::UIVisual, tileSize) == 60, "ABI offset drift: esengine::ecs::UIVisual.tileSize (EHT expected 60)");+static_assert(offsetof(esengine::ecs::UIVisual, fillMethod) == 68, "ABI offset drift: esengine::ecs::UIVisual.fillMethod (EHT expected 68)");+static_assert(offsetof(esengine::ecs::UIVisual, fillOrigin) == 69, "ABI offset drift: esengine::ecs::UIVisual.fillOrigin (EHT expected 69)");+static_assert(offsetof(esengine::ecs::UIVisual, fillAmount) == 72, "ABI offset drift: esengine::ecs::UIVisual.fillAmount (EHT expected 72)");+static_assert(offsetof(esengine::ecs::UIVisual, material) == 76, "ABI offset drift: esengine::ecs::UIVisual.material (EHT expected 76)");+static_assert(offsetof(esengine::ecs::UIVisual, enabled) == 80, "ABI offset drift: esengine::ecs::UIVisual.enabled (EHT expected 80)");static_assert(offsetof(esengine::ecs::Velocity, linear) == 0, "ABI offset drift: esengine::ecs::Velocity.linear (EHT expected 0)");static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drift: esengine::ecs::Velocity.angular (EHT expected 12)");@@ -2288,7 +2317,7 @@ static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drif// ABI Hash -- runtime handshake against the SDK bundle// =============================================================================-static const char* kEsAbiLayoutHash = "9219dd764c94a81e";+static const char* kEsAbiLayoutHash = "52526b76662ebd4a";std::string esengineGetAbiLayoutHash() {return std::string(kEsAbiLayoutHash);diff --git a/src/esengine/bindings/WebSDKEntry.cpp b/src/esengine/bindings/WebSDKEntry.cppindex baa0acbb9..4155323b9 100644--- a/src/esengine/bindings/WebSDKEntry.cpp+++ b/src/esengine/bindings/WebSDKEntry.cpp@@ -585,6 +585,8 @@ EMSCRIPTEN_BINDINGS(esengine_ui_systems) {emscripten::function("ui_getRenderOrder", &esengine::ui_getRenderOrder);emscripten::function("uiFlexLayout_update", &esengine::uiFlexLayout_update);emscripten::function("getUINodeHiddenInTree", &esengine::getUINodeHiddenInTree);+ emscripten::function("getUINodeAlphaInTree", &esengine::getUINodeAlphaInTree);+ emscripten::function("getUINodePointerBlockedInTree", &esengine::getUINodePointerBlockedInTree);emscripten::function("getUINodeComputedWidth", &esengine::getUINodeComputedWidth);emscripten::function("getUINodeComputedHeight", &esengine::getUINodeComputedHeight);emscripten::function("uiTree_markStructureDirty", &esengine::uiTree_markStructureDirty);diff --git a/src/esengine/data/shaders/batch.esshader b/src/esengine/data/shaders/batch.esshaderindex 3e67af3ef..4ca11d0aa 100644--- a/src/esengine/data/shaders/batch.esshader+++ b/src/esengine/data/shaders/batch.esshader@@ -10,6 +10,13 @@// Lit2D-domain shader, so applyLighting2D + LightConstants are injected.#pragma feature LIT+// Compile-time variant: discard fragments the sprite draws as (near-)transparent.+// Selected for a STENCIL MASK draw, which runs this shader with color writes off:+// without the discard every transparent corner of the quad still writes stencil,+// so a circular mask sprite would clip a rectangle. Off for ordinary sprites, so+// they keep an unconditional (early-Z friendly) fragment path.+#pragma feature ALPHA_CLIP+#pragma vertexlayout(location = 0) in vec2 a_position;layout(location = 1) in vec4 a_color;@@ -87,6 +94,12 @@ void main() {vec4 base = texColor * tint;fragColor = vec4(applyLighting2D(base.rgb, vec3(0.0, 0.0, 1.0), v_worldPos), base.a);#else+ #ifdef ALPHA_CLIP+ // The SPRITE's alpha, not the tinted result: a mask graphic is routinely+ // tinted to near-zero alpha so it masks without being seen, and testing the+ // tinted value would discard the whole mask and clip everything away.+ if (texColor.a < 0.5) discard;+ #endiffragColor = texColor * tint;#endif}@@ -182,6 +195,10 @@ struct VSOut {let base = texColor * tint;return vec4f(applyLighting2D(base.rgb, vec3f(0.0, 0.0, 1.0), v.v_worldPos), base.a);#else+ #ifdef ALPHA_CLIP+ // See the GLSL stage: test the sprite's alpha, not the tinted result.+ if (texColor.a < 0.5) { discard; }+ #endifreturn texColor * tint;#endif}diff --git a/src/esengine/ecs/UILayoutSystem.cpp b/src/esengine/ecs/UILayoutSystem.cppindex c9b14acb2..58f2e03c7 100644--- a/src/esengine/ecs/UILayoutSystem.cpp+++ b/src/esengine/ecs/UILayoutSystem.cpp@@ -12,9 +12,14 @@#include <unordered_map>#include <unordered_set>#include <vector>+#include <algorithm>namespace esengine::ecs {+// Reused across frames so the per-frame inherited walk allocates nothing.+static std::vector<f32> inherited_alpha_stack_;+static std::vector<u8> inherited_block_stack_;+// Retained Yoga node cache: one YGNode per UI entity, kept alive across frames.// A stable UI tree reuses its allocations instead of YGNodeNew/FreeRecursive// every solve; entities that leave the tree are reaped. The hierarchy + style@@ -334,6 +339,41 @@ void propagateHiddenInTree(Registry& registry, UITree& tree) {}}+// Resolve opacity and pointer-events hierarchically over the same DFS-ordered+// tree: opacity multiplies down (CSS `opacity`), pointer-events latches off+// (CSS `pointer-events: none` on an ancestor is not overridable by a child).+// Rendering and hit-testing read the resulting UINode bits, so neither needs+// tree knowledge — the contract propagateHiddenInTree already established.+//+// `depth` is monotonic in DFS order, so one running stack indexed by depth+// carries each node's inherited value to its children without a second walk.+void propagateInheritedUIState(Registry& registry, UITree& tree) {+ auto& nodes = tree.nodes_;+ if (nodes.empty()) return;++ inherited_alpha_stack_.assign(nodes.size() + 1, 1.0f);+ inherited_block_stack_.assign(nodes.size() + 1, static_cast<u8>(0));++ for (usize i = 0; i < nodes.size(); ++i) {+ const u16 depth = nodes[i].depth;+ const f32 parentAlpha = depth == 0 ? 1.0f : inherited_alpha_stack_[depth - 1];+ const bool parentBlocked = depth == 0 ? false : inherited_block_stack_[depth - 1] != 0;++ auto* n = registry.tryGet<UINode>(nodes[i].entity);+ if (!n) {+ inherited_alpha_stack_[depth] = parentAlpha;+ inherited_block_stack_[depth] = static_cast<u8>(parentBlocked);+ continue;+ }+ const f32 alpha = parentAlpha * std::clamp(n->opacity, 0.0f, 1.0f);+ const bool blocked = parentBlocked || n->pointerEvents == UIPointerEvents::None;+ n->alpha_in_tree_ = alpha;+ n->pointer_blocked_in_tree_ = blocked;+ inherited_alpha_stack_[depth] = alpha;+ inherited_block_stack_[depth] = static_cast<u8>(blocked);+ }+}+// A tween drives Transform fields directly in C++ (TweenSystem), invisible to the// TS change-tracking that feeds tsPropertyDirty. Scan the UINode anim_override_// bits so the gate keeps solving while any tween is active — and, via the caller's@@ -417,6 +457,7 @@ void UISystem::layoutUpdate(}propagateHiddenInTree(registry, tree);+ propagateInheritedUIState(registry, tree);LayoutRect cameraRect{ camLeft, camBottom, camRight, camTop };unifiedLayoutPass(registry, tree, *layoutCache_, cameraRect);diff --git a/src/esengine/ecs/UISystem.cpp b/src/esengine/ecs/UISystem.cppindex 819b7c03b..18063bed1 100644--- a/src/esengine/ecs/UISystem.cpp+++ b/src/esengine/ecs/UISystem.cpp@@ -50,6 +50,9 @@ void UISystem::hitTestUpdate(// Hit geometry from the UINode (CSS box, pivot-centered).auto* node = registry.tryGet<UINode>(entity);if (!node || node->hidden_in_tree_) continue;+ // pointer-events: none on this node or any ancestor — still drawn, but+ // the pointer passes straight through to whatever is behind it.+ if (node->pointer_blocked_in_tree_) continue;f32 baseW = node->computed_size_.x;f32 baseH = node->computed_size_.y;f32 pivotX = 0.5f, pivotY = 0.5f;diff --git a/src/esengine/ecs/components/UIMask.hpp b/src/esengine/ecs/components/UIMask.hppindex 4e8b10065..766628ff2 100644--- a/src/esengine/ecs/components/UIMask.hpp+++ b/src/esengine/ecs/components/UIMask.hpp@@ -19,6 +19,17 @@ struct UIMask {bool enabled{true};ES_PROPERTY()MaskMode mode{MaskMode::Scissor};++ /**+ * Stencil mode only: clip to the SHAPE this node draws rather than to its+ * box. 0 (default) keeps the box — the mask's whole quad writes stencil,+ * which is what a plain rounded panel wants and what earlier scenes relied+ * on. Above 0, fragments whose alpha falls below the cutoff stop writing+ * stencil, so a circular sprite masks a circle (the Unity `Mask` behaviour+ * an avatar frame needs).+ */+ ES_PROPERTY(tooltip="Stencil only: above 0, clip to the mask sprite's shape instead of its box.")+ f32 alphaCutoff{0.0f};};} // namespace esengine::ecsdiff --git a/src/esengine/ecs/components/UINode.hpp b/src/esengine/ecs/components/UINode.hppindex 63e46bdb8..24bd90a25 100644--- a/src/esengine/ecs/components/UINode.hpp+++ b/src/esengine/ecs/components/UINode.hpp@@ -48,6 +48,19 @@ enum class UIDisplay : u8 {None};+/**+ * @brief CSS `pointer-events`. None makes the node AND its whole subtree+ * transparent to the pointer — still drawn, but hits pass straight+ * through to whatever is behind. The hierarchical input gate (a panel+ * mid-fade, a decorative overlay). Contrast with Interactable.enabled,+ * which silences one entity without letting hits through it.+ */+ES_ENUM()+enum class UIPointerEvents : u8 {+ Auto,+ None+};+/*** @brief UINode — the CSS box-model layout input (the CSS/Flex* primary layout model).@@ -71,6 +84,19 @@ struct UINode {ES_PROPERTY(tooltip="None removes this node and its whole subtree from layout, rendering and input.")UIDisplay display{UIDisplay::Flex};+ /**+ * Subtree opacity, multiplied down the tree like CSS `opacity` — the one+ * knob that fades a whole panel. It multiplies into each descendant's own+ * alpha (it does NOT composite the subtree offscreen first), so overlapping+ * children show through one another mid-fade; that is the cheap, universal+ * behaviour, and the same trade every UI toolkit's group-alpha makes.+ */+ ES_PROPERTY(min=0, max=1, tooltip="Subtree opacity, multiplied down the tree. Fades this node and everything under it.")+ f32 opacity{1.0f};++ ES_PROPERTY(tooltip="None makes this node and its subtree transparent to the pointer — hits pass through to what is behind.")+ UIPointerEvents pointerEvents{UIPointerEvents::Auto};+// Box size; auto = content-/flex-driven.ES_PROPERTY()Dimension width{0.0f, 2};@@ -125,6 +151,13 @@ struct UINode {// hit-testing so the whole subtree disappears from all three.bool hidden_in_tree_{false};+ // Computed (not serialized), same pass and same contract as hidden_in_tree_:+ // the product of this node's `opacity` and every ancestor's, and whether any+ // ancestor (or this node) turned pointer events off. Rendering multiplies the+ // first in; hit-testing skips on the second. Consumers stay tree-unaware.+ f32 alpha_in_tree_{1.0f};+ bool pointer_blocked_in_tree_{false};+// Set by the tween system for Transform fields it drives, so the layout pass// leaves those fields alone this frame (cleared each frame).u8 anim_override_{0};diff --git a/src/esengine/ecs/components/UIVisual.hpp b/src/esengine/ecs/components/UIVisual.hppindex 4e4d61d0b..4557bea79 100644--- a/src/esengine/ecs/components/UIVisual.hpp+++ b/src/esengine/ecs/components/UIVisual.hpp@@ -54,6 +54,21 @@ enum class UIFillOrigin : u8 {Top};+/**+ * @brief How the texture is fitted into the node's box — CSS `object-fit`.+ * Fill stretches to the box (the default, and what a 9-slice or a tiled+ * visual always wants). Contain scales the image down until it fits+ * WHOLE inside the box, letterboxing the remainder — the "don't squash+ * my artwork" mode. Cover scales up until the box is covered and crops+ * the overflow, so the box is filled with no distortion.+ */+ES_ENUM()+enum class UIVisualFit : u8 {+ Fill,+ Contain,+ Cover+};+/*** @brief UIVisual — the single UI visual component, merging the* former low-level UIRenderer (what the renderer drew) and high-level@@ -76,6 +91,11 @@ struct UIVisual {ES_PROPERTY(animatable)glm::vec4 color{1.0f, 1.0f, 1.0f, 1.0f};+ // How the texture fills the box. Ignored by NineSlice and Tiled, whose+ // whole point is to adapt to the box rather than preserve a ratio.+ ES_PROPERTY(tooltip="How the image fits its box: Fill stretches, Contain letterboxes it whole, Cover fills and crops.")+ UIVisualFit fit{UIVisualFit::Fill};+// Base sub-region (identity = whole texture); Tiled/Filled build on it.ES_PROPERTY()glm::vec2 uvOffset{0.0f, 0.0f};diff --git a/src/esengine/renderer/ShaderEmbeds.generated.hpp b/src/esengine/renderer/ShaderEmbeds.generated.hppindex 0b8aa0d14..66a186402 100644--- a/src/esengine/renderer/ShaderEmbeds.generated.hpp+++ b/src/esengine/renderer/ShaderEmbeds.generated.hpp@@ -14,6 +14,13 @@ inline constexpr const char* BATCH = R"esshader(#pragma shader "Batch"// Lit2D-domain shader, so applyLighting2D + LightConstants are injected.#pragma feature LIT+// Compile-time variant: discard fragments the sprite draws as (near-)transparent.+// Selected for a STENCIL MASK draw, which runs this shader with color writes off:+// without the discard every transparent corner of the quad still writes stencil,+// so a circular mask sprite would clip a rectangle. Off for ordinary sprites, so+// they keep an unconditional (early-Z friendly) fragment path.+#pragma feature ALPHA_CLIP+#pragma vertexlayout(location = 0) in vec2 a_position;layout(location = 1) in vec4 a_color;@@ -91,6 +98,12 @@ void main() {vec4 base = texColor * tint;fragColor = vec4(applyLighting2D(base.rgb, vec3(0.0, 0.0, 1.0), v_worldPos), base.a);#else+ #ifdef ALPHA_CLIP+ // The SPRITE's alpha, not the tinted result: a mask graphic is routinely+ // tinted to near-zero alpha so it masks without being seen, and testing the+ // tinted value would discard the whole mask and clip everything away.+ if (texColor.a < 0.5) discard;+ #endiffragColor = texColor * tint;#endif}@@ -186,6 +199,10 @@ struct VSOut {let base = texColor * tint;return vec4f(applyLighting2D(base.rgb, vec3f(0.0, 0.0, 1.0), v.v_worldPos), base.a);#else+ #ifdef ALPHA_CLIP+ // See the GLSL stage: test the sprite's alpha, not the tinted result.+ if (texColor.a < 0.5) { discard; }+ #endifreturn texColor * tint;#endif}diff --git a/src/esengine/renderer/plugins/UIElementPlugin.cpp b/src/esengine/renderer/plugins/UIElementPlugin.cppindex f7969c9f9..29a496fcb 100644--- a/src/esengine/renderer/plugins/UIElementPlugin.cpp+++ b/src/esengine/renderer/plugins/UIElementPlugin.cpp@@ -8,6 +8,7 @@#include "../../ecs/components/Transform.hpp"#include "../../ecs/components/UIVisual.hpp"#include "../../ecs/components/UINode.hpp"+#include "../../ecs/components/UIMask.hpp"#include <algorithm>#include <cmath>@@ -153,6 +154,33 @@ void UIElementPlugin::collect(RenderCollectContext& collect_ctx) {glm::vec2 finalSize = glm::vec2(w, h) * glm::vec2(scale);+ // object-fit. Contain shrinks the QUAD until the whole image fits (the+ // box keeps its layout size; the image just stops filling it), Cover+ // keeps the quad and crops the UV instead — so neither ever distorts the+ // artwork. NineSlice and Tiled opt out: adapting to the box IS their job,+ // and a ratio-preserving 9-slice is a contradiction.+ if (renderer.fit != ecs::UIVisualFit::Fill && !useNineSlice+ && renderer.visualType != ecs::UIVisualType::Tiled+ && texSize.x > 0.0f && texSize.y > 0.0f+ && finalSize.x > 0.0f && finalSize.y > 0.0f) {+ const f32 boxRatio = finalSize.x / finalSize.y;+ const f32 texRatio = texSize.x / texSize.y;+ if (renderer.fit == ecs::UIVisualFit::Contain) {+ if (texRatio > boxRatio) finalSize.y = finalSize.x / texRatio;+ else finalSize.x = finalSize.y * texRatio;+ } else { // Cover: crop the overflowing axis in UV space, centred.+ if (texRatio > boxRatio) {+ const f32 keep = boxRatio / texRatio; // fraction of width kept+ uvOffset.x += uvScale.x * (1.0f - keep) * 0.5f;+ uvScale.x *= keep;+ } else {+ const f32 keep = texRatio / boxRatio; // fraction of height kept+ uvOffset.y += uvScale.y * (1.0f - keep) * 0.5f;+ uvScale.y *= keep;+ }+ }+ }+const bool isRadialFill = renderer.visualType == ecs::UIVisualType::Filled&& isRadialMethod(renderer.fillMethod);@@ -200,6 +228,15 @@ void UIElementPlugin::collect(RenderCollectContext& collect_ctx) {.type = RenderType::UIElement,};+ // A stencil mask with a cutoff clips to the SHAPE it draws, not its box:+ // the mask pass runs this same draw with color writes off, so it needs+ // the variant that discards transparent fragments — otherwise the whole+ // quad writes stencil and a circular mask clips a rectangle.+ if (const auto* mask = registry.tryGet<ecs::UIMask>(entity);+ mask && mask->enabled && mask->mode == ecs::MaskMode::Stencil && mask->alphaCutoff > 0.0f) {+ key.shaderId = ctx.frame->batchProgram({"ALPHA_CLIP"});+ }+// Same resolution as SpritePlugin: an unregistered handle falls back to// the default batch shader, so a dangling material renders plainly.if (renderer.material != 0) {@@ -215,22 +252,28 @@ void UIElementPlugin::collect(RenderCollectContext& collect_ctx) {constexpr glm::vec2 CENTERED_PIVOT{0.5f, 0.5f};+ // Subtree opacity (UINode.opacity, resolved down the tree by the layout+ // pass) multiplies into this visual's own alpha — the CSS `opacity`+ // model, applied per-visual rather than by compositing the subtree.+ glm::vec4 color = renderer.color;+ color.a *= node->alpha_in_tree_;+if (isRadialFill) {f32 sweep = std::clamp(renderer.fillAmount, 0.0f, 1.0f)* radialMaxSweep(renderer.fillMethod);emitRadialFill(buffers, draw_list, clips,glm::vec2(position), finalSize, angle,radialStartAngle(renderer.fillOrigin), sweep,- uvOffset, uvScale, renderer.color, key);+ uvOffset, uvScale, color, key);} else if (useNineSlice) {emitNineSlice(buffers, draw_list, clips,glm::vec2(position), finalSize, CENTERED_PIVOT,angle, texSize, sliceBorder,- uvOffset, uvScale, renderer.color, key);+ uvOffset, uvScale, color, key);} else {emitQuad(buffers, draw_list, clips,glm::vec2(position), finalSize, CENTERED_PIVOT,- angle, uvOffset, uvScale, renderer.color, key);+ angle, uvOffset, uvScale, color, key);}}}