@hackbuild/avatar-host 0.1.2 → 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 +4 -2
- package/dist/avatar-host.iife.js +9 -0
- package/dist/follow.d.ts +4 -0
- package/dist/follow.js +5 -0
- package/dist/source.js +1 -1
- package/dist/stage.d.ts +2 -0
- package/dist/stage.js +5 -0
- package/how.ts +1 -1
- package/package.json +1 -1
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.
|
|
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`,
|
|
@@ -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/avatar-host.iife.js
CHANGED
|
@@ -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/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/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}.
|
|
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/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.
|
|
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",
|