@anime-studio/director 0.2.1 → 0.3.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"direct.d.ts","sourceRoot":"","sources":["../src/direct.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EA4BF,MAAM,oBAAoB,CAAC;AAGxC,OAAO,KAAK,EAAmB,KAAK,EAAkC,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAgC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAqB/J;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK;IAAE,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,SAAS,GAAG,CAAC,EAAE,CAoDpO;AAKD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAKjE;AAED,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAS/D;AAcD,wFAAwF;AACxF,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QA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,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAOnG,CAAC;AA81IF;;;GAGG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,GAAG,QAAQ,CA8O1E;AAQD,0DAA0D;AAC1D;;;GAGG;AACH,MAAM,WAAW,YAAY;IAAG,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE;AAElD,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,GAAE,YAAiB,GAAG,KAAK,EAAE,CAiFjG;AA2JD,6FAA6F;AAC7F,KAAK,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAK/D,uIAAuI;AACvI,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CA+B9D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAyC3E"}
package/dist/direct.js CHANGED
@@ -351,8 +351,32 @@ class BlockScene {
351
351
  return Math.min(1, Math.max(0, Number(this.animation?.anticipation ?? 0) || 0));
352
352
  }
353
353
  push(a) {
354
+ // A pose the character does not draw is an error in a scene (it used to draw the default in
355
+ // silence): the director's own choices (a happy start, a scared face before a fall) are left
356
+ // out for such a character; staged ones are reported where they are staged (`stagedEmotion`).
357
+ if (a.action === "pose" && !this.hasPose(String(a.actor), String(a.control), a.value))
358
+ return;
354
359
  this.script.push(a);
355
360
  }
361
+ /** Whether the actor's character has this pose (a name or `{ name: weight }`; null: unset) on a pose control. */
362
+ hasPose(actor, control, value) {
363
+ const doc = this.kit.characters[this.characterOf(actor)];
364
+ const c = doc?.controls?.[control];
365
+ if (!c || c.type !== "pose" || value === null || value === undefined)
366
+ return true;
367
+ const views = control === "view" ? (doc.rig3d?.views ?? {}) : {};
368
+ const names = typeof value === "string" ? [value] : typeof value === "object" && !Array.isArray(value) ? Object.keys(value) : [];
369
+ return names.every((n) => n in (c.poses ?? {}) || n in views);
370
+ }
371
+ /** A staged emotion: a warning naming the character's emotions when it has no such pose. */
372
+ stagedEmotion(actor, value) {
373
+ if (this.hasPose(actor, "emotion", value))
374
+ return true;
375
+ const poses = Object.keys(this.kit.characters[this.characterOf(actor)]?.controls?.emotion?.poses ?? {});
376
+ const hint = typeof value === "string" && poses.length ? closest(value, poses) : ` (emotions: ${poses.join(", ") || "none"})`;
377
+ this.issue("warning", `${actor} has no emotion ${JSON.stringify(value)}${hint}`);
378
+ return false;
379
+ }
356
380
  mark(name) {
357
381
  if (typeof name !== "string") {
358
382
  this.issue("error", `expected a mark name, got ${JSON.stringify(name)} (cast "at" takes a mark; use "offset" to move along)`);
@@ -614,7 +638,7 @@ class BlockScene {
614
638
  this.present.push(id);
615
639
  if (this.hasClip(id, "idle"))
616
640
  this.push({ at: 0, actor: id, action: "play", clip: "idle", loop: true, layer: -1, fadeIn: 0 });
617
- if (this.hasControl(id, "emotion"))
641
+ if (this.hasControl(id, "emotion") && (o.emotion === undefined || this.stagedEmotion(id, o.emotion)))
618
642
  this.push({ at: 0, actor: id, action: "pose", control: "emotion", value: o.emotion ?? "happy", duration: 0 });
619
643
  if (this.hasControl(id, "view"))
620
644
  this.push({ at: 0, actor: id, action: "pose", control: "view", value: "profile", duration: 0 });
@@ -1830,7 +1854,7 @@ class BlockScene {
1830
1854
  break;
1831
1855
  }
1832
1856
  case "emotion":
1833
- for (const w of who.filter((w) => this.hasControl(w, "emotion")))
1857
+ for (const w of who.filter((w) => this.hasControl(w, "emotion") && this.stagedEmotion(w, b.value)))
1834
1858
  this.push({ at: this.t(at), actor: w, action: "pose", control: "emotion", value: b.value, duration: 0.35 });
1835
1859
  break;
1836
1860
  case "mount":