@streaming-cdn/rtc-web 1.3.26 → 1.3.28
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 +22 -1
- package/dist/avatar-vrm.d.ts +2 -0
- package/dist/rtc-web-avatar-vrm.es.js +67 -48
- 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.28
|
|
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,27 @@ 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.28 notes
|
|
361
|
+
|
|
362
|
+
- **The idle pose measures which way is down.** 1.3.27 lowered the arms out
|
|
363
|
+
of T-pose with a guessed rotation sign; on real rigs the guess raised every
|
|
364
|
+
arm skyward, and the crown measurement then framed the raised fingertips
|
|
365
|
+
as the top of the head. Each arm now tries both signs and keeps the one
|
|
366
|
+
that puts the wrist lower, so the pose is correct for any facing
|
|
367
|
+
convention or rig variant.
|
|
368
|
+
|
|
369
|
+
## 1.3.27 notes
|
|
370
|
+
|
|
371
|
+
- **VRM busts no longer clip at the canvas sides.** Characters ship in
|
|
372
|
+
T/A-pose; the square stage cut the outstretched arms and shoulders off
|
|
373
|
+
with hard vertical edges. The stage now lowers the arms into a natural
|
|
374
|
+
idle before measuring, sizes its width to the character's own measured
|
|
375
|
+
body (floor 4:3, cap 2:1 — `frameVrmBust` returns the aspect), and the
|
|
376
|
+
composite dissolves the bottom edge instead of stopping at a hard line
|
|
377
|
+
inside the tile. The stage aspect is the avatar sprite's capture field
|
|
378
|
+
only: output portrait/landscape orientation is unchanged and keeps
|
|
379
|
+
following the camera source.
|
|
380
|
+
|
|
360
381
|
## 1.3.26 notes
|
|
361
382
|
|
|
362
383
|
- **VRM avatars are framed from the model's own measurements.** The bust
|
package/dist/avatar-vrm.d.ts
CHANGED
|
@@ -27,10 +27,12 @@ export interface VrmStage {
|
|
|
27
27
|
export declare function frameVrmBust(measure: {
|
|
28
28
|
headY: number;
|
|
29
29
|
crownY: number;
|
|
30
|
+
bodyHalfWidth?: number;
|
|
30
31
|
}): {
|
|
31
32
|
windowHeight: number;
|
|
32
33
|
lookY: number;
|
|
33
34
|
distance: number;
|
|
35
|
+
aspect: number;
|
|
34
36
|
};
|
|
35
37
|
/**
|
|
36
38
|
* Adapts a VrmStage to the SDK's pluggable `AvatarRenderer`, so
|
|
@@ -1,68 +1,87 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as p from "three";
|
|
2
2
|
import { GLTFLoader as L } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
3
|
-
import { VRMLoaderPlugin as
|
|
4
|
-
function
|
|
5
|
-
const
|
|
6
|
-
return { windowHeight:
|
|
3
|
+
import { VRMLoaderPlugin as Y, VRMUtils as R } from "@pixiv/three-vrm";
|
|
4
|
+
function C(a) {
|
|
5
|
+
const d = a.crownY - a.headY, e = d > 0.05 && d < 1.5 ? d : 0.25, c = e * 2.1, i = a.headY + e * 0.45 - c * 0.08, s = c / 2 / Math.tan(28 / 2 * (Math.PI / 180)), l = Number(a.bodyHalfWidth), m = Number.isFinite(l) && l > 0.05 && l < 2 ? l * 2 * 1.08 : 0, t = Math.min(2, Math.max(4 / 3, m / c));
|
|
6
|
+
return { windowHeight: c, lookY: i, distance: s, aspect: t };
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function S(a, d) {
|
|
9
|
+
let e = null;
|
|
10
|
+
const c = () => {
|
|
11
|
+
const o = a.canvas;
|
|
12
|
+
(!e || e.width !== o.width || e.height !== o.height) && (e = o.ownerDocument.createElement("canvas"), e.width = o.width, e.height = o.height);
|
|
13
|
+
const i = e.getContext("2d");
|
|
14
|
+
i.clearRect(0, 0, e.width, e.height), i.drawImage(o, 0, 0), i.globalCompositeOperation = "destination-out";
|
|
15
|
+
const s = i.createLinearGradient(0, e.height * 0.88, 0, e.height);
|
|
16
|
+
return s.addColorStop(0, "rgba(0,0,0,0)"), s.addColorStop(1, "rgba(0,0,0,1)"), i.fillStyle = s, i.fillRect(0, e.height * 0.88, e.width, e.height * 0.12), i.globalCompositeOperation = "source-over", e;
|
|
17
|
+
};
|
|
9
18
|
return {
|
|
10
|
-
render(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
19
|
+
render(o, i, s, l, m) {
|
|
20
|
+
a.applyAndRender(i, d);
|
|
21
|
+
const t = a.canvas.width / a.canvas.height, y = c();
|
|
22
|
+
if (m) {
|
|
23
|
+
const r = m.radius * 5.2;
|
|
24
|
+
o.drawImage(y, m.x - r * t / 2, m.y - r * 0.42, r * t, r);
|
|
14
25
|
} else {
|
|
15
|
-
const
|
|
16
|
-
|
|
26
|
+
const r = Math.min(s, l);
|
|
27
|
+
o.drawImage(y, (s - r * t) / 2, (l - r) / 2, r * t, r);
|
|
17
28
|
}
|
|
18
29
|
},
|
|
19
30
|
dispose() {
|
|
20
|
-
|
|
31
|
+
a.dispose();
|
|
21
32
|
}
|
|
22
33
|
};
|
|
23
34
|
}
|
|
24
|
-
async function
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const s = new
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
async function W(a, d = 512) {
|
|
36
|
+
const e = document.createElement("canvas");
|
|
37
|
+
e.width = d, e.height = d;
|
|
38
|
+
const c = new p.WebGLRenderer({ canvas: e, alpha: !0, antialias: !0 });
|
|
39
|
+
c.setClearColor(0, 0);
|
|
40
|
+
const o = new p.Scene();
|
|
41
|
+
o.add(new p.AmbientLight(16777215, 1.1));
|
|
42
|
+
const i = new p.DirectionalLight(16777215, 1.4);
|
|
43
|
+
i.position.set(0.5, 1.2, 1.5), o.add(i);
|
|
44
|
+
const s = new p.PerspectiveCamera(28, 1, 0.1, 20), l = new L();
|
|
45
|
+
l.register((n) => new Y(n));
|
|
46
|
+
const m = await l.parseAsync(a, ""), t = m.userData.vrm;
|
|
47
|
+
R.removeUnnecessaryVertices(m.scene), R.combineSkeletons(m.scene), R.rotateVRM0(t), o.add(t.scene);
|
|
48
|
+
const y = new p.Vector3();
|
|
49
|
+
for (const n of ["left", "right"]) {
|
|
50
|
+
const w = t.humanoid?.getNormalizedBoneNode(`${n}UpperArm`);
|
|
51
|
+
if (!w) continue;
|
|
52
|
+
const b = t.humanoid?.getNormalizedBoneNode(`${n}Hand`) ?? t.humanoid?.getNormalizedBoneNode(`${n}LowerArm`) ?? w, h = (u) => (w.rotation.set(0, 0, u), b.getWorldPosition(y).y), M = h(1.15) < h(-1.15) ? 1.15 : -1.15;
|
|
53
|
+
w.rotation.set(0, 0, M), t.humanoid?.getNormalizedBoneNode(`${n}LowerArm`)?.rotation.set(0, 0, M * 0.1);
|
|
54
|
+
}
|
|
55
|
+
t.update(0);
|
|
56
|
+
const r = t.humanoid?.getNormalizedBoneNode("head"), f = new p.Vector3(0, 1.35, 0);
|
|
57
|
+
r && r.getWorldPosition(f), t.scene.updateWorldMatrix(!0, !0);
|
|
58
|
+
const k = new p.Box3().setFromObject(t.scene), V = Number.isFinite(k.max.y) ? k.max.y : f.y + 0.25, v = Math.max(Math.abs(k.min.x), Math.abs(k.max.x)), g = C({ headY: f.y, crownY: V, bodyHalfWidth: v });
|
|
59
|
+
e.width = Math.round(d * g.aspect), e.height = d, c.setSize(e.width, e.height, !1), s.aspect = g.aspect, s.updateProjectionMatrix(), s.position.set(0, g.lookY, g.distance), s.lookAt(0, g.lookY, 0);
|
|
60
|
+
const x = new p.Object3D();
|
|
61
|
+
x.position.set(0, f.y, 2), o.add(x), t.lookAt && (t.lookAt.target = x);
|
|
62
|
+
const N = new p.Clock();
|
|
44
63
|
return {
|
|
45
|
-
canvas:
|
|
46
|
-
applyAndRender(
|
|
47
|
-
const b =
|
|
48
|
-
if (
|
|
49
|
-
const
|
|
50
|
-
|
|
64
|
+
canvas: e,
|
|
65
|
+
applyAndRender(n, w) {
|
|
66
|
+
const b = w?.headGain ?? 0.9, h = t.expressionManager;
|
|
67
|
+
if (h) {
|
|
68
|
+
const M = h.expressionMap ?? {}, u = (A) => !!M[A];
|
|
69
|
+
u("blinkLeft") || u("blinkRight") ? (h.setValue("blinkLeft", n.blinkLeft), h.setValue("blinkRight", n.blinkRight)) : u("blink") && h.setValue("blink", (n.blinkLeft + n.blinkRight) / 2), u("aa") && h.setValue("aa", Math.max(0, n.jawOpen)), u("happy") && h.setValue("happy", Math.max(0, n.smile)), u("angry") && h.setValue("angry", Math.max(0, -n.smile) * 0.6);
|
|
51
70
|
}
|
|
52
|
-
|
|
71
|
+
r && r.rotation.set(-n.headPitch * b, n.headYaw * b, -n.headRoll * b), x.position.set(n.pupilX * 1.2, f.y - n.pupilY * 0.8, 2), t.update(N.getDelta()), c.render(o, s);
|
|
53
72
|
},
|
|
54
73
|
dispose() {
|
|
55
|
-
|
|
74
|
+
R.deepDispose(t.scene), c.dispose();
|
|
56
75
|
}
|
|
57
76
|
};
|
|
58
77
|
}
|
|
59
|
-
async function
|
|
60
|
-
const
|
|
61
|
-
return
|
|
78
|
+
async function G(a, d = {}) {
|
|
79
|
+
const e = await W(a, d.size ?? 640);
|
|
80
|
+
return S(e, { headGain: d.headGain });
|
|
62
81
|
}
|
|
63
82
|
export {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
83
|
+
G as createVrmAvatarRenderer,
|
|
84
|
+
W as createVrmStage,
|
|
85
|
+
C as frameVrmBust,
|
|
86
|
+
S as vrmAvatarRenderer
|
|
68
87
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(l,w){typeof exports=="object"&&typeof module<"u"?w(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"],w):(l=typeof globalThis<"u"?globalThis:l||self,w(l.StreamingCdnRtcAvatarVrm={},l.THREE,l.THREE,l.THREE_VRM))})(this,(function(l,w,S,b){"use strict";function j(n){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(o,e,s.get?s:{enumerable:!0,get:()=>n[e]})}}return o.default=n,Object.freeze(o)}const u=j(w);function L(n){const o=n.crownY-n.headY,e=o>.05&&o<1.5?o:.25,s=e*2.1,r=n.headY+e*.45-s*.08,d=s/2/Math.tan(28/2*(Math.PI/180)),m=Number(n.bodyHalfWidth),p=Number.isFinite(m)&&m>.05&&m<2?m*2*1.08:0,t=Math.min(2,Math.max(4/3,p/s));return{windowHeight:s,lookY:r,distance:d,aspect:t}}function A(n,o){let e=null;const s=()=>{const i=n.canvas;(!e||e.width!==i.width||e.height!==i.height)&&(e=i.ownerDocument.createElement("canvas"),e.width=i.width,e.height=i.height);const r=e.getContext("2d");r.clearRect(0,0,e.width,e.height),r.drawImage(i,0,0),r.globalCompositeOperation="destination-out";const d=r.createLinearGradient(0,e.height*.88,0,e.height);return d.addColorStop(0,"rgba(0,0,0,0)"),d.addColorStop(1,"rgba(0,0,0,1)"),r.fillStyle=d,r.fillRect(0,e.height*.88,e.width,e.height*.12),r.globalCompositeOperation="source-over",e};return{render(i,r,d,m,p){n.applyAndRender(r,o);const t=n.canvas.width/n.canvas.height,v=s();if(p){const c=p.radius*5.2;i.drawImage(v,p.x-c*t/2,p.y-c*.42,c*t,c)}else{const c=Math.min(d,m);i.drawImage(v,(d-c*t)/2,(m-c)/2,c*t,c)}},dispose(){n.dispose()}}}async function N(n,o=512){const e=document.createElement("canvas");e.width=o,e.height=o;const s=new u.WebGLRenderer({canvas:e,alpha:!0,antialias:!0});s.setClearColor(0,0);const i=new u.Scene;i.add(new u.AmbientLight(16777215,1.1));const r=new u.DirectionalLight(16777215,1.4);r.position.set(.5,1.2,1.5),i.add(r);const d=new u.PerspectiveCamera(28,1,.1,20),m=new S.GLTFLoader;m.register(a=>new b.VRMLoaderPlugin(a));const p=await m.parseAsync(n,""),t=p.userData.vrm;b.VRMUtils.removeUnnecessaryVertices(p.scene),b.VRMUtils.combineSkeletons(p.scene),b.VRMUtils.rotateVRM0(t),i.add(t.scene);const v=new u.Vector3;for(const a of["left","right"]){const g=t.humanoid?.getNormalizedBoneNode(`${a}UpperArm`);if(!g)continue;const M=t.humanoid?.getNormalizedBoneNode(`${a}Hand`)??t.humanoid?.getNormalizedBoneNode(`${a}LowerArm`)??g,h=f=>(g.rotation.set(0,0,f),M.getWorldPosition(v).y),V=h(1.15)<h(-1.15)?1.15:-1.15;g.rotation.set(0,0,V),t.humanoid?.getNormalizedBoneNode(`${a}LowerArm`)?.rotation.set(0,0,V*.1)}t.update(0);const c=t.humanoid?.getNormalizedBoneNode("head"),y=new u.Vector3(0,1.35,0);c&&c.getWorldPosition(y),t.scene.updateWorldMatrix(!0,!0);const k=new u.Box3().setFromObject(t.scene),C=Number.isFinite(k.max.y)?k.max.y:y.y+.25,T=Math.max(Math.abs(k.min.x),Math.abs(k.max.x)),R=L({headY:y.y,crownY:C,bodyHalfWidth:T});e.width=Math.round(o*R.aspect),e.height=o,s.setSize(e.width,e.height,!1),d.aspect=R.aspect,d.updateProjectionMatrix(),d.position.set(0,R.lookY,R.distance),d.lookAt(0,R.lookY,0);const x=new u.Object3D;x.position.set(0,y.y,2),i.add(x),t.lookAt&&(t.lookAt.target=x);const O=new u.Clock;return{canvas:e,applyAndRender(a,g){const M=g?.headGain??.9,h=t.expressionManager;if(h){const V=h.expressionMap??{},f=P=>!!V[P];f("blinkLeft")||f("blinkRight")?(h.setValue("blinkLeft",a.blinkLeft),h.setValue("blinkRight",a.blinkRight)):f("blink")&&h.setValue("blink",(a.blinkLeft+a.blinkRight)/2),f("aa")&&h.setValue("aa",Math.max(0,a.jawOpen)),f("happy")&&h.setValue("happy",Math.max(0,a.smile)),f("angry")&&h.setValue("angry",Math.max(0,-a.smile)*.6)}c&&c.rotation.set(-a.headPitch*M,a.headYaw*M,-a.headRoll*M),x.position.set(a.pupilX*1.2,y.y-a.pupilY*.8,2),t.update(O.getDelta()),s.render(i,d)},dispose(){b.VRMUtils.deepDispose(t.scene),s.dispose()}}}async function Y(n,o={}){const e=await N(n,o.size??640);return A(e,{headGain:o.headGain})}l.createVrmAvatarRenderer=Y,l.createVrmStage=N,l.frameVrmBust=L,l.vrmAvatarRenderer=A,Object.defineProperty(l,Symbol.toStringTag,{value:"Module"})}));
|