@motion-script/core / AssetTracker
Class: AssetTracker
Defined in: assets/tracker.ts:10
Collects asset requests emitted during a frame render pass and maintains their frame-range entries. Call start before rendering a frame and end after; use the request methods inside the render to register each asset needed.
Constructors
Constructor
new AssetTracker(
assetCatalog):AssetTracker
Defined in: assets/tracker.ts:12
Parameters
assetCatalog
Returns
AssetTracker
Accessors
assets
Get Signature
get assets():
ReadonlyMap<string,AssetRecord>
Defined in: assets/tracker.ts:40
Returns
ReadonlyMap<string, AssetRecord>
audioRequests
Get Signature
get audioRequests(): readonly
AudioRequest[]
Defined in: assets/tracker.ts:41
Returns
readonly AudioRequest[]
catalog
Get Signature
get catalog():
AssetCatalog
Defined in: assets/tracker.ts:16
Returns
isActive
Get Signature
get isActive():
boolean
Defined in: assets/tracker.ts:122
Whether a frame is currently open (between start and end).
Lets a caller that isn't sure whether it's running inside precomp's
per-frame pass — e.g. TrackMeasureScope/TrackRenderContext, which can
be invoked from a detached "hug" measurement outside that bracket (see
measureDetached in node-lifecycle.ts) — self-bracket instead of
throwing.
Returns
boolean
Methods
addAudioRequest()
addAudioRequest(
req):void
Defined in: assets/tracker.ts:68
Add an audio playback request. Stored by reference so mutations from stop() are reflected when audioRequests is read after the build. Deduplicated by id. Called from Sound.prepare. The owning node's path (from the active withOwnerPath scope) is stamped on first add for timeline display.
Parameters
req
Returns
void
clear()
clear():
void
Defined in: assets/tracker.ts:264
Clear all tracked entries (including loaders) without releasing the instance.
Returns
void
clearAudio()
clearAudio():
void
Defined in: assets/tracker.ts:107
Clear audio requests accumulated for the current scene. Call after reading audioRequests for each scene.
Returns
void
discardOutside()
discardOutside(
startFrame,endFrame):void
Defined in: assets/tracker.ts:255
Remove all tracked entries whose frame ranges fall entirely outside [startFrame, endFrame].
Parameters
startFrame
number
endFrame
number
Returns
void
dispose()
dispose():
void
Defined in: assets/tracker.ts:275
Release all state; the instance should not be used after this call.
Returns
void
end()
end():
void
Defined in: assets/tracker.ts:132
Mark the end of a frame render pass.
Returns
void
requestAudio()
requestAudio(
src):void
Defined in: assets/tracker.ts:86
Register an audio file for loading at the current frame (frame-range caching, like requestImage).
When src is already tracked as a video (the audio is the video's own
track — a Video node playing its clip's sound), leave that record
in place rather than clobbering it with an audio entry under the same
key. Audio data is fetched on demand via fetchAudioData/syncAudio, so
the record type is irrelevant for audio playback, and the video fill needs
its video record to decode frames.
Parameters
src
string
Returns
void
requestFont()
requestFont(
fontFamily,fontWeight):void
Defined in: assets/tracker.ts:242
Register a font face needed at the current frame, keyed by family only.
The key is deliberately not family@weight: loadFont registers the
whole family at once (every weight file), and continuous/variable weight
is rendered via the layout's fontVariations axis — never via a
per-weight file. Including the weight in the key would mint a distinct
asset entry for every frame of a weight tween (Inter@437.2, Inter@482.9,
…), exploding the asset map and re-dispatching a load per weight on every
prefetch tick. Keying by family collapses all of those to one stable entry.
Parameters
fontFamily
string
fontWeight
string
Returns
void
requestImage()
requestImage(
src,width?,height?):void
Defined in: assets/tracker.ts:178
Register an image asset needed at the current frame, tracking the maximum rendered size.
Validates that src exists in the manifest. A missing asset (e.g. a
deleted/renamed file, or a typo in src) throws here during the precomp
build pass, where precompScene records it as a BuildError that
surfaces in the player's errors panel — rather than silently failing to
paint at playback time. This mirrors requestVideo, which already
throws via getVideoDuration on an unknown src.
Parameters
src
string
width?
number = 0
height?
number = 0
Returns
void
requestLoader()
requestLoader(
key,load):void
Defined in: assets/tracker.ts:25
Register an opaque async loader needed at the current frame, tracked on the
timeline by key so the AssetManager runs it once its cache window
opens and disposes it when the window closes. Deduped by key (like
requestFont by family): the first registration's load callback is
kept and its frame range extends as later frames re-request the same key.
Parameters
key
string
load
Returns
void
requestVideo()
requestVideo(
src,width?,height?,trimStart?,trimEnd?):void
Defined in: assets/tracker.ts:202
Register a video asset needed at the current frame, tracking the maximum rendered size.
Parameters
src
string
width?
number = 0
height?
number = 0
trimStart?
number = 0
trimEnd?
number
Returns
void
start()
start(
frame):void
Defined in: assets/tracker.ts:127
Mark the beginning of a frame render pass so request methods know the current frame.
Parameters
frame
number
Returns
void
withOwnerPath()
withOwnerPath(
path,fn):void
Defined in: assets/tracker.ts:52
Run fn with path recorded as the owner of any audio requests added
during it, so the timeline can attribute each clip to its node. Restores
the previous owner afterward (prepare walks are not nested today, but this
keeps it correct if they ever are).
Parameters
path
string
fn
() => void
Returns
void