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): drive the timeline runtime in pure TS; C++ TimelineSystem now unused — REARCH_ANIMATION P4c (2a/2)
esengine1dbc62048719
diff --git a/sdk/src/timeline/TimelineControl.ts b/sdk/src/timeline/TimelineControl.tsindex 513cc676e..283a585f2 100644--- a/sdk/src/timeline/TimelineControl.ts+++ b/sdk/src/timeline/TimelineControl.ts@@ -1,82 +1,78 @@import type { Entity } from '../types';-import type { ESEngineModule } from '../wasm';import { defineResource } from '../resource';+import { createTimelineState, type TimelineState } from './TimelineDrive';+import { WrapMode } from './TimelineTypes';/**- * Per-App timeline playback control. Holds this App's entity->handle map and the- * (guarded) wasm module; published as the {@link Timeline} resource. Replaces- * the former process-global `TimelineControl` object + module/handle globals so- * two Apps' timelines never collide on entity id.- *- * `TimelinePlugin` keeps the module current via {@link setModule} each frame and- * records handles via {@link setHandle}; game code drives playback through+ * Per-App timeline playback control. Holds this App's per-entity playback state+ * and is published as the {@link Timeline} resource; game code drives playback via* `app.getResource(Timeline)`.+ *+ * The timeline runtime is pure TS now (docs/REARCH_ANIMATION.md P4c) — there is no+ * C++ handle or wasm module here. `TimelinePlugin` advances each entity's+ * {@link TimelineState} every frame; these methods just flip/seek that state.*/export class TimelineApi {- private readonly handles_ = new Map<Entity, number>();- private module_: ESEngineModule | null = null;+ private readonly states_ = new Map<Entity, TimelineState>();- /** @internal Plugin keeps the guarded module current each frame. */- setModule(mod: ESEngineModule | null): void {- this.module_ = mod;- }-- /** @internal */- setHandle(entity: Entity, handle: number): void {- this.handles_.set(entity, handle);+ /** @internal Plugin ensures (creating if needed) the per-entity playback state. */+ ensureState(entity: Entity, wrapMode: WrapMode, speed: number): TimelineState {+ let s = this.states_.get(entity);+ if (!s) {+ s = createTimelineState(wrapMode, speed);+ this.states_.set(entity, s);+ }+ return s;}- getHandle(entity: Entity): number | undefined {- return this.handles_.get(entity);+ getState(entity: Entity): TimelineState | undefined {+ return this.states_.get(entity);}- /** @internal Destroys the C++ timeline (if loaded) and forgets the handle. */- removeHandle(entity: Entity): void {- const handle = this.handles_.get(entity);- if (handle && this.module_) {- this.module_._tl_destroy(handle);- }- this.handles_.delete(entity);+ /** @internal Forget an entity's state (on despawn). */+ removeState(entity: Entity): void {+ this.states_.delete(entity);}/** @internal */- clearHandles(): void {- if (this.module_) {- for (const handle of this.handles_.values()) {- this.module_._tl_destroy(handle);- }- }- this.handles_.clear();+ clearStates(): void {+ this.states_.clear();}play(entity: Entity): void {- const handle = this.handles_.get(entity);- if (handle && this.module_) this.module_._tl_play(handle);+ const s = this.states_.get(entity);+ if (s) s.playing = true;}pause(entity: Entity): void {- const handle = this.handles_.get(entity);- if (handle && this.module_) this.module_._tl_pause(handle);+ const s = this.states_.get(entity);+ if (s) s.playing = false;}stop(entity: Entity): void {- const handle = this.handles_.get(entity);- if (handle && this.module_) this.module_._tl_stop(handle);+ const s = this.states_.get(entity);+ if (s) {+ s.playing = false;+ s.time = 0;+ s.prevTime = 0;+ s.spineClipIndices = {};+ }}setTime(entity: Entity, time: number): void {- const handle = this.handles_.get(entity);- if (handle && this.module_) this.module_._tl_setTime(handle, time);+ const s = this.states_.get(entity);+ if (s) {+ s.prevTime = s.time;+ s.time = time;+ }}isPlaying(entity: Entity): boolean {- const handle = this.handles_.get(entity);- return handle && this.module_ ? this.module_._tl_isPlaying(handle) !== 0 : false;+ return this.states_.get(entity)?.playing ?? false;}getCurrentTime(entity: Entity): number {- const handle = this.handles_.get(entity);- return handle && this.module_ ? this.module_._tl_getTime(handle) : 0;+ return this.states_.get(entity)?.time ?? 0;}}diff --git a/sdk/src/timeline/TimelinePlugin.ts b/sdk/src/timeline/TimelinePlugin.tsindex b0397ee20..d637d4fbf 100644--- a/sdk/src/timeline/TimelinePlugin.ts+++ b/sdk/src/timeline/TimelinePlugin.ts@@ -6,15 +6,10 @@ import { defineComponent, getComponent } from '../component';import { playModeOnly } from '../env';import { Audio, type AudioAPI } from '../audio/Audio';import { WrapMode, TrackType, type TimelineAsset, type AnimFramesTrack } from './TimelineTypes';-import { parseTimelineAsset } from './TimelineLoader';-import { uploadTimelineToWasm, type UploadResult } from './TimelineUploader';import { Timeline, TimelineApi } from './TimelineControl';-import {- resolveTrackTargets,- advanceAndProcess,-} from './TimelineRuntime';-import type { ESEngineModule } from '../wasm';-import { CoreApiBridge } from '../CoreApiBridge';+import { resolveChildEntity } from './TimelineRuntime';+import { advanceTimelineTS } from './TimelineDrive';+import type { SampleDeps } from './TimelineEvaluator';import type { Entity } from '../types';export { setNestedProperty } from './TimelineRuntime';@@ -53,7 +48,7 @@ export function getTimelineTextureHandle(timelinePath: string, textureUuid: strireturn activeTimelinePlugin?.getTextureHandle(timelinePath, textureUuid) ?? 0;}-const WRAP_MODE_MAP: Record<string, number> = {+const WRAP_MODE_MAP: Record<string, WrapMode> = {once: WrapMode.Once,loop: WrapMode.Loop,pingPong: WrapMode.PingPong,@@ -69,9 +64,7 @@ export class TimelinePlugin implements Plugin {private loadedAssets_ = new Map<string, TimelineAsset>();private textureHandles_ = new Map<string, Map<string, number>>();- private handles_ = new Map<number, UploadResult>();private animFramesStates_ = new Map<number, AnimFramesState>();- private bridge_ = new CoreApiBridge('timeline');registerAsset(path: string, asset: TimelineAsset): void {this.loadedAssets_.set(path, asset);@@ -95,78 +88,46 @@ export class TimelinePlugin implements Plugin {app.insertResource(Timeline, new TimelineApi());world.onDespawn((entity: Entity) => {- app.getResource(Timeline).removeHandle(entity);- this.handles_.delete(entity);+ app.getResource(Timeline).removeState(entity);this.animFramesStates_.delete(entity);});+ // The timeline runs entirely in TS (REARCH_ANIMATION P4c): a per-entity+ // clock + the shared evaluator (property tracks) + edge-detected event+ // dispatch — no wasm timeline, no upload, no per-frame poll. Property writes+ // land via world.set (the same path the editor preview uses).app.addSystemToSchedule(Schedule.Update, defineSystem([Res(Time)],(time: TimeData) => {- const rawModule = world.getWasmModule() as ESEngineModule;- if (!rawModule) return;- // Route the main module through the bridge once (re-connect only- // if the underlying module changes). Every `_tl_*` call below —- // and everything handed `module` (the Timeline resource via- // setModule, the uploader, the runtime) — then inherits the- // terminal-abort guard.- if (this.bridge_.raw !== rawModule) this.bridge_.connect(rawModule);- const module = this.bridge_.module;-const tl = app.getResource(Timeline);- tl.setModule(module);- const registry = world.getCppRegistry() as any;const audio: AudioAPI | null = app.hasResource(Audio) ? app.getResource(Audio) : null;-- const entities = world.getEntitiesWithComponents([TimelinePlayer]);- for (const entity of entities) {- const playerData = world.get(entity, TimelinePlayer) as TimelinePlayerData;- if (!playerData.timeline) continue;-- let uploadResult = this.handles_.get(entity);- if (!uploadResult) {- const asset = this.loadedAssets_.get(playerData.timeline);- if (!asset) continue;- uploadResult = uploadTimelineToWasm(module, asset);- if (!uploadResult.handle) continue;- resolveTrackTargets(world, module, uploadResult, entity);- this.handles_.set(entity, uploadResult);- tl.setHandle(entity, uploadResult.handle);-- const afTracks = asset.tracks.filter(- (t): t is AnimFramesTrack => t.type === TrackType.AnimFrames,- );- if (afTracks.length > 0) {- this.animFramesStates_.set(entity, {- tracks: afTracks,- lastFrameIndices: afTracks.map(() => -1),- });- }- }-- const handle = uploadResult.handle;-- if (playerData.playing && !module._tl_isPlaying(handle)) {- const currentTime = module._tl_getTime(handle);- if (currentTime === 0) {- module._tl_play(handle);- } else {- module._tl_play(handle);- module._tl_setTime(handle, currentTime);- }- } else if (!playerData.playing && module._tl_isPlaying(handle)) {- module._tl_pause(handle);- }-- const wrapModeNum = WRAP_MODE_MAP[playerData.wrapMode] ?? WrapMode.Once;- module._tl_setWrapMode(handle, wrapModeNum);-- advanceAndProcess(world, module, handle, entity, time.delta, playerData.speed, uploadResult, audio);- this.processAnimFrames(world, module, entity, handle, playerData.timeline);-- if (!module._tl_isPlaying(handle) && playerData.playing) {- playerData.playing = false;- world.insert(entity, TimelinePlayer, playerData);+ const deps: SampleDeps = {+ world,+ getComponent,+ resolveChild: (root, childPath) => resolveChildEntity(world, root, childPath),+ };++ for (const entity of world.getEntitiesWithComponents([TimelinePlayer])) {+ const player = world.get(entity, TimelinePlayer) as TimelinePlayerData;+ if (!player.timeline) continue;+ const asset = this.loadedAssets_.get(player.timeline);+ if (!asset) continue;++ const wrapMode = WRAP_MODE_MAP[player.wrapMode] ?? WrapMode.Once;+ const state = tl.ensureState(entity, wrapMode, player.speed);+ state.speed = player.speed;+ state.wrapMode = wrapMode;+ state.playing = player.playing;++ this.ensureAnimFrames(entity, asset);++ advanceTimelineTS(asset, entity, state, time.delta, { deps, audio });+ this.processAnimFrames(world, entity, state.time, player.timeline);++ // A clip that hit its end (Once) clears the component's play flag.+ if (!state.playing && player.playing) {+ player.playing = false;+ world.insert(entity, TimelinePlayer, player);}}},@@ -175,34 +136,42 @@ export class TimelinePlugin implements Plugin {}clearHandles(): void {- this.handles_.clear();this.animFramesStates_.clear();}cleanup(): void {- this.handles_.clear();this.animFramesStates_.clear();this.loadedAssets_.clear();this.textureHandles_.clear();activeTimelinePlugin = null;}+ private ensureAnimFrames(entity: Entity, asset: TimelineAsset): void {+ if (this.animFramesStates_.has(entity)) return;+ const afTracks = asset.tracks.filter(+ (t): t is AnimFramesTrack => t.type === TrackType.AnimFrames,+ );+ if (afTracks.length > 0) {+ this.animFramesStates_.set(entity, {+ tracks: afTracks,+ lastFrameIndices: afTracks.map(() => -1),+ });+ }+ }+private processAnimFrames(- world: any, module: ESEngineModule, entity: Entity, handle: number,- timelinePath: string,+ world: any, entity: Entity, currentTime: number, timelinePath: string,): void {const state = this.animFramesStates_.get(entity);if (!state) return;- const currentTime = module._tl_getTime(handle);const Sprite = getComponent('Sprite');if (!Sprite || !world.has(entity, Sprite)) return;const DEFAULT_DURATION = 1.0 / 12;for (let t = 0; t < state.tracks.length; t++) {- const track = state.tracks[t];- const frames = track.frames;+ const frames = state.tracks[t].frames;if (frames.length === 0) continue;let elapsed = 0;@@ -221,8 +190,7 @@ export class TimelinePlugin implements Plugin {if (frameIndex !== state.lastFrameIndices[t]) {state.lastFrameIndices[t] = frameIndex;- const textureUuid = frames[frameIndex].texture;- const textureHandle = getTimelineTextureHandle(timelinePath, textureUuid);+ const textureHandle = getTimelineTextureHandle(timelinePath, frames[frameIndex].texture);if (textureHandle) {const sprite = world.get(entity, Sprite);sprite.texture = textureHandle;diff --git a/sdk/src/timeline/TimelineRuntime.ts b/sdk/src/timeline/TimelineRuntime.tsindex b680cd6df..781adf7cd 100644--- a/sdk/src/timeline/TimelineRuntime.ts+++ b/sdk/src/timeline/TimelineRuntime.ts@@ -1,12 +1,16 @@import { getComponent, SpineAnimation } from '../component';import { SpriteAnimator } from '../animation/SpriteAnimator';import type { AudioAPI } from '../audio/Audio';-import { uploadTimelineToWasm, type UploadResult } from './TimelineUploader';-import type { TimelineAsset } from './TimelineTypes';-import type { ESEngineModule } from '../wasm';import type { Entity } from '../types';-const TimelineEventType = {+/**+ * Shared timeline runtime helpers (docs/REARCH_ANIMATION.md). The timeline is a+ * pure-TS runtime now (see TimelineDrive); this module holds the pieces shared by+ * the drive and the editor: child-entity resolution, nested-path writes, and the+ * event dispatcher.+ */++export const TimelineEventType = {SpinePlay: 0,SpineStop: 1,SpriteAnimPlay: 2,@@ -57,60 +61,9 @@ export function resolveChildEntity(world: any, rootEntity: Entity, childPath: streturn current;}-export function resolveTrackTargets(- world: any, module: ESEngineModule,- uploadResult: UploadResult, rootEntity: Entity,-): void {- let propertyIndex = 0;- let eventIndex = 0;-- for (const track of uploadResult.tracks) {- if (!track.childPath) {- if (track.type === 'property') propertyIndex++;- else eventIndex++;- continue;- }-- const resolved = resolveChildEntity(world, rootEntity, track.childPath);- if (resolved !== null) {- const isEvent = track.type !== 'property';- const index = isEvent ? eventIndex : propertyIndex;- module._tl_setTrackTarget(uploadResult.handle, isEvent ? 1 : 0, index, resolved as number);- }-- if (track.type === 'property') propertyIndex++;- else eventIndex++;- }-}--export function createTimelineHandle(- module: ESEngineModule, asset: TimelineAsset,-): UploadResult {- return uploadTimelineToWasm(module, asset);-}--export function destroyTimelineHandle(module: ESEngineModule, handle: number): void {- if (handle) module._tl_destroy(handle);-}--// Lazily created (some target environments inject TextDecoder after module load)-// and reused, instead of allocating a new TextDecoder for every decoded event.-let sharedTextDecoder: TextDecoder | null = null;--function decodeEventString(module: ESEngineModule, index: number): string {- const ptr = module._tl_getEventString(index);- const len = module._tl_getEventStringLen(index);- if (!ptr || len <= 0) return '';- const bytes = new Uint8Array(module.HEAPU8.buffer, ptr, len);- if (!sharedTextDecoder) sharedTextDecoder = new TextDecoder();- return sharedTextDecoder.decode(bytes);-}-/**- * Apply ONE decoded timeline event to the world (component mutations / audio).- * Shared by the legacy C++-poll path ({@link processTimelineEvents}) and the- * pure-TS runtime (TimelineDrive) so the dispatch lives in one place- * (docs/REARCH_ANIMATION.md P4c).+ * Apply ONE timeline event to the world (component mutations / audio). Called by+ * the pure-TS runtime (TimelineDrive) with edge-detected events.*/export function applyTimelineEvent(world: any, audio: AudioAPI | null,@@ -167,66 +120,3 @@ export function applyTimelineEvent(}}}--export { TimelineEventType };--export function processTimelineEvents(world: any, module: ESEngineModule, audio: AudioAPI | null = null): void {- const count = module._tl_getEventCount();- for (let i = 0; i < count; i++) {- applyTimelineEvent(- world, audio,- module._tl_getEventType(i),- module._tl_getEventEntity(i) as Entity,- module._tl_getEventIntParam(i),- module._tl_getEventFloatParam(i),- decodeEventString(module, i),- );- }-}--export function processCustomProperties(- world: any, module: ESEngineModule, uploadResult: UploadResult,-): void {- const count = module._tl_getCustomPropertyCount();- if (count === 0) return;-- // The property-track subset is constant for this uploadResult; compute it once- // instead of re-filtering (and allocating a new array) for every property —- // the old per-iteration filter was O(properties × tracks) per frame (M6).- const propertyTracks = uploadResult.tracks.filter(t => t.type === 'property');-- for (let i = 0; i < count; i++) {- const entity = module._tl_getCustomPropertyEntity(i);- const trackIndex = module._tl_getCustomPropertyTrackIndex(i);- const channelIndex = module._tl_getCustomPropertyChannelIndex(i);- const value = module._tl_getCustomPropertyValue(i);-- const trackInfo = propertyTracks[trackIndex];- if (!trackInfo?.component || !trackInfo.channelProperties) continue;-- const componentDef = getComponent(trackInfo.component);- if (!componentDef || !world.has(entity, componentDef)) continue;-- const data = world.get(entity, componentDef);- const propPath = trackInfo.channelProperties[channelIndex];- if (propPath && setNestedProperty(data, propPath, value)) {- world.set(entity, componentDef, data);- }- }-}--export function advanceAndProcess(- world: any, module: ESEngineModule,- handle: number, entity: Entity,- dt: number, speed: number,- uploadResult: UploadResult,- audio: AudioAPI | null = null,-): void {- module._tl_advance(- world.getCppRegistry() as any,- handle, entity, dt, speed,- );- processTimelineEvents(world, module, audio);- processCustomProperties(world, module, uploadResult);- module._tl_clearResults();-}diff --git a/sdk/src/timeline/TimelineUploader.ts b/sdk/src/timeline/TimelineUploader.tsdeleted file mode 100644index c6d530f5f..000000000--- a/sdk/src/timeline/TimelineUploader.ts+++ /dev/null@@ -1,271 +0,0 @@-import type { ESEngineModule } from '../wasm';-import type { TimelineAsset, PropertyTrack, Track } from './TimelineTypes';-import { TrackType, InterpType } from './TimelineTypes';-import { withScratch } from '../wasmScratch';-export { AnimTargetField, AnimTargetComponent, FIELD_MAP, COMPONENT_MAP } from './animTargets.generated';-import { AnimTargetField, AnimTargetComponent, FIELD_MAP, COMPONENT_MAP } from './animTargets.generated';--const INTERP_TYPE_MAP: Record<string, number> = {- [InterpType.Hermite]: 0,- [InterpType.Linear]: 1,- [InterpType.Step]: 2,- [InterpType.EaseIn]: 3,- [InterpType.EaseOut]: 4,- [InterpType.EaseInOut]: 5,-};--function interpTypeToNum(interp?: InterpType): number {- if (!interp) return 0;- return INTERP_TYPE_MAP[interp] ?? 0;-}--function resolveField(component: string, property: string): AnimTargetField {- return FIELD_MAP[component]?.[property] ?? AnimTargetField.CustomField;-}--function allocString(- module: ESEngineModule,- alloc: (size: number) => number,- str: string,-): [number, number] {- const encoder = new TextEncoder();- const bytes = encoder.encode(str);- const ptr = alloc(bytes.length);- new Uint8Array(module.HEAPU8.buffer, ptr, bytes.length).set(bytes);- return [ptr, bytes.length];-}--export interface UploadedTrackInfo {- type: string;- component?: string;- childPath: string;- channelProperties?: string[];-}--export interface UploadResult {- handle: number;- tracks: UploadedTrackInfo[];- totalPropertyChannels: number;-}--export function uploadTimelineToWasm(module: ESEngineModule, asset: TimelineAsset): UploadResult {- const handle = module._tl_create(asset.duration, asset.wrapMode);- if (!handle) return { handle: 0, tracks: [], totalPropertyChannels: 0 };-- const trackInfos: UploadedTrackInfo[] = [];- let totalPropertyChannels = 0;-- for (const track of asset.tracks) {- switch (track.type) {- case TrackType.Property:- uploadPropertyTrack(module, handle, track);- trackInfos.push({- type: 'property',- component: track.component,- childPath: track.childPath,- channelProperties: track.channels.map(c => c.property),- });- totalPropertyChannels += track.channels.length;- break;- case TrackType.Spine:- uploadSpineTrack(module, handle, track);- trackInfos.push({ type: 'spine', childPath: track.childPath });- break;- case TrackType.Audio:- uploadAudioTrack(module, handle, track);- trackInfos.push({ type: 'audio', childPath: track.childPath });- break;- case TrackType.Activation:- uploadActivationTrack(module, handle, track);- trackInfos.push({ type: 'activation', childPath: track.childPath });- break;- case TrackType.SpriteAnim:- uploadSpriteAnimTrack(module, handle, track);- trackInfos.push({ type: 'spriteAnim', childPath: track.childPath });- break;- }- }-- return { handle, tracks: trackInfos, totalPropertyChannels };-}--function uploadPropertyTrack(module: ESEngineModule, handle: number, track: PropertyTrack): void {- const channelCount = track.channels.length;- const component = COMPONENT_MAP[track.component] ?? AnimTargetComponent.Custom;- const isCustom = component === AnimTargetComponent.Custom;-- if (isCustom) {- uploadCustomPropertyTrack(module, handle, track);- return;- }-- withScratch(module, alloc => {- const [childPtr, childLen] = allocString(module, alloc, track.childPath);-- const fieldsPtr = alloc(channelCount);- const fieldsArr = new Uint8Array(module.HEAPU8.buffer, fieldsPtr, channelCount);- for (let i = 0; i < channelCount; i++) {- fieldsArr[i] = resolveField(track.component, track.channels[i].property);- }-- let totalKeyframes = 0;- const counts: number[] = [];- for (const ch of track.channels) {- counts.push(ch.keyframes.length);- totalKeyframes += ch.keyframes.length;- }-- const countsPtr = alloc(channelCount * 4);- new Int32Array(module.HEAPU8.buffer, countsPtr, channelCount).set(counts);-- const dataPtr = alloc(totalKeyframes * 5 * 4);- const dataArr = new Float32Array(module.HEAPU8.buffer, dataPtr, totalKeyframes * 5);- let offset = 0;- for (const ch of track.channels) {- for (const kf of ch.keyframes) {- dataArr[offset++] = kf.time;- dataArr[offset++] = kf.value;- dataArr[offset++] = kf.inTangent;- dataArr[offset++] = kf.outTangent;- dataArr[offset++] = interpTypeToNum(kf.interpolation);- }- }-- module._tl_addPropertyTrack(handle, childPtr, childLen, component,- fieldsPtr, channelCount, dataPtr, countsPtr);- });-}--function uploadCustomPropertyTrack(module: ESEngineModule, handle: number, track: PropertyTrack): void {- const channelCount = track.channels.length;-- withScratch(module, alloc => {- const [childPtr, childLen] = allocString(module, alloc, track.childPath);- const [compPtr, compLen] = allocString(module, alloc, track.component);-- const pathStrings = track.channels.map(c => new TextEncoder().encode(c.property));- let totalPathBytes = 0;- for (const p of pathStrings) totalPathBytes += p.length;-- const fieldPathsPtr = alloc(totalPathBytes);- let pathOffset = 0;- for (const p of pathStrings) {- new Uint8Array(module.HEAPU8.buffer, fieldPathsPtr + pathOffset, p.length).set(p);- pathOffset += p.length;- }-- const fieldPathLensPtr = alloc(channelCount * 4);- new Int32Array(module.HEAPU8.buffer, fieldPathLensPtr, channelCount).set(pathStrings.map(p => p.length));-- let totalKeyframes = 0;- const counts: number[] = [];- for (const ch of track.channels) {- counts.push(ch.keyframes.length);- totalKeyframes += ch.keyframes.length;- }-- const countsPtr = alloc(channelCount * 4);- new Int32Array(module.HEAPU8.buffer, countsPtr, channelCount).set(counts);-- const dataPtr = alloc(totalKeyframes * 5 * 4);- const dataArr = new Float32Array(module.HEAPU8.buffer, dataPtr, totalKeyframes * 5);- let dOffset = 0;- for (const ch of track.channels) {- for (const kf of ch.keyframes) {- dataArr[dOffset++] = kf.time;- dataArr[dOffset++] = kf.value;- dataArr[dOffset++] = kf.inTangent;- dataArr[dOffset++] = kf.outTangent;- dataArr[dOffset++] = interpTypeToNum(kf.interpolation);- }- }-- module._tl_addCustomPropertyTrack(handle, childPtr, childLen, compPtr, compLen,- fieldPathsPtr, fieldPathLensPtr, channelCount,- dataPtr, countsPtr);- });-}--function uploadSpineTrack(module: ESEngineModule, handle: number, track: Track): void {- if (track.type !== TrackType.Spine) return;- withScratch(module, alloc => {- const [childPtr, childLen] = allocString(module, alloc, track.childPath);- const clipCount = track.clips.length;-- const floatsPtr = alloc(clipCount * 4 * 4);- const floats = new Float32Array(module.HEAPU8.buffer, floatsPtr, clipCount * 4);- const animPtrsPtr = alloc(clipCount * 4);- const animPtrs = new Uint32Array(module.HEAPU8.buffer, animPtrsPtr, clipCount);- const animLensPtr = alloc(clipCount * 4);- const animLens = new Int32Array(module.HEAPU8.buffer, animLensPtr, clipCount);-- for (let i = 0; i < clipCount; i++) {- const clip = track.clips[i];- floats[i * 4] = clip.start;- floats[i * 4 + 1] = clip.duration;- floats[i * 4 + 2] = clip.speed;- floats[i * 4 + 3] = clip.loop ? 1.0 : 0.0;- const [aPtr, aLen] = allocString(module, alloc, clip.animation);- animPtrs[i] = aPtr;- animLens[i] = aLen;- }-- module._tl_addSpineTrack(handle, childPtr, childLen,- floatsPtr, animPtrsPtr, animLensPtr, clipCount, track.blendIn);- });-}--function uploadAudioTrack(module: ESEngineModule, handle: number, track: Track): void {- if (track.type !== TrackType.Audio) return;- withScratch(module, alloc => {- const [childPtr, childLen] = allocString(module, alloc, track.childPath);- const eventCount = track.events.length;-- const floatsPtr = alloc(eventCount * 2 * 4);- const floats = new Float32Array(module.HEAPU8.buffer, floatsPtr, eventCount * 2);- const clipPtrsPtr = alloc(eventCount * 4);- const clipPtrs = new Uint32Array(module.HEAPU8.buffer, clipPtrsPtr, eventCount);- const clipLensPtr = alloc(eventCount * 4);- const clipLens = new Int32Array(module.HEAPU8.buffer, clipLensPtr, eventCount);-- for (let i = 0; i < eventCount; i++) {- const evt = track.events[i];- floats[i * 2] = evt.time;- floats[i * 2 + 1] = evt.volume;- const [cPtr, cLen] = allocString(module, alloc, evt.clip);- clipPtrs[i] = cPtr;- clipLens[i] = cLen;- }-- module._tl_addAudioTrack(handle, childPtr, childLen,- floatsPtr, clipPtrsPtr, clipLensPtr, eventCount);- });-}--function uploadActivationTrack(module: ESEngineModule, handle: number, track: Track): void {- if (track.type !== TrackType.Activation) return;- withScratch(module, alloc => {- const [childPtr, childLen] = allocString(module, alloc, track.childPath);-- const rangesPtr = alloc(track.ranges.length * 2 * 4);- const rangesArr = new Float32Array(module.HEAPU8.buffer, rangesPtr, track.ranges.length * 2);- for (let i = 0; i < track.ranges.length; i++) {- rangesArr[i * 2] = track.ranges[i].start;- rangesArr[i * 2 + 1] = track.ranges[i].end;- }-- module._tl_addActivationTrack(handle, childPtr, childLen,- rangesPtr, track.ranges.length);- });-}--function uploadSpriteAnimTrack(module: ESEngineModule, handle: number, track: Track): void {- if (track.type !== TrackType.SpriteAnim) return;- withScratch(module, alloc => {- const [childPtr, childLen] = allocString(module, alloc, track.childPath);- const [clipPtr, clipLen] = allocString(module, alloc, track.clip);-- module._tl_addSpriteAnimTrack(handle, childPtr, childLen,- clipPtr, clipLen, track.startTime);- });-}diff --git a/sdk/src/timeline/index.ts b/sdk/src/timeline/index.tsindex db04567e5..72ee329a6 100644--- a/sdk/src/timeline/index.ts+++ b/sdk/src/timeline/index.ts@@ -28,13 +28,6 @@ export {type TimelineAssetPaths,} from './TimelineLoader';-export {- uploadTimelineToWasm,- AnimTargetField,- type UploadResult,- type UploadedTrackInfo,-} from './TimelineUploader';-export {Timeline,TimelineApi,@@ -42,13 +35,9 @@ export {export {resolveChildEntity,- resolveTrackTargets,- createTimelineHandle,- destroyTimelineHandle,- processTimelineEvents,- processCustomProperties,- advanceAndProcess,setNestedProperty,+ applyTimelineEvent,+ TimelineEventType,} from './TimelineRuntime';export {diff --git a/sdk/tests/timeline-tilemap-ui-bridge.test.ts b/sdk/tests/timeline-tilemap-ui-bridge.test.tsindex 826c5b0b9..ace5419ce 100644--- a/sdk/tests/timeline-tilemap-ui-bridge.test.ts+++ b/sdk/tests/timeline-tilemap-ui-bridge.test.ts@@ -92,29 +92,6 @@ describe('uiHelpers bridge', () => {// timeline — the plugin feeds TimelineControl a guarded module; verify the// control path honours it (the plugin wiring that produces the guarded module// is covered by typecheck).-// ----------------------------------------------------------------------------describe('timeline bridge (control path)', () => {- function makeModule(): ESEngineModule {- return {- _tl_play: vi.fn(),- _tl_isPlaying: () => 1,- onAbort: undefined,- } as unknown as ESEngineModule;- }-- it('honours the guarded module: short-circuits _tl_* after an abort', () => {- const raw = makeModule();- const bridge = new CoreApiBridge('timeline');- bridge.connect(raw);- const tl = new TimelineApi();- tl.setModule(bridge.module); // exactly what TimelinePlugin does- tl.setHandle(7 as unknown as Entity, 100);-- tl.play(7 as unknown as Entity);- expect((raw as unknown as { _tl_play: ReturnType<typeof vi.fn> })._tl_play)- .toHaveBeenCalledWith(100);-- abort(raw);- expect(() => tl.play(7 as unknown as Entity)).toThrow(WasmModuleAborted);- });-});+// The timeline control path no longer routes through the wasm module — the+// runtime is pure TS now (REARCH_ANIMATION P4c), so there's no `_tl_*` bridge to+// guard. (tilemap + ui bridges above still cover the CoreApiBridge guard.)