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(anim): consolidate easing onto one shared library (REARCH_ANIMATION P4a)
esengine1f6b63a40397
diff --git a/sdk/src/camera/CameraDirector.ts b/sdk/src/camera/CameraDirector.tsindex 9dbd19f03..fe1ccee14 100644--- a/sdk/src/camera/CameraDirector.ts+++ b/sdk/src/camera/CameraDirector.ts@@ -10,6 +10,7 @@*/import type { App } from '../app';import { defineResource } from '../resource';+import { applyEasing, EasingType } from '../animation/Easing';import type { CameraPOV } from './CameraPlugin';/** Easing for a view-target transition. */@@ -23,16 +24,10 @@ export type BlendCurve = (typeof BlendCurve)[keyof typeof BlendCurve];export function applyCurve(curve: number, t: number): number {const x = t < 0 ? 0 : t > 1 ? 1 : t;- switch (curve) {- case BlendCurve.EaseIn:- return x * x;- case BlendCurve.EaseOut:- return 1 - (1 - x) * (1 - x);- case BlendCurve.EaseInOut:- return x < 0.5 ? 2 * x * x : 1 - ((-2 * x + 2) * (-2 * x + 2)) / 2;- default:- return x; // Linear- }+ // BlendCurve 0..3 aligns with Easing's Linear/EaseInQuad/EaseOutQuad/EaseInOutQuad+ // (identical formulas) — delegate so the easing math lives in one place+ // (docs/REARCH_ANIMATION.md easing consolidation).+ return applyEasing(curve as EasingType, x);}/** Signed shortest angular delta a→b (radians), so a blend never spins the long way. */diff --git a/src/esengine/particle/ParticleEasing.hpp b/src/esengine/particle/ParticleEasing.hppindex aa8ece48d..3bb2e2780 100644--- a/src/esengine/particle/ParticleEasing.hpp+++ b/src/esengine/particle/ParticleEasing.hpp@@ -1,6 +1,7 @@#pragma once#include "../core/Types.hpp"+#include "../animation/EasingFunctions.hpp"namespace esengine::particle {@@ -11,21 +12,17 @@ enum class EasingType : i32 {EaseInOut = 3,};+// Delegates to the shared easing library so the math lives in ONE place+// (docs/REARCH_ANIMATION.md easing consolidation). Particle keeps its own 4-value+// enum (its serialized data format); the formulas are byte-identical to the quad+// easings, so this is behavior-preserving.inline f32 applyEasing(EasingType type, f32 t) {switch (type) {- case EasingType::EaseIn:- return t * t;- case EasingType::EaseOut:- return t * (2.0f - t);- case EasingType::EaseInOut: {- if (t < 0.5f) {- return 2.0f * t * t;- }- return -1.0f + (4.0f - 2.0f * t) * t;- }+ case EasingType::EaseIn: return animation::easeInQuad(t);+ case EasingType::EaseOut: return animation::easeOutQuad(t);+ case EasingType::EaseInOut: return animation::easeInOutQuad(t);case EasingType::Linear:- default:- return t;+ default: return animation::easeLinear(t);}}