Class: ZoomedScene
Defined in: core/ZoomedScene.ts:228
Scene with zoom/magnification capability. Displays a zoomed view of a region in a separate window, using Mobject-based camera frame and display objects compatible with Manim animations.
Extends
Constructors
Constructor
new ZoomedScene(
container,options):ZoomedScene
Defined in: core/ZoomedScene.ts:252
Parameters
container
HTMLElement
options
ZoomedSceneOptions = {}
Returns
ZoomedScene
Overrides
Properties
_autoRender
protected_autoRender:boolean=true
Defined in: core/Scene.ts:115
Inherited from
_disposed
protected_disposed:boolean=false
Defined in: core/Scene.ts:99
Inherited from
_waitCleanups
protected_waitCleanups: () =>void[] =[]
Defined in: core/Scene.ts:100
Returns
void
Inherited from
zoomedCamera
readonlyzoomedCamera:ZoomedCamera
Defined in: core/ZoomedScene.ts:230
The zoomed camera with its frame
zoomedDisplay
readonlyzoomedDisplay:ZoomedDisplay
Defined in: core/ZoomedScene.ts:233
The zoomed display (texture + border)
Accessors
_hasActiveLoop
Get Signature
get
protected_hasActiveLoop():boolean
Defined in: core/Scene.ts:325
Whether a render loop is active (play() or wait()). Used by ThreeDScene to avoid duplicate orbit rAF loops.
Returns
boolean
Inherited from
audioManager
Get Signature
get audioManager():
AudioManager
Defined in: core/Scene.ts:362
Get the audio manager (lazily created on first access). Use this to access lower-level audio controls.
Returns
Inherited from
backgroundOpacity
Get Signature
get backgroundOpacity():
number
Defined in: core/Scene.ts:1402
Get the background opacity (0 = fully transparent, 1 = fully opaque).
Returns
number
Set Signature
set backgroundOpacity(
value):void
Defined in: core/Scene.ts:1410
Set the background opacity (0 = fully transparent, 1 = fully opaque). Only effective if the scene was created with backgroundOpacity < 1.
Parameters
value
number
Returns
void
Inherited from
camera
Get Signature
get camera():
Camera2D
Defined in: core/Scene.ts:245
Get the camera.
Returns
Inherited from
currentTime
Get Signature
get currentTime():
number
Defined in: core/Scene.ts:343
Get the current playback time.
Returns
number
Inherited from
isHeadless
Get Signature
get isHeadless():
boolean
Defined in: core/Scene.ts:285
Whether this scene is running in headless mode (no WebGL renderer).
Returns
boolean
Inherited from
isPlaying
Get Signature
get isPlaying():
boolean
Defined in: core/Scene.ts:317
Get whether animations are currently playing.
Returns
boolean
Inherited from
isRenderLoopActive
Get Signature
get isRenderLoopActive():
boolean
Defined in: core/Scene.ts:336
Whether a continuous render loop is currently driving frames every tick: play(), or wait() with per-frame rendering (updaters present). A static wait() (render-once + timeout) does NOT count — manual renders are still needed there. Interaction helpers (e.g. Draggable) use this to skip redundant renders.
Returns
boolean
Inherited from
isZoomActive
Get Signature
get isZoomActive():
boolean
Defined in: core/ZoomedScene.ts:308
Check if zooming is active
Returns
boolean
mobjects
Get Signature
get mobjects():
ReadonlySet<Mobject>
Defined in: core/Scene.ts:350
Get all mobjects in the scene.
Returns
ReadonlySet<Mobject>
Inherited from
multiCamera
Get Signature
get multiCamera():
MultiCamera
Defined in: core/Scene.ts:259
Get the active MultiCamera, or null if single-camera rendering is in use.
Returns
Inherited from
renderer
Get Signature
get renderer():
IRenderer
Defined in: core/Scene.ts:252
Get the renderer.
Returns
Inherited from
stateManager
Get Signature
get stateManager():
SceneStateManager
Defined in: core/Scene.ts:1429
Get the scene's state manager for advanced undo/redo control.
Returns
Inherited from
threeScene
Get Signature
get threeScene():
Scene
Defined in: core/Scene.ts:238
Get the Three.js scene.
Returns
Scene
Inherited from
timeline
Get Signature
get timeline():
Timeline
Defined in: core/Scene.ts:301
Get the current timeline.
Returns
Inherited from
Methods
_cancelPendingRender()
protected_cancelPendingRender():void
Defined in: core/Scene.ts:981
Returns
void
Inherited from
_isInSceneGraph()
protected_isInSceneGraph(obj):boolean
Defined in: core/Scene.ts:518
Check if a THREE object is already part of this scene's graph.
Protected so subclasses with additional render graphs (e.g.
ThreeDScene's HUD scene) can extend this check — otherwise add()
reparents objects that are already correctly placed elsewhere.
Parameters
obj
Object3D
Returns
boolean
Inherited from
_needsPerFrameRendering()
protected_needsPerFrameRendering():boolean
Defined in: core/Scene.ts:955
Whether the scene needs per-frame rendering during wait(). Returns true if any mobject has updaters. Subclasses (e.g. ThreeDScene) can override to also check for ambient camera rotation, etc.
Returns
boolean
Inherited from
_render()
protected_render():void
Defined in: core/ZoomedScene.ts:366
Override _render to include zoom view on every frame (including animation loop). Uses a dedicated orthographic camera for the RT pass so the scene camera is never mutated -- this prevents THREE.js internal state contamination that caused the RT to render empty when the scene camera was temporarily modified.
Returns
void
Overrides
_renderMultiCamera()
protected_renderMultiCamera():void
Defined in: core/Scene.ts:1014
Render via the attached MultiCamera. Clears the full canvas first so arbitrary viewport layouts (e.g. picture-in-picture) don't leak stale pixels, and restores renderer state via try/finally even if a camera render throws.
Returns
void
Inherited from
_scheduleRender()
protected_scheduleRender():void
Defined in: core/Scene.ts:969
Queue a render to run on the next microtask. Multiple calls within the
same tick coalesce. If _cancelPendingRender() is called or
_suppressAutoRender is set before the microtask fires, the render is
skipped. Used by add() so a chained play() can suppress the
pre-animation flash described in issue #317.
Returns
void
Inherited from
activateZooming()
activateZooming():
this
Defined in: core/ZoomedScene.ts:315
Activate zooming: adds camera frame and display to the scene.
Returns
this
add()
add(...
mobjects):this
Defined in: core/Scene.ts:437
Add mobjects to the scene.
Parameters
mobjects
...Mobject[]
Mobjects to add
Returns
this
Inherited from
addForegroundMobject()
addForegroundMobject(...
mobjects):this
Defined in: core/Scene.ts:415
Add mobjects as foreground objects that render on top of everything. Matches Manim Python's add_foreground_mobject().
Parameters
mobjects
...Mobject[]
Mobjects to add in the foreground
Returns
this
Inherited from
addSound()
addSound(
url,options?):Promise<AudioTrack>
Defined in: core/Scene.ts:383
Add a sound to play at a specific time on the timeline.
Mirrors Python manim's self.add_sound("file.wav", time_offset=0.5).
Parameters
url
string
URL of the audio file
options?
Scheduling and playback options
Returns
Promise<AudioTrack>
Promise resolving to the created AudioTrack
Example
await scene.addSound('/sounds/click.wav', { time: 0.5 });
await scene.addSound('/sounds/whoosh.wav'); // plays at time 0
Inherited from
addSoundAtAnimation()
addSoundAtAnimation(
animation,url,options?):Promise<AudioTrack>
Defined in: core/Scene.ts:402
Add a sound that starts when a given animation begins.
Parameters
animation
The animation to sync with
url
string
URL of the audio file
options?
Omit<AddSoundOptions, "time"> & object
Additional options (timeOffset shifts relative to animation start)
Returns
Promise<AudioTrack>
Promise resolving to the created AudioTrack
Example
const fadeIn = new FadeIn(circle);
await scene.addSoundAtAnimation(fadeIn, '/sounds/appear.wav');
await scene.play(fadeIn);
Inherited from
batch()
batch(
callback):void
Defined in: core/Scene.ts:1245
Batch multiple mobject updates without re-rendering between each. Useful for performance when making many changes at once.
Parameters
callback
() => void
Function containing multiple mobject operations
Returns
void
Example
scene.batch(() => {
circle.setColor('red');
circle.shift([1, 0, 0]);
square.setStrokeOpacity(0.5);
});
Inherited from
clear()
clear(
options):this
Defined in: core/ZoomedScene.ts:429
Override clear to reset zoom state.
Parameters
options
render?
boolean
Returns
this
Overrides
deactivateZooming()
deactivateZooming():
this
Defined in: core/ZoomedScene.ts:334
Deactivate zooming: removes camera frame and display from the scene.
Returns
this
dispose()
dispose():
void
Defined in: core/ZoomedScene.ts:472
Clean up all resources.
Returns
void
Overrides
export()
export(
filename,options?):Promise<Blob>
Defined in: core/Scene.ts:1537
Export the scene animation as a file (GIF or video). Format is inferred from the filename extension.
Supported extensions:
.gif- Animated GIF.webm- WebM video (VP9).mp4- MP4 video (browser codec support varies).mov- QuickTime video (browser codec support varies)
Parameters
filename
string
Output filename (e.g. 'animation.gif', 'scene.webm')
options?
Export options (fps, quality, dimensions, etc.)
Returns
Promise<Blob>
The exported Blob
Example
// Export as GIF
const blob = await scene.export('animation.gif');
// Export as WebM with custom options
const blob = await scene.export('scene.webm', {
fps: 30,
quality: 0.8,
onProgress: (p) => console.log(`${Math.round(p * 100)}%`),
});
Inherited from
getCanvas()
getCanvas():
HTMLCanvasElement
Defined in: core/Scene.ts:1361
Get the canvas element.
Returns
HTMLCanvasElement
The HTMLCanvasElement used for rendering
Inherited from
getContainer()
getContainer():
HTMLElement
Defined in: core/Scene.ts:1370
Get the container element the scene is rendered into. Returns the parent element of the canvas.
Returns
HTMLElement
The container HTMLElement
Inherited from
getHeight()
getHeight():
number
Defined in: core/Scene.ts:1395
Get the height of the canvas in pixels.
Returns
number
Canvas height in pixels
Inherited from
getState()
getState(
label?):SceneSnapshot
Defined in: core/Scene.ts:1483
Get a snapshot of the current scene state without modifying stacks.
Parameters
label?
string
Returns
Inherited from
getTargetFps()
getTargetFps():
number
Defined in: core/Scene.ts:1271
Get the current target frame rate.
Returns
number
Target fps
Inherited from
getTimelineDuration()
getTimelineDuration():
number
Defined in: core/Scene.ts:1418
Get the total duration of the current timeline.
Returns
number
Duration in seconds, or 0 if no timeline
Inherited from
getWidth()
getWidth():
number
Defined in: core/Scene.ts:1387
Get the width of the canvas in pixels.
Returns
number
Canvas width in pixels
Inherited from
getZoomedDisplayPopOutAnimation()
getZoomedDisplayPopOutAnimation(
options?):Animation
Defined in: core/ZoomedScene.ts:353
Get a pop-out animation that moves the zoomed display from the camera frame to its current position, mimicking Manim's get_zoomed_display_pop_out_animation().
The animation starts by snapping the display onto the frame, then interpolates position and scale to the display's original state. Use { rateFunc: (t) => smooth(1 - t) } for a reverse pop-out.
Parameters
options?
Returns
isInView()
isInView(
object):boolean
Defined in: core/Scene.ts:1068
Check if an object is within the camera's view frustum. Useful for manual culling checks or debugging.
Parameters
object
Object3D
Three.js object to check
Returns
boolean
true if object is in view or if culling is disabled
Inherited from
pause()
pause():
this
Defined in: core/Scene.ts:868
Pause playback (video and audio).
Returns
this
Inherited from
play()
play(...
animations):Promise<void>
Defined in: core/Scene.ts:675
Play animations in parallel (all at once). Matches Manim's scene.play() behavior where multiple animations run simultaneously. Automatically adds mobjects to the scene if not already present.
Parameters
animations
...Animation[]
Animations to play
Returns
Promise<void>
Promise that resolves when all animations complete
Inherited from
playAll()
playAll(...
animations):Promise<void>
Defined in: core/Scene.ts:742
Play multiple animations in parallel (all at once). Alias for play() - delegates to play() to avoid duplicated logic.
Parameters
animations
...Animation[]
Animations to play simultaneously
Returns
Promise<void>
Promise that resolves when all animations complete
Inherited from
playWithTimestamps()
playWithTimestamps(
entries):Promise<void>
Defined in: core/Scene.ts:695
Play animations with explicit per-animation start/end times (seconds).
NOTE: this is a manim-widget wire-format feature — Python manim has no
equivalent per-animation timing API. It is used by the player when
deserializing AnimationGroup descriptors that carry start/end fields.
Each entry's end - start overrides the animation's own duration so the
Timeline schedules it for the correct window. WARNING: this permanently
mutates the Animation object's duration property. Reusing the same
animation instance in multiple calls will use the last set duration.
Parameters
entries
object[]
Returns
Promise<void>
Inherited from
redo()
redo():
boolean
Defined in: core/Scene.ts:1472
Redo the last undone change. The current state is pushed to the undo stack.
Returns
boolean
true if redo was applied, false if nothing to redo
Inherited from
remove()
remove(...
mobjects):this
Defined in: core/Scene.ts:482
Remove mobjects from the scene.
Parameters
mobjects
...Mobject[]
Mobjects to remove
Returns
this
Inherited from
render()
render():
void
Defined in: core/Scene.ts:1502
Force render a single frame. Useful for video export where frames need to be captured at specific times.
Returns
void
Inherited from
resize()
resize(
width,height):this
Defined in: core/ZoomedScene.ts:464
Handle window resize.
Parameters
width
number
height
number
Returns
this
Overrides
resume()
resume():
this
Defined in: core/Scene.ts:882
Resume playback (video and audio).
Returns
this
Inherited from
saveState()
saveState(
label?):SceneSnapshot
Defined in: core/Scene.ts:1448
Save the current state of all scene mobjects. Pushes onto the undo stack and clears the redo stack.
Parameters
label?
string
Optional human-readable label
Returns
The captured SceneSnapshot
Example
scene.add(circle, square);
scene.saveState();
circle.shift([2, 0, 0]);
scene.undo(); // circle returns to original position
Inherited from
seek()
seek(
time):this
Defined in: core/Scene.ts:853
Seek to a specific time in the timeline. Also seeks the audio manager if audio has been used.
Parameters
time
number
Time in seconds
Returns
this
Inherited from
setFrustumCulling()
setFrustumCulling(
enabled):this
Defined in: core/Scene.ts:1279
Enable or disable frustum culling.
Parameters
enabled
boolean
Whether frustum culling should be enabled
Returns
this
Inherited from
setState()
setState(
snapshot):void
Defined in: core/Scene.ts:1491
Apply a previously captured snapshot, overwriting all mobject states. Does NOT modify undo/redo stacks. Call saveState() first to preserve.
Parameters
snapshot
Returns
void
Inherited from
setTargetFps()
setTargetFps(
fps):this
Defined in: core/Scene.ts:1261
Set the target frame rate.
Parameters
fps
number
Target frames per second (1-120)
Returns
this
Inherited from
stop()
stop():
this
Defined in: core/Scene.ts:897
Stop playback and reset timeline (video and audio).
Returns
this
Inherited from
undo()
undo():
boolean
Defined in: core/Scene.ts:1458
Undo the last change (restore the most recently saved state). The current state is pushed to the redo stack.
Returns
boolean
true if undo was applied, false if nothing to undo
Inherited from
useMultiCamera()
useMultiCamera(
mc):this
Defined in: core/Scene.ts:270
Attach (or detach) a MultiCamera for split-screen, picture-in-picture, or
quad-view rendering. Pass null to revert to single-camera rendering.
Has no effect in headless mode (the NullRenderer cannot scissor viewports).
Parameters
mc
MultiCamera instance, or null to restore the default render path
Returns
this
this for chaining
Inherited from
wait()
wait(
duration):Promise<void>
Defined in: core/Scene.ts:752
Wait for a duration (pause between animations). Runs a render loop during the wait so that updaters keep ticking.
Parameters
duration
number = 1
Duration in seconds
Returns
Promise<void>
Promise that resolves after the duration
Inherited from
createHeadless()
staticcreateHeadless(options):ZoomedScene
Defined in: core/ZoomedScene.ts:482
Create a headless ZoomedScene for testing without a DOM container.
Parameters
options
ZoomedSceneOptions = {}
Returns
ZoomedScene