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.

feat(ui): Radial90/180 arc fills

esengineea14a62756d4
diff --git a/desktop/package.json b/desktop/package.json
index 59b5dcb24..a9157a9c5 100644
--- a/desktop/package.json
+++ b/desktop/package.json
@@ -30,7 +30,7 @@
"verify:render:text:rect": "vite build && ESTELLA_VERIFY_SCENE=/scenes/ui-text-rect.esscene ESTELLA_VERIFY_MANIFEST=/scenes/ui-text-sdf.textures.json electron scripts/headless-verify.mjs",
"verify:render:uinode": "vite build && ESTELLA_VERIFY_SCENE=/scenes/ui-node-flex.esscene ESTELLA_VERIFY_MANIFEST=/scenes/ui-node-flex.textures.json ESTELLA_VERIFY_W=800 ESTELLA_VERIFY_H=600 electron scripts/headless-verify.mjs",
"verify:render:uimask": "vite build && ESTELLA_VERIFY_SCENE=/scenes/ui-list-mask.esscene ESTELLA_VERIFY_MANIFEST=/scenes/ui-list-mask.textures.json ESTELLA_VERIFY_W=800 ESTELLA_VERIFY_H=600 ESTELLA_VERIFY_EXPECT=\"[{\\\"x\\\":0.5,\\\"y\\\":0.5,\\\"rgb\\\":[255,0,0],\\\"tol\\\":60},{\\\"x\\\":0.9,\\\"y\\\":0.5,\\\"rgb\\\":[0,0,255],\\\"tol\\\":60},{\\\"x\\\":0.5,\\\"y\\\":0.85,\\\"rgb\\\":[0,0,255],\\\"tol\\\":60},{\\\"x\\\":0.5,\\\"y\\\":0.15,\\\"rgb\\\":[0,0,255],\\\"tol\\\":60}]\" electron scripts/headless-verify.mjs",
- "verify:render:filled": "vite build && ESTELLA_VERIFY_SCENE=/scenes/ui-visual-filled.esscene ESTELLA_VERIFY_MANIFEST=/scenes/ui-visual-filled.textures.json ESTELLA_VERIFY_W=800 ESTELLA_VERIFY_H=600 ESTELLA_VERIFY_STEPS=2 ESTELLA_VERIFY_EXPECT=\"[{\\\"x\\\":0.18,\\\"y\\\":0.5,\\\"rgb\\\":[0,255,0],\\\"tol\\\":40},{\\\"x\\\":0.40,\\\"y\\\":0.5,\\\"rgb\\\":[255,0,0],\\\"tol\\\":40},{\\\"x\\\":0.58,\\\"y\\\":0.75,\\\"rgb\\\":[0,255,0],\\\"tol\\\":40},{\\\"x\\\":0.58,\\\"y\\\":0.25,\\\"rgb\\\":[255,0,0],\\\"tol\\\":40},{\\\"x\\\":0.30,\\\"y\\\":0.20,\\\"rgb\\\":[0,255,0],\\\"tol\\\":40},{\\\"x\\\":0.20,\\\"y\\\":0.333,\\\"rgb\\\":[255,0,0],\\\"tol\\\":40}]\" electron scripts/headless-verify.mjs",
+ "verify:render:filled": "vite build && ESTELLA_VERIFY_SCENE=/scenes/ui-visual-filled.esscene ESTELLA_VERIFY_MANIFEST=/scenes/ui-visual-filled.textures.json ESTELLA_VERIFY_W=800 ESTELLA_VERIFY_H=600 ESTELLA_VERIFY_STEPS=2 ESTELLA_VERIFY_EXPECT=\"[{\\\"x\\\":0.18,\\\"y\\\":0.5,\\\"rgb\\\":[0,255,0],\\\"tol\\\":40},{\\\"x\\\":0.40,\\\"y\\\":0.5,\\\"rgb\\\":[255,0,0],\\\"tol\\\":40},{\\\"x\\\":0.58,\\\"y\\\":0.75,\\\"rgb\\\":[0,255,0],\\\"tol\\\":40},{\\\"x\\\":0.58,\\\"y\\\":0.25,\\\"rgb\\\":[255,0,0],\\\"tol\\\":40},{\\\"x\\\":0.30,\\\"y\\\":0.20,\\\"rgb\\\":[0,255,0],\\\"tol\\\":40},{\\\"x\\\":0.20,\\\"y\\\":0.333,\\\"rgb\\\":[255,0,0],\\\"tol\\\":40},{\\\"x\\\":0.30,\\\"y\\\":0.833,\\\"rgb\\\":[0,255,0],\\\"tol\\\":40},{\\\"x\\\":0.20,\\\"y\\\":0.70,\\\"rgb\\\":[255,0,0],\\\"tol\\\":40}]\" electron scripts/headless-verify.mjs",
"verify:render:tilemap": "vite build && ESTELLA_VERIFY_SCENE=/scenes/tilemap-flip.esscene ESTELLA_VERIFY_MANIFEST=/scenes/tilemap-flip.textures.json ESTELLA_VERIFY_W=256 ESTELLA_VERIFY_H=256 ESTELLA_VERIFY_STEPS=2 ESTELLA_VERIFY_EXPECT=\"[{\\\"x\\\":0.40,\\\"y\\\":0.36,\\\"rgb\\\":[255,0,0]},{\\\"x\\\":0.60,\\\"y\\\":0.36,\\\"rgb\\\":[0,255,0]},{\\\"x\\\":0.40,\\\"y\\\":0.58,\\\"rgb\\\":[0,0,255]},{\\\"x\\\":0.60,\\\"y\\\":0.58,\\\"rgb\\\":[255,255,0]}]\" electron scripts/headless-verify.mjs",
"verify:render:tilemap:transform": "vite build && ESTELLA_VERIFY_SCENE=/scenes/tilemap-transform.esscene ESTELLA_VERIFY_MANIFEST=/scenes/tilemap-transform.textures.json ESTELLA_VERIFY_W=256 ESTELLA_VERIFY_H=256 ESTELLA_VERIFY_STEPS=2 ESTELLA_VERIFY_EXPECT=\"[{\\\"x\\\":0.40,\\\"y\\\":0.36,\\\"rgb\\\":[255,255,0]},{\\\"x\\\":0.60,\\\"y\\\":0.36,\\\"rgb\\\":[0,255,0]},{\\\"x\\\":0.40,\\\"y\\\":0.58,\\\"rgb\\\":[0,0,255]},{\\\"x\\\":0.60,\\\"y\\\":0.58,\\\"rgb\\\":[255,0,0]}]\" electron scripts/headless-verify.mjs",
"verify:render:material": "vite build && ESTELLA_VERIFY_SCENE=/scenes/mat-tint.esscene ESTELLA_VERIFY_MANIFEST=/scenes/mat-tint.textures.json ESTELLA_VERIFY_W=256 ESTELLA_VERIFY_H=256 ESTELLA_VERIFY_STEPS=2 ESTELLA_VERIFY_EXPECT=\"[{\\\"x\\\":0.5,\\\"y\\\":0.5,\\\"rgb\\\":[255,0,0],\\\"tol\\\":40}]\" electron scripts/headless-verify.mjs",
diff --git a/desktop/public/scenes/ui-visual-filled.esscene b/desktop/public/scenes/ui-visual-filled.esscene
index f6b16bd9b..f7950d2f0 100644
--- a/desktop/public/scenes/ui-visual-filled.esscene
+++ b/desktop/public/scenes/ui-visual-filled.esscene
@@ -17,7 +17,7 @@
"id": 1,
"name": "Canvas",
"parent": null,
- "children": [2, 4, 6],
+ "children": [2, 4, 6, 8],
"components": [
{ "type": "Transform", "data": {} },
{ "type": "Canvas", "data": { "designResolution": { "x": 800, "y": 600 }, "scaleMode": 2 } },
@@ -180,6 +180,58 @@
}
],
"visible": true
+ },
+ {
+ "id": 8,
+ "name": "R90Track",
+ "parent": 1,
+ "children": [9],
+ "components": [
+ { "type": "Transform", "data": {} },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": { "value": 120, "unit": 0 },
+ "insetTop": { "value": 380, "unit": 0 },
+ "width": { "value": 160, "unit": 0 },
+ "height": { "value": 160, "unit": 0 }
+ }
+ },
+ { "type": "UIVisual", "data": { "visualType": 1, "color": { "r": 1, "g": 0, "b": 0, "a": 1 }, "enabled": true } }
+ ],
+ "visible": true
+ },
+ {
+ "id": 9,
+ "name": "R90Fill",
+ "parent": 8,
+ "children": [],
+ "components": [
+ { "type": "Transform", "data": {} },
+ {
+ "type": "UINode",
+ "data": {
+ "position": 1,
+ "insetLeft": { "value": 0, "unit": 0 },
+ "insetTop": { "value": 0, "unit": 0 },
+ "insetRight": { "value": 0, "unit": 0 },
+ "insetBottom": { "value": 0, "unit": 0 }
+ }
+ },
+ {
+ "type": "UIVisual",
+ "data": {
+ "visualType": 5,
+ "color": { "r": 0, "g": 1, "b": 0, "a": 1 },
+ "fillMethod": 3,
+ "fillOrigin": 1,
+ "fillAmount": 1.0,
+ "enabled": true
+ }
+ }
+ ],
+ "visible": true
}
]
}
diff --git a/sdk/src/component.generated.ts b/sdk/src/component.generated.ts
index 8a4ef6f31..002d86813 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 = 'd5ee06760541c1d8';
+export const ABI_LAYOUT_HASH = '9f76797e876d6436';
export interface AssetFieldMeta {
field: string;
@@ -599,7 +599,7 @@ export const COMPONENT_META: Record<string, ComponentMetaEntry> = {
animatableFields: ['color.r', 'color.g', 'color.b', 'color.a', 'fillAmount'],
fields: {
visualType: { enum: [{ label: 'None', value: 0 }, { label: 'SolidColor', value: 1 }, { label: 'Image', value: 2 }, { label: 'NineSlice', value: 3 }, { label: 'Tiled', value: 4 }, { label: 'Filled', value: 5 }] },
- fillMethod: { enum: [{ label: 'Horizontal', value: 0 }, { label: 'Vertical', value: 1 }, { label: 'Radial360', value: 2 }] },
+ fillMethod: { enum: [{ label: 'Horizontal', value: 0 }, { label: 'Vertical', value: 1 }, { label: 'Radial360', value: 2 }, { label: 'Radial90', value: 3 }, { label: 'Radial180', value: 4 }] },
fillOrigin: { enum: [{ label: 'Left', value: 0 }, { label: 'Right', value: 1 }, { label: 'Bottom', value: 2 }, { label: 'Top', value: 3 }] },
},
},
diff --git a/sdk/src/ui/core/ui-visual.ts b/sdk/src/ui/core/ui-visual.ts
index b06f58bf6..cabfc9f6e 100644
--- a/sdk/src/ui/core/ui-visual.ts
+++ b/sdk/src/ui/core/ui-visual.ts
@@ -38,8 +38,12 @@ export const FillMethod = {
Horizontal: 0,
/** Linear crop along Y. */
Vertical: 1,
- /** Angular clockwise sweep of the full circle (cooldown / ring gauge). */
+ /** Clockwise sweep of the full circle (cooldown / ring gauge). */
Radial360: 2,
+ /** Clockwise sweep of a 90° arc from the origin edge (corner meter). */
+ Radial90: 3,
+ /** Clockwise sweep of a 180° arc from the origin edge (speedometer). */
+ Radial180: 4,
} as const;
export type FillMethod = (typeof FillMethod)[keyof typeof FillMethod];
diff --git a/sdk/src/wasm.generated.ts b/sdk/src/wasm.generated.ts
index 641ffa515..5a84343b3 100644
--- a/sdk/src/wasm.generated.ts
+++ b/sdk/src/wasm.generated.ts
@@ -135,6 +135,8 @@ export enum UIFillMethod {
Horizontal = 0,
Vertical = 1,
Radial360 = 2,
+ Radial90 = 3,
+ Radial180 = 4,
}
export enum UIFillOrigin {
diff --git a/src/esengine/bindings/EditorAPI.generated.cpp b/src/esengine/bindings/EditorAPI.generated.cpp
index 21b54a9f2..1ab97add3 100644
--- a/src/esengine/bindings/EditorAPI.generated.cpp
+++ b/src/esengine/bindings/EditorAPI.generated.cpp
@@ -466,7 +466,7 @@ std::string editor_getComponentSchema(const std::string& name) {
{"key":"sliceBorder.w","type":"float","group":"UIVisual"},
{"key":"tileSize.x","type":"float","group":"UIVisual"},
{"key":"tileSize.y","type":"float","group":"UIVisual"},
- {"key":"fillMethod","type":"enum","group":"UIVisual","values":["Horizontal","Vertical","Radial360"]},
+ {"key":"fillMethod","type":"enum","group":"UIVisual","values":["Horizontal","Vertical","Radial360","Radial90","Radial180"]},
{"key":"fillOrigin","type":"enum","group":"UIVisual","values":["Left","Right","Bottom","Top"]},
{"key":"fillAmount","type":"float","group":"UIVisual"},
{"key":"material","type":"asset","group":"UIVisual"},
diff --git a/src/esengine/bindings/WebBindings.generated.cpp b/src/esengine/bindings/WebBindings.generated.cpp
index 35096fa70..41f17d9ac 100644
--- a/src/esengine/bindings/WebBindings.generated.cpp
+++ b/src/esengine/bindings/WebBindings.generated.cpp
@@ -188,7 +188,9 @@ EMSCRIPTEN_BINDINGS(esengine_enums) {
enum_<esengine::ecs::UIFillMethod>("UIFillMethod")
.value("Horizontal", esengine::ecs::UIFillMethod::Horizontal)
.value("Vertical", esengine::ecs::UIFillMethod::Vertical)
- .value("Radial360", esengine::ecs::UIFillMethod::Radial360);
+ .value("Radial360", esengine::ecs::UIFillMethod::Radial360)
+ .value("Radial90", esengine::ecs::UIFillMethod::Radial90)
+ .value("Radial180", esengine::ecs::UIFillMethod::Radial180);
enum_<esengine::ecs::UIFillOrigin>("UIFillOrigin")
.value("Left", esengine::ecs::UIFillOrigin::Left)
@@ -1949,7 +1951,7 @@ static_assert(offsetof(esengine::ecs::Velocity, angular) == 12, "ABI offset drif
// ABI Hash -- runtime handshake against the SDK bundle
// =============================================================================
-static const char* kEsAbiLayoutHash = "d5ee06760541c1d8";
+static const char* kEsAbiLayoutHash = "9f76797e876d6436";
std::string esengineGetAbiLayoutHash() {
return std::string(kEsAbiLayoutHash);
diff --git a/src/esengine/ecs/components/UIVisual.hpp b/src/esengine/ecs/components/UIVisual.hpp
index a59827d0f..4e4d61d0b 100644
--- a/src/esengine/ecs/components/UIVisual.hpp
+++ b/src/esengine/ecs/components/UIVisual.hpp
@@ -32,15 +32,18 @@ enum class UIVisualType : u8 {
/**
* @brief Fill mode for a Filled UIVisual. Horizontal/Vertical are linear crops
- * along the axis; Radial360 is an angular clockwise sweep of the full
- * circle (cooldown / ring gauge) starting from the fillOrigin edge
- * (12/3/6/9 o'clock), growing by fillAmount.
+ * along the axis; the Radial modes are an angular clockwise sweep starting
+ * from the fillOrigin edge (12/3/6/9 o'clock), where fillAmount scales the
+ * wedge from 0 to the mode's arc (90/180/360 degrees) — cooldown rings,
+ * speedometer arcs, corner meters.
*/
ES_ENUM()
enum class UIFillMethod : u8 {
Horizontal,
Vertical,
- Radial360
+ Radial360,
+ Radial90,
+ Radial180
};
ES_ENUM()
diff --git a/src/esengine/renderer/plugins/BatchPlugin.cpp b/src/esengine/renderer/plugins/BatchPlugin.cpp
index 680125376..8d6ec978b 100644
--- a/src/esengine/renderer/plugins/BatchPlugin.cpp
+++ b/src/esengine/renderer/plugins/BatchPlugin.cpp
@@ -118,16 +118,14 @@ void BatchPlugin::emitNineSlice(
void BatchPlugin::emitRadialFill(
TransientBufferPool& buffers, DrawList& draw_list, const ClipState& clips,
const glm::vec2& center, const glm::vec2& size, f32 angle,
- f32 startAngle, f32 amount,
+ f32 startAngle, f32 sweep,
const glm::vec2& uvOffset, const glm::vec2& uvScale,
const glm::vec4& color, const BatchDrawKey& key
) {
- amount = std::clamp(amount, 0.0f, 1.0f);
- f32 hx = size.x * 0.5f, hy = size.y * 0.5f;
- if (amount <= 0.0001f || hx <= 0.0f || hy <= 0.0f) return;
-
constexpr f32 TWO_PI = 6.2831853071795864f;
- const f32 sweep = amount * TWO_PI;
+ sweep = std::clamp(sweep, 0.0f, TWO_PI);
+ f32 hx = size.x * 0.5f, hy = size.y * 0.5f;
+ if (sweep <= 0.0001f || hx <= 0.0f || hy <= 0.0f) return;
// Sample angles are the two endpoints plus any box corner the sweep crosses,
// measured as a clockwise distance from startAngle. Because the box edge
diff --git a/src/esengine/renderer/plugins/BatchPlugin.hpp b/src/esengine/renderer/plugins/BatchPlugin.hpp
index 967416dcd..05443fe26 100644
--- a/src/esengine/renderer/plugins/BatchPlugin.hpp
+++ b/src/esengine/renderer/plugins/BatchPlugin.hpp
@@ -54,20 +54,22 @@ protected:
const glm::vec4& color, const BatchDrawKey& key);
/**
- * @brief Emits a centered angular wedge (Radial360 Filled): a triangle fan
- * from the box center out to its perimeter, swept clockwise from
- * @p startAngle by @p amount of the full circle.
+ * @brief Emits a centered angular wedge (Radial Filled): a triangle fan from
+ * the box center out to its perimeter, swept clockwise from @p startAngle
+ * over @p sweep radians.
* @details The wedge boundary follows the rectangle exactly — box corners
* crossed by the sweep become fan vertices, so edges stay straight
* and corners sharp (≤5 triangles, no per-frame tessellation).
* One BatchVertex stream, same shader as emitQuad — a radial gauge
- * batches with every other UI quad.
+ * batches with every other UI quad. Radial90/180/360 differ only in
+ * the caller's @p sweep (fillAmount times the mode arc); the geometry
+ * is identical.
* @param startAngle Sweep start in radians, box-local (before @p angle rotation).
- * @param amount Filled fraction of the full circle, [0,1].
+ * @param sweep Total swept angle in radians, [0, 2π].
*/
void emitRadialFill(TransientBufferPool& buffers, DrawList& draw_list, const ClipState& clips,
const glm::vec2& center, const glm::vec2& size, f32 angle,
- f32 startAngle, f32 amount,
+ f32 startAngle, f32 sweep,
const glm::vec2& uvOffset, const glm::vec2& uvScale,
const glm::vec4& color, const BatchDrawKey& key);
diff --git a/src/esengine/renderer/plugins/UIElementPlugin.cpp b/src/esengine/renderer/plugins/UIElementPlugin.cpp
index c8f5e8976..c5f59f481 100644
--- a/src/esengine/renderer/plugins/UIElementPlugin.cpp
+++ b/src/esengine/renderer/plugins/UIElementPlugin.cpp
@@ -13,7 +13,13 @@
namespace esengine {
-// Clockwise Radial360 start direction (box-local, +y = up), by origin edge:
+static bool isRadialMethod(ecs::UIFillMethod m) {
+ return m == ecs::UIFillMethod::Radial360
+ || m == ecs::UIFillMethod::Radial90
+ || m == ecs::UIFillMethod::Radial180;
+}
+
+// Clockwise radial start direction (box-local, +y = up), by origin edge:
// Top = 12 o'clock, Right = 3, Bottom = 6, Left = 9.
static f32 radialStartAngle(ecs::UIFillOrigin origin) {
constexpr f32 HALF_PI = 1.57079632679f;
@@ -26,6 +32,16 @@ static f32 radialStartAngle(ecs::UIFillOrigin origin) {
return HALF_PI;
}
+// The mode's full arc; fillAmount scales the swept angle within it.
+static f32 radialMaxSweep(ecs::UIFillMethod m) {
+ constexpr f32 HALF_PI = 1.57079632679f;
+ switch (m) {
+ case ecs::UIFillMethod::Radial90: return HALF_PI;
+ case ecs::UIFillMethod::Radial180: return 2.0f * HALF_PI;
+ default: return 4.0f * HALF_PI; // Radial360
+ }
+}
+
void UIElementPlugin::collect(RenderCollectContext& collect_ctx) {
auto& registry = collect_ctx.registry;
auto& frustum = collect_ctx.frustum;
@@ -137,15 +153,15 @@ void UIElementPlugin::collect(RenderCollectContext& collect_ctx) {
glm::vec2 finalSize = glm::vec2(w, h) * glm::vec2(scale);
const bool isRadialFill = renderer.visualType == ecs::UIVisualType::Filled
- && renderer.fillMethod == ecs::UIFillMethod::Radial360;
+ && isRadialMethod(renderer.fillMethod);
// Filled derives its own UV/geometry, so 9-slice never applies. Linear
// fills crop the box in lockstep with the UV crop above: the box shrinks
// to fillAmount along the axis, anchored at fillOrigin, its center shifting
// toward that edge by half the removed extent (rotated into world space to
// match the pivot bake). A UV-only crop would no-op on a solid colour and
- // stretch a texture; cropping geometry too makes both reveal. Radial360
- // is emitted as a wedge fan instead (below), so it skips the box crop.
+ // stretch a texture; cropping geometry too makes both reveal. Radial fills
+ // are emitted as a wedge fan instead (below), so they skip the box crop.
if (renderer.visualType == ecs::UIVisualType::Filled) {
useNineSlice = false;
if (!isRadialFill) {
@@ -186,10 +202,11 @@ void UIElementPlugin::collect(RenderCollectContext& collect_ctx) {
constexpr glm::vec2 CENTERED_PIVOT{0.5f, 0.5f};
if (isRadialFill) {
+ f32 sweep = std::clamp(renderer.fillAmount, 0.0f, 1.0f)
+ * radialMaxSweep(renderer.fillMethod);
emitRadialFill(buffers, draw_list, clips,
glm::vec2(position), finalSize, angle,
- radialStartAngle(renderer.fillOrigin),
- std::clamp(renderer.fillAmount, 0.0f, 1.0f),
+ radialStartAngle(renderer.fillOrigin), sweep,
uvOffset, uvScale, renderer.color, key);
} else if (useNineSlice) {
emitNineSlice(buffers, draw_list, clips,