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
refactor(ui): canonicalize primitives in ui2/; ui/ files become shims
esenginee60d4b60822d
diff --git a/sdk/src/ui/Draggable.ts b/sdk/src/ui/Draggable.tsindex 02a5d1bef..eff408685 100644--- a/sdk/src/ui/Draggable.ts+++ b/sdk/src/ui/Draggable.ts@@ -1,37 +1,6 @@-import { defineComponent } from '../component';--export interface DraggableData {- enabled: boolean;- dragThreshold: number;- lockX: boolean;- lockY: boolean;- constraintMin: { x: number; y: number } | null;- constraintMax: { x: number; y: number } | null;-}--export const Draggable = defineComponent<DraggableData>('Draggable', {- enabled: true,- dragThreshold: 5,- lockX: false,- lockY: false,- constraintMin: null,- constraintMax: null,-});--export interface DragStateData {- isDragging: boolean;- startWorldPos: { x: number; y: number };- currentWorldPos: { x: number; y: number };- deltaWorld: { x: number; y: number };- totalDeltaWorld: { x: number; y: number };- pointerStartWorld: { x: number; y: number };-}--export const DragState = defineComponent<DragStateData>('DragState', {- isDragging: false,- startWorldPos: { x: 0, y: 0 },- currentWorldPos: { x: 0, y: 0 },- deltaWorld: { x: 0, y: 0 },- totalDeltaWorld: { x: 0, y: 0 },- pointerStartWorld: { x: 0, y: 0 },-});+export {+ Draggable,+ DragState,+ type DraggableData,+ type DragStateData,+} from '../ui2/behavior/draggable';diff --git a/sdk/src/ui/FlexContainer.ts b/sdk/src/ui/FlexContainer.tsindex 72b8c556c..e3ec70587 100644--- a/sdk/src/ui/FlexContainer.ts+++ b/sdk/src/ui/FlexContainer.ts@@ -1,38 +1,9 @@-import { defineBuiltin } from '../component';-import type { Vec2 } from '../types';-import type { Padding } from '../wasm.generated';--export const FlexDirection = { Row: 0, Column: 1, RowReverse: 2, ColumnReverse: 3 } as const;-export type FlexDirection = (typeof FlexDirection)[keyof typeof FlexDirection];--export const FlexWrap = { NoWrap: 0, Wrap: 1 } as const;-export type FlexWrap = (typeof FlexWrap)[keyof typeof FlexWrap];--export const JustifyContent = { Start: 0, Center: 1, End: 2, SpaceBetween: 3, SpaceAround: 4, SpaceEvenly: 5 } as const;-export type JustifyContent = (typeof JustifyContent)[keyof typeof JustifyContent];--export const AlignItems = { Start: 0, Center: 1, End: 2, Stretch: 3 } as const;-export type AlignItems = (typeof AlignItems)[keyof typeof AlignItems];--export const AlignContent = { Start: 0, Center: 1, End: 2, Stretch: 3, SpaceBetween: 4, SpaceAround: 5 } as const;-export type AlignContent = (typeof AlignContent)[keyof typeof AlignContent];--export interface FlexContainerData {- direction: FlexDirection;- wrap: FlexWrap;- justifyContent: JustifyContent;- alignItems: AlignItems;- alignContent: AlignContent;- gap: Vec2;- padding: Padding;-}--export const FlexContainer = defineBuiltin<FlexContainerData>('FlexContainer', {- direction: FlexDirection.Row,- wrap: FlexWrap.NoWrap,- justifyContent: JustifyContent.Start,- alignItems: AlignItems.Stretch,- alignContent: AlignContent.Start,- gap: { x: 0, y: 0 },- padding: { left: 0, top: 0, right: 0, bottom: 0 },-});+export {+ FlexContainer,+ FlexDirection,+ FlexWrap,+ JustifyContent,+ AlignItems,+ AlignContent,+ type FlexContainerData,+} from '../ui2/layout/flex';diff --git a/sdk/src/ui/FlexItem.ts b/sdk/src/ui/FlexItem.tsindex 0eb4c50a3..e5bbceff3 100644--- a/sdk/src/ui/FlexItem.ts+++ b/sdk/src/ui/FlexItem.ts@@ -1,35 +1,5 @@-import { defineBuiltin } from '../component';-import type { Padding } from '../wasm.generated';--export const AlignSelf = { Auto: 0, Start: 1, Center: 2, End: 3, Stretch: 4 } as const;-export type AlignSelf = (typeof AlignSelf)[keyof typeof AlignSelf];--export interface FlexItemData {- flexGrow: number;- flexShrink: number;- flexBasis: number;- order: number;- alignSelf: AlignSelf;- margin: Padding;- minWidth: number;- minHeight: number;- maxWidth: number;- maxHeight: number;- widthPercent: number;- heightPercent: number;-}--export const FlexItem = defineBuiltin<FlexItemData>('FlexItem', {- flexGrow: 0,- flexShrink: 1,- flexBasis: -1,- order: 0,- alignSelf: AlignSelf.Auto,- margin: { left: 0, top: 0, right: 0, bottom: 0 },- minWidth: -1,- minHeight: -1,- maxWidth: -1,- maxHeight: -1,- widthPercent: -1,- heightPercent: -1,-});+export {+ FlexItem,+ AlignSelf,+ type FlexItemData,+} from '../ui2/layout/flex';diff --git a/sdk/src/ui/Focusable.ts b/sdk/src/ui/Focusable.tsindex cf33609f7..6c1d564ec 100644--- a/sdk/src/ui/Focusable.ts+++ b/sdk/src/ui/Focusable.ts@@ -1,33 +1,6 @@-import { defineComponent } from '../component';-import { defineResource } from '../resource';-import type { Entity } from '../types';--export interface FocusableData {- tabIndex: number;- isFocused: boolean;-}--export const Focusable = defineComponent<FocusableData>('Focusable', {- tabIndex: 0,- isFocused: false,-});--export class FocusManagerState {- focusedEntity: Entity | null = null;-- focus(entity: Entity): Entity | null {- const prev = this.focusedEntity;- this.focusedEntity = entity;- return prev;- }-- blur(): Entity | null {- const prev = this.focusedEntity;- this.focusedEntity = null;- return prev;- }-}--export const FocusManager = defineResource<FocusManagerState>(- new FocusManagerState(), 'FocusManager'-);+export {+ Focusable,+ FocusManager,+ FocusManagerState,+ type FocusableData,+} from '../ui2/behavior/focusable';diff --git a/sdk/src/ui/Image.ts b/sdk/src/ui/Image.tsindex ef7312a69..fecd07139 100644--- a/sdk/src/ui/Image.ts+++ b/sdk/src/ui/Image.ts@@ -1,61 +1,7 @@-import { defineComponent } from '../component';-import type { Color } from '../types';-import { INVALID_TEXTURE } from '../types';--export const ImageType = {- Simple: 0,- Sliced: 1,- Tiled: 2,- Filled: 3,-} as const;--export type ImageType = (typeof ImageType)[keyof typeof ImageType];--export const FillMethod = {- Horizontal: 0,- Vertical: 1,-} as const;--export type FillMethod = (typeof FillMethod)[keyof typeof FillMethod];--export const FillOrigin = {- Left: 0,- Right: 1,- Bottom: 2,- Top: 3,-} as const;--export type FillOrigin = (typeof FillOrigin)[keyof typeof FillOrigin];--export interface ImageData {- texture: number;- color: Color;- imageType: number;- fillMethod: number;- fillOrigin: number;- fillAmount: number;- preserveAspect: boolean;- tileSize: { x: number; y: number };- layer: number;- material: number;- enabled: boolean;-}--export const Image = defineComponent<ImageData>('Image', {- texture: INVALID_TEXTURE,- color: { r: 1, g: 1, b: 1, a: 1 },- imageType: ImageType.Simple,- fillMethod: FillMethod.Horizontal,- fillOrigin: FillOrigin.Left,- fillAmount: 1,- preserveAspect: false,- tileSize: { x: 32, y: 32 },- layer: 0,- material: 0,- enabled: true,-}, {- assetFields: [- { field: 'texture', type: 'texture' },- { field: 'material', type: 'material' },- ],-});+export {+ Image,+ ImageType,+ FillMethod,+ FillOrigin,+ type ImageData,+} from '../ui2/core/image';diff --git a/sdk/src/ui/Interactable.ts b/sdk/src/ui/Interactable.tsindex 545ed302b..fbba1084f 100644--- a/sdk/src/ui/Interactable.ts+++ b/sdk/src/ui/Interactable.ts@@ -1,13 +1 @@-import { defineBuiltin } from '../component';--export interface InteractableData {- enabled: boolean;- blockRaycast: boolean;- raycastTarget: boolean;-}--export const Interactable = defineBuiltin<InteractableData>('Interactable', {- enabled: true,- blockRaycast: true,- raycastTarget: true,-});+export { Interactable, type InteractableData } from '../ui2/behavior/interactable';diff --git a/sdk/src/ui/UIInteraction.ts b/sdk/src/ui/UIInteraction.tsindex d68703175..5c1cac33f 100644--- a/sdk/src/ui/UIInteraction.ts+++ b/sdk/src/ui/UIInteraction.ts@@ -1,15 +1 @@-import { defineBuiltin } from '../component';--export interface UIInteractionData {- hovered: boolean;- pressed: boolean;- justPressed: boolean;- justReleased: boolean;-}--export const UIInteraction = defineBuiltin<UIInteractionData>('UIInteraction', {- hovered: false,- pressed: false,- justPressed: false,- justReleased: false,-});+export { UIInteraction, type UIInteractionData } from '../ui2/behavior/interactable';diff --git a/sdk/src/ui/UIMask.ts b/sdk/src/ui/UIMask.tsindex 1ce97cf21..655b67306 100644--- a/sdk/src/ui/UIMask.ts+++ b/sdk/src/ui/UIMask.ts@@ -1,22 +1 @@-import { defineBuiltin } from '../component';--export const MaskMode = {- Scissor: 0,- Stencil: 1,- Alpha: 2,-} as const;-export type MaskMode = (typeof MaskMode)[keyof typeof MaskMode];--export interface UIMaskData {- enabled: boolean;- mode: MaskMode;- maskTexture: number;- inverted: boolean;-}--export const UIMask = defineBuiltin<UIMaskData>('UIMask', {- enabled: true,- mode: MaskMode.Scissor,- maskTexture: 0,- inverted: false,-});+export { UIMask, MaskMode, type UIMaskData } from '../ui2/core/ui-mask';diff --git a/sdk/src/ui/UIRect.ts b/sdk/src/ui/UIRect.tsindex 1ddc18c93..e79247157 100644--- a/sdk/src/ui/UIRect.ts+++ b/sdk/src/ui/UIRect.ts@@ -1,20 +1 @@-import { defineBuiltin } from '../component';-import type { Vec2 } from '../types';--export interface UIRectData {- anchorMin: Vec2;- anchorMax: Vec2;- offsetMin: Vec2;- offsetMax: Vec2;- size: Vec2;- pivot: Vec2;-}--export const UIRect = defineBuiltin<UIRectData>('UIRect', {- anchorMin: { x: 0.5, y: 0.5 },- anchorMax: { x: 0.5, y: 0.5 },- offsetMin: { x: 0, y: 0 },- offsetMax: { x: 0, y: 0 },- size: { x: 100, y: 100 },- pivot: { x: 0.5, y: 0.5 },-});+export { UIRect, type UIRectData } from '../ui2/core/ui-rect';diff --git a/sdk/src/ui/UIRenderer.ts b/sdk/src/ui/UIRenderer.tsindex fe739bb31..8b015c3ce 100644--- a/sdk/src/ui/UIRenderer.ts+++ b/sdk/src/ui/UIRenderer.ts@@ -1,33 +1 @@-import { defineBuiltin } from '../component';-import type { Vec2, Vec4, Color } from '../types';--export const UIVisualType = {- None: 0,- SolidColor: 1,- Image: 2,- NineSlice: 3,-} as const;--export type UIVisualType = (typeof UIVisualType)[keyof typeof UIVisualType];--export interface UIRendererData {- visualType: UIVisualType;- texture: number;- color: Color;- uvOffset: Vec2;- uvScale: Vec2;- sliceBorder: Vec4;- material: number;- enabled: boolean;-}--export const UIRenderer = defineBuiltin<UIRendererData>('UIRenderer', {- visualType: UIVisualType.None,- texture: 0,- color: { r: 1, g: 1, b: 1, a: 1 },- uvOffset: { x: 0, y: 0 },- uvScale: { x: 1, y: 1 },- sliceBorder: { x: 0, y: 0, z: 0, w: 0 },- material: 0,- enabled: true,-});+export { UIRenderer, UIVisualType, type UIRendererData } from '../ui2/core/ui-renderer';diff --git a/sdk/src/ui/layouts/GridLayout.ts b/sdk/src/ui/layouts/GridLayout.tsindex b22bede56..a0792365d 100644--- a/sdk/src/ui/layouts/GridLayout.ts+++ b/sdk/src/ui/layouts/GridLayout.ts@@ -1,20 +1,5 @@-import { defineBuiltin } from '../../component';--export interface GridLayoutData {- direction: number; // 0=Vertical, 1=Horizontal- crossAxisCount: number;- itemSize: { x: number; y: number };- spacing: { x: number; y: number };-}--export const GridLayoutDirection = {- Vertical: 0,- Horizontal: 1,-} as const;--export const GridLayout = defineBuiltin<GridLayoutData>('GridLayout', {- direction: GridLayoutDirection.Vertical,- crossAxisCount: 3,- itemSize: { x: 100, y: 100 },- spacing: { x: 4, y: 4 },-});+export {+ GridLayout,+ GridLayoutDirection,+ type GridLayoutData,+} from '../../ui2/layout/grid';diff --git a/sdk/src/ui/text.ts b/sdk/src/ui/text.tsindex 63ccfa24a..b7b4de038 100644--- a/sdk/src/ui/text.ts+++ b/sdk/src/ui/text.ts@@ -1,68 +1,7 @@-import { defineComponent } from '../component';-import type { Color } from '../types';--export const TextAlign = {- Left: 0,- Center: 1,- Right: 2,-} as const;--export type TextAlign = (typeof TextAlign)[keyof typeof TextAlign];--export const TextVerticalAlign = {- Top: 0,- Middle: 1,- Bottom: 2,-} as const;--export type TextVerticalAlign = (typeof TextVerticalAlign)[keyof typeof TextVerticalAlign];--export const TextOverflow = {- Visible: 0,- Clip: 1,- Ellipsis: 2,-} as const;--export type TextOverflow = (typeof TextOverflow)[keyof typeof TextOverflow];--export interface TextData {- content: string;- fontFamily: string;- fontSize: number;- color: Color;- align: TextAlign;- verticalAlign: TextVerticalAlign;- wordWrap: boolean;- overflow: TextOverflow;- lineHeight: number;- bold: boolean;- italic: boolean;- strokeColor: Color;- strokeWidth: number;- shadowColor: Color;- shadowBlur: number;- shadowOffsetX: number;- shadowOffsetY: number;- richText: boolean;-}--export const Text = defineComponent<TextData>('Text', {- content: '',- fontFamily: 'Arial',- fontSize: 24,- color: { r: 1, g: 1, b: 1, a: 1 },- align: TextAlign.Left,- verticalAlign: TextVerticalAlign.Top,- wordWrap: true,- overflow: TextOverflow.Visible,- lineHeight: 1.2,- bold: false,- italic: false,- strokeColor: { r: 0, g: 0, b: 0, a: 1 },- strokeWidth: 0,- shadowColor: { r: 0, g: 0, b: 0, a: 1 },- shadowBlur: 0,- shadowOffsetX: 0,- shadowOffsetY: 0,- richText: false,-});+export {+ Text,+ TextAlign,+ TextVerticalAlign,+ TextOverflow,+ type TextData,+} from '../ui2/core/text';diff --git a/sdk/src/ui2/behavior/draggable.ts b/sdk/src/ui2/behavior/draggable.tsindex f8c7f206f..914d8b1ba 100644--- a/sdk/src/ui2/behavior/draggable.ts+++ b/sdk/src/ui2/behavior/draggable.ts@@ -1,6 +1,37 @@-export {- Draggable,- DragState,- type DraggableData,- type DragStateData,-} from '../../ui/Draggable';+import { defineComponent } from '../../component';++export interface DraggableData {+ enabled: boolean;+ dragThreshold: number;+ lockX: boolean;+ lockY: boolean;+ constraintMin: { x: number; y: number } | null;+ constraintMax: { x: number; y: number } | null;+}++export const Draggable = defineComponent<DraggableData>('Draggable', {+ enabled: true,+ dragThreshold: 5,+ lockX: false,+ lockY: false,+ constraintMin: null,+ constraintMax: null,+});++export interface DragStateData {+ isDragging: boolean;+ startWorldPos: { x: number; y: number };+ currentWorldPos: { x: number; y: number };+ deltaWorld: { x: number; y: number };+ totalDeltaWorld: { x: number; y: number };+ pointerStartWorld: { x: number; y: number };+}++export const DragState = defineComponent<DragStateData>('DragState', {+ isDragging: false,+ startWorldPos: { x: 0, y: 0 },+ currentWorldPos: { x: 0, y: 0 },+ deltaWorld: { x: 0, y: 0 },+ totalDeltaWorld: { x: 0, y: 0 },+ pointerStartWorld: { x: 0, y: 0 },+});diff --git a/sdk/src/ui2/behavior/focusable.ts b/sdk/src/ui2/behavior/focusable.tsindex 4aed82cb8..fc3ed47d6 100644--- a/sdk/src/ui2/behavior/focusable.ts+++ b/sdk/src/ui2/behavior/focusable.ts@@ -1,6 +1,33 @@-export {- Focusable,- FocusManager,- FocusManagerState,- type FocusableData,-} from '../../ui/Focusable';+import { defineComponent } from '../../component';+import { defineResource } from '../../resource';+import type { Entity } from '../../types';++export interface FocusableData {+ tabIndex: number;+ isFocused: boolean;+}++export const Focusable = defineComponent<FocusableData>('Focusable', {+ tabIndex: 0,+ isFocused: false,+});++export class FocusManagerState {+ focusedEntity: Entity | null = null;++ focus(entity: Entity): Entity | null {+ const prev = this.focusedEntity;+ this.focusedEntity = entity;+ return prev;+ }++ blur(): Entity | null {+ const prev = this.focusedEntity;+ this.focusedEntity = null;+ return prev;+ }+}++export const FocusManager = defineResource<FocusManagerState>(+ new FocusManagerState(), 'FocusManager'+);diff --git a/sdk/src/ui2/behavior/interactable.ts b/sdk/src/ui2/behavior/interactable.tsindex 18c078bb9..2d1a39f4a 100644--- a/sdk/src/ui2/behavior/interactable.ts+++ b/sdk/src/ui2/behavior/interactable.ts@@ -1,9 +1,27 @@-export {- Interactable,- type InteractableData,-} from '../../ui/Interactable';--export {- UIInteraction,- type UIInteractionData,-} from '../../ui/UIInteraction';+import { defineBuiltin } from '../../component';++export interface InteractableData {+ enabled: boolean;+ blockRaycast: boolean;+ raycastTarget: boolean;+}++export const Interactable = defineBuiltin<InteractableData>('Interactable', {+ enabled: true,+ blockRaycast: true,+ raycastTarget: true,+});++export interface UIInteractionData {+ hovered: boolean;+ pressed: boolean;+ justPressed: boolean;+ justReleased: boolean;+}++export const UIInteraction = defineBuiltin<UIInteractionData>('UIInteraction', {+ hovered: false,+ pressed: false,+ justPressed: false,+ justReleased: false,+});diff --git a/sdk/src/ui2/core/image.ts b/sdk/src/ui2/core/image.tsindex be31ecfd9..cb93cdf05 100644--- a/sdk/src/ui2/core/image.ts+++ b/sdk/src/ui2/core/image.ts@@ -1,7 +1,58 @@-export {- Image,- ImageType,- FillMethod,- FillOrigin,- type ImageData,-} from '../../ui/Image';+import { defineComponent } from '../../component';+import type { Color } from '../../types';+import { INVALID_TEXTURE } from '../../types';++export const ImageType = {+ Simple: 0,+ Sliced: 1,+ Tiled: 2,+ Filled: 3,+} as const;+export type ImageType = (typeof ImageType)[keyof typeof ImageType];++export const FillMethod = {+ Horizontal: 0,+ Vertical: 1,+} as const;+export type FillMethod = (typeof FillMethod)[keyof typeof FillMethod];++export const FillOrigin = {+ Left: 0,+ Right: 1,+ Bottom: 2,+ Top: 3,+} as const;+export type FillOrigin = (typeof FillOrigin)[keyof typeof FillOrigin];++export interface ImageData {+ texture: number;+ color: Color;+ imageType: number;+ fillMethod: number;+ fillOrigin: number;+ fillAmount: number;+ preserveAspect: boolean;+ tileSize: { x: number; y: number };+ layer: number;+ material: number;+ enabled: boolean;+}++export const Image = defineComponent<ImageData>('Image', {+ texture: INVALID_TEXTURE,+ color: { r: 1, g: 1, b: 1, a: 1 },+ imageType: ImageType.Simple,+ fillMethod: FillMethod.Horizontal,+ fillOrigin: FillOrigin.Left,+ fillAmount: 1,+ preserveAspect: false,+ tileSize: { x: 32, y: 32 },+ layer: 0,+ material: 0,+ enabled: true,+}, {+ assetFields: [+ { field: 'texture', type: 'texture' },+ { field: 'material', type: 'material' },+ ],+});diff --git a/sdk/src/ui2/core/text.ts b/sdk/src/ui2/core/text.tsindex ba02f45b1..72bf04c8c 100644--- a/sdk/src/ui2/core/text.ts+++ b/sdk/src/ui2/core/text.ts@@ -1,7 +1,65 @@-export {- Text,- TextAlign,- TextVerticalAlign,- TextOverflow,- type TextData,-} from '../../ui/text';+import { defineComponent } from '../../component';+import type { Color } from '../../types';++export const TextAlign = {+ Left: 0,+ Center: 1,+ Right: 2,+} as const;+export type TextAlign = (typeof TextAlign)[keyof typeof TextAlign];++export const TextVerticalAlign = {+ Top: 0,+ Middle: 1,+ Bottom: 2,+} as const;+export type TextVerticalAlign = (typeof TextVerticalAlign)[keyof typeof TextVerticalAlign];++export const TextOverflow = {+ Visible: 0,+ Clip: 1,+ Ellipsis: 2,+} as const;+export type TextOverflow = (typeof TextOverflow)[keyof typeof TextOverflow];++export interface TextData {+ content: string;+ fontFamily: string;+ fontSize: number;+ color: Color;+ align: TextAlign;+ verticalAlign: TextVerticalAlign;+ wordWrap: boolean;+ overflow: TextOverflow;+ lineHeight: number;+ bold: boolean;+ italic: boolean;+ strokeColor: Color;+ strokeWidth: number;+ shadowColor: Color;+ shadowBlur: number;+ shadowOffsetX: number;+ shadowOffsetY: number;+ richText: boolean;+}++export const Text = defineComponent<TextData>('Text', {+ content: '',+ fontFamily: 'Arial',+ fontSize: 24,+ color: { r: 1, g: 1, b: 1, a: 1 },+ align: TextAlign.Left,+ verticalAlign: TextVerticalAlign.Top,+ wordWrap: true,+ overflow: TextOverflow.Visible,+ lineHeight: 1.2,+ bold: false,+ italic: false,+ strokeColor: { r: 0, g: 0, b: 0, a: 1 },+ strokeWidth: 0,+ shadowColor: { r: 0, g: 0, b: 0, a: 1 },+ shadowBlur: 0,+ shadowOffsetX: 0,+ shadowOffsetY: 0,+ richText: false,+});diff --git a/sdk/src/ui2/core/ui-mask.ts b/sdk/src/ui2/core/ui-mask.tsindex a92b39631..8299854e0 100644--- a/sdk/src/ui2/core/ui-mask.ts+++ b/sdk/src/ui2/core/ui-mask.ts@@ -1,5 +1,22 @@-export {- UIMask,- MaskMode,- type UIMaskData,-} from '../../ui/UIMask';+import { defineBuiltin } from '../../component';++export const MaskMode = {+ Scissor: 0,+ Stencil: 1,+ Alpha: 2,+} as const;+export type MaskMode = (typeof MaskMode)[keyof typeof MaskMode];++export interface UIMaskData {+ enabled: boolean;+ mode: MaskMode;+ maskTexture: number;+ inverted: boolean;+}++export const UIMask = defineBuiltin<UIMaskData>('UIMask', {+ enabled: true,+ mode: MaskMode.Scissor,+ maskTexture: 0,+ inverted: false,+});diff --git a/sdk/src/ui2/core/ui-rect.ts b/sdk/src/ui2/core/ui-rect.tsindex 52b744544..c9ac92607 100644--- a/sdk/src/ui2/core/ui-rect.ts+++ b/sdk/src/ui2/core/ui-rect.ts@@ -1,4 +1,20 @@-export {- UIRect,- type UIRectData,-} from '../../ui/UIRect';+import { defineBuiltin } from '../../component';+import type { Vec2 } from '../../types';++export interface UIRectData {+ anchorMin: Vec2;+ anchorMax: Vec2;+ offsetMin: Vec2;+ offsetMax: Vec2;+ size: Vec2;+ pivot: Vec2;+}++export const UIRect = defineBuiltin<UIRectData>('UIRect', {+ anchorMin: { x: 0.5, y: 0.5 },+ anchorMax: { x: 0.5, y: 0.5 },+ offsetMin: { x: 0, y: 0 },+ offsetMax: { x: 0, y: 0 },+ size: { x: 100, y: 100 },+ pivot: { x: 0.5, y: 0.5 },+});diff --git a/sdk/src/ui2/core/ui-renderer.ts b/sdk/src/ui2/core/ui-renderer.tsindex 509857ea6..ad48ec134 100644--- a/sdk/src/ui2/core/ui-renderer.ts+++ b/sdk/src/ui2/core/ui-renderer.ts@@ -1,5 +1,33 @@-export {- UIRenderer,- UIVisualType,- type UIRendererData,-} from '../../ui/UIRenderer';+import { defineBuiltin } from '../../component';+import type { Color, Vec2, Vec4 } from '../../types';++export const UIVisualType = {+ None: 0,+ SolidColor: 1,+ Image: 2,+ NineSlice: 3,+} as const;++export type UIVisualType = (typeof UIVisualType)[keyof typeof UIVisualType];++export interface UIRendererData {+ visualType: UIVisualType;+ texture: number;+ color: Color;+ uvOffset: Vec2;+ uvScale: Vec2;+ sliceBorder: Vec4;+ material: number;+ enabled: boolean;+}++export const UIRenderer = defineBuiltin<UIRendererData>('UIRenderer', {+ visualType: UIVisualType.None,+ texture: 0,+ color: { r: 1, g: 1, b: 1, a: 1 },+ uvOffset: { x: 0, y: 0 },+ uvScale: { x: 1, y: 1 },+ sliceBorder: { x: 0, y: 0, z: 0, w: 0 },+ material: 0,+ enabled: true,+});diff --git a/sdk/src/ui2/layout/flex.ts b/sdk/src/ui2/layout/flex.tsindex d9f9a3ba8..9caa84ff3 100644--- a/sdk/src/ui2/layout/flex.ts+++ b/sdk/src/ui2/layout/flex.ts@@ -1,15 +1,75 @@-export {- FlexContainer,- FlexDirection,- FlexWrap,- JustifyContent,- AlignItems,- AlignContent,- type FlexContainerData,-} from '../../ui/FlexContainer';--export {- FlexItem,- AlignSelf,- type FlexItemData,-} from '../../ui/FlexItem';+import { defineBuiltin } from '../../component';+import type { Vec2 } from '../../types';+import type { Padding } from '../../wasm.generated';++// -- FlexContainer ------------------------------------------------------------++export const FlexDirection = { Row: 0, Column: 1, RowReverse: 2, ColumnReverse: 3 } as const;+export type FlexDirection = (typeof FlexDirection)[keyof typeof FlexDirection];++export const FlexWrap = { NoWrap: 0, Wrap: 1 } as const;+export type FlexWrap = (typeof FlexWrap)[keyof typeof FlexWrap];++export const JustifyContent = { Start: 0, Center: 1, End: 2, SpaceBetween: 3, SpaceAround: 4, SpaceEvenly: 5 } as const;+export type JustifyContent = (typeof JustifyContent)[keyof typeof JustifyContent];++export const AlignItems = { Start: 0, Center: 1, End: 2, Stretch: 3 } as const;+export type AlignItems = (typeof AlignItems)[keyof typeof AlignItems];++export const AlignContent = { Start: 0, Center: 1, End: 2, Stretch: 3, SpaceBetween: 4, SpaceAround: 5 } as const;+export type AlignContent = (typeof AlignContent)[keyof typeof AlignContent];++export interface FlexContainerData {+ direction: FlexDirection;+ wrap: FlexWrap;+ justifyContent: JustifyContent;+ alignItems: AlignItems;+ alignContent: AlignContent;+ gap: Vec2;+ padding: Padding;+}++export const FlexContainer = defineBuiltin<FlexContainerData>('FlexContainer', {+ direction: FlexDirection.Row,+ wrap: FlexWrap.NoWrap,+ justifyContent: JustifyContent.Start,+ alignItems: AlignItems.Stretch,+ alignContent: AlignContent.Start,+ gap: { x: 0, y: 0 },+ padding: { left: 0, top: 0, right: 0, bottom: 0 },+});++// -- FlexItem -----------------------------------------------------------------++export const AlignSelf = { Auto: 0, Start: 1, Center: 2, End: 3, Stretch: 4 } as const;+export type AlignSelf = (typeof AlignSelf)[keyof typeof AlignSelf];++export interface FlexItemData {+ flexGrow: number;+ flexShrink: number;+ flexBasis: number;+ order: number;+ alignSelf: AlignSelf;+ margin: Padding;+ minWidth: number;+ minHeight: number;+ maxWidth: number;+ maxHeight: number;+ widthPercent: number;+ heightPercent: number;+}++export const FlexItem = defineBuiltin<FlexItemData>('FlexItem', {+ flexGrow: 0,+ flexShrink: 1,+ flexBasis: -1,+ order: 0,+ alignSelf: AlignSelf.Auto,+ margin: { left: 0, top: 0, right: 0, bottom: 0 },+ minWidth: -1,+ minHeight: -1,+ maxWidth: -1,+ maxHeight: -1,+ widthPercent: -1,+ heightPercent: -1,+});diff --git a/sdk/src/ui2/layout/grid.ts b/sdk/src/ui2/layout/grid.tsindex e94648231..b22bede56 100644--- a/sdk/src/ui2/layout/grid.ts+++ b/sdk/src/ui2/layout/grid.ts@@ -1,5 +1,20 @@-export {- GridLayout,- GridLayoutDirection,- type GridLayoutData,-} from '../../ui/layouts/GridLayout';+import { defineBuiltin } from '../../component';++export interface GridLayoutData {+ direction: number; // 0=Vertical, 1=Horizontal+ crossAxisCount: number;+ itemSize: { x: number; y: number };+ spacing: { x: number; y: number };+}++export const GridLayoutDirection = {+ Vertical: 0,+ Horizontal: 1,+} as const;++export const GridLayout = defineBuiltin<GridLayoutData>('GridLayout', {+ direction: GridLayoutDirection.Vertical,+ crossAxisCount: 3,+ itemSize: { x: 100, y: 100 },+ spacing: { x: 4, y: 4 },+});