Skip to content

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.

refactor(component): drop redundant Canvas creation-default overrides

yhh5cba2641ba26
diff --git a/sdk/src/component.ts b/sdk/src/component.ts
index 9d60a0c1e..baa8a7abf 100644
--- a/sdk/src/component.ts
+++ b/sdk/src/component.ts
@@ -6,7 +6,7 @@
*/
import { Entity, Vec2, Vec3, Color, Quat } from './types';
-import { DEFAULT_DESIGN_WIDTH, DEFAULT_DESIGN_HEIGHT, DEFAULT_PIXELS_PER_UNIT, DEFAULT_SPRITE_SIZE } from './defaults';
+import { DEFAULT_SPRITE_SIZE } from './defaults';
import { COMPONENT_META, type AssetFieldMeta, type SpineFieldMeta } from './component.generated';
// C++-backed component data shapes, generated from the ES_COMPONENT structs (single
// source — a TS field can no longer drift from C++). Re-exported below so the public
@@ -623,13 +623,12 @@ export const Camera = defineBuiltin<CameraData>('Camera',
}
);
+// All Canvas creation defaults (designResolution 1920×1080 / pixelsPerUnit 100 /
+// scaleMode FixedHeight) match the C++ ctor, so they come straight from
+// COMPONENT_META — no TS override to drift when C++ changes. scaleMode's dropdown
+// is likewise generated from the C++ CanvasScaleMode enum.
export const Canvas = defineBuiltin<CanvasData>('Canvas',
- // scaleMode's dropdown is generated from the C++ CanvasScaleMode enum.
- metaDefaults<CanvasData>('Canvas', {
- designResolution: { x: DEFAULT_DESIGN_WIDTH, y: DEFAULT_DESIGN_HEIGHT },
- pixelsPerUnit: DEFAULT_PIXELS_PER_UNIT,
- scaleMode: ScaleMode.FixedHeight,
- })
+ metaDefaults<CanvasData>('Canvas')
);
export const Velocity = defineBuiltin<VelocityData>('Velocity',