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(component): single-source ShapeType from a C++ ES_ENUM
yhhffeedc974539
diff --git a/sdk/src/component.generated.ts b/sdk/src/component.generated.tsindex eccc733ff..5d10e0198 100644--- a/sdk/src/component.generated.ts+++ b/sdk/src/component.generated.ts@@ -15,7 +15,7 @@ import type { Dimension, Padding, VisualState } from './wasm.generated';* getAbiLayoutHash(); BuiltinBridge.connect() compares them and refuses to* run on mismatch, because mismatched offsets read the wrong heap bytes.*/-export const ABI_LAYOUT_HASH = 'b129a05be7804b7f';+export const ABI_LAYOUT_HASH = 'b5571b685cb3643f';export interface AssetFieldMeta {field: string;@@ -391,6 +391,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {colorFields: ['color'],animatableFields: [],fields: {+ shapeType: { enum: [{ label: 'Circle', value: 0 }, { label: 'Capsule', value: 1 }, { label: 'RoundedRect', value: 2 }] },cornerRadius: { min: 0 },layer: { step: 1, enumSource: "sortingLayers" },},diff --git a/sdk/src/component.ts b/sdk/src/component.tsindex baa8a7abf..434916638 100644--- a/sdk/src/component.ts+++ b/sdk/src/component.ts@@ -21,10 +21,10 @@ import type {// Builtin enums whose values come from C++ ES_ENUMs — imported from the generated// module (single source) and re-exported below, so a TS const cannot drift from the// C++ enum and the editor dropdowns (enumOptions) derive from the same values. The-// remaining hand-written enums (ShapeType, ParticleEasing) have no matching C++ enum-// yet, so they stay local; ScaleMode's canonical values come from CanvasScaleMode+// one remaining hand-written enum (ParticleEasing) has no matching C++ enum yet, so+// it stays local; ScaleMode's canonical values come from CanvasScaleMode// (only its Cocos-compat aliases ShowAll/NoBorder are TS-side).-import { ProjectionType, ClearFlags, EmitterShape, SimulationSpace, Light2DType, CanvasScaleMode } from './wasm.generated';+import { ProjectionType, ClearFlags, EmitterShape, SimulationSpace, Light2DType, CanvasScaleMode, ShapeType } from './wasm.generated';import { BlendMode } from './blend';import { getDefaultContext } from './context';import type {@@ -504,9 +504,10 @@ export function ensureBuiltinComponentsRegistered(): void {// =============================================================================// Single-sourced from C++ ES_ENUMs (see import above). ProjectionType, ClearFlags,-// EmitterShape, SimulationSpace and Light2DType are re-exported from the generated-// module; their values and the editor dropdowns built from them now have one source.-export { ProjectionType, ClearFlags, EmitterShape, SimulationSpace, Light2DType };+// EmitterShape, SimulationSpace, Light2DType and ShapeType are re-exported from the+// generated module; their values and the editor dropdowns built from them now have+// one source.+export { ProjectionType, ClearFlags, EmitterShape, SimulationSpace, Light2DType, ShapeType };// Canonical values single-sourced from the C++ CanvasScaleMode enum (generated);// ShowAll/NoBorder are Cocos-compat aliases with no C++ member.@@ -538,14 +539,6 @@ export type {export type LocalTransformData = TransformData;export type WorldTransformData = TransformData;-export const ShapeType = {- Circle: 0,- Capsule: 1,- RoundedRect: 2,-} as const;--export type ShapeType = (typeof ShapeType)[keyof typeof ShapeType];-// Camera = the generated C++ field shape + one editor-only field. `showFrustum`// drives gizmo rendering and has no C++ Camera member, so it is added here rather// than in the generated interface (the only hand-written Camera field).@@ -588,9 +581,9 @@ export const Sprite = defineBuiltin<SpriteData>('Sprite',}));+// shapeType's dropdown is generated from the C++ ShapeType enum (ES_PROPERTY enum=).export const ShapeRenderer = defineBuiltin<ShapeRendererData>('ShapeRenderer',- metaDefaults<ShapeRendererData>('ShapeRenderer'),- { fields: { shapeType: { enum: enumOptions(ShapeType) } } }+ metaDefaults<ShapeRendererData>('ShapeRenderer'));// type's dropdown is generated from the C++ Light2DType enum (ES_PROPERTY enum=).diff --git a/sdk/src/wasm.generated.ts b/sdk/src/wasm.generated.tsindex d958b19f3..1354317bf 100644--- a/sdk/src/wasm.generated.ts+++ b/sdk/src/wasm.generated.ts@@ -114,6 +114,12 @@ export enum ProjectionType {Orthographic = 1,}+export enum ShapeType {+ Circle = 0,+ Capsule = 1,+ RoundedRect = 2,+}+export enum SimulationSpace {World = 0,Local = 1,diff --git a/src/esengine/bindings/EditorAPI.generated.cpp b/src/esengine/bindings/EditorAPI.generated.cppindex 091a42f9c..20bb23994 100644--- a/src/esengine/bindings/EditorAPI.generated.cpp+++ b/src/esengine/bindings/EditorAPI.generated.cpp@@ -2,10 +2,10 @@* @file EditorAPI.generated.cpp* @brief Auto-generated editor API with string-dispatched component access* @details Generated by EHT - DO NOT EDIT- * @schema_hash 700d4705e6c35c0d+ * @schema_hash 1adb3706c1ad59cb*/-#define ES_EDITOR_API_SCHEMA_HASH "700d4705e6c35c0d"+#define ES_EDITOR_API_SCHEMA_HASH "1adb3706c1ad59cb"#include <emscripten/bind.h>#include <string>diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cppindex ef81e431f..53411facc 100644--- a/src/esengine/bindings/WebBindings.generated.cpp+++ b/src/esengine/bindings/WebBindings.generated.cpp@@ -171,6 +171,11 @@ EMSCRIPTEN_BINDINGS(esengine_enums) {.value("Perspective", esengine::ecs::ProjectionType::Perspective).value("Orthographic", esengine::ecs::ProjectionType::Orthographic);+ enum_<esengine::ecs::ShapeType>("ShapeType")+ .value("Circle", esengine::ecs::ShapeType::Circle)+ .value("Capsule", esengine::ecs::ShapeType::Capsule)+ .value("RoundedRect", esengine::ecs::ShapeType::RoundedRect);+enum_<esengine::ecs::SimulationSpace>("SimulationSpace").value("World", esengine::ecs::SimulationSpace::World).value("Local", esengine::ecs::SimulationSpace::Local);@@ -1943,7 +1948,7 @@ static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drif// ABI Hash -- runtime handshake against the SDK bundle// =============================================================================-static const char* kEsAbiLayoutHash = "b129a05be7804b7f";+static const char* kEsAbiLayoutHash = "b5571b685cb3643f";std::string esengineGetAbiLayoutHash() {return std::string(kEsAbiLayoutHash);diff --git a/src/esengine/ecs/components/ShapeRenderer.hpp b/src/esengine/ecs/components/ShapeRenderer.hppindex d6850d172..d882bd5ab 100644--- a/src/esengine/ecs/components/ShapeRenderer.hpp+++ b/src/esengine/ecs/components/ShapeRenderer.hpp@@ -8,9 +8,16 @@namespace esengine::ecs {+ES_ENUM()+enum class ShapeType : u8 {+ Circle = 0,+ Capsule = 1,+ RoundedRect = 2,+};+ES_COMPONENT()struct ShapeRenderer {- ES_PROPERTY()+ ES_PROPERTY(enum=ShapeType)u8 shapeType{0};ES_PROPERTY()