Storyboard scenes: intercut places fold into one scene

This commit is contained in:
gator 2026-09-22 22:18:33 +00:00
parent 41125f6fa2
commit bdccfa9147

View file

@ -1424,12 +1424,26 @@
// through seventy cards to find one. // through seventy cards to find one.
function hasScenes(shots) { return shots.length > 8 && shots.filter(function (x) { return x.scene; }).length > shots.length / 2; } function hasScenes(shots) { return shots.length > 8 && shots.filter(function (x) { return x.scene; }).length > shots.length / 2; }
function sceneKey(s) { return String(s.place || s.scene || s.setting || "").toLowerCase().replace(/^(int|ext)\.?\s*\/?\s*(int|ext)?\.?\s*/, "").replace(/\s*[-–—]\s*(day|night|dawn|dusk|morning|evening|afternoon|late afternoon|continuous|the storm|the tornado).*$/, "").replace(/[^a-z0-9]+/g, " ").trim(); } function sceneKey(s) { return String(s.place || s.scene || s.setting || "").toLowerCase().replace(/^(int|ext)\.?\s*\/?\s*(int|ext)?\.?\s*/, "").replace(/\s*[-–—]\s*(day|night|dawn|dusk|morning|evening|afternoon|late afternoon|continuous|the storm|the tornado).*$/, "").replace(/[^a-z0-9]+/g, " ").trim(); }
// Two keys name one place when one begins with the other ("farmyard",
// "farmyard gravel drive"). And a scene that cuts between the kitchen and
// the doorstep is ONE scene: a place that comes back within two groups
// folds everything since into itself.
function samePlace(a, b) { return a === b || (a && b && (a.indexOf(b) === 0 || b.indexOf(a) === 0)); }
function sceneGroups(shots) { function sceneGroups(shots) {
var groups = [], cur = null; var groups = [];
shots.forEach(function (s) { shots.forEach(function (s) {
var k = sceneKey(s); var k = sceneKey(s), cur = groups[groups.length - 1];
if (!cur || cur.key !== k) { cur = { key: k, name: s.scene || s.setting || k, shots: [] }; groups.push(cur); } if (cur && samePlace(cur.key, k)) { cur.shots.push(s); return; }
cur.shots.push(s); for (var back = 2; back <= 3; back++) {
var g = groups[groups.length - back];
if (g && samePlace(g.key, k)) {
var merged = groups.splice(groups.length - back + 1);
merged.forEach(function (m) { g.shots = g.shots.concat(m.shots); if (g.name.indexOf(m.name) < 0) g.name += " / " + m.name; });
g.shots.push(s);
return;
}
}
groups.push({ key: k, name: s.scene || s.setting || k, shots: [s] });
}); });
return groups; return groups;
} }