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