@streaming-cdn/rtc-web 1.3.25 → 1.3.26
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 +15 -1
- package/dist/avatar-vrm.d.ts +23 -0
- package/dist/rtc-web-avatar-vrm.es.js +49 -42
- package/dist/rtc-web-avatar-vrm.umd.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# RTC Web SDK 1.3.
|
|
1
|
+
# RTC Web SDK 1.3.26
|
|
2
2
|
|
|
3
3
|
The customer package contains compiled ESM/UMD JavaScript and TypeScript declarations. It intentionally excludes implementation source and source maps. Example source remains available under `examples/`.
|
|
4
4
|
|
|
@@ -357,6 +357,20 @@ operational diagnostics. Tokens, SDP, media, and chat content are never part of
|
|
|
357
357
|
that report. Set `reportSignalingDiagnostics: false` only when replacing this
|
|
358
358
|
with an application-owned diagnostics pipeline.
|
|
359
359
|
|
|
360
|
+
## 1.3.26 notes
|
|
361
|
+
|
|
362
|
+
- **VRM avatars are framed from the model's own measurements.** The bust
|
|
363
|
+
camera in `avatar-vrm` was fixed at a 0.42 m window aimed at the head
|
|
364
|
+
joint — which sits at the *bottom* of the skull — so characters with tall
|
|
365
|
+
hair or accessories had their crowns cropped, and big-headed models filled
|
|
366
|
+
the whole canvas and rendered far larger than the built-in avatar when
|
|
367
|
+
overlaid. `createVrmStage` now measures each model (head joint from the
|
|
368
|
+
humanoid, crown from the scene bounds, hair included) and frames the bust
|
|
369
|
+
so the skull spans ~38% of the canvas with its centre at 42% from the top —
|
|
370
|
+
the exact contract `vrmAvatarRenderer`'s overlay math expects. Every
|
|
371
|
+
character now appears the same size as the built-in stylized avatar,
|
|
372
|
+
whatever its proportions. The framing rule is exported as `frameVrmBust()`.
|
|
373
|
+
|
|
360
374
|
## 1.3.25 notes
|
|
361
375
|
|
|
362
376
|
- **B21 — per-peer quality no longer ratchets down on bandwidth-pinned
|
package/dist/avatar-vrm.d.ts
CHANGED
|
@@ -9,6 +9,29 @@ export interface VrmStage {
|
|
|
9
9
|
applyAndRender(rig: AvatarRig, options?: VrmRenderOptions): void;
|
|
10
10
|
dispose(): void;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Bust framing computed from the model's own measurements.
|
|
14
|
+
*
|
|
15
|
+
* Characters do not share proportions: the head joint sits at the bottom of
|
|
16
|
+
* the skull, and between a chibi and a tall model the joint-to-crown distance
|
|
17
|
+
* (hair and accessories included) spans several fold. A fixed camera cropped
|
|
18
|
+
* tall hair off and let big heads fill the whole canvas, which the overlay
|
|
19
|
+
* then multiplied into an avatar larger than the screen.
|
|
20
|
+
*
|
|
21
|
+
* The contract with `vrmAvatarRenderer` is proportional: the skull spans
|
|
22
|
+
* roughly 38% of the canvas (2 of the 5.2 head radii the overlay paints) with
|
|
23
|
+
* its centre at 42% from the top — the same size and seat as the built-in
|
|
24
|
+
* stylized head, so switching characters never changes how big the avatar
|
|
25
|
+
* appears over the person.
|
|
26
|
+
*/
|
|
27
|
+
export declare function frameVrmBust(measure: {
|
|
28
|
+
headY: number;
|
|
29
|
+
crownY: number;
|
|
30
|
+
}): {
|
|
31
|
+
windowHeight: number;
|
|
32
|
+
lookY: number;
|
|
33
|
+
distance: number;
|
|
34
|
+
};
|
|
12
35
|
/**
|
|
13
36
|
* Adapts a VrmStage to the SDK's pluggable `AvatarRenderer`, so
|
|
14
37
|
* `createAvatarPipeline` can publish a VRM character instead of the built-in
|
|
@@ -1,61 +1,68 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as d from "three";
|
|
2
2
|
import { GLTFLoader as L } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
3
|
-
import { VRMLoaderPlugin as
|
|
4
|
-
function
|
|
3
|
+
import { VRMLoaderPlugin as g, VRMUtils as w } from "@pixiv/three-vrm";
|
|
4
|
+
function A(n) {
|
|
5
|
+
const o = n.crownY - n.headY, t = o > 0.05 && o < 1.5 ? o : 0.25, r = t * 2.1, p = n.headY + t * 0.45 - r * 0.08, s = r / 2 / Math.tan(28 / 2 * (Math.PI / 180));
|
|
6
|
+
return { windowHeight: r, lookY: p, distance: s };
|
|
7
|
+
}
|
|
8
|
+
function C(n, o) {
|
|
5
9
|
return {
|
|
6
|
-
render(
|
|
7
|
-
if (
|
|
8
|
-
const a =
|
|
9
|
-
|
|
10
|
+
render(t, r, c, p, s) {
|
|
11
|
+
if (n.applyAndRender(r, o), s) {
|
|
12
|
+
const a = s.radius * 5.2;
|
|
13
|
+
t.drawImage(n.canvas, s.x - a / 2, s.y - a * 0.42, a, a);
|
|
10
14
|
} else {
|
|
11
|
-
const a = Math.min(
|
|
12
|
-
|
|
15
|
+
const a = Math.min(c, p);
|
|
16
|
+
t.drawImage(n.canvas, (c - a) / 2, (p - a) / 2, a, a);
|
|
13
17
|
}
|
|
14
18
|
},
|
|
15
19
|
dispose() {
|
|
16
|
-
|
|
20
|
+
n.dispose();
|
|
17
21
|
}
|
|
18
22
|
};
|
|
19
23
|
}
|
|
20
|
-
async function
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
a.register((e) => new
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const u = i.humanoid?.getNormalizedBoneNode("head"), h = new
|
|
34
|
-
u && u.getWorldPosition(h),
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const
|
|
24
|
+
async function G(n, o = 512) {
|
|
25
|
+
const t = document.createElement("canvas");
|
|
26
|
+
t.width = o, t.height = o;
|
|
27
|
+
const r = new d.WebGLRenderer({ canvas: t, alpha: !0, antialias: !0 });
|
|
28
|
+
r.setClearColor(0, 0);
|
|
29
|
+
const c = new d.Scene();
|
|
30
|
+
c.add(new d.AmbientLight(16777215, 1.1));
|
|
31
|
+
const p = new d.DirectionalLight(16777215, 1.4);
|
|
32
|
+
p.position.set(0.5, 1.2, 1.5), c.add(p);
|
|
33
|
+
const s = new d.PerspectiveCamera(28, 1, 0.1, 20), a = new L();
|
|
34
|
+
a.register((e) => new g(e));
|
|
35
|
+
const k = await a.parseAsync(n, ""), i = k.userData.vrm;
|
|
36
|
+
w.removeUnnecessaryVertices(k.scene), w.combineSkeletons(k.scene), w.rotateVRM0(i), c.add(i.scene);
|
|
37
|
+
const u = i.humanoid?.getNormalizedBoneNode("head"), h = new d.Vector3(0, 1.35, 0);
|
|
38
|
+
u && u.getWorldPosition(h), i.scene.updateWorldMatrix(!0, !0);
|
|
39
|
+
const R = new d.Box3().setFromObject(i.scene), V = Number.isFinite(R.max.y) ? R.max.y : h.y + 0.25, y = A({ headY: h.y, crownY: V });
|
|
40
|
+
s.position.set(0, y.lookY, y.distance), s.lookAt(0, y.lookY, 0);
|
|
41
|
+
const f = new d.Object3D();
|
|
42
|
+
f.position.set(0, h.y, 2), c.add(f), i.lookAt && (i.lookAt.target = f);
|
|
43
|
+
const M = new d.Clock();
|
|
38
44
|
return {
|
|
39
|
-
canvas:
|
|
40
|
-
applyAndRender(e,
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
+
canvas: t,
|
|
46
|
+
applyAndRender(e, Y) {
|
|
47
|
+
const b = Y?.headGain ?? 0.9, l = i.expressionManager;
|
|
48
|
+
if (l) {
|
|
49
|
+
const v = l.expressionMap ?? {}, m = (x) => !!v[x];
|
|
50
|
+
m("blinkLeft") || m("blinkRight") ? (l.setValue("blinkLeft", e.blinkLeft), l.setValue("blinkRight", e.blinkRight)) : m("blink") && l.setValue("blink", (e.blinkLeft + e.blinkRight) / 2), m("aa") && l.setValue("aa", Math.max(0, e.jawOpen)), m("happy") && l.setValue("happy", Math.max(0, e.smile)), m("angry") && l.setValue("angry", Math.max(0, -e.smile) * 0.6);
|
|
45
51
|
}
|
|
46
|
-
u && u.rotation.set(-e.headPitch *
|
|
52
|
+
u && u.rotation.set(-e.headPitch * b, e.headYaw * b, -e.headRoll * b), f.position.set(e.pupilX * 1.2, h.y - e.pupilY * 0.8, 2), i.update(M.getDelta()), r.render(c, s);
|
|
47
53
|
},
|
|
48
54
|
dispose() {
|
|
49
|
-
|
|
55
|
+
w.deepDispose(i.scene), r.dispose();
|
|
50
56
|
}
|
|
51
57
|
};
|
|
52
58
|
}
|
|
53
|
-
async function
|
|
54
|
-
const
|
|
55
|
-
return
|
|
59
|
+
async function B(n, o = {}) {
|
|
60
|
+
const t = await G(n, o.size ?? 640);
|
|
61
|
+
return C(t, { headGain: o.headGain });
|
|
56
62
|
}
|
|
57
63
|
export {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
B as createVrmAvatarRenderer,
|
|
65
|
+
G as createVrmStage,
|
|
66
|
+
A as frameVrmBust,
|
|
67
|
+
C as vrmAvatarRenderer
|
|
61
68
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(s,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("three"),require("three/examples/jsm/loaders/GLTFLoader.js"),require("@pixiv/three-vrm")):typeof define=="function"&&define.amd?define(["exports","three","three/examples/jsm/loaders/GLTFLoader.js","@pixiv/three-vrm"],f):(s=typeof globalThis<"u"?globalThis:s||self,f(s.StreamingCdnRtcAvatarVrm={},s.THREE,s.THREE,s.THREE_VRM))})(this,(function(s,f,
|
|
1
|
+
(function(s,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("three"),require("three/examples/jsm/loaders/GLTFLoader.js"),require("@pixiv/three-vrm")):typeof define=="function"&&define.amd?define(["exports","three","three/examples/jsm/loaders/GLTFLoader.js","@pixiv/three-vrm"],f):(s=typeof globalThis<"u"?globalThis:s||self,f(s.StreamingCdnRtcAvatarVrm={},s.THREE,s.THREE,s.THREE_VRM))})(this,(function(s,f,j,h){"use strict";function x(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const d=x(f);function M(e){const n=e.crownY-e.headY,t=n>.05&&n<1.5?n:.25,o=t*2.1,p=e.headY+t*.45-o*.08,i=o/2/Math.tan(28/2*(Math.PI/180));return{windowHeight:o,lookY:p,distance:i}}function V(e,n){return{render(t,o,l,p,i){if(e.applyAndRender(o,n),i){const r=i.radius*5.2;t.drawImage(e.canvas,i.x-r/2,i.y-r*.42,r,r)}else{const r=Math.min(l,p);t.drawImage(e.canvas,(l-r)/2,(p-r)/2,r,r)}},dispose(){e.dispose()}}}async function g(e,n=512){const t=document.createElement("canvas");t.width=n,t.height=n;const o=new d.WebGLRenderer({canvas:t,alpha:!0,antialias:!0});o.setClearColor(0,0);const l=new d.Scene;l.add(new d.AmbientLight(16777215,1.1));const p=new d.DirectionalLight(16777215,1.4);p.position.set(.5,1.2,1.5),l.add(p);const i=new d.PerspectiveCamera(28,1,.1,20),r=new j.GLTFLoader;r.register(a=>new h.VRMLoaderPlugin(a));const w=await r.parseAsync(e,""),c=w.userData.vrm;h.VRMUtils.removeUnnecessaryVertices(w.scene),h.VRMUtils.combineSkeletons(w.scene),h.VRMUtils.rotateVRM0(c),l.add(c.scene);const R=c.humanoid?.getNormalizedBoneNode("head"),y=new d.Vector3(0,1.35,0);R&&R.getWorldPosition(y),c.scene.updateWorldMatrix(!0,!0);const L=new d.Box3().setFromObject(c.scene),T=Number.isFinite(L.max.y)?L.max.y:y.y+.25,k=M({headY:y.y,crownY:T});i.position.set(0,k.lookY,k.distance),i.lookAt(0,k.lookY,0);const b=new d.Object3D;b.position.set(0,y.y,2),l.add(b),c.lookAt&&(c.lookAt.target=b);const Y=new d.Clock;return{canvas:t,applyAndRender(a,S){const v=S?.headGain??.9,u=c.expressionManager;if(u){const E=u.expressionMap??{},m=O=>!!E[O];m("blinkLeft")||m("blinkRight")?(u.setValue("blinkLeft",a.blinkLeft),u.setValue("blinkRight",a.blinkRight)):m("blink")&&u.setValue("blink",(a.blinkLeft+a.blinkRight)/2),m("aa")&&u.setValue("aa",Math.max(0,a.jawOpen)),m("happy")&&u.setValue("happy",Math.max(0,a.smile)),m("angry")&&u.setValue("angry",Math.max(0,-a.smile)*.6)}R&&R.rotation.set(-a.headPitch*v,a.headYaw*v,-a.headRoll*v),b.position.set(a.pupilX*1.2,y.y-a.pupilY*.8,2),c.update(Y.getDelta()),o.render(l,i)},dispose(){h.VRMUtils.deepDispose(c.scene),o.dispose()}}}async function A(e,n={}){const t=await g(e,n.size??640);return V(t,{headGain:n.headGain})}s.createVrmAvatarRenderer=A,s.createVrmStage=g,s.frameVrmBust=M,s.vrmAvatarRenderer=V,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}));
|