@nodetool-ai/timeline 0.8.17 → 0.8.19
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/dist/.nodetool-build-stamp +1 -1
- package/dist/animation/custom.d.ts.map +1 -1
- package/dist/animation/custom.js +35 -0
- package/dist/animation/custom.js.map +1 -1
- package/dist/animation/sample.d.ts +14 -0
- package/dist/animation/sample.d.ts.map +1 -1
- package/dist/animation/sample.js +22 -1
- package/dist/animation/sample.js.map +1 -1
- package/dist/animation/types.d.ts +8 -1
- package/dist/animation/types.d.ts.map +1 -1
- package/dist/animation/types.js +31 -3
- package/dist/animation/types.js.map +1 -1
- package/dist/authoredStyles.d.ts +7 -1
- package/dist/authoredStyles.d.ts.map +1 -1
- package/dist/authoredStyles.js +6 -1
- package/dist/authoredStyles.js.map +1 -1
- package/dist/finish-storyboard.d.ts.map +1 -1
- package/dist/finish-storyboard.js +6 -1
- package/dist/finish-storyboard.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/keyframes.d.ts +12 -2
- package/dist/keyframes.d.ts.map +1 -1
- package/dist/keyframes.js +24 -1
- package/dist/keyframes.js.map +1 -1
- package/dist/model3d.d.ts +132 -8
- package/dist/model3d.d.ts.map +1 -1
- package/dist/model3d.js +230 -7
- package/dist/model3d.js.map +1 -1
- package/dist/model3dBake.d.ts +41 -11
- package/dist/model3dBake.d.ts.map +1 -1
- package/dist/model3dBake.js +58 -21
- package/dist/model3dBake.js.map +1 -1
- package/dist/model3dBlockout.d.ts +62 -0
- package/dist/model3dBlockout.d.ts.map +1 -0
- package/dist/model3dBlockout.js +59 -0
- package/dist/model3dBlockout.js.map +1 -0
- package/dist/model3dCameraDescription.d.ts +27 -0
- package/dist/model3dCameraDescription.d.ts.map +1 -0
- package/dist/model3dCameraDescription.js +171 -0
- package/dist/model3dCameraDescription.js.map +1 -0
- package/dist/model3dCameraKeys.d.ts +47 -0
- package/dist/model3dCameraKeys.d.ts.map +1 -0
- package/dist/model3dCameraKeys.js +156 -0
- package/dist/model3dCameraKeys.js.map +1 -0
- package/dist/model3dCameraMoves.d.ts +97 -0
- package/dist/model3dCameraMoves.d.ts.map +1 -0
- package/dist/model3dCameraMoves.js +329 -0
- package/dist/model3dCameraMoves.js.map +1 -0
- package/dist/model3dReference.d.ts +75 -0
- package/dist/model3dReference.d.ts.map +1 -0
- package/dist/model3dReference.js +100 -0
- package/dist/model3dReference.js.map +1 -0
- package/dist/ops/apply.d.ts.map +1 -1
- package/dist/ops/apply.js +168 -2
- package/dist/ops/apply.js.map +1 -1
- package/dist/ops/op.d.ts +35 -2
- package/dist/ops/op.d.ts.map +1 -1
- package/dist/ops/op.js +2 -0
- package/dist/ops/op.js.map +1 -1
- package/dist/ops/parse.d.ts.map +1 -1
- package/dist/ops/parse.js +8 -0
- package/dist/ops/parse.js.map +1 -1
- package/dist/ops/types.d.ts +22 -0
- package/dist/ops/types.d.ts.map +1 -1
- package/dist/render/index.d.ts +1 -0
- package/dist/render/index.d.ts.map +1 -1
- package/dist/render/index.js +1 -0
- package/dist/render/index.js.map +1 -1
- package/dist/render/model3dReferenceSamples.d.ts +25 -0
- package/dist/render/model3dReferenceSamples.d.ts.map +1 -0
- package/dist/render/model3dReferenceSamples.js +25 -0
- package/dist/render/model3dReferenceSamples.js.map +1 -0
- package/dist/render/sceneModel.d.ts +1 -1
- package/dist/render/sceneModel.d.ts.map +1 -1
- package/dist/render/sceneModel.js +10 -5
- package/dist/render/sceneModel.js.map +1 -1
- package/dist/scene.d.ts +1 -0
- package/dist/scene.d.ts.map +1 -1
- package/dist/scene.js +1 -0
- package/dist/scene.js.map +1 -1
- package/dist/shotLink.d.ts +35 -0
- package/dist/shotLink.d.ts.map +1 -1
- package/dist/shotLink.js +100 -0
- package/dist/shotLink.js.map +1 -1
- package/dist/testing/ops.d.ts.map +1 -1
- package/dist/testing/ops.js +49 -2
- package/dist/testing/ops.js.map +1 -1
- package/dist/types.d.ts +30 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +5 -5
package/dist/ops/apply.js
CHANGED
|
@@ -32,6 +32,12 @@ import { findInstrumentPreset, listMidiInstruments, MIDI_INSTRUMENT_PRESETS } fr
|
|
|
32
32
|
import { DEFAULT_TEMPO, rescaleClipsForTempo, resolveTempo } from "../midi/tempo.js";
|
|
33
33
|
import { msToTicks } from "../midi/ticks.js";
|
|
34
34
|
import { computeModel3DBakeHash } from "../model3dBake.js";
|
|
35
|
+
import { describeModel3DCameraMove } from "../model3dCameraDescription.js";
|
|
36
|
+
import { DEFAULT_MODEL3D_REFERENCE_PASS, computeModel3DReferenceHash, model3dReferenceStatus } from "../model3dReference.js";
|
|
37
|
+
import { keyframeTimesMs } from "../keyframes.js";
|
|
38
|
+
import { MODEL3D_FREE_CAMERA_PROPERTIES } from "../model3d.js";
|
|
39
|
+
import { assertKnownEasing, keyModel3DFreeCamera, model3dFreeCameraReport, resolveModel3DLensFovDeg } from "../model3dCameraKeys.js";
|
|
40
|
+
import { MODEL3D_MAX_DOLLY_FRACTION, applyModel3DCameraMove, model3dCameraMoveSpec, model3dKeyframedFreeCameraPose } from "../model3dCameraMoves.js";
|
|
35
41
|
import { addReframeKeyframe, clearReframe, mediaTrackCanDriveReframe } from "../reframe.js";
|
|
36
42
|
import { adaptSequenceFormat } from "../retarget.js";
|
|
37
43
|
import { sourceRate } from "../sourceRate.js";
|
|
@@ -664,6 +670,17 @@ class OpScope {
|
|
|
664
670
|
return serializeTrack(this.state, track);
|
|
665
671
|
}
|
|
666
672
|
}
|
|
673
|
+
/**
|
|
674
|
+
* The keyframe helpers mint their own id for a keyframe animation they
|
|
675
|
+
* create. An op takes every id from its context, so a new animation is
|
|
676
|
+
* re-identified here and the ones the clip already had keep theirs.
|
|
677
|
+
*/
|
|
678
|
+
function withContextAnimationIds(scope, clip, animations) {
|
|
679
|
+
const known = new Set((clip.animations ?? []).map((a) => a.id));
|
|
680
|
+
return animations.map((animation) => known.has(animation.id)
|
|
681
|
+
? animation
|
|
682
|
+
: { ...animation, id: scope.ctx.newId("anim") });
|
|
683
|
+
}
|
|
667
684
|
/**
|
|
668
685
|
* `trimClip` on the end edge, capped at the source length when one is known.
|
|
669
686
|
* The refusal names the limit, which the engine's own message does not.
|
|
@@ -1100,9 +1117,102 @@ const OP_HANDLERS = {
|
|
|
1100
1117
|
"model3dStyle names a camera, an animation and lighting for a " +
|
|
1101
1118
|
"glTF, and nothing else reads it.");
|
|
1102
1119
|
}
|
|
1103
|
-
|
|
1120
|
+
if (op.keyAtMs === undefined) {
|
|
1121
|
+
if (op.keyEasing !== undefined) {
|
|
1122
|
+
throw new Error("keyEasing eases the move arriving at a camera key, so it needs " +
|
|
1123
|
+
"keyAtMs. Add keyAtMs, or leave keyEasing out.");
|
|
1124
|
+
}
|
|
1125
|
+
clip.model3dStyle = model3dStyleWithPatch(clip.model3dStyle, op.patch);
|
|
1126
|
+
scope.touch(clip.id);
|
|
1127
|
+
return { ok: true, clip: scope.clipOut(clip) };
|
|
1128
|
+
}
|
|
1129
|
+
// A key holds the pose, so the pose fields leave the patch and everything
|
|
1130
|
+
// else in it (the mode, the lighting) lands on the clip as usual.
|
|
1131
|
+
const { position, target, rollDeg, fovDeg, focalLengthMm, ...camera } = op.patch.camera ?? {};
|
|
1132
|
+
const lens = resolveModel3DLensFovDeg({ fovDeg, focalLengthMm }, "patch.camera");
|
|
1133
|
+
const keyed = {
|
|
1134
|
+
...clip,
|
|
1135
|
+
model3dStyle: model3dStyleWithPatch(clip.model3dStyle, {
|
|
1136
|
+
...op.patch,
|
|
1137
|
+
camera
|
|
1138
|
+
})
|
|
1139
|
+
};
|
|
1140
|
+
const animations = keyModel3DFreeCamera(keyed, op.keyAtMs, { position, target, rollDeg, fovDeg: lens }, { easing: op.keyEasing });
|
|
1141
|
+
clip.model3dStyle = keyed.model3dStyle;
|
|
1142
|
+
clip.animations = withContextAnimationIds(scope, clip, animations);
|
|
1104
1143
|
scope.touch(clip.id);
|
|
1105
|
-
return {
|
|
1144
|
+
return {
|
|
1145
|
+
ok: true,
|
|
1146
|
+
clip: scope.clipOut(clip),
|
|
1147
|
+
keyAtMs: op.keyAtMs,
|
|
1148
|
+
camera: model3dFreeCameraReport(model3dKeyframedFreeCameraPose(clip, op.keyAtMs)),
|
|
1149
|
+
cameraKeyTimesMs: keyframeTimesMs(clip, MODEL3D_FREE_CAMERA_PROPERTIES)
|
|
1150
|
+
};
|
|
1151
|
+
},
|
|
1152
|
+
apply_model3d_camera_move: (scope, op) => {
|
|
1153
|
+
const clip = scope.resolveClip(op.target);
|
|
1154
|
+
if (clip.mediaType !== "model3d") {
|
|
1155
|
+
throw new Error(`Clip "${clip.name}" is a ${clip.mediaType} clip, not a 3D clip. A ` +
|
|
1156
|
+
"camera move keys the camera of a model3d clip. Pass a clip that " +
|
|
1157
|
+
"add_model3d_clip placed.");
|
|
1158
|
+
}
|
|
1159
|
+
const mode = clip.model3dStyle?.camera.mode;
|
|
1160
|
+
if (mode !== "free") {
|
|
1161
|
+
throw new Error(`Camera move "${op.move}" needs a free camera, and clip ` +
|
|
1162
|
+
`"${clip.name}" has ${mode === undefined ? "no camera" : `a ${mode} camera`}. ` +
|
|
1163
|
+
'Call set_model3d_style with patch {camera: {mode: "free", ' +
|
|
1164
|
+
"position, target}} first, then apply the move.");
|
|
1165
|
+
}
|
|
1166
|
+
const spec = model3dCameraMoveSpec(op.move);
|
|
1167
|
+
const amount = op.amount ?? spec.defaultAmount;
|
|
1168
|
+
if (!Number.isFinite(amount)) {
|
|
1169
|
+
throw new Error(`amount must be a finite number of ${spec.unit}, and it is ${amount}. ` +
|
|
1170
|
+
`Leave it out for the ${op.move} default of ${spec.defaultAmount}.`);
|
|
1171
|
+
}
|
|
1172
|
+
if (spec.unit === "factor" && amount <= 0) {
|
|
1173
|
+
throw new Error(`amount for ${op.move} multiplies the focal length, so it must be ` +
|
|
1174
|
+
`above 0, and it is ${amount}. Use 1.5 to zoom in or 0.67 to zoom out.`);
|
|
1175
|
+
}
|
|
1176
|
+
if ((op.move === "pushIn" || op.move === "dollyZoom") &&
|
|
1177
|
+
amount > MODEL3D_MAX_DOLLY_FRACTION) {
|
|
1178
|
+
throw new Error(`amount for ${op.move} is the fraction of the eye-to-target distance ` +
|
|
1179
|
+
`the eye travels, at most ${MODEL3D_MAX_DOLLY_FRACTION}, and it is ` +
|
|
1180
|
+
`${amount}. To end closer, move the target with set_model3d_style ` +
|
|
1181
|
+
"or lengthen the lens with the zoom move.");
|
|
1182
|
+
}
|
|
1183
|
+
const startMs = op.startMs ?? 0;
|
|
1184
|
+
if (startMs >= clip.durationMs) {
|
|
1185
|
+
throw new Error(`startMs ${startMs} is at or past the end of clip "${clip.name}", ` +
|
|
1186
|
+
`which is ${clip.durationMs} ms long. startMs counts from the ` +
|
|
1187
|
+
`clip's start. Use a value below ${clip.durationMs}.`);
|
|
1188
|
+
}
|
|
1189
|
+
const durationMs = op.durationMs ?? clip.durationMs - startMs;
|
|
1190
|
+
if (startMs + durationMs > clip.durationMs + 0.5) {
|
|
1191
|
+
throw new Error(`durationMs ${durationMs} from startMs ${startMs} ends at ` +
|
|
1192
|
+
`${startMs + durationMs} ms, past the end of clip "${clip.name}" ` +
|
|
1193
|
+
`(${clip.durationMs} ms). Use a durationMs of at most ` +
|
|
1194
|
+
`${clip.durationMs - startMs}, or lengthen the clip with trim_clip.`);
|
|
1195
|
+
}
|
|
1196
|
+
if (op.easing !== undefined)
|
|
1197
|
+
assertKnownEasing(op.easing, "easing");
|
|
1198
|
+
const endMs = Math.min(startMs + durationMs, clip.durationMs);
|
|
1199
|
+
const from = model3dKeyframedFreeCameraPose(clip, startMs);
|
|
1200
|
+
clip.animations = withContextAnimationIds(scope, clip, applyModel3DCameraMove(clip, op.move, {
|
|
1201
|
+
startMs,
|
|
1202
|
+
durationMs,
|
|
1203
|
+
amount,
|
|
1204
|
+
easing: op.easing
|
|
1205
|
+
}));
|
|
1206
|
+
scope.touch(clip.id);
|
|
1207
|
+
return {
|
|
1208
|
+
ok: true,
|
|
1209
|
+
clip: scope.clipOut(clip),
|
|
1210
|
+
move: { id: spec.id, unit: spec.unit, amount },
|
|
1211
|
+
startMs,
|
|
1212
|
+
endMs,
|
|
1213
|
+
from: model3dFreeCameraReport(from),
|
|
1214
|
+
to: model3dFreeCameraReport(model3dKeyframedFreeCameraPose(clip, endMs))
|
|
1215
|
+
};
|
|
1106
1216
|
},
|
|
1107
1217
|
bake_model3d_clip: async (scope, op) => {
|
|
1108
1218
|
const state = scope.state;
|
|
@@ -1160,6 +1270,62 @@ const OP_HANDLERS = {
|
|
|
1160
1270
|
scope.touch(clip.id);
|
|
1161
1271
|
return { ok: true, clip: scope.clipOut(clip), bakeStarted: true };
|
|
1162
1272
|
},
|
|
1273
|
+
render_model3d_reference: async (scope, op) => {
|
|
1274
|
+
const state = scope.state;
|
|
1275
|
+
const clip = scope.resolveClip(op.target);
|
|
1276
|
+
if (clip.mediaType !== "model3d") {
|
|
1277
|
+
throw new Error(`Clip "${clip.name}" is a ${clip.mediaType} clip, not a 3D clip. ` +
|
|
1278
|
+
"Only a 3D clip has a set and a camera to render a reference from.");
|
|
1279
|
+
}
|
|
1280
|
+
const style = clip.model3dStyle;
|
|
1281
|
+
if (!style) {
|
|
1282
|
+
throw new Error(`Clip "${clip.name}" has no model3dStyle, so nothing names the ` +
|
|
1283
|
+
"camera a reference would be rendered through.");
|
|
1284
|
+
}
|
|
1285
|
+
if (!clip.currentAssetId) {
|
|
1286
|
+
throw new Error(`Clip "${clip.name}" has no glTF asset to render.`);
|
|
1287
|
+
}
|
|
1288
|
+
const pass = op.pass ?? DEFAULT_MODEL3D_REFERENCE_PASS;
|
|
1289
|
+
const sequence = {
|
|
1290
|
+
fps: state.fps,
|
|
1291
|
+
width: state.width,
|
|
1292
|
+
height: state.height
|
|
1293
|
+
};
|
|
1294
|
+
const dependencyHash = computeModel3DReferenceHash(clip, sequence, pass);
|
|
1295
|
+
if (model3dReferenceStatus(clip, sequence, pass) === "current") {
|
|
1296
|
+
return {
|
|
1297
|
+
ok: true,
|
|
1298
|
+
clip: scope.clipOut(clip),
|
|
1299
|
+
reference: style.reference,
|
|
1300
|
+
referenceRendered: false,
|
|
1301
|
+
note: "The stored reference already shows this clip, so nothing was rendered."
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
if (!scope.ctx.renderModel3DReference) {
|
|
1305
|
+
return {
|
|
1306
|
+
ok: true,
|
|
1307
|
+
clip: scope.clipOut(clip),
|
|
1308
|
+
referenceRendered: false,
|
|
1309
|
+
note: "This surface has no 3D renderer, so no reference was rendered."
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
1312
|
+
const rendered = await scope.ctx.renderModel3DReference({
|
|
1313
|
+
clip,
|
|
1314
|
+
sequence,
|
|
1315
|
+
pass,
|
|
1316
|
+
dependencyHash
|
|
1317
|
+
});
|
|
1318
|
+
const reference = { assetId: rendered.assetId, dependencyHash, pass };
|
|
1319
|
+
clip.model3dStyle = { ...style, reference };
|
|
1320
|
+
scope.touch(clip.id);
|
|
1321
|
+
return {
|
|
1322
|
+
ok: true,
|
|
1323
|
+
clip: scope.clipOut(clip),
|
|
1324
|
+
reference,
|
|
1325
|
+
referenceRendered: true,
|
|
1326
|
+
cameraMove: describeModel3DCameraMove(clip)
|
|
1327
|
+
};
|
|
1328
|
+
},
|
|
1163
1329
|
add_group: (scope, op) => {
|
|
1164
1330
|
const state = scope.state;
|
|
1165
1331
|
// Resolve every child before anything is written: a half-applied group
|