@nodetool-ai/timeline 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/dist/.nodetool-build-stamp +1 -0
- package/dist/animation/bakedAnimation.d.ts +84 -0
- package/dist/animation/bakedAnimation.d.ts.map +1 -0
- package/dist/animation/bakedAnimation.js +95 -0
- package/dist/animation/bakedAnimation.js.map +1 -0
- package/dist/animation/beat.d.ts +7 -0
- package/dist/animation/beat.d.ts.map +1 -0
- package/dist/animation/beat.js +36 -0
- package/dist/animation/beat.js.map +1 -0
- package/dist/animation/compile.d.ts +184 -0
- package/dist/animation/compile.d.ts.map +1 -0
- package/dist/animation/compile.js +312 -0
- package/dist/animation/compile.js.map +1 -0
- package/dist/animation/custom.d.ts +183 -0
- package/dist/animation/custom.d.ts.map +1 -0
- package/dist/animation/custom.js +583 -0
- package/dist/animation/custom.js.map +1 -0
- package/dist/animation/easing.d.ts +34 -0
- package/dist/animation/easing.d.ts.map +1 -0
- package/dist/animation/easing.js +332 -0
- package/dist/animation/easing.js.map +1 -0
- package/dist/animation/index.d.ts +20 -0
- package/dist/animation/index.d.ts.map +1 -0
- package/dist/animation/index.js +20 -0
- package/dist/animation/index.js.map +1 -0
- package/dist/animation/links.d.ts +33 -0
- package/dist/animation/links.d.ts.map +1 -0
- package/dist/animation/links.js +126 -0
- package/dist/animation/links.js.map +1 -0
- package/dist/animation/presets.d.ts +86 -0
- package/dist/animation/presets.d.ts.map +1 -0
- package/dist/animation/presets.js +642 -0
- package/dist/animation/presets.js.map +1 -0
- package/dist/animation/sample.d.ts +145 -0
- package/dist/animation/sample.d.ts.map +1 -0
- package/dist/animation/sample.js +390 -0
- package/dist/animation/sample.js.map +1 -0
- package/dist/animation/simplify.d.ts +70 -0
- package/dist/animation/simplify.d.ts.map +1 -0
- package/dist/animation/simplify.js +278 -0
- package/dist/animation/simplify.js.map +1 -0
- package/dist/animation/sourceCurves.d.ts +45 -0
- package/dist/animation/sourceCurves.d.ts.map +1 -0
- package/dist/animation/sourceCurves.js +168 -0
- package/dist/animation/sourceCurves.js.map +1 -0
- package/dist/animation/styleTracks.d.ts +23 -0
- package/dist/animation/styleTracks.d.ts.map +1 -0
- package/dist/animation/styleTracks.js +341 -0
- package/dist/animation/styleTracks.js.map +1 -0
- package/dist/animation/types.d.ts +269 -0
- package/dist/animation/types.d.ts.map +1 -0
- package/dist/animation/types.js +173 -0
- package/dist/animation/types.js.map +1 -0
- package/dist/animation/typewriter.d.ts +8 -0
- package/dist/animation/typewriter.d.ts.map +1 -0
- package/dist/animation/typewriter.js +32 -0
- package/dist/animation/typewriter.js.map +1 -0
- package/dist/audioFade.d.ts +73 -0
- package/dist/audioFade.d.ts.map +1 -0
- package/dist/audioFade.js +134 -0
- package/dist/audioFade.js.map +1 -0
- package/dist/authoredStyles.d.ts +61 -0
- package/dist/authoredStyles.d.ts.map +1 -0
- package/dist/authoredStyles.js +90 -0
- package/dist/authoredStyles.js.map +1 -0
- package/dist/authoring.d.ts +50 -0
- package/dist/authoring.d.ts.map +1 -0
- package/dist/authoring.js +207 -0
- package/dist/authoring.js.map +1 -0
- package/dist/beats.d.ts +103 -0
- package/dist/beats.d.ts.map +1 -0
- package/dist/beats.js +228 -0
- package/dist/beats.js.map +1 -0
- package/dist/clone.d.ts +32 -0
- package/dist/clone.d.ts.map +1 -0
- package/dist/clone.js +53 -0
- package/dist/clone.js.map +1 -0
- package/dist/composition.d.ts +87 -0
- package/dist/composition.d.ts.map +1 -0
- package/dist/composition.js +253 -0
- package/dist/composition.js.map +1 -0
- package/dist/crop.d.ts +48 -0
- package/dist/crop.d.ts.map +1 -0
- package/dist/crop.js +75 -0
- package/dist/crop.js.map +1 -0
- package/dist/defaults.d.ts +142 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/defaults.js +335 -0
- package/dist/defaults.js.map +1 -0
- package/dist/dependencyHash.d.ts +14 -0
- package/dist/dependencyHash.d.ts.map +1 -0
- package/dist/dependencyHash.js +19 -0
- package/dist/dependencyHash.js.map +1 -0
- package/dist/dropResolve.d.ts +40 -0
- package/dist/dropResolve.d.ts.map +1 -0
- package/dist/dropResolve.js +137 -0
- package/dist/dropResolve.js.map +1 -0
- package/dist/examples/node.d.ts +11 -0
- package/dist/examples/node.d.ts.map +1 -0
- package/dist/examples/node.js +87 -0
- package/dist/examples/node.js.map +1 -0
- package/dist/extension.d.ts +52 -0
- package/dist/extension.d.ts.map +1 -0
- package/dist/extension.js +269 -0
- package/dist/extension.js.map +1 -0
- package/dist/extensionRequest.d.ts +40 -0
- package/dist/extensionRequest.d.ts.map +1 -0
- package/dist/extensionRequest.js +135 -0
- package/dist/extensionRequest.js.map +1 -0
- package/dist/fill-text.d.ts +30 -0
- package/dist/fill-text.d.ts.map +1 -0
- package/dist/fill-text.js +73 -0
- package/dist/fill-text.js.map +1 -0
- package/dist/fonts/catalog.d.ts +97 -0
- package/dist/fonts/catalog.d.ts.map +1 -0
- package/dist/fonts/catalog.js +276 -0
- package/dist/fonts/catalog.js.map +1 -0
- package/dist/fonts/css.d.ts +24 -0
- package/dist/fonts/css.d.ts.map +1 -0
- package/dist/fonts/css.js +50 -0
- package/dist/fonts/css.js.map +1 -0
- package/dist/fonts/index.d.ts +10 -0
- package/dist/fonts/index.d.ts.map +1 -0
- package/dist/fonts/index.js +10 -0
- package/dist/fonts/index.js.map +1 -0
- package/dist/fonts/register-node.d.ts +45 -0
- package/dist/fonts/register-node.d.ts.map +1 -0
- package/dist/fonts/register-node.js +71 -0
- package/dist/fonts/register-node.js.map +1 -0
- package/dist/generatedMatte.d.ts +86 -0
- package/dist/generatedMatte.d.ts.map +1 -0
- package/dist/generatedMatte.js +152 -0
- package/dist/generatedMatte.js.map +1 -0
- package/dist/generative.d.ts +145 -0
- package/dist/generative.d.ts.map +1 -0
- package/dist/generative.js +396 -0
- package/dist/generative.js.map +1 -0
- package/dist/group.d.ts +47 -0
- package/dist/group.d.ts.map +1 -0
- package/dist/group.js +131 -0
- package/dist/group.js.map +1 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/dist/interchange.d.ts +47 -0
- package/dist/interchange.d.ts.map +1 -0
- package/dist/interchange.js +158 -0
- package/dist/interchange.js.map +1 -0
- package/dist/keyframes.d.ts +44 -0
- package/dist/keyframes.d.ts.map +1 -0
- package/dist/keyframes.js +148 -0
- package/dist/keyframes.js.map +1 -0
- package/dist/lineDelivery.d.ts +108 -0
- package/dist/lineDelivery.d.ts.map +1 -0
- package/dist/lineDelivery.js +154 -0
- package/dist/lineDelivery.js.map +1 -0
- package/dist/linked.d.ts +41 -0
- package/dist/linked.d.ts.map +1 -0
- package/dist/linked.js +166 -0
- package/dist/linked.js.map +1 -0
- package/dist/lipSyncRequest.d.ts +65 -0
- package/dist/lipSyncRequest.d.ts.map +1 -0
- package/dist/lipSyncRequest.js +73 -0
- package/dist/lipSyncRequest.js.map +1 -0
- package/dist/measureClipDurations.d.ts +7 -0
- package/dist/measureClipDurations.d.ts.map +1 -0
- package/dist/measureClipDurations.js +17 -0
- package/dist/measureClipDurations.js.map +1 -0
- package/dist/mediaTrack.d.ts +120 -0
- package/dist/mediaTrack.d.ts.map +1 -0
- package/dist/mediaTrack.js +269 -0
- package/dist/mediaTrack.js.map +1 -0
- package/dist/midi/cacheKey.d.ts +25 -0
- package/dist/midi/cacheKey.d.ts.map +1 -0
- package/dist/midi/cacheKey.js +54 -0
- package/dist/midi/cacheKey.js.map +1 -0
- package/dist/midi/edit.d.ts +48 -0
- package/dist/midi/edit.d.ts.map +1 -0
- package/dist/midi/edit.js +93 -0
- package/dist/midi/edit.js.map +1 -0
- package/dist/midi/engines/bl1.d.ts +29 -0
- package/dist/midi/engines/bl1.d.ts.map +1 -0
- package/dist/midi/engines/bl1.js +128 -0
- package/dist/midi/engines/bl1.js.map +1 -0
- package/dist/midi/engines/dr1.d.ts +28 -0
- package/dist/midi/engines/dr1.d.ts.map +1 -0
- package/dist/midi/engines/dr1.js +101 -0
- package/dist/midi/engines/dr1.js.map +1 -0
- package/dist/midi/engines/dsp.d.ts +126 -0
- package/dist/midi/engines/dsp.d.ts.map +1 -0
- package/dist/midi/engines/dsp.js +371 -0
- package/dist/midi/engines/dsp.js.map +1 -0
- package/dist/midi/engines/index.d.ts +13 -0
- package/dist/midi/engines/index.d.ts.map +1 -0
- package/dist/midi/engines/index.js +13 -0
- package/dist/midi/engines/index.js.map +1 -0
- package/dist/midi/engines/kits.d.ts +12 -0
- package/dist/midi/engines/kits.d.ts.map +1 -0
- package/dist/midi/engines/kits.js +121 -0
- package/dist/midi/engines/kits.js.map +1 -0
- package/dist/midi/engines/wavetables.d.ts +45 -0
- package/dist/midi/engines/wavetables.d.ts.map +1 -0
- package/dist/midi/engines/wavetables.js +334 -0
- package/dist/midi/engines/wavetables.js.map +1 -0
- package/dist/midi/engines/wt1.d.ts +30 -0
- package/dist/midi/engines/wt1.d.ts.map +1 -0
- package/dist/midi/engines/wt1.js +91 -0
- package/dist/midi/engines/wt1.js.map +1 -0
- package/dist/midi/grid.d.ts +51 -0
- package/dist/midi/grid.d.ts.map +1 -0
- package/dist/midi/grid.js +104 -0
- package/dist/midi/grid.js.map +1 -0
- package/dist/midi/index.d.ts +20 -0
- package/dist/midi/index.d.ts.map +1 -0
- package/dist/midi/index.js +20 -0
- package/dist/midi/index.js.map +1 -0
- package/dist/midi/instrument.d.ts +32 -0
- package/dist/midi/instrument.d.ts.map +1 -0
- package/dist/midi/instrument.js +73 -0
- package/dist/midi/instrument.js.map +1 -0
- package/dist/midi/notes.d.ts +46 -0
- package/dist/midi/notes.d.ts.map +1 -0
- package/dist/midi/notes.js +121 -0
- package/dist/midi/notes.js.map +1 -0
- package/dist/midi/notesEdit.d.ts +94 -0
- package/dist/midi/notesEdit.d.ts.map +1 -0
- package/dist/midi/notesEdit.js +159 -0
- package/dist/midi/notesEdit.js.map +1 -0
- package/dist/midi/presets.d.ts +29 -0
- package/dist/midi/presets.d.ts.map +1 -0
- package/dist/midi/presets.js +281 -0
- package/dist/midi/presets.js.map +1 -0
- package/dist/midi/tempo.d.ts +27 -0
- package/dist/midi/tempo.d.ts.map +1 -0
- package/dist/midi/tempo.js +57 -0
- package/dist/midi/tempo.js.map +1 -0
- package/dist/midi/ticks.d.ts +25 -0
- package/dist/midi/ticks.d.ts.map +1 -0
- package/dist/midi/ticks.js +35 -0
- package/dist/midi/ticks.js.map +1 -0
- package/dist/midi/voice.d.ts +148 -0
- package/dist/midi/voice.d.ts.map +1 -0
- package/dist/midi/voice.js +348 -0
- package/dist/midi/voice.js.map +1 -0
- package/dist/midi/wav.d.ts +14 -0
- package/dist/midi/wav.d.ts.map +1 -0
- package/dist/midi/wav.js +51 -0
- package/dist/midi/wav.js.map +1 -0
- package/dist/model3d.d.ts +41 -0
- package/dist/model3d.d.ts.map +1 -0
- package/dist/model3d.js +39 -0
- package/dist/model3d.js.map +1 -0
- package/dist/model3dBake.d.ts +80 -0
- package/dist/model3dBake.d.ts.map +1 -0
- package/dist/model3dBake.js +127 -0
- package/dist/model3dBake.js.map +1 -0
- package/dist/ops/apply.d.ts +32 -0
- package/dist/ops/apply.d.ts.map +1 -0
- package/dist/ops/apply.js +1595 -0
- package/dist/ops/apply.js.map +1 -0
- package/dist/ops/index.d.ts +13 -0
- package/dist/ops/index.d.ts.map +1 -0
- package/dist/ops/index.js +13 -0
- package/dist/ops/index.js.map +1 -0
- package/dist/ops/op.d.ts +407 -0
- package/dist/ops/op.d.ts.map +1 -0
- package/dist/ops/op.js +61 -0
- package/dist/ops/op.js.map +1 -0
- package/dist/ops/serialize.d.ts +77 -0
- package/dist/ops/serialize.d.ts.map +1 -0
- package/dist/ops/serialize.js +81 -0
- package/dist/ops/serialize.js.map +1 -0
- package/dist/ops/types.d.ts +150 -0
- package/dist/ops/types.d.ts.map +1 -0
- package/dist/ops/types.js +12 -0
- package/dist/ops/types.js.map +1 -0
- package/dist/pathSampling.d.ts +51 -0
- package/dist/pathSampling.d.ts.map +1 -0
- package/dist/pathSampling.js +111 -0
- package/dist/pathSampling.js.map +1 -0
- package/dist/placement/index.d.ts +2 -0
- package/dist/placement/index.d.ts.map +1 -0
- package/dist/placement/index.js +2 -0
- package/dist/placement/index.js.map +1 -0
- package/dist/placement/resolveTrackPlacement.d.ts +40 -0
- package/dist/placement/resolveTrackPlacement.d.ts.map +1 -0
- package/dist/placement/resolveTrackPlacement.js +71 -0
- package/dist/placement/resolveTrackPlacement.js.map +1 -0
- package/dist/production.d.ts +99 -0
- package/dist/production.d.ts.map +1 -0
- package/dist/production.js +328 -0
- package/dist/production.js.map +1 -0
- package/dist/reassemble.d.ts +68 -0
- package/dist/reassemble.d.ts.map +1 -0
- package/dist/reassemble.js +187 -0
- package/dist/reassemble.js.map +1 -0
- package/dist/recipe.d.ts +24 -0
- package/dist/recipe.d.ts.map +1 -0
- package/dist/recipe.js +89 -0
- package/dist/recipe.js.map +1 -0
- package/dist/recordedVoiceReplacement.d.ts +70 -0
- package/dist/recordedVoiceReplacement.d.ts.map +1 -0
- package/dist/recordedVoiceReplacement.js +82 -0
- package/dist/recordedVoiceReplacement.js.map +1 -0
- package/dist/reframe.d.ts +31 -0
- package/dist/reframe.d.ts.map +1 -0
- package/dist/reframe.js +227 -0
- package/dist/reframe.js.map +1 -0
- package/dist/render/canvas2d.d.ts +419 -0
- package/dist/render/canvas2d.d.ts.map +1 -0
- package/dist/render/canvas2d.js +1392 -0
- package/dist/render/canvas2d.js.map +1 -0
- package/dist/render/color.d.ts +26 -0
- package/dist/render/color.d.ts.map +1 -0
- package/dist/render/color.js +305 -0
- package/dist/render/color.js.map +1 -0
- package/dist/render/cpuLegacyEffects.d.ts +17 -0
- package/dist/render/cpuLegacyEffects.d.ts.map +1 -0
- package/dist/render/cpuLegacyEffects.js +347 -0
- package/dist/render/cpuLegacyEffects.js.map +1 -0
- package/dist/render/cpuVisualEffects.d.ts +13 -0
- package/dist/render/cpuVisualEffects.d.ts.map +1 -0
- package/dist/render/cpuVisualEffects.js +388 -0
- package/dist/render/cpuVisualEffects.js.map +1 -0
- package/dist/render/cubeLut.d.ts +12 -0
- package/dist/render/cubeLut.d.ts.map +1 -0
- package/dist/render/cubeLut.js +81 -0
- package/dist/render/cubeLut.js.map +1 -0
- package/dist/render/curveFitting.d.ts +28 -0
- package/dist/render/curveFitting.d.ts.map +1 -0
- package/dist/render/curveFitting.js +94 -0
- package/dist/render/curveFitting.js.map +1 -0
- package/dist/render/draw.d.ts +265 -0
- package/dist/render/draw.d.ts.map +1 -0
- package/dist/render/draw.js +929 -0
- package/dist/render/draw.js.map +1 -0
- package/dist/render/effects.d.ts +120 -0
- package/dist/render/effects.d.ts.map +1 -0
- package/dist/render/effects.js +804 -0
- package/dist/render/effects.js.map +1 -0
- package/dist/render/frameCompositor.d.ts +502 -0
- package/dist/render/frameCompositor.d.ts.map +1 -0
- package/dist/render/frameCompositor.js +1331 -0
- package/dist/render/frameCompositor.js.map +1 -0
- package/dist/render/index.d.ts +27 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +27 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/layout.d.ts +17 -0
- package/dist/render/layout.d.ts.map +1 -0
- package/dist/render/layout.js +197 -0
- package/dist/render/layout.js.map +1 -0
- package/dist/render/model3dBakeSamples.d.ts +45 -0
- package/dist/render/model3dBakeSamples.d.ts.map +1 -0
- package/dist/render/model3dBakeSamples.js +68 -0
- package/dist/render/model3dBakeSamples.js.map +1 -0
- package/dist/render/motionBlur.d.ts +170 -0
- package/dist/render/motionBlur.d.ts.map +1 -0
- package/dist/render/motionBlur.js +193 -0
- package/dist/render/motionBlur.js.map +1 -0
- package/dist/render/sceneModel.d.ts +577 -0
- package/dist/render/sceneModel.d.ts.map +1 -0
- package/dist/render/sceneModel.js +1460 -0
- package/dist/render/sceneModel.js.map +1 -0
- package/dist/render/shapeGeometry.d.ts +81 -0
- package/dist/render/shapeGeometry.d.ts.map +1 -0
- package/dist/render/shapeGeometry.js +460 -0
- package/dist/render/shapeGeometry.js.map +1 -0
- package/dist/render/spatial.d.ts +9 -0
- package/dist/render/spatial.d.ts.map +1 -0
- package/dist/render/spatial.js +58 -0
- package/dist/render/spatial.js.map +1 -0
- package/dist/render/svgPath.d.ts +80 -0
- package/dist/render/svgPath.d.ts.map +1 -0
- package/dist/render/svgPath.js +199 -0
- package/dist/render/svgPath.js.map +1 -0
- package/dist/render/temporal.d.ts +6 -0
- package/dist/render/temporal.d.ts.map +1 -0
- package/dist/render/temporal.js +74 -0
- package/dist/render/temporal.js.map +1 -0
- package/dist/render/textLayout.d.ts +159 -0
- package/dist/render/textLayout.d.ts.map +1 -0
- package/dist/render/textLayout.js +301 -0
- package/dist/render/textLayout.js.map +1 -0
- package/dist/render/trackEffects.d.ts +23 -0
- package/dist/render/trackEffects.d.ts.map +1 -0
- package/dist/render/trackEffects.js +93 -0
- package/dist/render/trackEffects.js.map +1 -0
- package/dist/render/transform.d.ts +54 -0
- package/dist/render/transform.d.ts.map +1 -0
- package/dist/render/transform.js +222 -0
- package/dist/render/transform.js.map +1 -0
- package/dist/render/transition.d.ts +109 -0
- package/dist/render/transition.d.ts.map +1 -0
- package/dist/render/transition.js +351 -0
- package/dist/render/transition.js.map +1 -0
- package/dist/retarget.d.ts +73 -0
- package/dist/retarget.d.ts.map +1 -0
- package/dist/retarget.js +305 -0
- package/dist/retarget.js.map +1 -0
- package/dist/rippleEdit.d.ts +83 -0
- package/dist/rippleEdit.d.ts.map +1 -0
- package/dist/rippleEdit.js +184 -0
- package/dist/rippleEdit.js.map +1 -0
- package/dist/scene.d.ts +28 -0
- package/dist/scene.d.ts.map +1 -0
- package/dist/scene.js +28 -0
- package/dist/scene.js.map +1 -0
- package/dist/script-link.d.ts +52 -0
- package/dist/script-link.d.ts.map +1 -0
- package/dist/script-link.js +78 -0
- package/dist/script-link.js.map +1 -0
- package/dist/script.d.ts +52 -0
- package/dist/script.d.ts.map +1 -0
- package/dist/script.js +93 -0
- package/dist/script.js.map +1 -0
- package/dist/snap.d.ts +2 -0
- package/dist/snap.d.ts.map +1 -0
- package/dist/snap.js +21 -0
- package/dist/snap.js.map +1 -0
- package/dist/snapping/buildSnapPoints.d.ts +16 -0
- package/dist/snapping/buildSnapPoints.d.ts.map +1 -0
- package/dist/snapping/buildSnapPoints.js +39 -0
- package/dist/snapping/buildSnapPoints.js.map +1 -0
- package/dist/snapping/index.d.ts +3 -0
- package/dist/snapping/index.d.ts.map +1 -0
- package/dist/snapping/index.js +3 -0
- package/dist/snapping/index.js.map +1 -0
- package/dist/snapping/resolveSnap.d.ts +19 -0
- package/dist/snapping/resolveSnap.d.ts.map +1 -0
- package/dist/snapping/resolveSnap.js +39 -0
- package/dist/snapping/resolveSnap.js.map +1 -0
- package/dist/sourceRate.d.ts +12 -0
- package/dist/sourceRate.d.ts.map +1 -0
- package/dist/sourceRate.js +13 -0
- package/dist/sourceRate.js.map +1 -0
- package/dist/spatialVideoRequest.d.ts +91 -0
- package/dist/spatialVideoRequest.d.ts.map +1 -0
- package/dist/spatialVideoRequest.js +175 -0
- package/dist/spatialVideoRequest.js.map +1 -0
- package/dist/splitClip.d.ts +3 -0
- package/dist/splitClip.d.ts.map +1 -0
- package/dist/splitClip.js +190 -0
- package/dist/splitClip.js.map +1 -0
- package/dist/stableSerialize.d.ts +11 -0
- package/dist/stableSerialize.d.ts.map +1 -0
- package/dist/stableSerialize.js +31 -0
- package/dist/stableSerialize.js.map +1 -0
- package/dist/staleSet.d.ts +41 -0
- package/dist/staleSet.d.ts.map +1 -0
- package/dist/staleSet.js +106 -0
- package/dist/staleSet.js.map +1 -0
- package/dist/storyboard.d.ts +221 -0
- package/dist/storyboard.d.ts.map +1 -0
- package/dist/storyboard.js +417 -0
- package/dist/storyboard.js.map +1 -0
- package/dist/subtitles.d.ts +61 -0
- package/dist/subtitles.d.ts.map +1 -0
- package/dist/subtitles.js +92 -0
- package/dist/subtitles.js.map +1 -0
- package/dist/takes.d.ts +76 -0
- package/dist/takes.d.ts.map +1 -0
- package/dist/takes.js +238 -0
- package/dist/takes.js.map +1 -0
- package/dist/timeRemap.d.ts +101 -0
- package/dist/timeRemap.d.ts.map +1 -0
- package/dist/timeRemap.js +183 -0
- package/dist/timeRemap.js.map +1 -0
- package/dist/trackOrder.d.ts +38 -0
- package/dist/trackOrder.d.ts.map +1 -0
- package/dist/trackOrder.js +54 -0
- package/dist/trackOrder.js.map +1 -0
- package/dist/transitionAtCut.d.ts +89 -0
- package/dist/transitionAtCut.d.ts.map +1 -0
- package/dist/transitionAtCut.js +217 -0
- package/dist/transitionAtCut.js.map +1 -0
- package/dist/trimClip.d.ts +13 -0
- package/dist/trimClip.d.ts.map +1 -0
- package/dist/trimClip.js +60 -0
- package/dist/trimClip.js.map +1 -0
- package/dist/types.d.ts +1772 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +84 -0
- package/dist/types.js.map +1 -0
- package/fonts/BebasNeue-Regular.ttf +0 -0
- package/fonts/Inter-ExtraBold.ttf +0 -0
- package/fonts/Inter-Italic-Variable.ttf +0 -0
- package/fonts/Inter-SemiBold.ttf +0 -0
- package/fonts/Inter-Variable.ttf +0 -0
- package/fonts/JetBrainsMono-Italic-Variable.ttf +0 -0
- package/fonts/JetBrainsMono-Variable.ttf +0 -0
- package/fonts/Lora-Italic-Variable.ttf +0 -0
- package/fonts/Lora-Variable.ttf +0 -0
- package/fonts/OFL-BebasNeue.txt +93 -0
- package/fonts/OFL-Inter.txt +93 -0
- package/fonts/OFL-JetBrainsMono.txt +93 -0
- package/fonts/OFL-Lora.txt +93 -0
- package/fonts/OFL-PlayfairDisplay.txt +93 -0
- package/fonts/OFL-SpaceGrotesk.txt +93 -0
- package/fonts/PlayfairDisplay-Italic-Variable.ttf +0 -0
- package/fonts/PlayfairDisplay-Variable.ttf +0 -0
- package/fonts/SpaceGrotesk-Variable.ttf +0 -0
- package/package.json +108 -0
|
@@ -0,0 +1,1460 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sceneModel — the single source of truth for "what is on screen at time t".
|
|
3
|
+
*
|
|
4
|
+
* The live preview, the browser's offline exporter, and the server-side
|
|
5
|
+
* `RenderTimeline` node all drive their layer lists from
|
|
6
|
+
* {@link computeActiveLayers}, so an exported video is composited from the
|
|
7
|
+
* exact same scene description the user previewed — 1:1 with live, wherever
|
|
8
|
+
* the render runs.
|
|
9
|
+
*
|
|
10
|
+
* Everything here is pure (no DOM, no GPU, no store access) so it is trivially
|
|
11
|
+
* testable and reusable across every render path.
|
|
12
|
+
*/
|
|
13
|
+
import { isClipGrainEffect } from "../types.js";
|
|
14
|
+
import { applySmoothingToSample, isMediaTrackStale, sampleMediaTrackAt } from "../mediaTrack.js";
|
|
15
|
+
import { renderableReframe, resolveReframeCrop } from "../reframe.js";
|
|
16
|
+
import { compileClipAnimations, hasActiveAnimationWindow, hasStaggeredAnimation, isIdentitySample, parseStaggerUnit, sampleAnimations } from "../animation/index.js";
|
|
17
|
+
import { resolveAnimatedStyleTracks, resolveAnimatedTextContent, resolveAnimationLinks } from "../animation/index.js";
|
|
18
|
+
import { clipSourceMsAt } from "../timeRemap.js";
|
|
19
|
+
import { resolveBeatAnimations } from "../animation/beat.js";
|
|
20
|
+
import { countTextStaggerUnits } from "./textLayout.js";
|
|
21
|
+
import { buildTransformMatrix } from "./transform.js";
|
|
22
|
+
import { resolveClipLayouts } from "./layout.js";
|
|
23
|
+
import { resolveCamera2D, sampleCamera2D } from "./spatial.js";
|
|
24
|
+
import { expandTemporalClips, clipSteppedTime } from "./temporal.js";
|
|
25
|
+
import { resolveTransition } from "./transition.js";
|
|
26
|
+
/** Clamp a resolved opacity into the range both compositors agree on. */
|
|
27
|
+
const clamp01 = (v) => (v < 0 ? 0 : v > 1 ? 1 : v);
|
|
28
|
+
/**
|
|
29
|
+
* Top-of-UI track (lowest `track.index`) renders on top in the composite —
|
|
30
|
+
* matches Premiere / Resolve / FCP. The compositor draws layers from low z to
|
|
31
|
+
* high z, so we invert the UI index. The constant offset keeps numbers
|
|
32
|
+
* positive for DOM placeholder z-indices too.
|
|
33
|
+
*/
|
|
34
|
+
export const LAYER_Z_BASE = 1000;
|
|
35
|
+
export const trackZ = (uiIndex) => LAYER_Z_BASE - uiIndex;
|
|
36
|
+
/**
|
|
37
|
+
* Stacking order for overlays drawn on top of the whole preview frame, above
|
|
38
|
+
* every `trackZ` layer. A local scale (not the global `Z_INDEX`/`theme.zIndex`
|
|
39
|
+
* theme scale, whose `commandMenu` at 9999 means the command palette) — these
|
|
40
|
+
* are top-of-preview chrome, semantically distinct from app-level stacking.
|
|
41
|
+
* The magic-generation wash sits below the corner status badges, which sit
|
|
42
|
+
* below the transform gizmo.
|
|
43
|
+
*/
|
|
44
|
+
export const PREVIEW_OVERLAY_Z = {
|
|
45
|
+
magicWash: 9998,
|
|
46
|
+
badge: 9999,
|
|
47
|
+
gizmo: 10000
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Synthetic track index assigned to caption layers so they always composite on
|
|
51
|
+
* top of every real track. Words live on their media clip (an audio voiceover
|
|
52
|
+
* or an imported audio/video clip), which can sit on any track — but the
|
|
53
|
+
* caption must stay legible above the picture, so `trackZ(-1)` puts it one
|
|
54
|
+
* step above `LAYER_Z_BASE`.
|
|
55
|
+
*/
|
|
56
|
+
const CAPTION_TRACK_INDEX = -1;
|
|
57
|
+
/**
|
|
58
|
+
* Max simultaneous video layers. The live preview is bounded by its hot
|
|
59
|
+
* HTMLVideoElement pool; the renderer applies the same cap so the exported
|
|
60
|
+
* frame matches what the preview showed when many video clips overlap.
|
|
61
|
+
*/
|
|
62
|
+
export const MAX_VIDEO_LAYERS = 8;
|
|
63
|
+
/**
|
|
64
|
+
* Max simultaneous live 3D layers. Each one holds its own WebGL context in the
|
|
65
|
+
* browser and its own scene in the headless renderer, and browsers allow only
|
|
66
|
+
* about sixteen contexts per page across the whole editor (R2). A baked 3D clip
|
|
67
|
+
* plays as video and costs a decode slot instead, so it is not counted here.
|
|
68
|
+
*/
|
|
69
|
+
export const MAX_MODEL3D_LAYERS = 2;
|
|
70
|
+
export function isClipActive(clip, currentTimeMs) {
|
|
71
|
+
return (currentTimeMs >= clip.startMs &&
|
|
72
|
+
currentTimeMs < clip.startMs + clip.durationMs);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Opacity multiplier for a clip's incoming transition given the playhead.
|
|
76
|
+
*
|
|
77
|
+
* On the same track the later-starting clip composites on top, so a dissolve is
|
|
78
|
+
* just the incoming clip fading in over the one beneath it — the outgoing clip
|
|
79
|
+
* stays fully opaque (fading it too would bleed the black seed through).
|
|
80
|
+
*
|
|
81
|
+
* - `transitionIn` unset → **auto**: fade in across the overlap with a preceding
|
|
82
|
+
* same-track clip (the overlap length is the duration). No overlap → 1.
|
|
83
|
+
* - `transitionIn` set with `durationMs > 0` → explicit ramp over that window
|
|
84
|
+
* from the clip's start (independent of overlap; also gives fade-from-black
|
|
85
|
+
* for a clip with nothing beneath it).
|
|
86
|
+
* - `durationMs <= 0` → opt-out: a zero-length transition is a hard cut, so 1
|
|
87
|
+
* even when the clips overlap.
|
|
88
|
+
*
|
|
89
|
+
* The incoming half of {@link resolveTransition}, kept as its own name because
|
|
90
|
+
* "how visible is this clip mid-dissolve" is the question every caller outside
|
|
91
|
+
* the compositors asks.
|
|
92
|
+
*
|
|
93
|
+
* `sameTrackClips` must already be filtered to clip's track.
|
|
94
|
+
*/
|
|
95
|
+
export function crossfadeOpacity(clip, sameTrackClips, currentTimeMs) {
|
|
96
|
+
return (resolveTransition(clip, sameTrackClips, currentTimeMs)?.incoming.opacity ??
|
|
97
|
+
1);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Every cut in flight on one track at `currentTimeMs`, keyed by the clip whose
|
|
101
|
+
* layer carries it. `activeClips` must be one track's active clips in start
|
|
102
|
+
* order — during an overlap both sides are active, which is what lets the
|
|
103
|
+
* outgoing partner be found without walking the whole document.
|
|
104
|
+
*
|
|
105
|
+
* A clip can be on both sides at once when its own transition has not finished
|
|
106
|
+
* before the next one starts. Its own (incoming) record wins the geometry,
|
|
107
|
+
* because that is the cut it declares; the two opacities multiply, so it still
|
|
108
|
+
* leaves as the next clip arrives.
|
|
109
|
+
*/
|
|
110
|
+
function resolveTrackTransitions(activeClips, currentTimeMs) {
|
|
111
|
+
const byClipId = new Map();
|
|
112
|
+
for (const clip of activeClips) {
|
|
113
|
+
const pair = resolveTransition(clip, activeClips, currentTimeMs);
|
|
114
|
+
if (!pair)
|
|
115
|
+
continue;
|
|
116
|
+
const outgoing = pair.outgoing;
|
|
117
|
+
if (outgoing && pair.outgoingClip) {
|
|
118
|
+
const id = pair.outgoingClip.id;
|
|
119
|
+
const existing = byClipId.get(id);
|
|
120
|
+
byClipId.set(id, existing
|
|
121
|
+
? { ...existing, opacity: existing.opacity * outgoing.opacity }
|
|
122
|
+
: outgoing);
|
|
123
|
+
}
|
|
124
|
+
const existing = byClipId.get(clip.id);
|
|
125
|
+
byClipId.set(clip.id, existing
|
|
126
|
+
? {
|
|
127
|
+
...pair.incoming,
|
|
128
|
+
opacity: pair.incoming.opacity * existing.opacity
|
|
129
|
+
}
|
|
130
|
+
: pair.incoming);
|
|
131
|
+
}
|
|
132
|
+
return byClipId;
|
|
133
|
+
}
|
|
134
|
+
/** Resolve cuts within a track and a shared group parent before any layers draw. */
|
|
135
|
+
function resolveDocumentTransitions(clips, currentTimeMs) {
|
|
136
|
+
const groupIds = new Set(clips.filter((clip) => clip.mediaType === "group").map((clip) => clip.id));
|
|
137
|
+
const byTrack = new Map();
|
|
138
|
+
for (const clip of clips) {
|
|
139
|
+
if (clip.mediaType === "adjustment" || !isClipActive(clip, currentTimeMs))
|
|
140
|
+
continue;
|
|
141
|
+
const parentId = clip.parentId && groupIds.has(clip.parentId) ? clip.parentId : undefined;
|
|
142
|
+
let byParent = byTrack.get(clip.trackId);
|
|
143
|
+
if (!byParent) {
|
|
144
|
+
byParent = new Map();
|
|
145
|
+
byTrack.set(clip.trackId, byParent);
|
|
146
|
+
}
|
|
147
|
+
const siblings = byParent.get(parentId);
|
|
148
|
+
if (siblings)
|
|
149
|
+
siblings.push(clip);
|
|
150
|
+
else
|
|
151
|
+
byParent.set(parentId, [clip]);
|
|
152
|
+
}
|
|
153
|
+
const transitions = new Map();
|
|
154
|
+
for (const byParent of byTrack.values()) {
|
|
155
|
+
for (const siblings of byParent.values()) {
|
|
156
|
+
siblings.sort((a, b) => a.startMs - b.startMs);
|
|
157
|
+
for (const [id, transition] of resolveTrackTransitions(siblings, currentTimeMs)) {
|
|
158
|
+
transitions.set(id, transition);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return transitions;
|
|
163
|
+
}
|
|
164
|
+
/** The asset id that should be drawn for a clip in its current status. */
|
|
165
|
+
export function effectiveAssetId(clip) {
|
|
166
|
+
switch (clip.status) {
|
|
167
|
+
case "generated":
|
|
168
|
+
case "stale":
|
|
169
|
+
case "locked":
|
|
170
|
+
case "generating":
|
|
171
|
+
return clip.currentAssetId;
|
|
172
|
+
default:
|
|
173
|
+
return undefined;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function resolveBlendMode(b) {
|
|
177
|
+
return b ?? "normal";
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The source-media time (seconds) a clip's video element should display at
|
|
181
|
+
* timeline position `currentTimeMs`. Honors the clip's in-point and speed
|
|
182
|
+
* (unless the speed change is already baked into the asset). Shared by the
|
|
183
|
+
* live preview's seek scheduling and the renderer's deterministic seeking so
|
|
184
|
+
* the same frame is shown in both.
|
|
185
|
+
*
|
|
186
|
+
* A clip carrying a `timeRemap` reads its source position off that curve
|
|
187
|
+
* instead (D13): the keyframes name absolute source milliseconds, so neither
|
|
188
|
+
* the rate nor the in-point applies on top of them.
|
|
189
|
+
*
|
|
190
|
+
* Delegates to `clipSourceMsAt` (`timeRemap.ts`) — the same source time a
|
|
191
|
+
* source-anchored custom animation is sampled at — so this and the animation
|
|
192
|
+
* sampler can't drift into disagreeing about what "now" is on the clip's
|
|
193
|
+
* media clock.
|
|
194
|
+
*/
|
|
195
|
+
export function clipSourceTimeSec(clip, currentTimeMs) {
|
|
196
|
+
return clipSourceMsAt(clip, clipSteppedTime(clip, currentTimeMs)) / 1000;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* The time a **baked** `model3d` clip's video is seeked to (design §D6, time
|
|
200
|
+
* origin). A bake is the clip's evaluated picture rendered from its own first
|
|
201
|
+
* frame, so it plays from 0 however the clip is trimmed, sped up or reversed:
|
|
202
|
+
* the seek is clip-local time and nothing else.
|
|
203
|
+
*/
|
|
204
|
+
export function bakedClipSourceTimeSec(clip, currentTimeMs) {
|
|
205
|
+
return Math.max(0, (currentTimeMs - clip.startMs) / 1000);
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Resolve a clip's caption to its on-screen word state at `currentTimeMs`.
|
|
209
|
+
* Returns `undefined` for clips that carry no caption. Word timings are
|
|
210
|
+
* clip-local (relative to `clip.startMs`), so moving or splitting the clip
|
|
211
|
+
* needs no rewrite of the words.
|
|
212
|
+
*/
|
|
213
|
+
export function resolveCaptionAtTime(clip, currentTimeMs) {
|
|
214
|
+
if (!clip.caption)
|
|
215
|
+
return undefined;
|
|
216
|
+
const local = currentTimeMs - clip.startMs;
|
|
217
|
+
return {
|
|
218
|
+
words: clip.caption.words.map((w) => ({
|
|
219
|
+
text: w.word,
|
|
220
|
+
active: local >= w.startMs && local < w.endMs
|
|
221
|
+
})),
|
|
222
|
+
style: clip.caption.style
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Whether a group has to composite its children into an intermediate surface
|
|
227
|
+
* before they blend.
|
|
228
|
+
*
|
|
229
|
+
* An effect and a non-normal blend mode must run once on the composed picture.
|
|
230
|
+
* A transition also needs one surface so its geometry and coverage apply to
|
|
231
|
+
* the assembly, not each child. Opacity alone does not require a surface.
|
|
232
|
+
*
|
|
233
|
+
* An adjustment child treats the composite of the siblings beneath it, and
|
|
234
|
+
* "the siblings" only exists as a picture once the
|
|
235
|
+
* group has a surface of its own. Without it the adjustment would reach the
|
|
236
|
+
* whole frame below the group, which is not what putting it inside says.
|
|
237
|
+
*/
|
|
238
|
+
export function groupNeedsPrecomposite(group, holdsAdjustment = false, hasTransition = false) {
|
|
239
|
+
if (holdsAdjustment)
|
|
240
|
+
return true;
|
|
241
|
+
if (hasTransition || (group.transitionIn?.durationMs ?? 0) > 0)
|
|
242
|
+
return true;
|
|
243
|
+
if (resolveBlendMode(group.blendMode) !== "normal")
|
|
244
|
+
return true;
|
|
245
|
+
return (group.effects ?? []).some((effect) => effect.enabled);
|
|
246
|
+
}
|
|
247
|
+
/** A group's own transform and opacity at `currentTimeMs`, animations folded in. */
|
|
248
|
+
function groupProps(group, currentTimeMs, canvas, cache, tempo) {
|
|
249
|
+
const layer = {
|
|
250
|
+
clip: group,
|
|
251
|
+
transform: group.transform,
|
|
252
|
+
opacity: group.opacity ?? 1
|
|
253
|
+
};
|
|
254
|
+
if (!canvas)
|
|
255
|
+
return layer;
|
|
256
|
+
const animated = resolveAnimatedLayerProps(layer, currentTimeMs, canvas, cache, { mediaTracks: [], clips: [], tempo });
|
|
257
|
+
return { transform: animated.transform, opacity: animated.opacity };
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Resolve every group clip at `currentTimeMs`, parents before children.
|
|
261
|
+
*
|
|
262
|
+
* A group may itself name a parent, so each one is resolved by walking its
|
|
263
|
+
* parent chain up to the first ancestor already resolved (or to a clip that is
|
|
264
|
+
* not a group), then folding back down: matrices compose `parent × own`,
|
|
265
|
+
* opacities multiply, windows intersect. Resolution is independent of tracks —
|
|
266
|
+
* a group parents by id, and I9 keeps z-order the child's own track's.
|
|
267
|
+
*
|
|
268
|
+
* A chain that revisits a group it already walked is a cycle. It is refused,
|
|
269
|
+
* not followed: every group on that chain resolves unparented and carries
|
|
270
|
+
* `cycle`, which is what stops this from recursing forever on a document that
|
|
271
|
+
* names a parent in a loop.
|
|
272
|
+
*/
|
|
273
|
+
export function resolveGroups(clips, currentTimeMs, canvas, cache, tempo, transitions, camera) {
|
|
274
|
+
const groupTransitions = transitions ?? resolveDocumentTransitions(clips, currentTimeMs);
|
|
275
|
+
const groupById = new Map();
|
|
276
|
+
for (const clip of clips) {
|
|
277
|
+
if (clip.mediaType === "group")
|
|
278
|
+
groupById.set(clip.id, clip);
|
|
279
|
+
}
|
|
280
|
+
// A group holding a live adjustment composites its children whatever else it
|
|
281
|
+
// carries: the adjustment treats that composite (see
|
|
282
|
+
// {@link groupNeedsPrecomposite}).
|
|
283
|
+
const adjusted = new Set();
|
|
284
|
+
for (const clip of clips) {
|
|
285
|
+
if (clip.mediaType !== "adjustment" || clip.parentId === undefined) {
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
if (isClipActive(clip, currentTimeMs))
|
|
289
|
+
adjusted.add(clip.parentId);
|
|
290
|
+
}
|
|
291
|
+
const resolved = new Map();
|
|
292
|
+
for (const group of groupById.values()) {
|
|
293
|
+
if (resolved.has(group.id))
|
|
294
|
+
continue;
|
|
295
|
+
const chain = [];
|
|
296
|
+
const walked = new Set();
|
|
297
|
+
let cursor = group;
|
|
298
|
+
let cycle = false;
|
|
299
|
+
while (cursor && !resolved.has(cursor.id)) {
|
|
300
|
+
if (walked.has(cursor.id)) {
|
|
301
|
+
cycle = true;
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
walked.add(cursor.id);
|
|
305
|
+
chain.push(cursor);
|
|
306
|
+
cursor = cursor.parentId ? groupById.get(cursor.parentId) : undefined;
|
|
307
|
+
}
|
|
308
|
+
// Fold from the ancestor end of the chain back down to `group`.
|
|
309
|
+
let inherited = cursor ? resolved.get(cursor.id) : undefined;
|
|
310
|
+
for (let i = chain.length - 1; i >= 0; i -= 1) {
|
|
311
|
+
const current = chain[i];
|
|
312
|
+
// A chain that reaches a cycle cannot say what any of its links inherit,
|
|
313
|
+
// so none of them inherit anything.
|
|
314
|
+
const parent = cycle ? undefined : inherited;
|
|
315
|
+
const own = groupProps(current, currentTimeMs, canvas, cache, tempo);
|
|
316
|
+
const spatial = camera && !parent?.cameraApplied && own.transform?.depthPx !== undefined
|
|
317
|
+
? resolveCamera2D(own.transform ?? IDENTITY_TRANSFORM, sampleCamera2D(camera, currentTimeMs), current.effects)
|
|
318
|
+
: null;
|
|
319
|
+
const effects = spatial?.effects ?? current.effects;
|
|
320
|
+
const transition = groupTransitions.get(current.id);
|
|
321
|
+
const precompose = groupNeedsPrecomposite(effects === current.effects ? current : { ...current, effects }, adjusted.has(current.id), transition !== undefined);
|
|
322
|
+
const folded = (parent?.opacity ?? 1) * own.opacity;
|
|
323
|
+
const entry = {
|
|
324
|
+
// A precompositing group hands its children full opacity: its own is
|
|
325
|
+
// applied once, to the composed surface, which is the whole point of
|
|
326
|
+
// the intermediate — two overlapping children must not each be dimmed.
|
|
327
|
+
opacity: precompose ? 1 : folded,
|
|
328
|
+
window: {
|
|
329
|
+
startMs: Math.max(current.startMs, parent?.window.startMs ?? Number.NEGATIVE_INFINITY),
|
|
330
|
+
endMs: Math.min(current.startMs + current.durationMs, parent?.window.endMs ?? Number.POSITIVE_INFINITY)
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
if (spatial || parent?.cameraApplied)
|
|
334
|
+
entry.cameraApplied = true;
|
|
335
|
+
if (canvas) {
|
|
336
|
+
entry.matrix = buildTransformMatrix(spatial?.transform ?? own.transform ?? IDENTITY_TRANSFORM,
|
|
337
|
+
// A group has no source to fit, so its matrix is a pure clip-space
|
|
338
|
+
// transform: the identity base makes its anchor and position mean
|
|
339
|
+
// the frame, not a bitmap.
|
|
340
|
+
{ x: 1, y: 1 }, canvas.width, canvas.height, parent?.matrix);
|
|
341
|
+
}
|
|
342
|
+
if (cycle)
|
|
343
|
+
entry.cycle = true;
|
|
344
|
+
if (precompose) {
|
|
345
|
+
entry.surfaceId = current.id;
|
|
346
|
+
entry.precomposite = {
|
|
347
|
+
opacity: clamp01(folded * (transition?.opacity ?? 1)),
|
|
348
|
+
blendMode: resolveBlendMode(current.blendMode),
|
|
349
|
+
effects,
|
|
350
|
+
parentSurfaceId: parent?.surfaceId
|
|
351
|
+
};
|
|
352
|
+
if (transition)
|
|
353
|
+
entry.precomposite.transition = transition;
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
356
|
+
entry.surfaceId = parent?.surfaceId;
|
|
357
|
+
}
|
|
358
|
+
resolved.set(current.id, entry);
|
|
359
|
+
inherited = entry;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return resolved;
|
|
363
|
+
}
|
|
364
|
+
/** Channels of a matte source that can drive a layer's alpha (D6). */
|
|
365
|
+
export const MATTE_MODES = ["alpha", "luma"];
|
|
366
|
+
/**
|
|
367
|
+
* Narrow a document's matte `mode` to one this build applies, or `null` for one
|
|
368
|
+
* it does not — which the scene model leaves unmatted, the way an unknown
|
|
369
|
+
* transition type falls back to a cross-fade (I2).
|
|
370
|
+
*/
|
|
371
|
+
export function parseMatteMode(mode) {
|
|
372
|
+
return MATTE_MODES.includes(mode)
|
|
373
|
+
? mode
|
|
374
|
+
: null;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Resolve every layer active at `currentTimeMs`, in the order the compositor
|
|
378
|
+
* should blend them: media layers first (bottom track first, top track last),
|
|
379
|
+
* then caption layers appended on top. Also computes the change horizon (see
|
|
380
|
+
* {@link ActiveLayersResult}), so a caller driving a per-frame loop (the live
|
|
381
|
+
* preview's rAF tick) can skip recomputation while the query time stays below
|
|
382
|
+
* it and the input arrays are unchanged — steady-state playback inside a
|
|
383
|
+
* clip's middle (no boundary crossed, no caption word transition) becomes a
|
|
384
|
+
* single float compare instead of re-deriving the whole scene.
|
|
385
|
+
*
|
|
386
|
+
* Captions are sourced from any active clip that carries word-level
|
|
387
|
+
* `caption.words` — the voiceover audio clip or an imported audio/video clip —
|
|
388
|
+
* regardless of its track type, and are given {@link CAPTION_TRACK_INDEX} so
|
|
389
|
+
* they always composite above the picture. A clip that carries a caption but
|
|
390
|
+
* has no drawable asset (a caption-only overlay) contributes only the caption;
|
|
391
|
+
* a captioned video contributes both its picture and its caption. Audio clips
|
|
392
|
+
* never contribute a media layer.
|
|
393
|
+
*
|
|
394
|
+
* A group clip contributes no layer of its own. Every clip naming one with
|
|
395
|
+
* `parentId` carries the group's matrix as `parentMatrix`, has the group's
|
|
396
|
+
* opacity multiplied into its own, and is left out entirely while the query
|
|
397
|
+
* time sits outside the group's window. A group carrying effects, a blend
|
|
398
|
+
* mode, or a transition instead contributes a {@link PrecompositeLayer}: its
|
|
399
|
+
* children name it in `precomposeGroupId` and draw into its surface, and the
|
|
400
|
+
* surface blends once.
|
|
401
|
+
*
|
|
402
|
+
* An adjustment clip contributes no layer either. It becomes an
|
|
403
|
+
* {@link AdjustmentLayer}: the effect chain a compositor runs on whatever the
|
|
404
|
+
* surface holds at that clip's z, blended back over the untreated composite at
|
|
405
|
+
* the adjustment's opacity. Inside a group it treats the group's own surface —
|
|
406
|
+
* which is why a group holding one always precomposites — so it reaches its
|
|
407
|
+
* siblings beneath it and nothing outside.
|
|
408
|
+
*
|
|
409
|
+
* Video layers are capped to keep parity with the live preview's video pool;
|
|
410
|
+
* the cap is applied in composite order (top tracks win, matching the preview
|
|
411
|
+
* which fills slots while iterating top-to-bottom). Each clip the cap turns
|
|
412
|
+
* away is named in `droppedLayers` so a host can say what is missing from the
|
|
413
|
+
* frame instead of showing a picture that quietly lost a layer.
|
|
414
|
+
*/
|
|
415
|
+
function computeActiveLayersWithHorizonBase(tracks, clips, currentTimeMs, options = {}) {
|
|
416
|
+
const maxVideoLayers = options.maxVideoLayers ?? MAX_VIDEO_LAYERS;
|
|
417
|
+
const transitions = resolveDocumentTransitions(clips, currentTimeMs);
|
|
418
|
+
// Parents before children: a child's opacity, matrix and window all come
|
|
419
|
+
// from a group that may sit on any track, so every group is resolved before
|
|
420
|
+
// the track walk starts.
|
|
421
|
+
const groups = resolveGroups(clips, currentTimeMs, options.canvas, options.animationCache, options.tempo, transitions, options.camera2d);
|
|
422
|
+
const sortedTracks = [...tracks].sort((a, b) => a.index - b.index);
|
|
423
|
+
const layoutCanvas = options.canvas;
|
|
424
|
+
const layoutClips = layoutCanvas
|
|
425
|
+
? clips.map((clip) => {
|
|
426
|
+
if (!clip.textStyle || !clip.animations?.length)
|
|
427
|
+
return clip;
|
|
428
|
+
const animated = resolveAnimatedLayerProps({ clip, transform: clip.transform, opacity: clip.opacity ?? 1 }, currentTimeMs, layoutCanvas, options.animationCache, { mediaTracks: options.mediaTracks ?? [], clips, tempo: options.tempo });
|
|
429
|
+
return animated.textStyle ? { ...clip, textStyle: animated.textStyle } : clip;
|
|
430
|
+
})
|
|
431
|
+
: clips;
|
|
432
|
+
const layouts = layoutCanvas ? resolveClipLayouts(layoutClips, layoutCanvas) : new Map();
|
|
433
|
+
const clipsByTrackId = new Map();
|
|
434
|
+
for (const c of clips) {
|
|
435
|
+
const arr = clipsByTrackId.get(c.trackId);
|
|
436
|
+
if (arr)
|
|
437
|
+
arr.push(c);
|
|
438
|
+
else
|
|
439
|
+
clipsByTrackId.set(c.trackId, [c]);
|
|
440
|
+
}
|
|
441
|
+
const mediaLayers = [];
|
|
442
|
+
const captionLayers = [];
|
|
443
|
+
const resolvedAdjustments = [];
|
|
444
|
+
const droppedLayers = [];
|
|
445
|
+
let videoCount = 0;
|
|
446
|
+
let model3dCount = 0;
|
|
447
|
+
// Matte sources are diverted, not drawn: the clips named by a readable
|
|
448
|
+
// `matte` are held aside as the walk reaches them and handed to the layers
|
|
449
|
+
// that name them once the walk is over — the source may sit on a track below
|
|
450
|
+
// the one that reads it (D6).
|
|
451
|
+
const clipById = new Map(clips.map((clip) => [clip.id, clip]));
|
|
452
|
+
const matteSourceIds = new Set();
|
|
453
|
+
for (const clip of clips) {
|
|
454
|
+
const matte = clip.matte;
|
|
455
|
+
if (!matte || parseMatteMode(matte.mode) === null)
|
|
456
|
+
continue;
|
|
457
|
+
const source = clipById.get(matte.sourceClipId);
|
|
458
|
+
// An adjustment has no pixels to read a channel out of, so it is no more a
|
|
459
|
+
// matte source than a clip that is not in the document — the layer naming
|
|
460
|
+
// it draws unmatted rather than vanishing.
|
|
461
|
+
if (!source || source.mediaType === "adjustment")
|
|
462
|
+
continue;
|
|
463
|
+
matteSourceIds.add(matte.sourceClipId);
|
|
464
|
+
}
|
|
465
|
+
const matteLayers = new Map();
|
|
466
|
+
const emitMedia = (layer) => {
|
|
467
|
+
layer.transform = layouts.get(layer.clipId) ?? layer.transform;
|
|
468
|
+
layer.camera2d = layer.parentMatrix && layer.clip.parentId && groups.get(layer.clip.parentId)?.cameraApplied
|
|
469
|
+
? null
|
|
470
|
+
: options.camera2d;
|
|
471
|
+
if (matteSourceIds.has(layer.clipId))
|
|
472
|
+
matteLayers.set(layer.clipId, layer);
|
|
473
|
+
else
|
|
474
|
+
mediaLayers.push(layer);
|
|
475
|
+
};
|
|
476
|
+
/**
|
|
477
|
+
* Surfaces an emitted layer actually draws into. A precompositing group with
|
|
478
|
+
* nothing under it at this time is not reported, so no host allocates a
|
|
479
|
+
* frame-sized surface to composite nothing onto.
|
|
480
|
+
*/
|
|
481
|
+
const usedSurfaces = new Set();
|
|
482
|
+
// Change horizon: the smallest upcoming time at which `isClipActive`,
|
|
483
|
+
// `resolveCaptionAtTime`'s active-word index, or the active-layer set could
|
|
484
|
+
// flip for ANY input considered below. Tracked alongside the existing scan
|
|
485
|
+
// so steady-state callers pay nothing extra beyond a few comparisons.
|
|
486
|
+
let nextChangeMs = Number.POSITIVE_INFINITY;
|
|
487
|
+
const considerBoundary = (ms) => {
|
|
488
|
+
if (ms > currentTimeMs && ms < nextChangeMs)
|
|
489
|
+
nextChangeMs = ms;
|
|
490
|
+
};
|
|
491
|
+
// A group window clips children on every track, so its edges move the layer
|
|
492
|
+
// set even when the group itself sits on a track this walk never reaches.
|
|
493
|
+
for (const group of groups.values()) {
|
|
494
|
+
considerBoundary(group.window.startMs);
|
|
495
|
+
considerBoundary(group.window.endMs);
|
|
496
|
+
}
|
|
497
|
+
for (const clip of clips) {
|
|
498
|
+
if ((clip.transitionIn?.durationMs ?? 0) > 0) {
|
|
499
|
+
considerBoundary(clip.startMs + clip.transitionIn.durationMs);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
for (const track of sortedTracks) {
|
|
503
|
+
if (!track.visible)
|
|
504
|
+
continue;
|
|
505
|
+
const isVisual = track.type === "video" || track.type === "overlay";
|
|
506
|
+
const trackClips = clipsByTrackId.get(track.id) ?? [];
|
|
507
|
+
// Any clip starting on this track (active or not) can add a layer —
|
|
508
|
+
// mirrors `isClipActive`'s `>=` boundary at `startMs`.
|
|
509
|
+
for (const c of trackClips) {
|
|
510
|
+
considerBoundary(c.startMs);
|
|
511
|
+
}
|
|
512
|
+
// A group draws nothing itself: it is a transform parent, and its children
|
|
513
|
+
// carry its contribution to the frame. The transition resolver handles
|
|
514
|
+
// group clips as siblings separately, without pairing them with children.
|
|
515
|
+
// An adjustment is held out for the same reason: it treats the picture beneath,
|
|
516
|
+
// so it can be neither side of a cut.
|
|
517
|
+
const activeClips = trackClips
|
|
518
|
+
.filter((c) => c.mediaType !== "group" &&
|
|
519
|
+
c.mediaType !== "adjustment" &&
|
|
520
|
+
isClipActive(c, options.layerTimeMs?.(c) ?? currentTimeMs))
|
|
521
|
+
.sort((a, b) => a.startMs - b.startMs);
|
|
522
|
+
const drawClips = [...activeClips].sort((a, b) => {
|
|
523
|
+
// Echoes sit below the present image even though their source clock
|
|
524
|
+
// starts later. The same rule places farther 2.5D cards behind nearer.
|
|
525
|
+
const depth = (a.transform?.depthPx ?? 0) - (b.transform?.depthPx ?? 0);
|
|
526
|
+
if (depth !== 0)
|
|
527
|
+
return depth;
|
|
528
|
+
const aEcho = a.id.includes(":echo:") ? 0 : 1;
|
|
529
|
+
const bEcho = b.id.includes(":echo:") ? 0 : 1;
|
|
530
|
+
if (aEcho !== bEcho)
|
|
531
|
+
return aEcho - bEcho;
|
|
532
|
+
return a.startMs - b.startMs;
|
|
533
|
+
});
|
|
534
|
+
// Adjustments: resolved here so they carry this track's index, which is the
|
|
535
|
+
// z their treatment runs at. Only a visual track has a composite to treat.
|
|
536
|
+
if (isVisual) {
|
|
537
|
+
for (const clip of trackClips) {
|
|
538
|
+
if (clip.mediaType !== "adjustment")
|
|
539
|
+
continue;
|
|
540
|
+
if (!isClipActive(clip, currentTimeMs))
|
|
541
|
+
continue;
|
|
542
|
+
considerBoundary(clip.startMs + clip.durationMs);
|
|
543
|
+
const parent = clip.parentId ? groups.get(clip.parentId) : undefined;
|
|
544
|
+
if (parent &&
|
|
545
|
+
(currentTimeMs < parent.window.startMs ||
|
|
546
|
+
currentTimeMs >= parent.window.endMs)) {
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
const resolved = resolveAdjustment(clip, track.index, parent, currentTimeMs, options, clips);
|
|
550
|
+
if (resolved)
|
|
551
|
+
resolvedAdjustments.push(resolved);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
for (const clip of drawClips) {
|
|
555
|
+
// Mirrors `isClipActive`'s `<` boundary: the clip stops being active
|
|
556
|
+
// (and its layer disappears) exactly at its end.
|
|
557
|
+
considerBoundary(clip.startMs + clip.durationMs);
|
|
558
|
+
// A clip whose parent is missing or cyclic renders unparented (D4); the
|
|
559
|
+
// validator is where that is reported.
|
|
560
|
+
const parent = clip.parentId ? groups.get(clip.parentId) : undefined;
|
|
561
|
+
if (parent &&
|
|
562
|
+
(currentTimeMs < parent.window.startMs ||
|
|
563
|
+
currentTimeMs >= parent.window.endMs)) {
|
|
564
|
+
continue;
|
|
565
|
+
}
|
|
566
|
+
const parentMatrix = parent?.matrix;
|
|
567
|
+
const precomposeGroupId = parent?.surfaceId;
|
|
568
|
+
if (precomposeGroupId)
|
|
569
|
+
usedSurfaces.add(precomposeGroupId);
|
|
570
|
+
const transition = transitions.get(clip.id);
|
|
571
|
+
const baseOpacity = (clip.opacity ?? 1) * (parent?.opacity ?? 1);
|
|
572
|
+
// Clamped here and nowhere else: the GPU compositor multiplies this into
|
|
573
|
+
// the shader raw while Canvas 2D clamps it, so an out-of-range clip or
|
|
574
|
+
// group opacity drew a different picture on each host. Animations still
|
|
575
|
+
// multiply on top afterwards (I3) — `clampSample` settles those.
|
|
576
|
+
const opacity = clamp01(baseOpacity * (transition?.opacity ?? 1));
|
|
577
|
+
const opacityCoverage = clamp01((parent?.opacity ?? 1) * (transition?.opacity ?? 1));
|
|
578
|
+
// Captions ride on their media clip and always render on top.
|
|
579
|
+
const caption = resolveCaptionAtTime(clip, currentTimeMs);
|
|
580
|
+
if (caption && !matteSourceIds.has(clip.id)) {
|
|
581
|
+
if (clip.caption) {
|
|
582
|
+
// Mirrors `resolveCaptionAtTime`'s word boundaries: the active
|
|
583
|
+
// word's end and the next word's start each flip which word index
|
|
584
|
+
// is reported active.
|
|
585
|
+
const local = currentTimeMs - clip.startMs;
|
|
586
|
+
for (const w of clip.caption.words) {
|
|
587
|
+
if (local >= w.startMs && local < w.endMs) {
|
|
588
|
+
considerBoundary(clip.startMs + w.endMs);
|
|
589
|
+
}
|
|
590
|
+
else if (w.startMs > local) {
|
|
591
|
+
considerBoundary(clip.startMs + w.startMs);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
captionLayers.push({
|
|
596
|
+
kind: "caption",
|
|
597
|
+
clip,
|
|
598
|
+
clipId: clip.id,
|
|
599
|
+
trackIndex: CAPTION_TRACK_INDEX,
|
|
600
|
+
blendMode: resolveBlendMode(clip.blendMode),
|
|
601
|
+
opacity,
|
|
602
|
+
opacityCoverage,
|
|
603
|
+
assetId: undefined,
|
|
604
|
+
transform: clip.transform,
|
|
605
|
+
parentMatrix,
|
|
606
|
+
precomposeGroupId,
|
|
607
|
+
// A caption is drawn frame-sized and untransformed, so it takes the
|
|
608
|
+
// cut's opacity (already in `opacity`) and none of its geometry.
|
|
609
|
+
caption
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
// Only visual tracks draw picture; audio clips never do.
|
|
613
|
+
if (!isVisual)
|
|
614
|
+
continue;
|
|
615
|
+
if (clip.mediaType === "audio")
|
|
616
|
+
continue;
|
|
617
|
+
// A midi clip is notes, not pixels — it never becomes a layer.
|
|
618
|
+
if (clip.mediaType === "midi")
|
|
619
|
+
continue;
|
|
620
|
+
if (clip.mediaType === "text") {
|
|
621
|
+
if (!clip.textStyle)
|
|
622
|
+
continue;
|
|
623
|
+
emitMedia({
|
|
624
|
+
kind: "text",
|
|
625
|
+
clip,
|
|
626
|
+
clipId: clip.id,
|
|
627
|
+
trackIndex: track.index,
|
|
628
|
+
blendMode: resolveBlendMode(clip.blendMode),
|
|
629
|
+
opacity,
|
|
630
|
+
opacityCoverage,
|
|
631
|
+
assetId: undefined,
|
|
632
|
+
transform: clip.transform,
|
|
633
|
+
parentMatrix,
|
|
634
|
+
precomposeGroupId,
|
|
635
|
+
borderRadius: clip.borderRadius,
|
|
636
|
+
crop: clip.crop,
|
|
637
|
+
effects: clip.effects,
|
|
638
|
+
trackEffects: track.effects,
|
|
639
|
+
textStyle: clip.textStyle,
|
|
640
|
+
shapeMask: clip.mask,
|
|
641
|
+
transition
|
|
642
|
+
});
|
|
643
|
+
continue;
|
|
644
|
+
}
|
|
645
|
+
if (clip.mediaType === "shape") {
|
|
646
|
+
if (!clip.shapeStyle)
|
|
647
|
+
continue;
|
|
648
|
+
emitMedia({
|
|
649
|
+
kind: "shape",
|
|
650
|
+
clip,
|
|
651
|
+
clipId: clip.id,
|
|
652
|
+
trackIndex: track.index,
|
|
653
|
+
blendMode: resolveBlendMode(clip.blendMode),
|
|
654
|
+
opacity,
|
|
655
|
+
opacityCoverage,
|
|
656
|
+
assetId: undefined,
|
|
657
|
+
transform: clip.transform,
|
|
658
|
+
parentMatrix,
|
|
659
|
+
precomposeGroupId,
|
|
660
|
+
borderRadius: clip.borderRadius,
|
|
661
|
+
crop: clip.crop,
|
|
662
|
+
effects: clip.effects,
|
|
663
|
+
trackEffects: track.effects,
|
|
664
|
+
shapeStyle: clip.shapeStyle,
|
|
665
|
+
shapeMask: clip.mask,
|
|
666
|
+
transition
|
|
667
|
+
});
|
|
668
|
+
continue;
|
|
669
|
+
}
|
|
670
|
+
if (clip.mediaType === "model3d") {
|
|
671
|
+
const style = clip.model3dStyle;
|
|
672
|
+
// Nothing names the camera, lighting or animation, so nothing can be
|
|
673
|
+
// drawn. The validator reports it as `model3d_style_missing`.
|
|
674
|
+
if (!style)
|
|
675
|
+
continue;
|
|
676
|
+
const common3d = {
|
|
677
|
+
clip,
|
|
678
|
+
clipId: clip.id,
|
|
679
|
+
trackIndex: track.index,
|
|
680
|
+
blendMode: resolveBlendMode(clip.blendMode),
|
|
681
|
+
opacity,
|
|
682
|
+
opacityCoverage,
|
|
683
|
+
transform: clip.transform,
|
|
684
|
+
parentMatrix,
|
|
685
|
+
precomposeGroupId,
|
|
686
|
+
borderRadius: clip.borderRadius,
|
|
687
|
+
crop: clip.crop,
|
|
688
|
+
effects: clip.effects,
|
|
689
|
+
trackEffects: track.effects,
|
|
690
|
+
shapeMask: clip.mask,
|
|
691
|
+
transition
|
|
692
|
+
};
|
|
693
|
+
// A bake whose hash still matches the live document is the picture the
|
|
694
|
+
// clip would draw, already rendered: it plays as an ordinary video
|
|
695
|
+
// layer, costs a decode slot, and needs no 3D renderer at all.
|
|
696
|
+
const bake = style.bake;
|
|
697
|
+
if (bake && options.model3dBakeHash?.(clip) === bake.dependencyHash) {
|
|
698
|
+
if (!matteSourceIds.has(clip.id)) {
|
|
699
|
+
if (videoCount >= maxVideoLayers) {
|
|
700
|
+
droppedLayers.push({
|
|
701
|
+
clipId: clip.id,
|
|
702
|
+
reason: "video_layer_cap"
|
|
703
|
+
});
|
|
704
|
+
continue;
|
|
705
|
+
}
|
|
706
|
+
videoCount += 1;
|
|
707
|
+
}
|
|
708
|
+
emitMedia({
|
|
709
|
+
kind: "video",
|
|
710
|
+
...common3d,
|
|
711
|
+
assetId: bake.assetId,
|
|
712
|
+
bakeSourceTimeSec: bakedClipSourceTimeSec(clip, currentTimeMs)
|
|
713
|
+
});
|
|
714
|
+
continue;
|
|
715
|
+
}
|
|
716
|
+
// Every live 3D layer with a glTF to load costs a renderer context, a
|
|
717
|
+
// matte source included — a matte is rendered to read its channel, so
|
|
718
|
+
// it is not the free ride a diverted video layer is. A clip with no
|
|
719
|
+
// asset yet loads nothing and draws the host's placeholder.
|
|
720
|
+
const glbAssetId = effectiveAssetId(clip);
|
|
721
|
+
if (glbAssetId !== undefined) {
|
|
722
|
+
if (model3dCount >= MAX_MODEL3D_LAYERS) {
|
|
723
|
+
droppedLayers.push({
|
|
724
|
+
clipId: clip.id,
|
|
725
|
+
reason: "model3d_layer_cap"
|
|
726
|
+
});
|
|
727
|
+
continue;
|
|
728
|
+
}
|
|
729
|
+
model3dCount += 1;
|
|
730
|
+
}
|
|
731
|
+
emitMedia({
|
|
732
|
+
kind: "model3d",
|
|
733
|
+
...common3d,
|
|
734
|
+
assetId: glbAssetId,
|
|
735
|
+
model3dStyle: style,
|
|
736
|
+
sourceTimeSec: clipSourceTimeSec(clip, currentTimeMs) * style.animation.speed
|
|
737
|
+
});
|
|
738
|
+
continue;
|
|
739
|
+
}
|
|
740
|
+
const assetId = effectiveAssetId(clip);
|
|
741
|
+
// A caption-only clip (no drawable asset) contributes just its caption.
|
|
742
|
+
if (caption && assetId === undefined)
|
|
743
|
+
continue;
|
|
744
|
+
const reframeTrack = clip.reframe?.trackId
|
|
745
|
+
? options.mediaTracks?.find((candidate) => candidate.id === clip.reframe?.trackId)
|
|
746
|
+
: undefined;
|
|
747
|
+
const activeReframe = renderableReframe(clip, reframeTrack);
|
|
748
|
+
const reframeCrop = activeReframe && options.canvas
|
|
749
|
+
? resolveReframeCrop(activeReframe, clipSourceMsAt(clip, currentTimeMs), {
|
|
750
|
+
width: activeReframe.sourceWidth ??
|
|
751
|
+
clip.width ??
|
|
752
|
+
options.canvas.width,
|
|
753
|
+
height: activeReframe.sourceHeight ??
|
|
754
|
+
clip.height ??
|
|
755
|
+
options.canvas.height
|
|
756
|
+
}, options.canvas, reframeTrack)
|
|
757
|
+
: undefined;
|
|
758
|
+
const common = {
|
|
759
|
+
clip,
|
|
760
|
+
clipId: clip.id,
|
|
761
|
+
trackIndex: track.index,
|
|
762
|
+
blendMode: resolveBlendMode(clip.blendMode),
|
|
763
|
+
opacity,
|
|
764
|
+
opacityCoverage,
|
|
765
|
+
assetId,
|
|
766
|
+
transform: clip.transform,
|
|
767
|
+
parentMatrix,
|
|
768
|
+
precomposeGroupId,
|
|
769
|
+
borderRadius: clip.borderRadius,
|
|
770
|
+
// Reframe is a time-varying authored crop. Clearing it reveals the
|
|
771
|
+
// clip's prior static crop unchanged.
|
|
772
|
+
crop: reframeCrop ?? clip.crop,
|
|
773
|
+
effects: clip.effects,
|
|
774
|
+
trackEffects: track.effects,
|
|
775
|
+
shapeMask: clip.mask,
|
|
776
|
+
transition
|
|
777
|
+
};
|
|
778
|
+
if (clip.mediaType === "image") {
|
|
779
|
+
emitMedia({ kind: "image", ...common });
|
|
780
|
+
}
|
|
781
|
+
else {
|
|
782
|
+
// video | overlay
|
|
783
|
+
// Counted after the matte diversion, not before: a matte source never
|
|
784
|
+
// draws, so charging it a decode slot pushed a visible video layer
|
|
785
|
+
// over the cap — and dropping the source blanked the layer reading it.
|
|
786
|
+
if (common.assetId && !matteSourceIds.has(clip.id)) {
|
|
787
|
+
if (videoCount >= maxVideoLayers) {
|
|
788
|
+
droppedLayers.push({
|
|
789
|
+
clipId: clip.id,
|
|
790
|
+
reason: "video_layer_cap"
|
|
791
|
+
});
|
|
792
|
+
continue;
|
|
793
|
+
}
|
|
794
|
+
videoCount += 1;
|
|
795
|
+
}
|
|
796
|
+
emitMedia({ kind: "video", ...common });
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
const drawn = attachMattes(mediaLayers, matteLayers, clipById, droppedLayers);
|
|
801
|
+
const precomposites = collectPrecomposites(clips, tracks, groups, usedSurfaces);
|
|
802
|
+
if (precomposites.length > 0) {
|
|
803
|
+
const stackOrderByClipId = new Map();
|
|
804
|
+
for (const trackClips of clipsByTrackId.values()) {
|
|
805
|
+
const ordered = trackClips
|
|
806
|
+
.filter((clip) => clip.mediaType !== "adjustment")
|
|
807
|
+
.sort((a, b) => {
|
|
808
|
+
const depth = (a.transform?.depthPx ?? 0) - (b.transform?.depthPx ?? 0);
|
|
809
|
+
if (depth !== 0)
|
|
810
|
+
return depth;
|
|
811
|
+
const aEcho = a.id.includes(":echo:") ? 0 : 1;
|
|
812
|
+
const bEcho = b.id.includes(":echo:") ? 0 : 1;
|
|
813
|
+
if (aEcho !== bEcho)
|
|
814
|
+
return aEcho - bEcho;
|
|
815
|
+
return a.startMs - b.startMs;
|
|
816
|
+
});
|
|
817
|
+
ordered.forEach((clip, index) => stackOrderByClipId.set(clip.id, index));
|
|
818
|
+
}
|
|
819
|
+
for (const layer of drawn) {
|
|
820
|
+
layer.stackOrder = stackOrderByClipId.get(layer.clipId);
|
|
821
|
+
}
|
|
822
|
+
for (const group of precomposites) {
|
|
823
|
+
group.stackOrder = stackOrderByClipId.get(group.clipId);
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
// An adjustment inside a group treats that group's surface. A group with
|
|
827
|
+
// nothing else on screen composites nothing, so the adjustment has nothing to
|
|
828
|
+
// treat — dropped here rather than left naming a surface no host builds.
|
|
829
|
+
const built = new Set(precomposites.map((p) => p.clipId));
|
|
830
|
+
const adjustments = resolvedAdjustments.filter((a) => a.precomposeGroupId === undefined || built.has(a.precomposeGroupId));
|
|
831
|
+
return {
|
|
832
|
+
layers: [...drawn, ...captionLayers],
|
|
833
|
+
adjustments,
|
|
834
|
+
precomposites,
|
|
835
|
+
droppedLayers,
|
|
836
|
+
nextChangeMs
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
export function computeActiveLayersWithHorizon(tracks, clips, currentTimeMs, options = {}) {
|
|
840
|
+
return computeActiveLayersWithHorizonBase(tracks, expandTemporalClips(clips), currentTimeMs, options);
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* One adjustment clip as a plan record, or null when its chain would treat
|
|
844
|
+
* nothing.
|
|
845
|
+
*
|
|
846
|
+
* The effect chain and the opacity both come back through
|
|
847
|
+
* `resolveAnimatedLayerProps`, so an animated grade or a keyframed strength
|
|
848
|
+
* lands here rather than in each compositor. Without a canvas there is nothing
|
|
849
|
+
* to compile animations against, so the clip's own static values stand — the
|
|
850
|
+
* same fallback a group's transform takes.
|
|
851
|
+
*/
|
|
852
|
+
function resolveAdjustment(clip, trackIndex, parent, currentTimeMs, options, clips) {
|
|
853
|
+
const base = (clip.opacity ?? 1) * (parent?.opacity ?? 1);
|
|
854
|
+
const animated = options.canvas
|
|
855
|
+
? resolveAnimatedLayerProps({ clip, opacity: base, opacityCoverage: parent?.opacity ?? 1 }, currentTimeMs, options.canvas, options.animationCache, { mediaTracks: options.mediaTracks ?? [], clips, tempo: options.tempo })
|
|
856
|
+
: null;
|
|
857
|
+
const effects = (animated?.effects ?? clip.effects ?? []).filter((effect) => effect.enabled);
|
|
858
|
+
if (effects.length === 0)
|
|
859
|
+
return null;
|
|
860
|
+
const out = {
|
|
861
|
+
clip,
|
|
862
|
+
clipId: clip.id,
|
|
863
|
+
trackIndex,
|
|
864
|
+
opacity: clamp01(animated?.opacity ?? base),
|
|
865
|
+
effects
|
|
866
|
+
};
|
|
867
|
+
const mask = animated?.clipMask ?? clip.mask;
|
|
868
|
+
if (mask)
|
|
869
|
+
out.mask = mask;
|
|
870
|
+
if (animated?.mask)
|
|
871
|
+
out.wipe = animated.mask;
|
|
872
|
+
if (parent?.surfaceId)
|
|
873
|
+
out.precomposeGroupId = parent.surfaceId;
|
|
874
|
+
return out;
|
|
875
|
+
}
|
|
876
|
+
/**
|
|
877
|
+
* The keyhole a clip's own generated matte drives, or undefined when it has
|
|
878
|
+
* none this build applies (D2).
|
|
879
|
+
*
|
|
880
|
+
* A generated matte is a luma mask video cut from the clip's source frame for
|
|
881
|
+
* frame, carried on the clip rather than on a second one. So the source layer
|
|
882
|
+
* is this layer again with the mask asset in place of the picture: same clip,
|
|
883
|
+
* same placement, same source time — which is what makes a trim, a split or a
|
|
884
|
+
* speed change move the matte with the footage instead of sliding it off.
|
|
885
|
+
*
|
|
886
|
+
* A status other than `ready` resolves to nothing and the layer draws unmatted:
|
|
887
|
+
* a generation in flight must not blank the shot it was asked to cut out.
|
|
888
|
+
*
|
|
889
|
+
* The keyhole carries the layer's geometry and none of its look. Its effects
|
|
890
|
+
* would grade the mask; its shape mask and its opacity are already on the
|
|
891
|
+
* picture, and applying them again would multiply twice. A cut in flight
|
|
892
|
+
* contributes its offset and scale for the same reason the geometry does —
|
|
893
|
+
* without them a pushed layer would slide out from under its own matte — and
|
|
894
|
+
* not its reveal or its dip solid, which the picture already carries.
|
|
895
|
+
*/
|
|
896
|
+
function resolveGeneratedMatte(layer) {
|
|
897
|
+
const generated = layer.clip.generatedMatte;
|
|
898
|
+
if (!generated)
|
|
899
|
+
return undefined;
|
|
900
|
+
if ((generated.status ?? "ready") !== "ready")
|
|
901
|
+
return undefined;
|
|
902
|
+
const transition = layer.transition;
|
|
903
|
+
const source = {
|
|
904
|
+
kind: "video",
|
|
905
|
+
clip: layer.clip,
|
|
906
|
+
clipId: layer.clipId,
|
|
907
|
+
trackIndex: layer.trackIndex,
|
|
908
|
+
blendMode: "normal",
|
|
909
|
+
opacity: 1,
|
|
910
|
+
assetId: generated.assetId,
|
|
911
|
+
transform: layer.transform,
|
|
912
|
+
parentMatrix: layer.parentMatrix,
|
|
913
|
+
precomposeGroupId: layer.precomposeGroupId,
|
|
914
|
+
transition: transition
|
|
915
|
+
? { ...transition, mask: undefined, solid: undefined }
|
|
916
|
+
: undefined
|
|
917
|
+
};
|
|
918
|
+
const resolved = {
|
|
919
|
+
mode: "luma",
|
|
920
|
+
invert: generated.invert ?? false,
|
|
921
|
+
layer: source
|
|
922
|
+
};
|
|
923
|
+
if (generated.strength !== undefined) {
|
|
924
|
+
resolved.strength = clamp01(generated.strength);
|
|
925
|
+
}
|
|
926
|
+
if (generated.featherPx !== undefined && generated.featherPx > 0) {
|
|
927
|
+
resolved.featherPx = generated.featherPx;
|
|
928
|
+
}
|
|
929
|
+
return resolved;
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Hand each matted layer the source layer that drives its alpha, and drop the
|
|
933
|
+
* ones whose source drew nothing at this time.
|
|
934
|
+
*
|
|
935
|
+
* Three outcomes, and the difference between the last two is what the caller
|
|
936
|
+
* can act on. The source resolved to a layer: the matte is attached. The source
|
|
937
|
+
* clip is in the document but produced no layer here — outside its own window,
|
|
938
|
+
* on a hidden track — so its matte is empty and the layer it drives shows
|
|
939
|
+
* nothing; the layer is dropped and named. The source clip is not in the
|
|
940
|
+
* document at all — or is an adjustment, which has no pixels a channel could
|
|
941
|
+
* be read out of: the matte is ignored and the layer draws unmatted, which is
|
|
942
|
+
* what `matte_source_missing` reports, the way a missing parent renders
|
|
943
|
+
* unparented.
|
|
944
|
+
*/
|
|
945
|
+
function attachMattes(layers, matteLayers, clipById, droppedLayers) {
|
|
946
|
+
const out = [];
|
|
947
|
+
for (const layer of layers) {
|
|
948
|
+
// A generated matte is cut from this clip's own source, so it needs no
|
|
949
|
+
// source clip to be present and nothing to keep in sync — and it wins over
|
|
950
|
+
// an authored `matte` on the same clip: the cutout is what the user asked
|
|
951
|
+
// the picture to be, and a compositor applies one keyhole, not two.
|
|
952
|
+
const generated = resolveGeneratedMatte(layer);
|
|
953
|
+
if (generated) {
|
|
954
|
+
layer.matte = generated;
|
|
955
|
+
out.push(layer);
|
|
956
|
+
continue;
|
|
957
|
+
}
|
|
958
|
+
const matte = layer.clip.matte;
|
|
959
|
+
const mode = matte ? parseMatteMode(matte.mode) : null;
|
|
960
|
+
if (!matte || mode === null) {
|
|
961
|
+
out.push(layer);
|
|
962
|
+
continue;
|
|
963
|
+
}
|
|
964
|
+
const source = matteLayers.get(matte.sourceClipId);
|
|
965
|
+
if (source) {
|
|
966
|
+
layer.matte = { mode, invert: matte.invert ?? false, layer: source };
|
|
967
|
+
out.push(layer);
|
|
968
|
+
continue;
|
|
969
|
+
}
|
|
970
|
+
// A source that is not in the document, and an adjustment — which has no
|
|
971
|
+
// pixels of its own — are the same case: no matte, and the layer draws.
|
|
972
|
+
const sourceClip = clipById.get(matte.sourceClipId);
|
|
973
|
+
if (!sourceClip || sourceClip.mediaType === "adjustment") {
|
|
974
|
+
out.push(layer);
|
|
975
|
+
continue;
|
|
976
|
+
}
|
|
977
|
+
droppedLayers.push({
|
|
978
|
+
clipId: layer.clipId,
|
|
979
|
+
reason: "matte_source_inactive"
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
return out;
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* The precomposite layers for the surfaces `usedSurfaces` names, innermost
|
|
986
|
+
* first.
|
|
987
|
+
*
|
|
988
|
+
* A surface only reaches the frame through the one holding it, so a nested
|
|
989
|
+
* group is pulled in even when no layer drew straight into its parent. Ordering
|
|
990
|
+
* by how deep a surface sits means a host building them in array order always
|
|
991
|
+
* finds a nested surface already composed. At equal depth, sort by track and
|
|
992
|
+
* group start time; child-track discovery order does not determine where two
|
|
993
|
+
* group surfaces stack.
|
|
994
|
+
*/
|
|
995
|
+
function collectPrecomposites(clips, tracks, groups, usedSurfaces) {
|
|
996
|
+
if (usedSurfaces.size === 0)
|
|
997
|
+
return [];
|
|
998
|
+
const needed = new Set();
|
|
999
|
+
for (const id of usedSurfaces) {
|
|
1000
|
+
let cursor = id;
|
|
1001
|
+
while (cursor && !needed.has(cursor)) {
|
|
1002
|
+
needed.add(cursor);
|
|
1003
|
+
cursor = groups.get(cursor)?.precomposite?.parentSurfaceId;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
const trackIndexById = new Map();
|
|
1007
|
+
for (const track of tracks)
|
|
1008
|
+
trackIndexById.set(track.id, track.index);
|
|
1009
|
+
const groupClipById = new Map();
|
|
1010
|
+
for (const clip of clips) {
|
|
1011
|
+
if (needed.has(clip.id))
|
|
1012
|
+
groupClipById.set(clip.id, clip);
|
|
1013
|
+
}
|
|
1014
|
+
const depthOf = (id) => {
|
|
1015
|
+
let depth = 0;
|
|
1016
|
+
let cursor = groups.get(id)?.precomposite?.parentSurfaceId;
|
|
1017
|
+
while (cursor) {
|
|
1018
|
+
depth += 1;
|
|
1019
|
+
cursor = groups.get(cursor)?.precomposite?.parentSurfaceId;
|
|
1020
|
+
}
|
|
1021
|
+
return depth;
|
|
1022
|
+
};
|
|
1023
|
+
const out = [];
|
|
1024
|
+
for (const id of needed) {
|
|
1025
|
+
const precomposite = groups.get(id)?.precomposite;
|
|
1026
|
+
const clip = groupClipById.get(id);
|
|
1027
|
+
if (!precomposite || !clip)
|
|
1028
|
+
continue;
|
|
1029
|
+
const layer = {
|
|
1030
|
+
clipId: id,
|
|
1031
|
+
// A group always sits on a track; falling back to the caption index
|
|
1032
|
+
// rather than 0 keeps a surface whose track went missing on top of the
|
|
1033
|
+
// picture instead of buried under it.
|
|
1034
|
+
trackIndex: trackIndexById.get(clip.trackId) ?? CAPTION_TRACK_INDEX,
|
|
1035
|
+
opacity: precomposite.opacity,
|
|
1036
|
+
blendMode: precomposite.blendMode,
|
|
1037
|
+
effects: precomposite.effects,
|
|
1038
|
+
precomposeGroupId: precomposite.parentSurfaceId
|
|
1039
|
+
};
|
|
1040
|
+
if (precomposite.transition)
|
|
1041
|
+
layer.transition = precomposite.transition;
|
|
1042
|
+
out.push(layer);
|
|
1043
|
+
}
|
|
1044
|
+
return out.sort((a, b) => {
|
|
1045
|
+
const depth = depthOf(b.clipId) - depthOf(a.clipId);
|
|
1046
|
+
if (depth !== 0)
|
|
1047
|
+
return depth;
|
|
1048
|
+
const track = b.trackIndex - a.trackIndex;
|
|
1049
|
+
if (track !== 0)
|
|
1050
|
+
return track;
|
|
1051
|
+
return groupClipById.get(a.clipId).startMs - groupClipById.get(b.clipId).startMs;
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* {@link computeActiveLayersWithHorizon}, discarding the change horizon. Kept
|
|
1056
|
+
* as the stable entry point for callers that only need the layer set (the
|
|
1057
|
+
* offline renderer, tests) — its signature must stay a plain `ActiveLayer[]`
|
|
1058
|
+
* return.
|
|
1059
|
+
*/
|
|
1060
|
+
export function computeActiveLayers(tracks, clips, currentTimeMs, options = {}) {
|
|
1061
|
+
return computeActiveLayersWithHorizon(tracks, clips, currentTimeMs, options)
|
|
1062
|
+
.layers;
|
|
1063
|
+
}
|
|
1064
|
+
export function createAnimationCompileCache() {
|
|
1065
|
+
return new Map();
|
|
1066
|
+
}
|
|
1067
|
+
/**
|
|
1068
|
+
* The unit a clip's staggered animations are timed and drawn in, and how many
|
|
1069
|
+
* of it the clip's text holds. A clip lays out in ONE unit — the rasterizer
|
|
1070
|
+
* walks a single list — so the first enabled animation naming a unit this
|
|
1071
|
+
* build knows decides it, and the compiler drops a stagger declaring another.
|
|
1072
|
+
*
|
|
1073
|
+
* Non-text clips and clips with no stagger count zero, which is how a stagger
|
|
1074
|
+
* config stays a no-op outside text.
|
|
1075
|
+
*/
|
|
1076
|
+
export function clipStaggerCount(clip, canvas) {
|
|
1077
|
+
const none = { unit: "word", count: 0 };
|
|
1078
|
+
if (clip.mediaType !== "text" || !clip.textStyle)
|
|
1079
|
+
return none;
|
|
1080
|
+
for (const animation of clip.animations ?? []) {
|
|
1081
|
+
if (animation.enabled === false || !animation.stagger)
|
|
1082
|
+
continue;
|
|
1083
|
+
const unit = parseStaggerUnit(animation.stagger.unit);
|
|
1084
|
+
if (!unit)
|
|
1085
|
+
continue;
|
|
1086
|
+
return { unit, count: countTextStaggerUnits(clip.textStyle, canvas, unit) };
|
|
1087
|
+
}
|
|
1088
|
+
return none;
|
|
1089
|
+
}
|
|
1090
|
+
function compiledFor(clip, canvas, cache, tempo) {
|
|
1091
|
+
const animations = clip.animations;
|
|
1092
|
+
if (!animations || animations.length === 0)
|
|
1093
|
+
return [];
|
|
1094
|
+
const { unit: staggerUnit, count: staggerCount } = clipStaggerCount(clip, canvas);
|
|
1095
|
+
const beatSignature = animations.some((animation) => animation.beat)
|
|
1096
|
+
? `${clip.startMs}:${tempo?.bpm ?? 120}:${tempo?.offsetMs ?? 0}`
|
|
1097
|
+
: "";
|
|
1098
|
+
const timedAnimations = resolveBeatAnimations(clip, tempo);
|
|
1099
|
+
if (cache) {
|
|
1100
|
+
const hit = cache.get(clip.id);
|
|
1101
|
+
if (hit &&
|
|
1102
|
+
hit.animationsRef === animations &&
|
|
1103
|
+
hit.durationMs === clip.durationMs &&
|
|
1104
|
+
hit.canvasW === canvas.width &&
|
|
1105
|
+
hit.canvasH === canvas.height &&
|
|
1106
|
+
hit.staggerUnit === staggerUnit &&
|
|
1107
|
+
hit.staggerCount === staggerCount
|
|
1108
|
+
&& hit.beatSignature === beatSignature) {
|
|
1109
|
+
return hit.compiled;
|
|
1110
|
+
}
|
|
1111
|
+
const compiled = compileClipAnimations(timedAnimations, clip.durationMs, canvas, {
|
|
1112
|
+
staggerCount,
|
|
1113
|
+
staggerUnit
|
|
1114
|
+
});
|
|
1115
|
+
cache.set(clip.id, {
|
|
1116
|
+
animationsRef: animations,
|
|
1117
|
+
durationMs: clip.durationMs,
|
|
1118
|
+
canvasW: canvas.width,
|
|
1119
|
+
canvasH: canvas.height,
|
|
1120
|
+
staggerUnit,
|
|
1121
|
+
staggerCount,
|
|
1122
|
+
beatSignature,
|
|
1123
|
+
compiled
|
|
1124
|
+
});
|
|
1125
|
+
return compiled;
|
|
1126
|
+
}
|
|
1127
|
+
return compileClipAnimations(timedAnimations, clip.durationMs, canvas, {
|
|
1128
|
+
staggerCount,
|
|
1129
|
+
staggerUnit
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
const IDENTITY_TRANSFORM = {
|
|
1133
|
+
position: { x: 0, y: 0 },
|
|
1134
|
+
scale: { x: 1, y: 1 },
|
|
1135
|
+
rotation: 0,
|
|
1136
|
+
anchor: { x: 0.5, y: 0.5 }
|
|
1137
|
+
};
|
|
1138
|
+
/**
|
|
1139
|
+
* Compose a layer's static transform/opacity with its animation sample at
|
|
1140
|
+
* `currentTimeMs`. Returns the layer's existing values (no allocation) when the
|
|
1141
|
+
* clip has no enabled animations or the sample is identity at this time.
|
|
1142
|
+
*
|
|
1143
|
+
* `sample.opacity` multiplies the already-resolved layer opacity (base ×
|
|
1144
|
+
* crossfade), so animations compose with `transitionIn` rather than fight it.
|
|
1145
|
+
*/
|
|
1146
|
+
/**
|
|
1147
|
+
* The offset/scale/rotation a clip's `trackBinding` contributes to its
|
|
1148
|
+
* transform at `currentTimeMs`, or `undefined` when the clip carries no
|
|
1149
|
+
* binding, names a track not in `mediaTracks`, or binds in a mode not yet
|
|
1150
|
+
* live (see `TrackBinding.mode`'s doc comment — only `"position"` and
|
|
1151
|
+
* `"position_scale"` are folded here; `"transform"`, `"mask"`,
|
|
1152
|
+
* `"effect_region"` and `"reframe"` contribute nothing here; Smart Reframe
|
|
1153
|
+
* resolves through the clip's first-class `reframe` field during scene
|
|
1154
|
+
* construction instead.
|
|
1155
|
+
*
|
|
1156
|
+
* The track's normalized `x`/`y` (0..1 over the SOURCE frame) is read as a
|
|
1157
|
+
* fraction of the canvas the same way a transform's own position is
|
|
1158
|
+
* authored — offset from center in canvas pixels — which is exact when the
|
|
1159
|
+
* clip's source and the sequence share an aspect ratio and an approximation
|
|
1160
|
+
* otherwise (a cropped or letterboxed source has no stored mapping back to
|
|
1161
|
+
* canvas space here). `mode: "position_scale"` additionally applies
|
|
1162
|
+
* `binding.scale` as an explicit multiplier; it does NOT derive a scale from
|
|
1163
|
+
* the tracked box's own width/height, since no baseline size is recorded to
|
|
1164
|
+
* normalize against.
|
|
1165
|
+
*/
|
|
1166
|
+
function resolveTrackBindingOffset(clip, tracking, currentTimeMs, canvas) {
|
|
1167
|
+
const binding = clip.trackBinding;
|
|
1168
|
+
if (!binding || !tracking)
|
|
1169
|
+
return undefined;
|
|
1170
|
+
if (binding.mode !== "position" && binding.mode !== "position_scale") {
|
|
1171
|
+
return undefined;
|
|
1172
|
+
}
|
|
1173
|
+
const track = tracking.mediaTracks.find((t) => t.id === binding.trackId);
|
|
1174
|
+
if (!track || track.status !== "ready")
|
|
1175
|
+
return undefined;
|
|
1176
|
+
const owner = tracking.clips.find((candidate) => candidate.id === track.clipId);
|
|
1177
|
+
if (!owner || isMediaTrackStale(track, owner))
|
|
1178
|
+
return undefined;
|
|
1179
|
+
const sourceMs = clipSourceMsAt(owner, currentTimeMs);
|
|
1180
|
+
const sample = binding.smoothing !== undefined && binding.smoothing > 0
|
|
1181
|
+
? applySmoothingToSample(track, sourceMs, binding.smoothing)
|
|
1182
|
+
: sampleMediaTrackAt(track, sourceMs);
|
|
1183
|
+
if (!sample || sample.x === undefined || sample.y === undefined) {
|
|
1184
|
+
return undefined;
|
|
1185
|
+
}
|
|
1186
|
+
const px = (sample.x - 0.5) * canvas.width;
|
|
1187
|
+
const py = (sample.y - 0.5) * canvas.height;
|
|
1188
|
+
return {
|
|
1189
|
+
x: px + (binding.offset?.x ?? 0),
|
|
1190
|
+
y: py + (binding.offset?.y ?? 0),
|
|
1191
|
+
scale: binding.mode === "position_scale" ? (binding.scale ?? 1) : 1,
|
|
1192
|
+
rotation: binding.rotationOffset ?? 0
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
export function resolveAnimatedLayerProps(layer, currentTimeMs, canvas, cache, tracking) {
|
|
1196
|
+
const clip = layer.clip;
|
|
1197
|
+
currentTimeMs = clipSteppedTime(clip, currentTimeMs);
|
|
1198
|
+
const trackOffset = resolveTrackBindingOffset(clip, tracking, currentTimeMs, canvas);
|
|
1199
|
+
const compiled = compiledFor(clip, canvas, cache, tracking?.tempo);
|
|
1200
|
+
const links = resolveAnimationLinks(clip, currentTimeMs, tracking?.clips ?? [], canvas, tracking?.tempo);
|
|
1201
|
+
if (compiled.length === 0 && Object.keys(links).length === 0) {
|
|
1202
|
+
return cameraProps(staticProps(layer, currentTimeMs, trackOffset), layer.camera2d, currentTimeMs);
|
|
1203
|
+
}
|
|
1204
|
+
const localMs = currentTimeMs - clip.startMs;
|
|
1205
|
+
const styles = resolveAnimatedStyleTracks(clip, compiled, localMs);
|
|
1206
|
+
const textContent = resolveAnimatedTextContent({ animations: clip.animations, textStyle: styles.textStyle }, compiled, localMs);
|
|
1207
|
+
const textStyle = styles.textStyle && textContent !== undefined && textContent !== styles.textStyle.text
|
|
1208
|
+
? { ...styles.textStyle, text: textContent }
|
|
1209
|
+
: styles.textStyle;
|
|
1210
|
+
const s = sampleAnimations(compiled, localMs, undefined, clipSourceMsAt(clip, clipSteppedTime(clip, currentTimeMs)));
|
|
1211
|
+
if (isIdentitySample(s) && !trackOffset &&
|
|
1212
|
+
styles.shapeStyle === clip.shapeStyle && textStyle === clip.textStyle &&
|
|
1213
|
+
styles.effects === clip.effects && styles.clipMask === clip.mask &&
|
|
1214
|
+
styles.borderRadius === clip.borderRadius &&
|
|
1215
|
+
Object.keys(links).length === 0) {
|
|
1216
|
+
return cameraProps(staticProps(layer, currentTimeMs, trackOffset), layer.camera2d, currentTimeMs);
|
|
1217
|
+
}
|
|
1218
|
+
const base = layer.transform ?? IDENTITY_TRANSFORM;
|
|
1219
|
+
// `positionX/Y` and `anchorX/Y` replace the clip's own value when driven;
|
|
1220
|
+
// `offsetX/Y` still add on top, so an offset animation composes with a
|
|
1221
|
+
// position one instead of fighting it. The track binding's offset folds in
|
|
1222
|
+
// the same way `offsetX/Y` does — additive, not replacing.
|
|
1223
|
+
const transform = {
|
|
1224
|
+
position: {
|
|
1225
|
+
x: links.positionX ?? ((s.positionX ?? base.position.x) + s.offsetX + (trackOffset?.x ?? 0)),
|
|
1226
|
+
y: links.positionY ?? ((s.positionY ?? base.position.y) + s.offsetY + (trackOffset?.y ?? 0))
|
|
1227
|
+
},
|
|
1228
|
+
scale: {
|
|
1229
|
+
x: links.scale ?? (base.scale.x * s.scale * s.scaleX * (trackOffset?.scale ?? 1)),
|
|
1230
|
+
y: links.scale ?? (base.scale.y * s.scale * s.scaleY * (trackOffset?.scale ?? 1))
|
|
1231
|
+
},
|
|
1232
|
+
rotation: links.rotation ?? (base.rotation + s.rotation + (trackOffset?.rotation ?? 0)),
|
|
1233
|
+
anchor: s.anchorX === undefined && s.anchorY === undefined
|
|
1234
|
+
? base.anchor
|
|
1235
|
+
: { x: s.anchorX ?? base.anchor.x, y: s.anchorY ?? base.anchor.y }
|
|
1236
|
+
};
|
|
1237
|
+
if (base.depthPx !== undefined)
|
|
1238
|
+
transform.depthPx = base.depthPx;
|
|
1239
|
+
if (base.rotationX !== undefined || s.rotationX !== 0) {
|
|
1240
|
+
transform.rotationX = (base.rotationX ?? 0) + s.rotationX;
|
|
1241
|
+
}
|
|
1242
|
+
if (base.rotationY !== undefined || s.rotationY !== 0) {
|
|
1243
|
+
transform.rotationY = (base.rotationY ?? 0) + s.rotationY;
|
|
1244
|
+
}
|
|
1245
|
+
if (base.perspective !== undefined)
|
|
1246
|
+
transform.perspective = base.perspective;
|
|
1247
|
+
// `s.mask` is freshly allocated per sampleAnimations call here (no scratch
|
|
1248
|
+
// is passed), so handing it out is safe.
|
|
1249
|
+
return cameraProps({
|
|
1250
|
+
transform,
|
|
1251
|
+
opacity: links.opacity === undefined
|
|
1252
|
+
? layer.opacity * s.opacity
|
|
1253
|
+
: clamp01(links.opacity * (layer.opacityCoverage ?? 1)),
|
|
1254
|
+
mask: s.mask,
|
|
1255
|
+
effects: seedAnimatedGrain(composeAnimatedEffects(styles?.effects ?? clip.effects, s), currentTimeMs),
|
|
1256
|
+
shapeStyle: composeAnimatedShapeStyle(styles?.shapeStyle ?? clip.shapeStyle, s),
|
|
1257
|
+
textStyle,
|
|
1258
|
+
clipMask: styles?.clipMask ?? clip.mask,
|
|
1259
|
+
borderRadius: styles.borderRadius ?? clip.borderRadius,
|
|
1260
|
+
cameraAzimuth: s.cameraAzimuth,
|
|
1261
|
+
cameraElevation: s.cameraElevation,
|
|
1262
|
+
cameraZoom: s.cameraZoom,
|
|
1263
|
+
cameraFov: s.cameraFov
|
|
1264
|
+
}, layer.camera2d, currentTimeMs);
|
|
1265
|
+
}
|
|
1266
|
+
function cameraProps(props, camera, timeMs) {
|
|
1267
|
+
if (!camera || !props.transform)
|
|
1268
|
+
return props;
|
|
1269
|
+
const placed = resolveCamera2D(props.transform, sampleCamera2D(camera, timeMs), props.effects);
|
|
1270
|
+
return { ...props, transform: placed.transform, effects: placed.effects };
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* The layer's own values, for a clip with no animation in flight. `trackOffset`
|
|
1274
|
+
* — when a `trackBinding` is live — folds into `transform` the same additive
|
|
1275
|
+
* way it does in the animated path, so a bound layer with no animations still
|
|
1276
|
+
* follows its track.
|
|
1277
|
+
*/
|
|
1278
|
+
function staticProps(layer, currentTimeMs, trackOffset) {
|
|
1279
|
+
const base = layer.transform ?? IDENTITY_TRANSFORM;
|
|
1280
|
+
const transform = trackOffset
|
|
1281
|
+
? {
|
|
1282
|
+
position: {
|
|
1283
|
+
x: base.position.x + trackOffset.x,
|
|
1284
|
+
y: base.position.y + trackOffset.y
|
|
1285
|
+
},
|
|
1286
|
+
scale: {
|
|
1287
|
+
x: base.scale.x * trackOffset.scale,
|
|
1288
|
+
y: base.scale.y * trackOffset.scale
|
|
1289
|
+
},
|
|
1290
|
+
rotation: base.rotation + trackOffset.rotation,
|
|
1291
|
+
anchor: base.anchor
|
|
1292
|
+
}
|
|
1293
|
+
: layer.transform;
|
|
1294
|
+
if (trackOffset && transform) {
|
|
1295
|
+
if (base.rotationX !== undefined)
|
|
1296
|
+
transform.rotationX = base.rotationX;
|
|
1297
|
+
if (base.rotationY !== undefined)
|
|
1298
|
+
transform.rotationY = base.rotationY;
|
|
1299
|
+
if (base.perspective !== undefined)
|
|
1300
|
+
transform.perspective = base.perspective;
|
|
1301
|
+
if (base.depthPx !== undefined)
|
|
1302
|
+
transform.depthPx = base.depthPx;
|
|
1303
|
+
}
|
|
1304
|
+
return {
|
|
1305
|
+
transform,
|
|
1306
|
+
opacity: layer.opacity,
|
|
1307
|
+
effects: seedAnimatedGrain(layer.clip.effects, currentTimeMs),
|
|
1308
|
+
shapeStyle: layer.clip.shapeStyle,
|
|
1309
|
+
textStyle: layer.clip.textStyle,
|
|
1310
|
+
clipMask: layer.clip.mask,
|
|
1311
|
+
borderRadius: layer.clip.borderRadius,
|
|
1312
|
+
cameraAzimuth: 0,
|
|
1313
|
+
cameraElevation: 0,
|
|
1314
|
+
cameraZoom: 1,
|
|
1315
|
+
cameraFov: 0
|
|
1316
|
+
};
|
|
1317
|
+
}
|
|
1318
|
+
/**
|
|
1319
|
+
* Fold the sampled effect values into the clip's static effects for the
|
|
1320
|
+
* compositor pre-pass. The animated blur and the grade's additive terms ADD to
|
|
1321
|
+
* the aggregated values and its multipliers MULTIPLY — the same aggregation
|
|
1322
|
+
* `effectsProcessor` / `canvas2d` `computeFilterForEffects` apply across
|
|
1323
|
+
* effects — so a synthesized blur effect and a synthesized color effect
|
|
1324
|
+
* appended to the static list land on exactly those rules. Returns the static
|
|
1325
|
+
* array unchanged when the sampled values are identity (no allocation on the
|
|
1326
|
+
* steady path).
|
|
1327
|
+
*/
|
|
1328
|
+
function composeAnimatedEffects(staticEffects, s) {
|
|
1329
|
+
const hasColor = s.brightness !== 0 ||
|
|
1330
|
+
s.saturation !== 1 ||
|
|
1331
|
+
s.contrast !== 1 ||
|
|
1332
|
+
s.hue !== 0 ||
|
|
1333
|
+
s.temperature !== 0 ||
|
|
1334
|
+
s.tint !== 0;
|
|
1335
|
+
const hasBlur = s.blur > 0;
|
|
1336
|
+
if (!hasColor && !hasBlur)
|
|
1337
|
+
return staticEffects;
|
|
1338
|
+
const out = staticEffects ? [...staticEffects] : [];
|
|
1339
|
+
if (hasColor) {
|
|
1340
|
+
out.push({
|
|
1341
|
+
id: "anim-color",
|
|
1342
|
+
type: "color",
|
|
1343
|
+
enabled: true,
|
|
1344
|
+
brightness: s.brightness,
|
|
1345
|
+
saturation: s.saturation,
|
|
1346
|
+
contrast: s.contrast,
|
|
1347
|
+
hue: s.hue,
|
|
1348
|
+
temperature: s.temperature,
|
|
1349
|
+
tint: s.tint
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1352
|
+
if (hasBlur) {
|
|
1353
|
+
out.push({ id: "anim-blur", type: "blur", enabled: true, radius: s.blur });
|
|
1354
|
+
}
|
|
1355
|
+
return out;
|
|
1356
|
+
}
|
|
1357
|
+
/**
|
|
1358
|
+
* Give every `animate` grain the frame's own seed, so the pattern rolls the way
|
|
1359
|
+
* exposed stock does instead of sitting on the picture like dirt on the lens.
|
|
1360
|
+
*
|
|
1361
|
+
* The seed is the frame time, not a counter and not `Math.random`: re-rendering
|
|
1362
|
+
* one frame draws the same grain, which is what lets a cached render be handed
|
|
1363
|
+
* back and what makes the preview and the export agree. Every host resolves its
|
|
1364
|
+
* layers through {@link resolveAnimatedLayerProps}, so this is the one place
|
|
1365
|
+
* the roll happens; a grain with `animate` off keeps whatever seed the document
|
|
1366
|
+
* stored, and a chain with no animated grain is returned untouched.
|
|
1367
|
+
*/
|
|
1368
|
+
function seedAnimatedGrain(effects, currentTimeMs) {
|
|
1369
|
+
if (!effects?.some((e) => e.enabled && ((isClipGrainEffect(e) && e.animate) || ((e.type === "generator" || e.type === "stylize") && e.animate)))) {
|
|
1370
|
+
return effects;
|
|
1371
|
+
}
|
|
1372
|
+
const seed = Math.floor(currentTimeMs);
|
|
1373
|
+
return effects.map((e) => {
|
|
1374
|
+
if (!e.enabled)
|
|
1375
|
+
return e;
|
|
1376
|
+
if (isClipGrainEffect(e) && e.animate)
|
|
1377
|
+
return { ...e, seed };
|
|
1378
|
+
if ((e.type === "generator" || e.type === "stylize") && e.animate)
|
|
1379
|
+
return { ...e, time: currentTimeMs / 1000 };
|
|
1380
|
+
return e;
|
|
1381
|
+
});
|
|
1382
|
+
}
|
|
1383
|
+
/**
|
|
1384
|
+
* Apply the sampled trim range to the clip's shape style. Both channels
|
|
1385
|
+
* replace rather than compose, so an undriven one leaves the clip's own value
|
|
1386
|
+
* in place; an unanimated clip keeps its own object.
|
|
1387
|
+
*/
|
|
1388
|
+
function composeAnimatedShapeStyle(staticStyle, s) {
|
|
1389
|
+
if (!staticStyle)
|
|
1390
|
+
return staticStyle;
|
|
1391
|
+
if (s.trimStart === undefined && s.trimEnd === undefined)
|
|
1392
|
+
return staticStyle;
|
|
1393
|
+
return {
|
|
1394
|
+
...staticStyle,
|
|
1395
|
+
trimStart: s.trimStart ?? staticStyle.trimStart,
|
|
1396
|
+
trimEnd: s.trimEnd ?? staticStyle.trimEnd
|
|
1397
|
+
};
|
|
1398
|
+
}
|
|
1399
|
+
/**
|
|
1400
|
+
* Resolve the stagger context for a text layer at `currentTimeMs`, or `null`
|
|
1401
|
+
* when the clip has no staggered animation. Shared by the live preview, the
|
|
1402
|
+
* export renderer, and the agent frame harness so per-word motion is drawn
|
|
1403
|
+
* from one code path (preview == export).
|
|
1404
|
+
*/
|
|
1405
|
+
export function resolveTextStaggerContext(clip, currentTimeMs, canvas, cache, tempo) {
|
|
1406
|
+
if (clip.mediaType !== "text")
|
|
1407
|
+
return null;
|
|
1408
|
+
const compiled = compiledFor(clip, canvas, cache, tempo);
|
|
1409
|
+
if (compiled.length === 0 || !hasStaggeredAnimation(compiled))
|
|
1410
|
+
return null;
|
|
1411
|
+
return {
|
|
1412
|
+
compiled,
|
|
1413
|
+
localMs: currentTimeMs - clip.startMs,
|
|
1414
|
+
sourceMs: clipSourceMsAt(clip, currentTimeMs)
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1417
|
+
/**
|
|
1418
|
+
* True when any active layer has an animation whose window covers
|
|
1419
|
+
* `currentTimeMs`. The live preview uses this to keep redrawing every rAF tick
|
|
1420
|
+
* while motion is in flight, even though the cached layer *set* is unchanged.
|
|
1421
|
+
*/
|
|
1422
|
+
export function hasActiveAnimation(layers, currentTimeMs, canvas, cache, clips, tempo) {
|
|
1423
|
+
// Group clips never appear in `layers`, but their motion rides into every
|
|
1424
|
+
// child through `parentMatrix`, so a still child of a moving group is a
|
|
1425
|
+
// moving layer. `clips` is how the ancestors are reached; without it only
|
|
1426
|
+
// the layers' own animations are seen.
|
|
1427
|
+
const byId = clips ? new Map(clips.map((clip) => [clip.id, clip])) : null;
|
|
1428
|
+
const animating = (clip) => {
|
|
1429
|
+
if (clip.animationLinks?.length)
|
|
1430
|
+
return true;
|
|
1431
|
+
if (clip.effects?.some((effect) => effect.enabled && (effect.type === "generator" || effect.type === "stylize" || isClipGrainEffect(effect)) && effect.animate))
|
|
1432
|
+
return true;
|
|
1433
|
+
if (!clip.animations || clip.animations.length === 0)
|
|
1434
|
+
return false;
|
|
1435
|
+
const compiled = compiledFor(clip, canvas, cache, tempo);
|
|
1436
|
+
return hasActiveAnimationWindow(compiled, currentTimeMs - clip.startMs);
|
|
1437
|
+
};
|
|
1438
|
+
const chainAnimating = (clip) => {
|
|
1439
|
+
let cursor = clip;
|
|
1440
|
+
// Bounded walk: the validator reports a parent cycle, the render ignores it.
|
|
1441
|
+
for (let hops = 0; cursor && hops < MAX_PARENT_HOPS; hops++) {
|
|
1442
|
+
if (animating(cursor))
|
|
1443
|
+
return true;
|
|
1444
|
+
cursor = cursor.parentId && byId ? byId.get(cursor.parentId) : undefined;
|
|
1445
|
+
}
|
|
1446
|
+
return false;
|
|
1447
|
+
};
|
|
1448
|
+
for (const layer of layers) {
|
|
1449
|
+
if (layer.camera2d?.keyframes?.length)
|
|
1450
|
+
return true;
|
|
1451
|
+
if (chainAnimating(layer.clip))
|
|
1452
|
+
return true;
|
|
1453
|
+
if (layer.matte && chainAnimating(layer.matte.layer.clip))
|
|
1454
|
+
return true;
|
|
1455
|
+
}
|
|
1456
|
+
return false;
|
|
1457
|
+
}
|
|
1458
|
+
/** Longest parent chain the motion check follows before giving up. */
|
|
1459
|
+
const MAX_PARENT_HOPS = 64;
|
|
1460
|
+
//# sourceMappingURL=sceneModel.js.map
|