@hackbuild/avatar-host 0.1.3 → 0.1.5
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 +1 -1
- package/dist/avatar-host.iife.js +10 -1
- package/dist/portrait.js +1 -1
- package/dist/source.js +1 -1
- package/package.json +2 -2
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`,
|
package/dist/avatar-host.iife.js
CHANGED
|
@@ -146,7 +146,7 @@ var HackbuildAvatarHost = (function(exports, three) {
|
|
|
146
146
|
for (const k of ORDER) if (model = files.find((f) => kindOf(f.name) === k)) break;
|
|
147
147
|
if (!model) {
|
|
148
148
|
const ext = files.map((f) => extOf(f.name)).find((e) => e === "pmx" || e === "pmd" || e === "vrma" || e === "bvh");
|
|
149
|
-
if (ext === "pmx" || ext === "pmd") throw new Error(`this file is a ${ext}.
|
|
149
|
+
if (ext === "pmx" || ext === "pmd") throw new Error(`this file is a ${ext}. open it with the mmd loader of the avatar package.`);
|
|
150
150
|
if (ext) throw new Error(`a ${ext} file is an animation. drop a body: a .vrm, .glb, .gltf or .fbx.`);
|
|
151
151
|
throw new Error("this drop has no model. drop a .vrm, .glb, .gltf or .fbx file.");
|
|
152
152
|
}
|
|
@@ -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/portrait.js
CHANGED
|
@@ -19,7 +19,6 @@ const MARGIN = 1.06;
|
|
|
19
19
|
export const SAMPLES = 24;
|
|
20
20
|
/** Bones that judge a frame; fingers would outvote them by count. */
|
|
21
21
|
export const MEASURED = ["spine", "chest", "neck", "head", "leftShoulder", "leftUpperArm", "leftLowerArm", "rightShoulder", "rightUpperArm", "rightLowerArm", "leftUpperLeg", "leftLowerLeg", "rightUpperLeg", "rightLowerLeg"];
|
|
22
|
-
const v = new Vector3();
|
|
23
22
|
/** One renderer, scene, lights and camera, and the framing both portraits share. */
|
|
24
23
|
class Shot {
|
|
25
24
|
canvas;
|
|
@@ -57,6 +56,7 @@ class Shot {
|
|
|
57
56
|
}
|
|
58
57
|
/** Points an orthographic camera at `box` from the portrait angle and fits it, `aspect` width over height. */
|
|
59
58
|
export function frameBox(cam, box, aspect = 1) {
|
|
59
|
+
const v = new Vector3();
|
|
60
60
|
const center = box.getCenter(new Vector3());
|
|
61
61
|
const reach = Math.max(1e-3, box.getSize(v).length() * 2);
|
|
62
62
|
const dir = new Vector3(Math.sin(YAW) * Math.cos(PITCH), Math.sin(PITCH), Math.cos(YAW) * Math.cos(PITCH));
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hackbuild/avatar-host",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
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",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"build": "node ../../tools/build-package.mjs avatar-host"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@hackbuild/avatar": "0.1.
|
|
44
|
+
"@hackbuild/avatar": "0.1.3",
|
|
45
45
|
"@hackbuild/environment": "0.1.1",
|
|
46
46
|
"@hackbuild/lipsync": "0.1.1",
|
|
47
47
|
"@hackbuild/organic": "0.1.1",
|