@hackbuild/avatar-host 0.1.2 → 0.1.3

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 CHANGED
@@ -76,7 +76,9 @@ The main entry has no three.js:
76
76
  distance eases to fit the pose, pulls back from the first frame a pose
77
77
  outgrows the view and comes closer only once 12 percent too far; a hand
78
78
  zoom is left alone (rate 3, dead zone 0.06, slack 0.12, margin 1.12,
79
- vendor, all options).
79
+ vendor, all options). `follow: { follow: false }` in the stage options,
80
+ or `stage.setFollow(false)` at any time, turns following off; the
81
+ camera then moves only by hand or `resetView`.
80
82
  - `loadBody` and `bodyAdapters`: the scene level loader. A dropped
81
83
  model's references go through the source's resolver, and the load waits
82
84
  for every texture the loader started before it resolves. The rig wasm
package/dist/follow.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { Box3, type PerspectiveCamera, Vector3 } from "three";
2
2
  export interface FollowOptions {
3
+ /** Follow the body; false leaves the camera where the person or the last framing put it. Default true. */
4
+ follow?: boolean;
3
5
  /** Ease rate per second toward a new framing. Default 3 (vendor). */
4
6
  rate?: number;
5
7
  /** Body movement under this share of its height moves nothing. Default 0.06 (vendor). */
@@ -15,6 +17,8 @@ export declare class FollowCamera {
15
17
  readonly target: Vector3;
16
18
  /** Set when the person picked a distance; fitting then leaves it alone. */
17
19
  zoomed: boolean;
20
+ /** False: step moves nothing; frame, zoomBy and released still work. */
21
+ follow: boolean;
18
22
  /** Where the person panned to, from the body's centre. */
19
23
  readonly offset: Vector3;
20
24
  readonly rate: number;
package/dist/follow.js CHANGED
@@ -10,6 +10,8 @@ export class FollowCamera {
10
10
  target;
11
11
  /** Set when the person picked a distance; fitting then leaves it alone. */
12
12
  zoomed = false;
13
+ /** False: step moves nothing; frame, zoomBy and released still work. */
14
+ follow;
13
15
  /** Where the person panned to, from the body's centre. */
14
16
  offset = new Vector3();
15
17
  rate;
@@ -24,6 +26,7 @@ export class FollowCamera {
24
26
  target, opts = {}) {
25
27
  this.camera = camera;
26
28
  this.target = target;
29
+ this.follow = opts.follow ?? true;
27
30
  this.rate = opts.rate ?? 3;
28
31
  this.deadZone = opts.deadZone ?? 0.06;
29
32
  this.slack = opts.slack ?? 0.12;
@@ -62,6 +65,8 @@ export class FollowCamera {
62
65
  }
63
66
  /** One frame of following. Returns true when the camera moved. */
64
67
  step(box, dt) {
68
+ if (!this.follow)
69
+ return false;
65
70
  const k = 1 - Math.exp(-dt * this.rate);
66
71
  const h = Math.max(box.getSize(this.v2).y, 0.5);
67
72
  const gap = this.v1.copy(box.getCenter(this.v3)).add(this.offset).sub(this.target);
package/dist/stage.d.ts CHANGED
@@ -140,6 +140,8 @@ export declare class AvatarStage {
140
140
  setActive(on: boolean): void;
141
141
  /** A sheet or a modal covers the stage fully. */
142
142
  setCovered(on: boolean): void;
143
+ /** Turns the follow camera on or off. Off, the camera stays put until the person moves it or `resetView` frames the body. */
144
+ setFollow(on: boolean): void;
143
145
  /** factor above 1 moves closer. */
144
146
  zoomBy(factor: number): void;
145
147
  /** Frames the body again and forgets the person's pan and zoom. */
package/dist/stage.js CHANGED
@@ -236,6 +236,11 @@ export class AvatarStage {
236
236
  setCovered(on) {
237
237
  this.loop.hold("covered", on);
238
238
  }
239
+ /** Turns the follow camera on or off. Off, the camera stays put until the person moves it or `resetView` frames the body. */
240
+ setFollow(on) {
241
+ this.follow.follow = on;
242
+ this.loop.invalidate();
243
+ }
239
244
  /** factor above 1 moves closer. */
240
245
  zoomBy(factor) {
241
246
  this.follow.zoomBy(factor, this.controls.minDistance, this.controls.maxDistance);
package/how.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  const how: HowDoc = {
5
5
  what: "host a character on a three.js stage in any container: ticketed loads through @hackbuild/avatar, a follow camera, the presence frame order, a loop that pauses when hidden, and a hb-avatar-host element.",
6
6
  how: [
7
- "a character on a three.js stage in any container. bodies load through @hackbuild/avatar into the normalized humanoid space; the camera frames and follows the posed body.",
7
+ "a character on a three.js stage in any container. bodies load through @hackbuild/avatar into the normalized humanoid space; the camera frames and follows the posed body; setFollow(false) or follow: { follow: false } in the options keeps it still.",
8
8
  "loads are ticketed: show(source) resolves to the result, or to null when a later show replaced it, so a slow file never lands over a newer one. a drop of files finds the model and the files it references by path, then by name.",
9
9
  "one animation loop runs, and it stops while the page is hidden, the host is off screen or at zero size, or a sheet covers it. the main entry has no three.js; the hb-avatar-host element is under /three.",
10
10
  "/thumbs draws previews in the background, one at a time on one renderer: clips on a clay figure at their most telling frame, characters at rest. urgent items go first, each is tried once, and the renderer is freed 20 s after the queue empties. save gets a png blob.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hackbuild/avatar-host",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Host a character on a three.js stage in any container: ticketed loads through @hackbuild/avatar, a follow camera, the presence frame order, a loop that pauses when hidden, and a hb-avatar-host element.",
5
5
  "type": "module",
6
6
  "license": "MIT",