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: add typed WASM accessors, RenderCollectContext, and component collision detection
esengine0b7e21867f60
diff --git a/sdk/src/component.ts b/sdk/src/component.tsindex 354694265..ecd0a0438 100644--- a/sdk/src/component.ts+++ b/sdk/src/component.ts@@ -123,8 +123,15 @@ export function defineComponent<T extends object>(defaults: T,metadata?: ComponentMetadata,): ComponentDef<T> {- const existing = componentRegistry.get(name) ?? getComponentRegistry().get(name);- if (existing) return existing as ComponentDef<T>;+ const userExisting = getComponentRegistry().get(name);+ if (userExisting) return userExisting as ComponentDef<T>;++ const globalExisting = componentRegistry.get(name);+ if (globalExisting) {+ throw new Error(+ `Component name collision: user component "${name}" conflicts with an existing ${globalExisting._builtin ? 'builtin' : 'user'} component of the same name`+ );+ }const def = createComponentDef(name, defaults, metadata);getComponentRegistry().set(name, def);@@ -134,8 +141,15 @@ export function defineComponent<T extends object>(}export function defineTag(name: string): ComponentDef<{}> {- const existing = componentRegistry.get(name) ?? getComponentRegistry().get(name);- if (existing) return existing as ComponentDef<{}>;+ const userExisting = getComponentRegistry().get(name);+ if (userExisting) return userExisting as ComponentDef<{}>;++ const globalExisting = componentRegistry.get(name);+ if (globalExisting) {+ throw new Error(+ `Component name collision: tag "${name}" conflicts with an existing ${globalExisting._builtin ? 'builtin' : 'user'} component of the same name`+ );+ }const def = createComponentDef(name, {});getComponentRegistry().set(name, def);@@ -227,6 +241,14 @@ function detectColorKeys(defaults: unknown): readonly string[] {}export function defineBuiltin<T>(name: string, defaults: T, metadata?: ComponentMetadata): BuiltinComponentDef<T> {+ const existing = componentRegistry.get(name);+ if (existing) {+ if (existing._builtin) return existing as BuiltinComponentDef<T>;+ throw new Error(+ `Component name collision: builtin component "${name}" conflicts with an existing user component of the same name`+ );+ }+const meta = COMPONENT_META[name];const def: BuiltinComponentDef<T> = {_id: Symbol(`Builtin_${name}`),diff --git a/sdk/src/ecs/BuiltinBridge.ts b/sdk/src/ecs/BuiltinBridge.tsindex ef3e90a61..aea7f98a0 100644--- a/sdk/src/ecs/BuiltinBridge.ts+++ b/sdk/src/ecs/BuiltinBridge.ts@@ -9,6 +9,7 @@ import type { CppRegistry, ESEngineModule } from '../wasm';import { validateComponentData, formatValidationErrors } from '../validation';import { handleWasmError } from '../wasmError';import { PTR_LAYOUTS } from '../ptrLayouts.generated';+import { PTR_ACCESSORS } from './ptrAccessors.generated';// =============================================================================// Color conversion helpers@@ -76,6 +77,11 @@ export function readPtrField(}}+interface XY { x: number; y: number }+interface XYZ { x: number; y: number; z: number }+interface XYZW { x: number; y: number; z: number; w: number }+interface RGBA { r: number; g: number; b: number; a: number }+export function fillPtrFields(f32: Float32Array, u32: Uint32Array, u8: Uint8Array,ptr: number, fields: readonly PtrFieldDesc[], target: Record<string, unknown>,@@ -91,23 +97,23 @@ export function fillPtrFields(case 'bool': target[field.name] = u8[byteOff] !== 0; break;case 'u8': target[field.name] = u8[byteOff]; break;case 'vec2': {- const v = target[field.name] as any;+ const v = target[field.name] as XY;v.x = f32[idx]; v.y = f32[idx + 1];break;}case 'vec3': {- const v = target[field.name] as any;+ const v = target[field.name] as XYZ;v.x = f32[idx]; v.y = f32[idx + 1]; v.z = f32[idx + 2];break;}case 'vec4':case 'quat': {- const v = target[field.name] as any;+ const v = target[field.name] as XYZW;v.x = f32[idx]; v.y = f32[idx + 1]; v.z = f32[idx + 2]; v.w = f32[idx + 3];break;}case 'color': {- const v = target[field.name] as any;+ const v = target[field.name] as RGBA;v.r = f32[idx]; v.g = f32[idx + 1]; v.b = f32[idx + 2]; v.a = f32[idx + 3];break;}@@ -130,23 +136,25 @@ export function createPreallocatedResult(fields: readonly PtrFieldDesc[]): Recorreturn obj;}+export type PtrFieldValue = number | boolean | XY | XYZ | XYZW | RGBA;+export function writePtrField(f32: Float32Array, u32: Uint32Array, u8: Uint8Array,- ptr: number, field: PtrFieldDesc, value: any,+ ptr: number, field: PtrFieldDesc, value: PtrFieldValue | unknown,): void {const byteOff = ptr + field.offset;const idx = byteOff >> 2;switch (field.type) {- case 'f32': f32[idx] = value; break;- case 'i32': u32[idx] = value | 0; break;- case 'u32': u32[idx] = value; break;+ case 'f32': f32[idx] = value as number; break;+ case 'i32': u32[idx] = (value as number) | 0; break;+ case 'u32': u32[idx] = value as number; break;case 'bool': u8[byteOff] = value ? 1 : 0; break;- case 'u8': u8[byteOff] = value; break;- case 'vec2': f32[idx] = value.x; f32[idx + 1] = value.y; break;- case 'vec3': f32[idx] = value.x; f32[idx + 1] = value.y; f32[idx + 2] = value.z; break;+ case 'u8': u8[byteOff] = value as number; break;+ case 'vec2': { const v = value as XY; f32[idx] = v.x; f32[idx + 1] = v.y; break; }+ case 'vec3': { const v = value as XYZ; f32[idx] = v.x; f32[idx + 1] = v.y; f32[idx + 2] = v.z; break; }case 'vec4':- case 'quat': f32[idx] = value.x; f32[idx + 1] = value.y; f32[idx + 2] = value.z; f32[idx + 3] = value.w; break;- case 'color': f32[idx] = value.r; f32[idx + 1] = value.g; f32[idx + 2] = value.b; f32[idx + 3] = value.a; break;+ case 'quat': { const v = value as XYZW; f32[idx] = v.x; f32[idx + 1] = v.y; f32[idx + 2] = v.z; f32[idx + 3] = v.w; break; }+ case 'color': { const v = value as RGBA; f32[idx] = v.r; f32[idx + 1] = v.g; f32[idx + 2] = v.b; f32[idx + 3] = v.a; break; }}}@@ -330,41 +338,38 @@ export class BuiltinBridge {resolvePtrFn(cppName: string): ((entity: Entity) => number) | null {const layout = PTR_LAYOUTS[cppName];if (!layout) return null;- const fn = (this.module_ as any)[layout.ptrFn] as ((r: any, e: number) => number) | undefined;+ const mod = this.module_ as Record<string, unknown> | null;+ if (!mod) return null;+ const fn = mod[layout.ptrFn] as ((r: CppRegistry, e: number) => number) | undefined;if (!fn) return null;const reg = this.cppRegistry_!;return (e: Entity) => fn(reg, e);}resolvePtrSetter(cppName: string): ((entity: Entity, data: unknown) => void) | null {- const layout = PTR_LAYOUTS[cppName];- if (!layout) return null;+ const accessor = PTR_ACCESSORS[cppName];+ if (!accessor) return null;const getPtrFn = this.resolvePtrFn(cppName);if (!getPtrFn) return null;const mod = this.module_!;- const fields = layout.fields;return (e: Entity, data: unknown) => {const ptr = getPtrFn(e);if (!ptr) return;- const d = data as any;- for (let i = 0; i < fields.length; i++) {- writePtrField(mod.HEAPF32, mod.HEAPU32, mod.HEAPU8, ptr, fields[i], d[fields[i].name]);- }+ accessor.write(mod.HEAPF32, mod.HEAPU32, mod.HEAPU8, ptr, data);};}resolvePtrGetter(cppName: string): ((entity: Entity) => unknown) | null {- const layout = PTR_LAYOUTS[cppName];- if (!layout) return null;+ const accessor = PTR_ACCESSORS[cppName];+ if (!accessor) return null;const getPtrFn = this.resolvePtrFn(cppName);if (!getPtrFn) return null;const mod = this.module_!;- const fields = layout.fields;- const cached = createPreallocatedResult(fields);+ const cached = accessor.create();return (e: Entity) => {const ptr = getPtrFn(e);if (!ptr) return null;- fillPtrFields(mod.HEAPF32, mod.HEAPU32, mod.HEAPU8, ptr, fields, cached);+ accessor.fill(mod.HEAPF32, mod.HEAPU32, mod.HEAPU8, ptr, cached);return cached;};}diff --git a/sdk/src/ecs/ptrAccessors.generated.ts b/sdk/src/ecs/ptrAccessors.generated.tsnew file mode 100644index 000000000..fa715de8f--- /dev/null+++ b/sdk/src/ecs/ptrAccessors.generated.ts@@ -0,0 +1,1356 @@+/**+ * @file ptrAccessors.generated.ts+ * @brief Auto-generated type-safe WASM pointer accessors+ * @details Generated by EHT - DO NOT EDIT+ */++interface Vec2 { x: number; y: number; }+interface Vec3 { x: number; y: number; z: number; }+interface Vec4 { x: number; y: number; z: number; w: number; }+interface Color { r: number; g: number; b: number; a: number; }++export interface UIRectPtrData {+ anchorMin: Vec2;+ anchorMax: Vec2;+ offsetMin: Vec2;+ offsetMax: Vec2;+ size: Vec2;+ pivot: Vec2;+}++export function fillUIRect(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: UIRectPtrData,+): void {+ const anchorMin_ = out.anchorMin; anchorMin_.x = f32[ptr >> 2]; anchorMin_.y = f32[(ptr >> 2) + 1];+ const anchorMax_ = out.anchorMax; anchorMax_.x = f32[(ptr + 8) >> 2]; anchorMax_.y = f32[((ptr + 8) >> 2) + 1];+ const offsetMin_ = out.offsetMin; offsetMin_.x = f32[(ptr + 16) >> 2]; offsetMin_.y = f32[((ptr + 16) >> 2) + 1];+ const offsetMax_ = out.offsetMax; offsetMax_.x = f32[(ptr + 24) >> 2]; offsetMax_.y = f32[((ptr + 24) >> 2) + 1];+ const size_ = out.size; size_.x = f32[(ptr + 32) >> 2]; size_.y = f32[((ptr + 32) >> 2) + 1];+ const pivot_ = out.pivot; pivot_.x = f32[(ptr + 40) >> 2]; pivot_.y = f32[((ptr + 40) >> 2) + 1];+}++export function writeUIRect(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: UIRectPtrData,+): void {+ f32[ptr >> 2] = data.anchorMin.x; f32[(ptr >> 2) + 1] = data.anchorMin.y;+ f32[(ptr + 8) >> 2] = data.anchorMax.x; f32[((ptr + 8) >> 2) + 1] = data.anchorMax.y;+ f32[(ptr + 16) >> 2] = data.offsetMin.x; f32[((ptr + 16) >> 2) + 1] = data.offsetMin.y;+ f32[(ptr + 24) >> 2] = data.offsetMax.x; f32[((ptr + 24) >> 2) + 1] = data.offsetMax.y;+ f32[(ptr + 32) >> 2] = data.size.x; f32[((ptr + 32) >> 2) + 1] = data.size.y;+ f32[(ptr + 40) >> 2] = data.pivot.x; f32[((ptr + 40) >> 2) + 1] = data.pivot.y;+}++export function createUIRectData(): UIRectPtrData {+ return {+ anchorMin: { x: 0, y: 0 },+ anchorMax: { x: 0, y: 0 },+ offsetMin: { x: 0, y: 0 },+ offsetMax: { x: 0, y: 0 },+ size: { x: 0, y: 0 },+ pivot: { x: 0, y: 0 },+ };+}++export interface FlexItemPtrData {+ flexGrow: number;+ flexShrink: number;+ flexBasis: number;+ order: number;+ alignSelf: number;+ minWidth: number;+ minHeight: number;+ maxWidth: number;+ maxHeight: number;+ widthPercent: number;+ heightPercent: number;+}++export function fillFlexItem(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: FlexItemPtrData,+): void {+ out.flexGrow = f32[ptr >> 2];+ out.flexShrink = f32[(ptr + 4) >> 2];+ out.flexBasis = f32[(ptr + 8) >> 2];+ out.order = u32[(ptr + 12) >> 2] | 0;+ out.alignSelf = u8[ptr + 16];+ out.minWidth = f32[(ptr + 20) >> 2];+ out.minHeight = f32[(ptr + 24) >> 2];+ out.maxWidth = f32[(ptr + 28) >> 2];+ out.maxHeight = f32[(ptr + 32) >> 2];+ out.widthPercent = f32[(ptr + 36) >> 2];+ out.heightPercent = f32[(ptr + 40) >> 2];+}++export function writeFlexItem(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: FlexItemPtrData,+): void {+ f32[ptr >> 2] = data.flexGrow;+ f32[(ptr + 4) >> 2] = data.flexShrink;+ f32[(ptr + 8) >> 2] = data.flexBasis;+ u32[(ptr + 12) >> 2] = data.order | 0;+ u8[ptr + 16] = data.alignSelf;+ f32[(ptr + 20) >> 2] = data.minWidth;+ f32[(ptr + 24) >> 2] = data.minHeight;+ f32[(ptr + 28) >> 2] = data.maxWidth;+ f32[(ptr + 32) >> 2] = data.maxHeight;+ f32[(ptr + 36) >> 2] = data.widthPercent;+ f32[(ptr + 40) >> 2] = data.heightPercent;+}++export function createFlexItemData(): FlexItemPtrData {+ return {+ flexGrow: 0,+ flexShrink: 0,+ flexBasis: 0,+ order: 0,+ alignSelf: 0,+ minWidth: 0,+ minHeight: 0,+ maxWidth: 0,+ maxHeight: 0,+ widthPercent: 0,+ heightPercent: 0,+ };+}++export interface BoxColliderPtrData {+ halfExtents: Vec2;+ offset: Vec2;+ density: number;+ friction: number;+ restitution: number;+ isSensor: boolean;+ enabled: boolean;+ categoryBits: number;+ maskBits: number;+}++export function fillBoxCollider(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: BoxColliderPtrData,+): void {+ const halfExtents_ = out.halfExtents; halfExtents_.x = f32[ptr >> 2]; halfExtents_.y = f32[(ptr >> 2) + 1];+ const offset_ = out.offset; offset_.x = f32[(ptr + 8) >> 2]; offset_.y = f32[((ptr + 8) >> 2) + 1];+ out.density = f32[(ptr + 16) >> 2];+ out.friction = f32[(ptr + 20) >> 2];+ out.restitution = f32[(ptr + 24) >> 2];+ out.isSensor = u8[ptr + 28] !== 0;+ out.enabled = u8[ptr + 29] !== 0;+ out.categoryBits = u32[(ptr + 32) >> 2];+ out.maskBits = u32[(ptr + 36) >> 2];+}++export function writeBoxCollider(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: BoxColliderPtrData,+): void {+ f32[ptr >> 2] = data.halfExtents.x; f32[(ptr >> 2) + 1] = data.halfExtents.y;+ f32[(ptr + 8) >> 2] = data.offset.x; f32[((ptr + 8) >> 2) + 1] = data.offset.y;+ f32[(ptr + 16) >> 2] = data.density;+ f32[(ptr + 20) >> 2] = data.friction;+ f32[(ptr + 24) >> 2] = data.restitution;+ u8[ptr + 28] = data.isSensor ? 1 : 0;+ u8[ptr + 29] = data.enabled ? 1 : 0;+ u32[(ptr + 32) >> 2] = data.categoryBits;+ u32[(ptr + 36) >> 2] = data.maskBits;+}++export function createBoxColliderData(): BoxColliderPtrData {+ return {+ halfExtents: { x: 0, y: 0 },+ offset: { x: 0, y: 0 },+ density: 0,+ friction: 0,+ restitution: 0,+ isSensor: false,+ enabled: false,+ categoryBits: 0,+ maskBits: 0,+ };+}++export interface CircleColliderPtrData {+ radius: number;+ offset: Vec2;+ density: number;+ friction: number;+ restitution: number;+ isSensor: boolean;+ enabled: boolean;+ categoryBits: number;+ maskBits: number;+}++export function fillCircleCollider(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: CircleColliderPtrData,+): void {+ out.radius = f32[ptr >> 2];+ const offset_ = out.offset; offset_.x = f32[(ptr + 4) >> 2]; offset_.y = f32[((ptr + 4) >> 2) + 1];+ out.density = f32[(ptr + 12) >> 2];+ out.friction = f32[(ptr + 16) >> 2];+ out.restitution = f32[(ptr + 20) >> 2];+ out.isSensor = u8[ptr + 24] !== 0;+ out.enabled = u8[ptr + 25] !== 0;+ out.categoryBits = u32[(ptr + 28) >> 2];+ out.maskBits = u32[(ptr + 32) >> 2];+}++export function writeCircleCollider(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: CircleColliderPtrData,+): void {+ f32[ptr >> 2] = data.radius;+ f32[(ptr + 4) >> 2] = data.offset.x; f32[((ptr + 4) >> 2) + 1] = data.offset.y;+ f32[(ptr + 12) >> 2] = data.density;+ f32[(ptr + 16) >> 2] = data.friction;+ f32[(ptr + 20) >> 2] = data.restitution;+ u8[ptr + 24] = data.isSensor ? 1 : 0;+ u8[ptr + 25] = data.enabled ? 1 : 0;+ u32[(ptr + 28) >> 2] = data.categoryBits;+ u32[(ptr + 32) >> 2] = data.maskBits;+}++export function createCircleColliderData(): CircleColliderPtrData {+ return {+ radius: 0,+ offset: { x: 0, y: 0 },+ density: 0,+ friction: 0,+ restitution: 0,+ isSensor: false,+ enabled: false,+ categoryBits: 0,+ maskBits: 0,+ };+}++export interface CapsuleColliderPtrData {+ radius: number;+ halfHeight: number;+ offset: Vec2;+ density: number;+ friction: number;+ restitution: number;+ isSensor: boolean;+ enabled: boolean;+ categoryBits: number;+ maskBits: number;+}++export function fillCapsuleCollider(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: CapsuleColliderPtrData,+): void {+ out.radius = f32[ptr >> 2];+ out.halfHeight = f32[(ptr + 4) >> 2];+ const offset_ = out.offset; offset_.x = f32[(ptr + 8) >> 2]; offset_.y = f32[((ptr + 8) >> 2) + 1];+ out.density = f32[(ptr + 16) >> 2];+ out.friction = f32[(ptr + 20) >> 2];+ out.restitution = f32[(ptr + 24) >> 2];+ out.isSensor = u8[ptr + 28] !== 0;+ out.enabled = u8[ptr + 29] !== 0;+ out.categoryBits = u32[(ptr + 32) >> 2];+ out.maskBits = u32[(ptr + 36) >> 2];+}++export function writeCapsuleCollider(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: CapsuleColliderPtrData,+): void {+ f32[ptr >> 2] = data.radius;+ f32[(ptr + 4) >> 2] = data.halfHeight;+ f32[(ptr + 8) >> 2] = data.offset.x; f32[((ptr + 8) >> 2) + 1] = data.offset.y;+ f32[(ptr + 16) >> 2] = data.density;+ f32[(ptr + 20) >> 2] = data.friction;+ f32[(ptr + 24) >> 2] = data.restitution;+ u8[ptr + 28] = data.isSensor ? 1 : 0;+ u8[ptr + 29] = data.enabled ? 1 : 0;+ u32[(ptr + 32) >> 2] = data.categoryBits;+ u32[(ptr + 36) >> 2] = data.maskBits;+}++export function createCapsuleColliderData(): CapsuleColliderPtrData {+ return {+ radius: 0,+ halfHeight: 0,+ offset: { x: 0, y: 0 },+ density: 0,+ friction: 0,+ restitution: 0,+ isSensor: false,+ enabled: false,+ categoryBits: 0,+ maskBits: 0,+ };+}++export interface SegmentColliderPtrData {+ point1: Vec2;+ point2: Vec2;+ density: number;+ friction: number;+ restitution: number;+ isSensor: boolean;+ enabled: boolean;+ categoryBits: number;+ maskBits: number;+}++export function fillSegmentCollider(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: SegmentColliderPtrData,+): void {+ const point1_ = out.point1; point1_.x = f32[ptr >> 2]; point1_.y = f32[(ptr >> 2) + 1];+ const point2_ = out.point2; point2_.x = f32[(ptr + 8) >> 2]; point2_.y = f32[((ptr + 8) >> 2) + 1];+ out.density = f32[(ptr + 16) >> 2];+ out.friction = f32[(ptr + 20) >> 2];+ out.restitution = f32[(ptr + 24) >> 2];+ out.isSensor = u8[ptr + 28] !== 0;+ out.enabled = u8[ptr + 29] !== 0;+ out.categoryBits = u32[(ptr + 32) >> 2];+ out.maskBits = u32[(ptr + 36) >> 2];+}++export function writeSegmentCollider(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: SegmentColliderPtrData,+): void {+ f32[ptr >> 2] = data.point1.x; f32[(ptr >> 2) + 1] = data.point1.y;+ f32[(ptr + 8) >> 2] = data.point2.x; f32[((ptr + 8) >> 2) + 1] = data.point2.y;+ f32[(ptr + 16) >> 2] = data.density;+ f32[(ptr + 20) >> 2] = data.friction;+ f32[(ptr + 24) >> 2] = data.restitution;+ u8[ptr + 28] = data.isSensor ? 1 : 0;+ u8[ptr + 29] = data.enabled ? 1 : 0;+ u32[(ptr + 32) >> 2] = data.categoryBits;+ u32[(ptr + 36) >> 2] = data.maskBits;+}++export function createSegmentColliderData(): SegmentColliderPtrData {+ return {+ point1: { x: 0, y: 0 },+ point2: { x: 0, y: 0 },+ density: 0,+ friction: 0,+ restitution: 0,+ isSensor: false,+ enabled: false,+ categoryBits: 0,+ maskBits: 0,+ };+}++export interface FanLayoutPtrData {+ radius: number;+ maxSpreadAngle: number;+ maxCardAngle: number;+ tiltFactor: number;+ cardSpacing: number;+ direction: number;+}++export function fillFanLayout(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: FanLayoutPtrData,+): void {+ out.radius = f32[ptr >> 2];+ out.maxSpreadAngle = f32[(ptr + 4) >> 2];+ out.maxCardAngle = f32[(ptr + 8) >> 2];+ out.tiltFactor = f32[(ptr + 12) >> 2];+ out.cardSpacing = f32[(ptr + 16) >> 2];+ out.direction = u32[(ptr + 20) >> 2] | 0;+}++export function writeFanLayout(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: FanLayoutPtrData,+): void {+ f32[ptr >> 2] = data.radius;+ f32[(ptr + 4) >> 2] = data.maxSpreadAngle;+ f32[(ptr + 8) >> 2] = data.maxCardAngle;+ f32[(ptr + 12) >> 2] = data.tiltFactor;+ f32[(ptr + 16) >> 2] = data.cardSpacing;+ u32[(ptr + 20) >> 2] = data.direction | 0;+}++export function createFanLayoutData(): FanLayoutPtrData {+ return {+ radius: 0,+ maxSpreadAngle: 0,+ maxCardAngle: 0,+ tiltFactor: 0,+ cardSpacing: 0,+ direction: 0,+ };+}++export interface ParticleEmitterPtrData {+ rate: number;+ burstCount: number;+ burstInterval: number;+ duration: number;+ looping: boolean;+ playOnStart: boolean;+ maxParticles: number;+ lifetimeMin: number;+ lifetimeMax: number;+ shape: number;+ shapeRadius: number;+ shapeSize: Vec2;+ shapeAngle: number;+ speedMin: number;+ speedMax: number;+ angleSpreadMin: number;+ angleSpreadMax: number;+ startSizeMin: number;+ startSizeMax: number;+ endSizeMin: number;+ endSizeMax: number;+ sizeEasing: number;+ startColor: Color;+ endColor: Color;+ colorEasing: number;+ rotationMin: number;+ rotationMax: number;+ angularVelocityMin: number;+ angularVelocityMax: number;+ gravity: Vec2;+ damping: number;+ texture: number;+ spriteColumns: number;+ spriteRows: number;+ spriteFPS: number;+ spriteLoop: boolean;+ blendMode: number;+ layer: number;+ material: number;+ simulationSpace: number;+ enabled: boolean;+}++export function fillParticleEmitter(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: ParticleEmitterPtrData,+): void {+ out.rate = f32[ptr >> 2];+ out.burstCount = u32[(ptr + 4) >> 2] | 0;+ out.burstInterval = f32[(ptr + 8) >> 2];+ out.duration = f32[(ptr + 12) >> 2];+ out.looping = u8[ptr + 16] !== 0;+ out.playOnStart = u8[ptr + 17] !== 0;+ out.maxParticles = u32[(ptr + 20) >> 2] | 0;+ out.lifetimeMin = f32[(ptr + 24) >> 2];+ out.lifetimeMax = f32[(ptr + 28) >> 2];+ out.shape = u32[(ptr + 32) >> 2] | 0;+ out.shapeRadius = f32[(ptr + 36) >> 2];+ const shapeSize_ = out.shapeSize; shapeSize_.x = f32[(ptr + 40) >> 2]; shapeSize_.y = f32[((ptr + 40) >> 2) + 1];+ out.shapeAngle = f32[(ptr + 48) >> 2];+ out.speedMin = f32[(ptr + 52) >> 2];+ out.speedMax = f32[(ptr + 56) >> 2];+ out.angleSpreadMin = f32[(ptr + 60) >> 2];+ out.angleSpreadMax = f32[(ptr + 64) >> 2];+ out.startSizeMin = f32[(ptr + 68) >> 2];+ out.startSizeMax = f32[(ptr + 72) >> 2];+ out.endSizeMin = f32[(ptr + 76) >> 2];+ out.endSizeMax = f32[(ptr + 80) >> 2];+ out.sizeEasing = u32[(ptr + 84) >> 2] | 0;+ const startColor_ = out.startColor; startColor_.r = f32[(ptr + 88) >> 2]; startColor_.g = f32[((ptr + 88) >> 2) + 1]; startColor_.b = f32[((ptr + 88) >> 2) + 2]; startColor_.a = f32[((ptr + 88) >> 2) + 3];+ const endColor_ = out.endColor; endColor_.r = f32[(ptr + 104) >> 2]; endColor_.g = f32[((ptr + 104) >> 2) + 1]; endColor_.b = f32[((ptr + 104) >> 2) + 2]; endColor_.a = f32[((ptr + 104) >> 2) + 3];+ out.colorEasing = u32[(ptr + 120) >> 2] | 0;+ out.rotationMin = f32[(ptr + 124) >> 2];+ out.rotationMax = f32[(ptr + 128) >> 2];+ out.angularVelocityMin = f32[(ptr + 132) >> 2];+ out.angularVelocityMax = f32[(ptr + 136) >> 2];+ const gravity_ = out.gravity; gravity_.x = f32[(ptr + 140) >> 2]; gravity_.y = f32[((ptr + 140) >> 2) + 1];+ out.damping = f32[(ptr + 148) >> 2];+ out.texture = u32[(ptr + 152) >> 2];+ out.spriteColumns = u32[(ptr + 156) >> 2] | 0;+ out.spriteRows = u32[(ptr + 160) >> 2] | 0;+ out.spriteFPS = f32[(ptr + 164) >> 2];+ out.spriteLoop = u8[ptr + 168] !== 0;+ out.blendMode = u32[(ptr + 172) >> 2] | 0;+ out.layer = u32[(ptr + 176) >> 2] | 0;+ out.material = u32[(ptr + 180) >> 2];+ out.simulationSpace = u32[(ptr + 184) >> 2] | 0;+ out.enabled = u8[ptr + 188] !== 0;+}++export function writeParticleEmitter(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: ParticleEmitterPtrData,+): void {+ f32[ptr >> 2] = data.rate;+ u32[(ptr + 4) >> 2] = data.burstCount | 0;+ f32[(ptr + 8) >> 2] = data.burstInterval;+ f32[(ptr + 12) >> 2] = data.duration;+ u8[ptr + 16] = data.looping ? 1 : 0;+ u8[ptr + 17] = data.playOnStart ? 1 : 0;+ u32[(ptr + 20) >> 2] = data.maxParticles | 0;+ f32[(ptr + 24) >> 2] = data.lifetimeMin;+ f32[(ptr + 28) >> 2] = data.lifetimeMax;+ u32[(ptr + 32) >> 2] = data.shape | 0;+ f32[(ptr + 36) >> 2] = data.shapeRadius;+ f32[(ptr + 40) >> 2] = data.shapeSize.x; f32[((ptr + 40) >> 2) + 1] = data.shapeSize.y;+ f32[(ptr + 48) >> 2] = data.shapeAngle;+ f32[(ptr + 52) >> 2] = data.speedMin;+ f32[(ptr + 56) >> 2] = data.speedMax;+ f32[(ptr + 60) >> 2] = data.angleSpreadMin;+ f32[(ptr + 64) >> 2] = data.angleSpreadMax;+ f32[(ptr + 68) >> 2] = data.startSizeMin;+ f32[(ptr + 72) >> 2] = data.startSizeMax;+ f32[(ptr + 76) >> 2] = data.endSizeMin;+ f32[(ptr + 80) >> 2] = data.endSizeMax;+ u32[(ptr + 84) >> 2] = data.sizeEasing | 0;+ f32[(ptr + 88) >> 2] = data.startColor.r; f32[((ptr + 88) >> 2) + 1] = data.startColor.g; f32[((ptr + 88) >> 2) + 2] = data.startColor.b; f32[((ptr + 88) >> 2) + 3] = data.startColor.a;+ f32[(ptr + 104) >> 2] = data.endColor.r; f32[((ptr + 104) >> 2) + 1] = data.endColor.g; f32[((ptr + 104) >> 2) + 2] = data.endColor.b; f32[((ptr + 104) >> 2) + 3] = data.endColor.a;+ u32[(ptr + 120) >> 2] = data.colorEasing | 0;+ f32[(ptr + 124) >> 2] = data.rotationMin;+ f32[(ptr + 128) >> 2] = data.rotationMax;+ f32[(ptr + 132) >> 2] = data.angularVelocityMin;+ f32[(ptr + 136) >> 2] = data.angularVelocityMax;+ f32[(ptr + 140) >> 2] = data.gravity.x; f32[((ptr + 140) >> 2) + 1] = data.gravity.y;+ f32[(ptr + 148) >> 2] = data.damping;+ u32[(ptr + 152) >> 2] = data.texture;+ u32[(ptr + 156) >> 2] = data.spriteColumns | 0;+ u32[(ptr + 160) >> 2] = data.spriteRows | 0;+ f32[(ptr + 164) >> 2] = data.spriteFPS;+ u8[ptr + 168] = data.spriteLoop ? 1 : 0;+ u32[(ptr + 172) >> 2] = data.blendMode | 0;+ u32[(ptr + 176) >> 2] = data.layer | 0;+ u32[(ptr + 180) >> 2] = data.material;+ u32[(ptr + 184) >> 2] = data.simulationSpace | 0;+ u8[ptr + 188] = data.enabled ? 1 : 0;+}++export function createParticleEmitterData(): ParticleEmitterPtrData {+ return {+ rate: 0,+ burstCount: 0,+ burstInterval: 0,+ duration: 0,+ looping: false,+ playOnStart: false,+ maxParticles: 0,+ lifetimeMin: 0,+ lifetimeMax: 0,+ shape: 0,+ shapeRadius: 0,+ shapeSize: { x: 0, y: 0 },+ shapeAngle: 0,+ speedMin: 0,+ speedMax: 0,+ angleSpreadMin: 0,+ angleSpreadMax: 0,+ startSizeMin: 0,+ startSizeMax: 0,+ endSizeMin: 0,+ endSizeMax: 0,+ sizeEasing: 0,+ startColor: { r: 0, g: 0, b: 0, a: 0 },+ endColor: { r: 0, g: 0, b: 0, a: 0 },+ colorEasing: 0,+ rotationMin: 0,+ rotationMax: 0,+ angularVelocityMin: 0,+ angularVelocityMax: 0,+ gravity: { x: 0, y: 0 },+ damping: 0,+ texture: 0,+ spriteColumns: 0,+ spriteRows: 0,+ spriteFPS: 0,+ spriteLoop: false,+ blendMode: 0,+ layer: 0,+ material: 0,+ simulationSpace: 0,+ enabled: false,+ };+}++export interface TransformPtrData {+ position: Vec3;+ rotation: Vec4;+ scale: Vec3;+ worldPosition: Vec3;+ worldRotation: Vec4;+ worldScale: Vec3;+}++export function fillTransform(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: TransformPtrData,+): void {+ const position_ = out.position; position_.x = f32[ptr >> 2]; position_.y = f32[(ptr >> 2) + 1]; position_.z = f32[(ptr >> 2) + 2];+ const rotation_ = out.rotation; rotation_.x = f32[(ptr + 12) >> 2]; rotation_.y = f32[((ptr + 12) >> 2) + 1]; rotation_.z = f32[((ptr + 12) >> 2) + 2]; rotation_.w = f32[((ptr + 12) >> 2) + 3];+ const scale_ = out.scale; scale_.x = f32[(ptr + 28) >> 2]; scale_.y = f32[((ptr + 28) >> 2) + 1]; scale_.z = f32[((ptr + 28) >> 2) + 2];+ const worldPosition_ = out.worldPosition; worldPosition_.x = f32[(ptr + 40) >> 2]; worldPosition_.y = f32[((ptr + 40) >> 2) + 1]; worldPosition_.z = f32[((ptr + 40) >> 2) + 2];+ const worldRotation_ = out.worldRotation; worldRotation_.x = f32[(ptr + 52) >> 2]; worldRotation_.y = f32[((ptr + 52) >> 2) + 1]; worldRotation_.z = f32[((ptr + 52) >> 2) + 2]; worldRotation_.w = f32[((ptr + 52) >> 2) + 3];+ const worldScale_ = out.worldScale; worldScale_.x = f32[(ptr + 68) >> 2]; worldScale_.y = f32[((ptr + 68) >> 2) + 1]; worldScale_.z = f32[((ptr + 68) >> 2) + 2];+}++export function writeTransform(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: TransformPtrData,+): void {+ f32[ptr >> 2] = data.position.x; f32[(ptr >> 2) + 1] = data.position.y; f32[(ptr >> 2) + 2] = data.position.z;+ f32[(ptr + 12) >> 2] = data.rotation.x; f32[((ptr + 12) >> 2) + 1] = data.rotation.y; f32[((ptr + 12) >> 2) + 2] = data.rotation.z; f32[((ptr + 12) >> 2) + 3] = data.rotation.w;+ f32[(ptr + 28) >> 2] = data.scale.x; f32[((ptr + 28) >> 2) + 1] = data.scale.y; f32[((ptr + 28) >> 2) + 2] = data.scale.z;+ f32[(ptr + 40) >> 2] = data.worldPosition.x; f32[((ptr + 40) >> 2) + 1] = data.worldPosition.y; f32[((ptr + 40) >> 2) + 2] = data.worldPosition.z;+ f32[(ptr + 52) >> 2] = data.worldRotation.x; f32[((ptr + 52) >> 2) + 1] = data.worldRotation.y; f32[((ptr + 52) >> 2) + 2] = data.worldRotation.z; f32[((ptr + 52) >> 2) + 3] = data.worldRotation.w;+ f32[(ptr + 68) >> 2] = data.worldScale.x; f32[((ptr + 68) >> 2) + 1] = data.worldScale.y; f32[((ptr + 68) >> 2) + 2] = data.worldScale.z;+}++export function createTransformData(): TransformPtrData {+ return {+ position: { x: 0, y: 0, z: 0 },+ rotation: { x: 0, y: 0, z: 0, w: 0 },+ scale: { x: 0, y: 0, z: 0 },+ worldPosition: { x: 0, y: 0, z: 0 },+ worldRotation: { x: 0, y: 0, z: 0, w: 0 },+ worldScale: { x: 0, y: 0, z: 0 },+ };+}++export interface UIRendererPtrData {+ visualType: number;+ texture: number;+ color: Color;+ uvOffset: Vec2;+ uvScale: Vec2;+ sliceBorder: Vec4;+ material: number;+ enabled: boolean;+}++export function fillUIRenderer(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: UIRendererPtrData,+): void {+ 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];+ out.material = u32[(ptr + 56) >> 2];+ out.enabled = u8[ptr + 60] !== 0;+}++export function writeUIRenderer(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: UIRendererPtrData,+): void {+ 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;+ u32[(ptr + 56) >> 2] = data.material;+ u8[ptr + 60] = data.enabled ? 1 : 0;+}++export function createUIRendererData(): UIRendererPtrData {+ return {+ visualType: 0,+ texture: 0,+ color: { r: 0, g: 0, b: 0, a: 0 },+ uvOffset: { x: 0, y: 0 },+ uvScale: { x: 0, y: 0 },+ sliceBorder: { x: 0, y: 0, z: 0, w: 0 },+ material: 0,+ enabled: false,+ };+}++export interface GridLayoutPtrData {+ direction: number;+ crossAxisCount: number;+ itemSize: Vec2;+ spacing: Vec2;+}++export function fillGridLayout(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: GridLayoutPtrData,+): void {+ out.direction = u32[ptr >> 2] | 0;+ out.crossAxisCount = u32[(ptr + 4) >> 2] | 0;+ const itemSize_ = out.itemSize; itemSize_.x = f32[(ptr + 8) >> 2]; itemSize_.y = f32[((ptr + 8) >> 2) + 1];+ const spacing_ = out.spacing; spacing_.x = f32[(ptr + 16) >> 2]; spacing_.y = f32[((ptr + 16) >> 2) + 1];+}++export function writeGridLayout(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: GridLayoutPtrData,+): void {+ u32[ptr >> 2] = data.direction | 0;+ u32[(ptr + 4) >> 2] = data.crossAxisCount | 0;+ f32[(ptr + 8) >> 2] = data.itemSize.x; f32[((ptr + 8) >> 2) + 1] = data.itemSize.y;+ f32[(ptr + 16) >> 2] = data.spacing.x; f32[((ptr + 16) >> 2) + 1] = data.spacing.y;+}++export function createGridLayoutData(): GridLayoutPtrData {+ return {+ direction: 0,+ crossAxisCount: 0,+ itemSize: { x: 0, y: 0 },+ spacing: { x: 0, y: 0 },+ };+}++export interface VelocityPtrData {+ linear: Vec3;+ angular: Vec3;+}++export function fillVelocity(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: VelocityPtrData,+): void {+ const linear_ = out.linear; linear_.x = f32[ptr >> 2]; linear_.y = f32[(ptr >> 2) + 1]; linear_.z = f32[(ptr >> 2) + 2];+ const angular_ = out.angular; angular_.x = f32[(ptr + 12) >> 2]; angular_.y = f32[((ptr + 12) >> 2) + 1]; angular_.z = f32[((ptr + 12) >> 2) + 2];+}++export function writeVelocity(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: VelocityPtrData,+): void {+ f32[ptr >> 2] = data.linear.x; f32[(ptr >> 2) + 1] = data.linear.y; f32[(ptr >> 2) + 2] = data.linear.z;+ f32[(ptr + 12) >> 2] = data.angular.x; f32[((ptr + 12) >> 2) + 1] = data.angular.y; f32[((ptr + 12) >> 2) + 2] = data.angular.z;+}++export function createVelocityData(): VelocityPtrData {+ return {+ linear: { x: 0, y: 0, z: 0 },+ angular: { x: 0, y: 0, z: 0 },+ };+}++export interface SpineAnimationPtrData {+ timeScale: number;+ loop: boolean;+ playing: boolean;+ flipX: boolean;+ flipY: boolean;+ color: Color;+ layer: number;+ skeletonScale: number;+ material: number;+ enabled: boolean;+}++export function fillSpineAnimation(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: SpineAnimationPtrData,+): void {+ out.timeScale = f32[ptr >> 2];+ out.loop = u8[ptr + 4] !== 0;+ out.playing = u8[ptr + 5] !== 0;+ out.flipX = u8[ptr + 6] !== 0;+ out.flipY = u8[ptr + 7] !== 0;+ 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];+ out.layer = u32[(ptr + 24) >> 2] | 0;+ out.skeletonScale = f32[(ptr + 28) >> 2];+ out.material = u32[(ptr + 32) >> 2];+ out.enabled = u8[ptr + 36] !== 0;+}++export function writeSpineAnimation(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: SpineAnimationPtrData,+): void {+ f32[ptr >> 2] = data.timeScale;+ u8[ptr + 4] = data.loop ? 1 : 0;+ u8[ptr + 5] = data.playing ? 1 : 0;+ u8[ptr + 6] = data.flipX ? 1 : 0;+ u8[ptr + 7] = data.flipY ? 1 : 0;+ 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;+ u32[(ptr + 24) >> 2] = data.layer | 0;+ f32[(ptr + 28) >> 2] = data.skeletonScale;+ u32[(ptr + 32) >> 2] = data.material;+ u8[ptr + 36] = data.enabled ? 1 : 0;+}++export function createSpineAnimationData(): SpineAnimationPtrData {+ return {+ timeScale: 0,+ loop: false,+ playing: false,+ flipX: false,+ flipY: false,+ color: { r: 0, g: 0, b: 0, a: 0 },+ layer: 0,+ skeletonScale: 0,+ material: 0,+ enabled: false,+ };+}++export interface InteractablePtrData {+ enabled: boolean;+ blockRaycast: boolean;+ raycastTarget: boolean;+}++export function fillInteractable(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: InteractablePtrData,+): void {+ out.enabled = u8[ptr] !== 0;+ out.blockRaycast = u8[ptr + 1] !== 0;+ out.raycastTarget = u8[ptr + 2] !== 0;+}++export function writeInteractable(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: InteractablePtrData,+): void {+ u8[ptr] = data.enabled ? 1 : 0;+ u8[ptr + 1] = data.blockRaycast ? 1 : 0;+ u8[ptr + 2] = data.raycastTarget ? 1 : 0;+}++export function createInteractableData(): InteractablePtrData {+ return {+ enabled: false,+ blockRaycast: false,+ raycastTarget: false,+ };+}++export interface UIInteractionPtrData {+ hovered: boolean;+ pressed: boolean;+ justPressed: boolean;+ justReleased: boolean;+}++export function fillUIInteraction(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: UIInteractionPtrData,+): void {+ out.hovered = u8[ptr] !== 0;+ out.pressed = u8[ptr + 1] !== 0;+ out.justPressed = u8[ptr + 2] !== 0;+ out.justReleased = u8[ptr + 3] !== 0;+}++export function writeUIInteraction(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: UIInteractionPtrData,+): void {+ u8[ptr] = data.hovered ? 1 : 0;+ u8[ptr + 1] = data.pressed ? 1 : 0;+ u8[ptr + 2] = data.justPressed ? 1 : 0;+ u8[ptr + 3] = data.justReleased ? 1 : 0;+}++export function createUIInteractionData(): UIInteractionPtrData {+ return {+ hovered: false,+ pressed: false,+ justPressed: false,+ justReleased: false,+ };+}++export interface RigidBodyPtrData {+ bodyType: number;+ gravityScale: number;+ linearDamping: number;+ angularDamping: number;+ fixedRotation: boolean;+ bullet: boolean;+ enabled: boolean;+}++export function fillRigidBody(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: RigidBodyPtrData,+): void {+ out.bodyType = u8[ptr];+ out.gravityScale = f32[(ptr + 4) >> 2];+ out.linearDamping = f32[(ptr + 8) >> 2];+ out.angularDamping = f32[(ptr + 12) >> 2];+ out.fixedRotation = u8[ptr + 16] !== 0;+ out.bullet = u8[ptr + 17] !== 0;+ out.enabled = u8[ptr + 18] !== 0;+}++export function writeRigidBody(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: RigidBodyPtrData,+): void {+ u8[ptr] = data.bodyType;+ f32[(ptr + 4) >> 2] = data.gravityScale;+ f32[(ptr + 8) >> 2] = data.linearDamping;+ f32[(ptr + 12) >> 2] = data.angularDamping;+ u8[ptr + 16] = data.fixedRotation ? 1 : 0;+ u8[ptr + 17] = data.bullet ? 1 : 0;+ u8[ptr + 18] = data.enabled ? 1 : 0;+}++export function createRigidBodyData(): RigidBodyPtrData {+ return {+ bodyType: 0,+ gravityScale: 0,+ linearDamping: 0,+ angularDamping: 0,+ fixedRotation: false,+ bullet: false,+ enabled: false,+ };+}++export interface BitmapTextPtrData {+ color: Color;+ fontSize: number;+ align: number;+ spacing: number;+ layer: number;+ font: number;+ enabled: boolean;+}++export function fillBitmapText(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: BitmapTextPtrData,+): void {+ const color_ = out.color; color_.r = f32[ptr >> 2]; color_.g = f32[(ptr >> 2) + 1]; color_.b = f32[(ptr >> 2) + 2]; color_.a = f32[(ptr >> 2) + 3];+ out.fontSize = f32[(ptr + 16) >> 2];+ out.align = u8[ptr + 20];+ out.spacing = f32[(ptr + 24) >> 2];+ out.layer = u32[(ptr + 28) >> 2] | 0;+ out.font = u32[(ptr + 32) >> 2];+ out.enabled = u8[ptr + 36] !== 0;+}++export function writeBitmapText(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: BitmapTextPtrData,+): void {+ f32[ptr >> 2] = data.color.r; f32[(ptr >> 2) + 1] = data.color.g; f32[(ptr >> 2) + 2] = data.color.b; f32[(ptr >> 2) + 3] = data.color.a;+ f32[(ptr + 16) >> 2] = data.fontSize;+ u8[ptr + 20] = data.align;+ f32[(ptr + 24) >> 2] = data.spacing;+ u32[(ptr + 28) >> 2] = data.layer | 0;+ u32[(ptr + 32) >> 2] = data.font;+ u8[ptr + 36] = data.enabled ? 1 : 0;+}++export function createBitmapTextData(): BitmapTextPtrData {+ return {+ color: { r: 0, g: 0, b: 0, a: 0 },+ fontSize: 0,+ align: 0,+ spacing: 0,+ layer: 0,+ font: 0,+ enabled: false,+ };+}++export interface SpritePtrData {+ texture: number;+ color: Color;+ size: Vec2;+ pivot: Vec2;+ uvOffset: Vec2;+ uvScale: Vec2;+ layer: number;+ flipX: boolean;+ flipY: boolean;+ tileSize: Vec2;+ tileSpacing: Vec2;+ material: number;+ enabled: boolean;+}++export function fillSprite(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: SpritePtrData,+): void {+ out.texture = u32[ptr >> 2];+ const color_ = out.color; color_.r = f32[(ptr + 4) >> 2]; color_.g = f32[((ptr + 4) >> 2) + 1]; color_.b = f32[((ptr + 4) >> 2) + 2]; color_.a = f32[((ptr + 4) >> 2) + 3];+ const size_ = out.size; size_.x = f32[(ptr + 20) >> 2]; size_.y = f32[((ptr + 20) >> 2) + 1];+ const pivot_ = out.pivot; pivot_.x = f32[(ptr + 28) >> 2]; pivot_.y = f32[((ptr + 28) >> 2) + 1];+ const uvOffset_ = out.uvOffset; uvOffset_.x = f32[(ptr + 36) >> 2]; uvOffset_.y = f32[((ptr + 36) >> 2) + 1];+ const uvScale_ = out.uvScale; uvScale_.x = f32[(ptr + 44) >> 2]; uvScale_.y = f32[((ptr + 44) >> 2) + 1];+ out.layer = u32[(ptr + 52) >> 2] | 0;+ out.flipX = u8[ptr + 56] !== 0;+ out.flipY = u8[ptr + 57] !== 0;+ const tileSize_ = out.tileSize; tileSize_.x = f32[(ptr + 60) >> 2]; tileSize_.y = f32[((ptr + 60) >> 2) + 1];+ const tileSpacing_ = out.tileSpacing; tileSpacing_.x = f32[(ptr + 68) >> 2]; tileSpacing_.y = f32[((ptr + 68) >> 2) + 1];+ out.material = u32[(ptr + 76) >> 2];+ out.enabled = u8[ptr + 80] !== 0;+}++export function writeSprite(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: SpritePtrData,+): void {+ u32[ptr >> 2] = data.texture;+ f32[(ptr + 4) >> 2] = data.color.r; f32[((ptr + 4) >> 2) + 1] = data.color.g; f32[((ptr + 4) >> 2) + 2] = data.color.b; f32[((ptr + 4) >> 2) + 3] = data.color.a;+ f32[(ptr + 20) >> 2] = data.size.x; f32[((ptr + 20) >> 2) + 1] = data.size.y;+ f32[(ptr + 28) >> 2] = data.pivot.x; f32[((ptr + 28) >> 2) + 1] = data.pivot.y;+ f32[(ptr + 36) >> 2] = data.uvOffset.x; f32[((ptr + 36) >> 2) + 1] = data.uvOffset.y;+ f32[(ptr + 44) >> 2] = data.uvScale.x; f32[((ptr + 44) >> 2) + 1] = data.uvScale.y;+ u32[(ptr + 52) >> 2] = data.layer | 0;+ u8[ptr + 56] = data.flipX ? 1 : 0;+ u8[ptr + 57] = data.flipY ? 1 : 0;+ f32[(ptr + 60) >> 2] = data.tileSize.x; f32[((ptr + 60) >> 2) + 1] = data.tileSize.y;+ f32[(ptr + 68) >> 2] = data.tileSpacing.x; f32[((ptr + 68) >> 2) + 1] = data.tileSpacing.y;+ u32[(ptr + 76) >> 2] = data.material;+ u8[ptr + 80] = data.enabled ? 1 : 0;+}++export function createSpriteData(): SpritePtrData {+ return {+ texture: 0,+ color: { r: 0, g: 0, b: 0, a: 0 },+ size: { x: 0, y: 0 },+ pivot: { x: 0, y: 0 },+ uvOffset: { x: 0, y: 0 },+ uvScale: { x: 0, y: 0 },+ layer: 0,+ flipX: false,+ flipY: false,+ tileSize: { x: 0, y: 0 },+ tileSpacing: { x: 0, y: 0 },+ material: 0,+ enabled: false,+ };+}++export interface UIMaskPtrData {+ enabled: boolean;+ mode: number;+}++export function fillUIMask(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: UIMaskPtrData,+): void {+ out.enabled = u8[ptr] !== 0;+ out.mode = u8[ptr + 1];+}++export function writeUIMask(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: UIMaskPtrData,+): void {+ u8[ptr] = data.enabled ? 1 : 0;+ u8[ptr + 1] = data.mode;+}++export function createUIMaskData(): UIMaskPtrData {+ return {+ enabled: false,+ mode: 0,+ };+}++export interface FlexContainerPtrData {+ direction: number;+ wrap: number;+ justifyContent: number;+ alignItems: number;+ alignContent: number;+ gap: Vec2;+}++export function fillFlexContainer(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: FlexContainerPtrData,+): void {+ out.direction = u8[ptr];+ out.wrap = u8[ptr + 1];+ out.justifyContent = u8[ptr + 2];+ out.alignItems = u8[ptr + 3];+ out.alignContent = u8[ptr + 4];+ const gap_ = out.gap; gap_.x = f32[(ptr + 8) >> 2]; gap_.y = f32[((ptr + 8) >> 2) + 1];+}++export function writeFlexContainer(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: FlexContainerPtrData,+): void {+ u8[ptr] = data.direction;+ u8[ptr + 1] = data.wrap;+ u8[ptr + 2] = data.justifyContent;+ u8[ptr + 3] = data.alignItems;+ u8[ptr + 4] = data.alignContent;+ f32[(ptr + 8) >> 2] = data.gap.x; f32[((ptr + 8) >> 2) + 1] = data.gap.y;+}++export function createFlexContainerData(): FlexContainerPtrData {+ return {+ direction: 0,+ wrap: 0,+ justifyContent: 0,+ alignItems: 0,+ alignContent: 0,+ gap: { x: 0, y: 0 },+ };+}++export interface ShapeRendererPtrData {+ shapeType: number;+ color: Color;+ size: Vec2;+ cornerRadius: number;+ layer: number;+ enabled: boolean;+}++export function fillShapeRenderer(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: ShapeRendererPtrData,+): void {+ out.shapeType = u8[ptr];+ const color_ = out.color; color_.r = f32[(ptr + 4) >> 2]; color_.g = f32[((ptr + 4) >> 2) + 1]; color_.b = f32[((ptr + 4) >> 2) + 2]; color_.a = f32[((ptr + 4) >> 2) + 3];+ const size_ = out.size; size_.x = f32[(ptr + 20) >> 2]; size_.y = f32[((ptr + 20) >> 2) + 1];+ out.cornerRadius = f32[(ptr + 28) >> 2];+ out.layer = u32[(ptr + 32) >> 2] | 0;+ out.enabled = u8[ptr + 36] !== 0;+}++export function writeShapeRenderer(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: ShapeRendererPtrData,+): void {+ u8[ptr] = data.shapeType;+ f32[(ptr + 4) >> 2] = data.color.r; f32[((ptr + 4) >> 2) + 1] = data.color.g; f32[((ptr + 4) >> 2) + 2] = data.color.b; f32[((ptr + 4) >> 2) + 3] = data.color.a;+ f32[(ptr + 20) >> 2] = data.size.x; f32[((ptr + 20) >> 2) + 1] = data.size.y;+ f32[(ptr + 28) >> 2] = data.cornerRadius;+ u32[(ptr + 32) >> 2] = data.layer | 0;+ u8[ptr + 36] = data.enabled ? 1 : 0;+}++export function createShapeRendererData(): ShapeRendererPtrData {+ return {+ shapeType: 0,+ color: { r: 0, g: 0, b: 0, a: 0 },+ size: { x: 0, y: 0 },+ cornerRadius: 0,+ layer: 0,+ enabled: false,+ };+}++export interface SelectablePtrData {+ selected: boolean;+ group: number;+}++export function fillSelectable(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: SelectablePtrData,+): void {+ out.selected = u8[ptr] !== 0;+ out.group = u32[(ptr + 4) >> 2] | 0;+}++export function writeSelectable(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: SelectablePtrData,+): void {+ u8[ptr] = data.selected ? 1 : 0;+ u32[(ptr + 4) >> 2] = data.group | 0;+}++export function createSelectableData(): SelectablePtrData {+ return {+ selected: false,+ group: 0,+ };+}++export interface LayoutGroupPtrData {+ direction: number;+ spacing: number;+ childAlignment: number;+ reverseOrder: boolean;+}++export function fillLayoutGroup(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: LayoutGroupPtrData,+): void {+ out.direction = u8[ptr];+ out.spacing = f32[(ptr + 4) >> 2];+ out.childAlignment = u8[ptr + 8];+ out.reverseOrder = u8[ptr + 9] !== 0;+}++export function writeLayoutGroup(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: LayoutGroupPtrData,+): void {+ u8[ptr] = data.direction;+ f32[(ptr + 4) >> 2] = data.spacing;+ u8[ptr + 8] = data.childAlignment;+ u8[ptr + 9] = data.reverseOrder ? 1 : 0;+}++export function createLayoutGroupData(): LayoutGroupPtrData {+ return {+ direction: 0,+ spacing: 0,+ childAlignment: 0,+ reverseOrder: false,+ };+}++export interface CanvasPtrData {+ designResolution: Vec2;+ pixelsPerUnit: number;+ scaleMode: number;+ matchWidthOrHeight: number;+ backgroundColor: Color;+}++export function fillCanvas(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: CanvasPtrData,+): void {+ const designResolution_ = out.designResolution; designResolution_.x = f32[ptr >> 2]; designResolution_.y = f32[(ptr >> 2) + 1];+ out.pixelsPerUnit = f32[(ptr + 8) >> 2];+ out.scaleMode = u8[ptr + 12];+ out.matchWidthOrHeight = f32[(ptr + 16) >> 2];+ const backgroundColor_ = out.backgroundColor; backgroundColor_.r = f32[(ptr + 20) >> 2]; backgroundColor_.g = f32[((ptr + 20) >> 2) + 1]; backgroundColor_.b = f32[((ptr + 20) >> 2) + 2]; backgroundColor_.a = f32[((ptr + 20) >> 2) + 3];+}++export function writeCanvas(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: CanvasPtrData,+): void {+ f32[ptr >> 2] = data.designResolution.x; f32[(ptr >> 2) + 1] = data.designResolution.y;+ f32[(ptr + 8) >> 2] = data.pixelsPerUnit;+ u8[ptr + 12] = data.scaleMode;+ f32[(ptr + 16) >> 2] = data.matchWidthOrHeight;+ f32[(ptr + 20) >> 2] = data.backgroundColor.r; f32[((ptr + 20) >> 2) + 1] = data.backgroundColor.g; f32[((ptr + 20) >> 2) + 2] = data.backgroundColor.b; f32[((ptr + 20) >> 2) + 3] = data.backgroundColor.a;+}++export function createCanvasData(): CanvasPtrData {+ return {+ designResolution: { x: 0, y: 0 },+ pixelsPerUnit: 0,+ scaleMode: 0,+ matchWidthOrHeight: 0,+ backgroundColor: { r: 0, g: 0, b: 0, a: 0 },+ };+}++export interface CameraPtrData {+ projectionType: number;+ fov: number;+ orthoSize: number;+ nearPlane: number;+ farPlane: number;+ aspectRatio: number;+ isActive: boolean;+ priority: number;+ viewportX: number;+ viewportY: number;+ viewportW: number;+ viewportH: number;+ clearFlags: number;+}++export function fillCamera(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, out: CameraPtrData,+): void {+ out.projectionType = u8[ptr];+ out.fov = f32[(ptr + 4) >> 2];+ out.orthoSize = f32[(ptr + 8) >> 2];+ out.nearPlane = f32[(ptr + 12) >> 2];+ out.farPlane = f32[(ptr + 16) >> 2];+ out.aspectRatio = f32[(ptr + 20) >> 2];+ out.isActive = u8[ptr + 24] !== 0;+ out.priority = u32[(ptr + 28) >> 2] | 0;+ out.viewportX = f32[(ptr + 32) >> 2];+ out.viewportY = f32[(ptr + 36) >> 2];+ out.viewportW = f32[(ptr + 40) >> 2];+ out.viewportH = f32[(ptr + 44) >> 2];+ out.clearFlags = u32[(ptr + 48) >> 2] | 0;+}++export function writeCamera(+ f32: Float32Array, u32: Uint32Array, u8: Uint8Array,+ ptr: number, data: CameraPtrData,+): void {+ u8[ptr] = data.projectionType;+ f32[(ptr + 4) >> 2] = data.fov;+ f32[(ptr + 8) >> 2] = data.orthoSize;+ f32[(ptr + 12) >> 2] = data.nearPlane;+ f32[(ptr + 16) >> 2] = data.farPlane;+ f32[(ptr + 20) >> 2] = data.aspectRatio;+ u8[ptr + 24] = data.isActive ? 1 : 0;+ u32[(ptr + 28) >> 2] = data.priority | 0;+ f32[(ptr + 32) >> 2] = data.viewportX;+ f32[(ptr + 36) >> 2] = data.viewportY;+ f32[(ptr + 40) >> 2] = data.viewportW;+ f32[(ptr + 44) >> 2] = data.viewportH;+ u32[(ptr + 48) >> 2] = data.clearFlags | 0;+}++export function createCameraData(): CameraPtrData {+ return {+ projectionType: 0,+ fov: 0,+ orthoSize: 0,+ nearPlane: 0,+ farPlane: 0,+ aspectRatio: 0,+ isActive: false,+ priority: 0,+ viewportX: 0,+ viewportY: 0,+ viewportW: 0,+ viewportH: 0,+ clearFlags: 0,+ };+}++export interface PtrAccessor<T> {+ fill: (f32: Float32Array, u32: Uint32Array, u8: Uint8Array, ptr: number, out: T) => void;+ write: (f32: Float32Array, u32: Uint32Array, u8: Uint8Array, ptr: number, data: T) => void;+ create: () => T;+}++export const PTR_ACCESSORS: Record<string, PtrAccessor<any>> = {+ UIRect: { fill: fillUIRect, write: writeUIRect, create: createUIRectData },+ FlexItem: { fill: fillFlexItem, write: writeFlexItem, create: createFlexItemData },+ BoxCollider: { fill: fillBoxCollider, write: writeBoxCollider, create: createBoxColliderData },+ CircleCollider: { fill: fillCircleCollider, write: writeCircleCollider, create: createCircleColliderData },+ CapsuleCollider: { fill: fillCapsuleCollider, write: writeCapsuleCollider, create: createCapsuleColliderData },+ SegmentCollider: { fill: fillSegmentCollider, write: writeSegmentCollider, create: createSegmentColliderData },+ FanLayout: { fill: fillFanLayout, write: writeFanLayout, create: createFanLayoutData },+ ParticleEmitter: { fill: fillParticleEmitter, write: writeParticleEmitter, create: createParticleEmitterData },+ Transform: { fill: fillTransform, write: writeTransform, create: createTransformData },+ UIRenderer: { fill: fillUIRenderer, write: writeUIRenderer, create: createUIRendererData },+ GridLayout: { fill: fillGridLayout, write: writeGridLayout, create: createGridLayoutData },+ Velocity: { fill: fillVelocity, write: writeVelocity, create: createVelocityData },+ SpineAnimation: { fill: fillSpineAnimation, write: writeSpineAnimation, create: createSpineAnimationData },+ Interactable: { fill: fillInteractable, write: writeInteractable, create: createInteractableData },+ UIInteraction: { fill: fillUIInteraction, write: writeUIInteraction, create: createUIInteractionData },+ RigidBody: { fill: fillRigidBody, write: writeRigidBody, create: createRigidBodyData },+ BitmapText: { fill: fillBitmapText, write: writeBitmapText, create: createBitmapTextData },+ Sprite: { fill: fillSprite, write: writeSprite, create: createSpriteData },+ UIMask: { fill: fillUIMask, write: writeUIMask, create: createUIMaskData },+ FlexContainer: { fill: fillFlexContainer, write: writeFlexContainer, create: createFlexContainerData },+ ShapeRenderer: { fill: fillShapeRenderer, write: writeShapeRenderer, create: createShapeRendererData },+ Selectable: { fill: fillSelectable, write: writeSelectable, create: createSelectableData },+ LayoutGroup: { fill: fillLayoutGroup, write: writeLayoutGroup, create: createLayoutGroupData },+ Canvas: { fill: fillCanvas, write: writeCanvas, create: createCanvasData },+ Camera: { fill: fillCamera, write: writeCamera, create: createCameraData },+};diff --git a/sdk/tests/component.test.ts b/sdk/tests/component.test.tsindex 6b07df958..469a1b555 100644--- a/sdk/tests/component.test.ts+++ b/sdk/tests/component.test.ts@@ -1,11 +1,13 @@import { describe, it, expect, beforeEach } from 'vitest';import {defineComponent,+ defineBuiltin,defineTag,getComponent,getUserComponent,getComponentDefaults,clearUserComponents,+ unregisterComponent,} from '../src/component';describe('Component Registry', () => {@@ -169,6 +171,38 @@ describe('Component Registry', () => {});});+ describe('name collision detection', () => {+ it('should throw when defineComponent collides with a builtin', () => {+ expect(() => defineComponent('Transform', { x: 0 })).toThrow(+ /Component name collision.*"Transform".*builtin/+ );+ });++ it('should throw when defineTag collides with a builtin', () => {+ expect(() => defineTag('Sprite')).toThrow(+ /Component name collision.*"Sprite".*builtin/+ );+ });++ it('should throw when defineBuiltin collides with a user component', () => {+ defineComponent('MyCustom', { v: 1 });+ try {+ expect(() => defineBuiltin('MyCustom', { v: 2 })).toThrow(+ /Component name collision.*"MyCustom".*user/+ );+ } finally {+ unregisterComponent('MyCustom');+ }+ });++ it('should allow idempotent re-registration of the same builtin', () => {+ const first = defineBuiltin('TestBuiltin', { a: 1 });+ const second = defineBuiltin('TestBuiltin', { a: 1 });+ expect(first).toBe(second);+ unregisterComponent('TestBuiltin');+ });+ });+describe('complex scenarios', () => {it('should handle many components', () => {for (let i = 0; i < 100; i++) {diff --git a/src/esengine/renderer/RenderFrame.cpp b/src/esengine/renderer/RenderFrame.cppindex 4203fb85c..a1de988a7 100644--- a/src/esengine/renderer/RenderFrame.cpp+++ b/src/esengine/renderer/RenderFrame.cpp@@ -381,9 +381,10 @@ void RenderFrame::collectAll(ecs::Registry& registry, u32 skipFlags) {auto ctx = makeContext();+ RenderCollectContext collectCtx{registry, frustum_, clip_state_, pool_, draw_list_, ctx};for (auto& plugin : plugins_) {if (skipFlags != 0 && (skipFlags & plugin->skipFlag()) != 0) continue;- plugin->collect(registry, frustum_, clip_state_, pool_, draw_list_, ctx);+ plugin->collect(collectCtx);}}diff --git a/src/esengine/renderer/RenderTypePlugin.hpp b/src/esengine/renderer/RenderTypePlugin.hppindex 87aea4947..115de2b6a 100644--- a/src/esengine/renderer/RenderTypePlugin.hpp+++ b/src/esengine/renderer/RenderTypePlugin.hpp@@ -27,6 +27,15 @@ struct RenderFrameContext {glm::mat4 view_projection{1.0f};};+struct RenderCollectContext {+ ecs::Registry& registry;+ const Frustum& frustum;+ const ClipState& clip_state;+ TransientBufferPool& buffer_pool;+ DrawList& draw_list;+ RenderFrameContext& frame_context;+};+class RenderTypePlugin {public:virtual ~RenderTypePlugin() = default;@@ -36,14 +45,7 @@ public:virtual u32 skipFlag() const { return 0; }- virtual void collect(- ecs::Registry& registry,- const Frustum& frustum,- const ClipState& clips,- TransientBufferPool& buffers,- DrawList& draw_list,- RenderFrameContext& ctx- ) = 0;+ virtual void collect(RenderCollectContext& ctx) = 0;virtual bool needsCustomDraw() const { return false; }virtual bool handlesType(RenderType type) const { (void)type; return false; }diff --git a/src/esengine/renderer/plugins/ParticlePlugin.cpp b/src/esengine/renderer/plugins/ParticlePlugin.cppindex a7dd19b95..170621673 100644--- a/src/esengine/renderer/plugins/ParticlePlugin.cpp+++ b/src/esengine/renderer/plugins/ParticlePlugin.cpp@@ -17,14 +17,12 @@ void ParticlePlugin::init(RenderFrameContext& ctx) {batch_shader_id_ = ctx.batch_shader_id;}-void ParticlePlugin::collect(- ecs::Registry& registry,- const Frustum&,- const ClipState& clips,- TransientBufferPool& buffers,- DrawList& draw_list,- RenderFrameContext& ctx-) {+void ParticlePlugin::collect(RenderCollectContext& collect_ctx) {+ auto& registry = collect_ctx.registry;+ auto& clips = collect_ctx.clip_state;+ auto& buffers = collect_ctx.buffer_pool;+ auto& draw_list = collect_ctx.draw_list;+ auto& ctx = collect_ctx.frame_context;if (!particle_system_) return;auto emitterView = registry.view<ecs::Transform, ecs::ParticleEmitter>();diff --git a/src/esengine/renderer/plugins/ParticlePlugin.hpp b/src/esengine/renderer/plugins/ParticlePlugin.hppindex 051dd79ac..08609cdd5 100644--- a/src/esengine/renderer/plugins/ParticlePlugin.hpp+++ b/src/esengine/renderer/plugins/ParticlePlugin.hpp@@ -15,14 +15,7 @@ public:void setParticleSystem(particle::ParticleSystem* system) { particle_system_ = system; }- void collect(- ecs::Registry& registry,- const Frustum& frustum,- const ClipState& clips,- TransientBufferPool& buffers,- DrawList& draw_list,- RenderFrameContext& ctx- ) override;+ void collect(RenderCollectContext& ctx) override;private:particle::ParticleSystem* particle_system_ = nullptr;diff --git a/src/esengine/renderer/plugins/ShapePlugin.cpp b/src/esengine/renderer/plugins/ShapePlugin.cppindex 59d223f60..0262704a6 100644--- a/src/esengine/renderer/plugins/ShapePlugin.cpp+++ b/src/esengine/renderer/plugins/ShapePlugin.cpp@@ -27,14 +27,13 @@ void ShapePlugin::init(RenderFrameContext& ctx) {void ShapePlugin::shutdown() {}-void ShapePlugin::collect(- ecs::Registry& registry,- const Frustum& frustum,- const ClipState& clips,- TransientBufferPool& buffers,- DrawList& draw_list,- RenderFrameContext& ctx-) {+void ShapePlugin::collect(RenderCollectContext& collect_ctx) {+ auto& registry = collect_ctx.registry;+ auto& frustum = collect_ctx.frustum;+ auto& clips = collect_ctx.clip_state;+ auto& buffers = collect_ctx.buffer_pool;+ auto& draw_list = collect_ctx.draw_list;+ auto& ctx = collect_ctx.frame_context;auto shapeView = registry.view<ecs::Transform, ecs::ShapeRenderer>();for (auto entity : shapeView) {diff --git a/src/esengine/renderer/plugins/ShapePlugin.hpp b/src/esengine/renderer/plugins/ShapePlugin.hppindex 02d450bf7..5959d6ac7 100644--- a/src/esengine/renderer/plugins/ShapePlugin.hpp+++ b/src/esengine/renderer/plugins/ShapePlugin.hpp@@ -11,14 +11,7 @@ public:void init(RenderFrameContext& ctx) override;void shutdown() override;- void collect(- ecs::Registry& registry,- const Frustum& frustum,- const ClipState& clips,- TransientBufferPool& buffers,- DrawList& draw_list,- RenderFrameContext& ctx- ) override;+ void collect(RenderCollectContext& ctx) override;bool needsCustomDraw() const override { return true; }bool handlesType(RenderType type) const override { return type == RenderType::Shape; }diff --git a/src/esengine/renderer/plugins/SpinePlugin.cpp b/src/esengine/renderer/plugins/SpinePlugin.cppindex 29b069e40..93845fd0b 100644--- a/src/esengine/renderer/plugins/SpinePlugin.cpp+++ b/src/esengine/renderer/plugins/SpinePlugin.cpp@@ -219,14 +219,12 @@ void SpinePlugin::emitMeshAttachment(emitBatch(textureId, blend, buffers, draw_list, clips, entity, layer, depth, ctx);}-void SpinePlugin::collect(- ecs::Registry& registry,- const Frustum& /* frustum */,- const ClipState& clips,- TransientBufferPool& buffers,- DrawList& draw_list,- RenderFrameContext& ctx-) {+void SpinePlugin::collect(RenderCollectContext& collect_ctx) {+ auto& registry = collect_ctx.registry;+ auto& clips = collect_ctx.clip_state;+ auto& buffers = collect_ctx.buffer_pool;+ auto& draw_list = collect_ctx.draw_list;+ auto& ctx = collect_ctx.frame_context;if (!spine_system_) return;auto view = registry.view<ecs::SpineAnimation>();diff --git a/src/esengine/renderer/plugins/SpinePlugin.hpp b/src/esengine/renderer/plugins/SpinePlugin.hppindex 0ed6caa5c..090c6b381 100644--- a/src/esengine/renderer/plugins/SpinePlugin.hpp+++ b/src/esengine/renderer/plugins/SpinePlugin.hpp@@ -21,14 +21,7 @@ public:void setSpineSystem(spine::SpineSystem* system) { spine_system_ = system; }- void collect(- ecs::Registry& registry,- const Frustum& frustum,- const ClipState& clips,- TransientBufferPool& buffers,- DrawList& draw_list,- RenderFrameContext& ctx- ) override;+ void collect(RenderCollectContext& ctx) override;private:u32 getTextureId(void* spineTexture, RenderFrameContext& ctx);diff --git a/src/esengine/renderer/plugins/SpritePlugin.cpp b/src/esengine/renderer/plugins/SpritePlugin.cppindex c82ed78ce..c40e87c7d 100644--- a/src/esengine/renderer/plugins/SpritePlugin.cpp+++ b/src/esengine/renderer/plugins/SpritePlugin.cpp@@ -14,14 +14,13 @@ void SpritePlugin::init(RenderFrameContext& ctx) {batch_shader_id_ = ctx.batch_shader_id;}-void SpritePlugin::collect(- ecs::Registry& registry,- const Frustum& frustum,- const ClipState& clips,- TransientBufferPool& buffers,- DrawList& draw_list,- RenderFrameContext& ctx-) {+void SpritePlugin::collect(RenderCollectContext& collect_ctx) {+ auto& registry = collect_ctx.registry;+ auto& frustum = collect_ctx.frustum;+ auto& clips = collect_ctx.clip_state;+ auto& buffers = collect_ctx.buffer_pool;+ auto& draw_list = collect_ctx.draw_list;+ auto& ctx = collect_ctx.frame_context;auto spriteView = registry.view<ecs::Transform, ecs::Sprite>();for (auto entity : spriteView) {diff --git a/src/esengine/renderer/plugins/SpritePlugin.hpp b/src/esengine/renderer/plugins/SpritePlugin.hppindex 006506baa..ef0187945 100644--- a/src/esengine/renderer/plugins/SpritePlugin.hpp+++ b/src/esengine/renderer/plugins/SpritePlugin.hpp@@ -11,14 +11,7 @@ public:void init(RenderFrameContext& ctx) override;void shutdown() override {}- void collect(- ecs::Registry& registry,- const Frustum& frustum,- const ClipState& clips,- TransientBufferPool& buffers,- DrawList& draw_list,- RenderFrameContext& ctx- ) override;+ void collect(RenderCollectContext& ctx) override;private:static constexpr glm::vec4 QUAD_POSITIONS[4] = {diff --git a/src/esengine/renderer/plugins/TextPlugin.cpp b/src/esengine/renderer/plugins/TextPlugin.cppindex 2596c7474..9d0811508 100644--- a/src/esengine/renderer/plugins/TextPlugin.cpp+++ b/src/esengine/renderer/plugins/TextPlugin.cpp@@ -43,14 +43,13 @@ u32 TextPlugin::decodeUtf8(const char* data, u16 length, u16& pos) {return b0;}-void TextPlugin::collect(- ecs::Registry& registry,- const Frustum& frustum,- const ClipState& clips,- TransientBufferPool& buffers,- DrawList& draw_list,- RenderFrameContext& ctx-) {+void TextPlugin::collect(RenderCollectContext& collect_ctx) {+ auto& registry = collect_ctx.registry;+ auto& frustum = collect_ctx.frustum;+ auto& clips = collect_ctx.clip_state;+ auto& buffers = collect_ctx.buffer_pool;+ auto& draw_list = collect_ctx.draw_list;+ auto& ctx = collect_ctx.frame_context;auto textView = registry.view<ecs::Transform, ecs::BitmapText>();for (auto entity : textView) {diff --git a/src/esengine/renderer/plugins/TextPlugin.hpp b/src/esengine/renderer/plugins/TextPlugin.hppindex dc49aaa7b..9e7e9d2e5 100644--- a/src/esengine/renderer/plugins/TextPlugin.hpp+++ b/src/esengine/renderer/plugins/TextPlugin.hpp@@ -11,14 +11,7 @@ public:void init(RenderFrameContext& ctx) override;void shutdown() override {}- void collect(- ecs::Registry& registry,- const Frustum& frustum,- const ClipState& clips,- TransientBufferPool& buffers,- DrawList& draw_list,- RenderFrameContext& ctx- ) override;+ void collect(RenderCollectContext& ctx) override;private:static constexpr u16 QUAD_INDICES[6] = { 0, 1, 2, 2, 3, 0 };diff --git a/src/esengine/renderer/plugins/TilemapRenderPlugin.cpp b/src/esengine/renderer/plugins/TilemapRenderPlugin.cppindex 1bfc08178..a3ac2d90b 100644--- a/src/esengine/renderer/plugins/TilemapRenderPlugin.cpp+++ b/src/esengine/renderer/plugins/TilemapRenderPlugin.cpp@@ -90,14 +90,12 @@ void TilemapRenderPlugin::rebuildChunk(}}-void TilemapRenderPlugin::collect(- ecs::Registry& registry,- const Frustum& /* frustum */,- const ClipState& clips,- TransientBufferPool& buffers,- DrawList& draw_list,- RenderFrameContext& ctx-) {+void TilemapRenderPlugin::collect(RenderCollectContext& collect_ctx) {+ auto& registry = collect_ctx.registry;+ auto& clips = collect_ctx.clip_state;+ auto& buffers = collect_ctx.buffer_pool;+ auto& draw_list = collect_ctx.draw_list;+ auto& ctx = collect_ctx.frame_context;if (!tilemap_system_) return;const auto& layers = tilemap_system_->allLayers();diff --git a/src/esengine/renderer/plugins/TilemapRenderPlugin.hpp b/src/esengine/renderer/plugins/TilemapRenderPlugin.hppindex eb72af2c8..04ec6f0b6 100644--- a/src/esengine/renderer/plugins/TilemapRenderPlugin.hpp+++ b/src/esengine/renderer/plugins/TilemapRenderPlugin.hpp@@ -19,14 +19,7 @@ public:void setTilemapSystem(tilemap::TilemapSystem* system) { tilemap_system_ = system; }- void collect(- ecs::Registry& registry,- const Frustum& frustum,- const ClipState& clips,- TransientBufferPool& buffers,- DrawList& draw_list,- RenderFrameContext& ctx- ) override;+ void collect(RenderCollectContext& ctx) override;private:struct ChunkCache {diff --git a/src/esengine/renderer/plugins/UIElementPlugin.cpp b/src/esengine/renderer/plugins/UIElementPlugin.cppindex ca949e906..573a9f61e 100644--- a/src/esengine/renderer/plugins/UIElementPlugin.cpp+++ b/src/esengine/renderer/plugins/UIElementPlugin.cpp@@ -14,14 +14,13 @@ void UIElementPlugin::init(RenderFrameContext& ctx) {batch_shader_id_ = ctx.batch_shader_id;}-void UIElementPlugin::collect(- ecs::Registry& registry,- const Frustum& frustum,- const ClipState& clips,- TransientBufferPool& buffers,- DrawList& draw_list,- RenderFrameContext& ctx-) {+void UIElementPlugin::collect(RenderCollectContext& collect_ctx) {+ auto& registry = collect_ctx.registry;+ auto& frustum = collect_ctx.frustum;+ auto& clips = collect_ctx.clip_state;+ auto& buffers = collect_ctx.buffer_pool;+ auto& draw_list = collect_ctx.draw_list;+ auto& ctx = collect_ctx.frame_context;auto uiView = registry.view<ecs::Transform, ecs::UIRenderer, ecs::UIRect>();for (auto entity : uiView) {diff --git a/src/esengine/renderer/plugins/UIElementPlugin.hpp b/src/esengine/renderer/plugins/UIElementPlugin.hppindex 71f61b35c..cac4c8b19 100644--- a/src/esengine/renderer/plugins/UIElementPlugin.hpp+++ b/src/esengine/renderer/plugins/UIElementPlugin.hpp@@ -11,14 +11,7 @@ public:void init(RenderFrameContext& ctx) override;void shutdown() override {}- void collect(- ecs::Registry& registry,- const Frustum& frustum,- const ClipState& clips,- TransientBufferPool& buffers,- DrawList& draw_list,- RenderFrameContext& ctx- ) override;+ void collect(RenderCollectContext& ctx) override;private:static constexpr glm::vec4 QUAD_POSITIONS[4] = {diff --git a/tools/eht.py b/tools/eht.pyindex 2abd7f514..58cffbef2 100644--- a/tools/eht.py+++ b/tools/eht.py@@ -1269,6 +1269,148 @@ class PtrLayoutGenerator:lines.extend(['};', ''])return '\n'.join(lines)+ def _ts_type_for(self, ptr_type: str) -> str:+ return {+ 'f32': 'number', 'i32': 'number', 'u32': 'number',+ 'bool': 'boolean', 'u8': 'number',+ 'vec2': 'Vec2', 'vec3': 'Vec3', 'vec4': 'Vec4',+ 'quat': 'Vec4', 'color': 'Color',+ }[ptr_type]++ def generate_accessors(self) -> str:+ lines = [+ '/**',+ ' * @file ptrAccessors.generated.ts',+ ' * @brief Auto-generated type-safe WASM pointer accessors',+ ' * @details Generated by EHT - DO NOT EDIT',+ ' */',+ '',+ 'interface Vec2 { x: number; y: number; }',+ 'interface Vec3 { x: number; y: number; z: number; }',+ 'interface Vec4 { x: number; y: number; z: number; w: number; }',+ 'interface Color { r: number; g: number; b: number; a: number; }',+ '',+ ]++ accessor_names = []++ for layout in self.layouts:+ name = layout['name']+ fields = layout['fields']++ # Generate data interface+ lines.append(f'export interface {name}PtrData {{')+ for f in fields:+ ts_type = self._ts_type_for(f['type'])+ lines.append(f' {f["name"]}: {ts_type};')+ lines.append('}')+ lines.append('')++ # Generate fill function (mutates pre-allocated object)+ lines.append(f'export function fill{name}(')+ lines.append(f' f32: Float32Array, u32: Uint32Array, u8: Uint8Array,')+ lines.append(f' ptr: number, out: {name}PtrData,')+ lines.append(f'): void {{')+ for f in fields:+ byte_off = f['offset']+ idx_expr = f'(ptr + {byte_off}) >> 2' if byte_off else 'ptr >> 2'+ byte_expr = f'ptr + {byte_off}' if byte_off else 'ptr'+ ft = f['type']+ fn = f['name']+ if ft == 'f32':+ lines.append(f' out.{fn} = f32[{idx_expr}];')+ elif ft == 'i32':+ lines.append(f' out.{fn} = u32[{idx_expr}] | 0;')+ elif ft == 'u32':+ lines.append(f' out.{fn} = u32[{idx_expr}];')+ elif ft == 'bool':+ lines.append(f' out.{fn} = u8[{byte_expr}] !== 0;')+ elif ft == 'u8':+ lines.append(f' out.{fn} = u8[{byte_expr}];')+ elif ft == 'vec2':+ lines.append(f' const {fn}_ = out.{fn}; {fn}_.x = f32[{idx_expr}]; {fn}_.y = f32[({idx_expr}) + 1];')+ elif ft == 'vec3':+ lines.append(f' const {fn}_ = out.{fn}; {fn}_.x = f32[{idx_expr}]; {fn}_.y = f32[({idx_expr}) + 1]; {fn}_.z = f32[({idx_expr}) + 2];')+ elif ft in ('vec4', 'quat'):+ lines.append(f' const {fn}_ = out.{fn}; {fn}_.x = f32[{idx_expr}]; {fn}_.y = f32[({idx_expr}) + 1]; {fn}_.z = f32[({idx_expr}) + 2]; {fn}_.w = f32[({idx_expr}) + 3];')+ elif ft == 'color':+ lines.append(f' const {fn}_ = out.{fn}; {fn}_.r = f32[{idx_expr}]; {fn}_.g = f32[({idx_expr}) + 1]; {fn}_.b = f32[({idx_expr}) + 2]; {fn}_.a = f32[({idx_expr}) + 3];')+ lines.append('}')+ lines.append('')++ # Generate write function+ lines.append(f'export function write{name}(')+ lines.append(f' f32: Float32Array, u32: Uint32Array, u8: Uint8Array,')+ lines.append(f' ptr: number, data: {name}PtrData,')+ lines.append(f'): void {{')+ for f in fields:+ byte_off = f['offset']+ idx_expr = f'(ptr + {byte_off}) >> 2' if byte_off else 'ptr >> 2'+ byte_expr = f'ptr + {byte_off}' if byte_off else 'ptr'+ ft = f['type']+ fn = f['name']+ if ft == 'f32':+ lines.append(f' f32[{idx_expr}] = data.{fn};')+ elif ft == 'i32':+ lines.append(f' u32[{idx_expr}] = data.{fn} | 0;')+ elif ft == 'u32':+ lines.append(f' u32[{idx_expr}] = data.{fn};')+ elif ft == 'bool':+ lines.append(f' u8[{byte_expr}] = data.{fn} ? 1 : 0;')+ elif ft == 'u8':+ lines.append(f' u8[{byte_expr}] = data.{fn};')+ elif ft == 'vec2':+ lines.append(f' f32[{idx_expr}] = data.{fn}.x; f32[({idx_expr}) + 1] = data.{fn}.y;')+ elif ft == 'vec3':+ lines.append(f' f32[{idx_expr}] = data.{fn}.x; f32[({idx_expr}) + 1] = data.{fn}.y; f32[({idx_expr}) + 2] = data.{fn}.z;')+ elif ft in ('vec4', 'quat'):+ lines.append(f' f32[{idx_expr}] = data.{fn}.x; f32[({idx_expr}) + 1] = data.{fn}.y; f32[({idx_expr}) + 2] = data.{fn}.z; f32[({idx_expr}) + 3] = data.{fn}.w;')+ elif ft == 'color':+ lines.append(f' f32[{idx_expr}] = data.{fn}.r; f32[({idx_expr}) + 1] = data.{fn}.g; f32[({idx_expr}) + 2] = data.{fn}.b; f32[({idx_expr}) + 3] = data.{fn}.a;')+ lines.append('}')+ lines.append('')++ # Generate preallocate function+ lines.append(f'export function create{name}Data(): {name}PtrData {{')+ lines.append(' return {')+ for f in fields:+ ft = f['type']+ fn = f['name']+ if ft in ('f32', 'i32', 'u32', 'u8'):+ lines.append(f' {fn}: 0,')+ elif ft == 'bool':+ lines.append(f' {fn}: false,')+ elif ft == 'vec2':+ lines.append(f' {fn}: {{ x: 0, y: 0 }},')+ elif ft == 'vec3':+ lines.append(f' {fn}: {{ x: 0, y: 0, z: 0 }},')+ elif ft in ('vec4', 'quat'):+ lines.append(f' {fn}: {{ x: 0, y: 0, z: 0, w: 0 }},')+ elif ft == 'color':+ lines.append(f' {fn}: {{ r: 0, g: 0, b: 0, a: 0 }},')+ lines.append(' };')+ lines.append('}')+ lines.append('')++ accessor_names.append(name)++ # Generate accessor registry type+ lines.append('export interface PtrAccessor<T> {')+ lines.append(' fill: (f32: Float32Array, u32: Uint32Array, u8: Uint8Array, ptr: number, out: T) => void;')+ lines.append(' write: (f32: Float32Array, u32: Uint32Array, u8: Uint8Array, ptr: number, data: T) => void;')+ lines.append(' create: () => T;')+ lines.append('}')+ lines.append('')++ # Generate accessor map+ lines.append('export const PTR_ACCESSORS: Record<string, PtrAccessor<any>> = {')+ for name in accessor_names:+ lines.append(f' {name}: {{ fill: fill{name}, write: write{name}, create: create{name}Data }},')+ lines.append('};')+ lines.append('')++ return '\n'.join(lines)+def main():parser = argparse.ArgumentParser(description='EHT - ESEngine Header Tool')@@ -1344,6 +1486,11 @@ def main():print(f"Generating: {ptr_path}")ptr_path.write_text(ptr_gen.generate(), encoding='utf-8')+ accessor_path = args.ts_output / 'src' / 'ecs' / 'ptrAccessors.generated.ts'+ if accessor_path.parent.exists():+ print(f"Generating: {accessor_path}")+ accessor_path.write_text(ptr_gen.generate_accessors(), encoding='utf-8')+print("[OK] Done!")return 0