@hackbuild/avatar-host 0.1.3 → 0.1.4

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
@@ -22,7 +22,7 @@ The main entry has no three.js:
22
22
  a drop, with a resolver that finds referenced files by path below the
23
23
  model's folder, then by file name anywhere in the drop, ignoring case.
24
24
  Misses are listed; object URLs are freed by `release`. A `.pmx` drop
25
- reads "this file is a pmx. convert it to vrm or glb."
25
+ reads "this file is a pmx. open it with the mmd loader of the avatar package."
26
26
  - `droppedFiles(dataTransfer)`: walks dropped folders and keeps each
27
27
  file's relative path.
28
28
  - `StageLoop`: the pause reasons (`hidden`, `offscreen`, `inactive`,
@@ -10936,6 +10936,8 @@ var HackbuildAvatarHost = (function(exports, three) {
10936
10936
  target;
10937
10937
  /** Set when the person picked a distance; fitting then leaves it alone. */
10938
10938
  zoomed = false;
10939
+ /** False: step moves nothing; frame, zoomBy and released still work. */
10940
+ follow;
10939
10941
  /** Where the person panned to, from the body's centre. */
10940
10942
  offset = new three.Vector3();
10941
10943
  rate;
@@ -10948,6 +10950,7 @@ var HackbuildAvatarHost = (function(exports, three) {
10948
10950
  constructor(camera, target, opts = {}) {
10949
10951
  this.camera = camera;
10950
10952
  this.target = target;
10953
+ this.follow = opts.follow ?? true;
10951
10954
  this.rate = opts.rate ?? 3;
10952
10955
  this.deadZone = opts.deadZone ?? .06;
10953
10956
  this.slack = opts.slack ?? .12;
@@ -10984,6 +10987,7 @@ var HackbuildAvatarHost = (function(exports, three) {
10984
10987
  }
10985
10988
  /** One frame of following. Returns true when the camera moved. */
10986
10989
  step(box, dt) {
10990
+ if (!this.follow) return false;
10987
10991
  const k = 1 - Math.exp(-dt * this.rate);
10988
10992
  const h = Math.max(box.getSize(this.v2).y, .5);
10989
10993
  const gap = this.v1.copy(box.getCenter(this.v3)).add(this.offset).sub(this.target);
@@ -13178,6 +13182,11 @@ var HackbuildAvatarHost = (function(exports, three) {
13178
13182
  setCovered(on) {
13179
13183
  this.loop.hold("covered", on);
13180
13184
  }
13185
+ /** Turns the follow camera on or off. Off, the camera stays put until the person moves it or `resetView` frames the body. */
13186
+ setFollow(on) {
13187
+ this.follow.follow = on;
13188
+ this.loop.invalidate();
13189
+ }
13181
13190
  /** factor above 1 moves closer. */
13182
13191
  zoomBy(factor) {
13183
13192
  this.follow.zoomBy(factor, this.controls.minDistance, this.controls.maxDistance);
package/dist/source.js CHANGED
@@ -41,7 +41,7 @@ export function sourceFromFiles(files, urls = browserUrls) {
41
41
  if (!model) {
42
42
  const ext = files.map((f) => extOf(f.name)).find((e) => e === "pmx" || e === "pmd" || e === "vrma" || e === "bvh");
43
43
  if (ext === "pmx" || ext === "pmd")
44
- throw new Error(`this file is a ${ext}. convert it to vrm or glb.`);
44
+ throw new Error(`this file is a ${ext}. open it with the mmd loader of the avatar package.`);
45
45
  if (ext)
46
46
  throw new Error(`a ${ext} file is an animation. drop a body: a .vrm, .glb, .gltf or .fbx.`);
47
47
  throw new Error("this drop has no model. drop a .vrm, .glb, .gltf or .fbx file.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hackbuild/avatar-host",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
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",