@streaming-cdn/rtc-web 1.3.25 → 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 CHANGED
@@ -1,4 +1,4 @@
1
- # RTC Web SDK 1.3.25
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,32 @@ 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
+
372
+ ## 1.3.26 notes
373
+
374
+ - **VRM avatars are framed from the model's own measurements.** The bust
375
+ camera in `avatar-vrm` was fixed at a 0.42 m window aimed at the head
376
+ joint — which sits at the *bottom* of the skull — so characters with tall
377
+ hair or accessories had their crowns cropped, and big-headed models filled
378
+ the whole canvas and rendered far larger than the built-in avatar when
379
+ overlaid. `createVrmStage` now measures each model (head joint from the
380
+ humanoid, crown from the scene bounds, hair included) and frames the bust
381
+ so the skull spans ~38% of the canvas with its centre at 42% from the top —
382
+ the exact contract `vrmAvatarRenderer`'s overlay math expects. Every
383
+ character now appears the same size as the built-in stylized avatar,
384
+ whatever its proportions. The framing rule is exported as `frameVrmBust()`.
385
+
360
386
  ## 1.3.25 notes
361
387
 
362
388
  - **B21 — per-peer quality no longer ratchets down on bandwidth-pinned
@@ -9,6 +9,31 @@ 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
+ bodyHalfWidth?: number;
31
+ }): {
32
+ windowHeight: number;
33
+ lookY: number;
34
+ distance: number;
35
+ aspect: number;
36
+ };
12
37
  /**
13
38
  * Adapts a VrmStage to the SDK's pluggable `AvatarRenderer`, so
14
39
  * `createAvatarPipeline` can publish a VRM character instead of the built-in
@@ -1,61 +1,82 @@
1
- import * as l from "three";
2
- import { GLTFLoader as L } from "three/examples/jsm/loaders/GLTFLoader.js";
1
+ import * as m from "three";
2
+ import { GLTFLoader as Y } from "three/examples/jsm/loaders/GLTFLoader.js";
3
3
  import { VRMLoaderPlugin as A, VRMUtils as k } from "@pixiv/three-vrm";
4
- function M(t, c) {
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
+ }
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
+ };
5
18
  return {
6
- render(n, p, s, m, o) {
7
- if (t.applyAndRender(p, c), o) {
8
- const a = o.radius * 5.2;
9
- n.drawImage(t.canvas, o.x - a / 2, o.y - a * 0.42, a, a);
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);
10
25
  } else {
11
- const a = Math.min(s, m);
12
- n.drawImage(t.canvas, (s - a) / 2, (m - a) / 2, a, a);
26
+ const o = Math.min(r, h);
27
+ n.drawImage(u, (r - o * t) / 2, (h - o) / 2, o * t, o);
13
28
  }
14
29
  },
15
30
  dispose() {
16
- t.dispose();
31
+ i.dispose();
17
32
  }
18
33
  };
19
34
  }
20
- async function g(t, c = 512) {
21
- const n = document.createElement("canvas");
22
- n.width = c, n.height = c;
23
- const p = new l.WebGLRenderer({ canvas: n, alpha: !0, antialias: !0 });
24
- p.setClearColor(0, 0);
25
- const s = new l.Scene();
26
- s.add(new l.AmbientLight(16777215, 1.1));
27
- const m = new l.DirectionalLight(16777215, 1.4);
28
- m.position.set(0.5, 1.2, 1.5), s.add(m);
29
- const o = new l.PerspectiveCamera(28, 1, 0.1, 20), a = new L();
30
- a.register((e) => new A(e));
31
- const w = await a.parseAsync(t, ""), i = w.userData.vrm;
32
- k.removeUnnecessaryVertices(w.scene), k.combineSkeletons(w.scene), k.rotateVRM0(i), s.add(i.scene);
33
- const u = i.humanoid?.getNormalizedBoneNode("head"), h = new l.Vector3(0, 1.35, 0);
34
- u && u.getWorldPosition(h), o.position.set(0, h.y + 0.03, 0.85), o.lookAt(0, h.y + 0.01, 0);
35
- const f = new l.Object3D();
36
- f.position.set(0, h.y, 2), s.add(f), i.lookAt && (i.lookAt.target = f);
37
- const b = new l.Clock();
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();
38
58
  return {
39
- canvas: n,
40
- applyAndRender(e, R) {
41
- const y = R?.headGain ?? 0.9, r = i.expressionManager;
42
- if (r) {
43
- const V = r.expressionMap ?? {}, d = (v) => !!V[v];
44
- d("blinkLeft") || d("blinkRight") ? (r.setValue("blinkLeft", e.blinkLeft), r.setValue("blinkRight", e.blinkRight)) : d("blink") && r.setValue("blink", (e.blinkLeft + e.blinkRight) / 2), d("aa") && r.setValue("aa", Math.max(0, e.jawOpen)), d("happy") && r.setValue("happy", Math.max(0, e.smile)), d("angry") && r.setValue("angry", Math.max(0, -e.smile) * 0.6);
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);
45
65
  }
46
- u && u.rotation.set(-e.headPitch * y, e.headYaw * y, -e.headRoll * y), f.position.set(e.pupilX * 1.2, h.y - e.pupilY * 0.8, 2), i.update(b.getDelta()), p.render(s, o);
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);
47
67
  },
48
68
  dispose() {
49
- k.deepDispose(i.scene), p.dispose();
69
+ k.deepDispose(t.scene), c.dispose();
50
70
  }
51
71
  };
52
72
  }
53
- async function D(t, c = {}) {
54
- const n = await g(t, c.size ?? 640);
55
- return M(n, { headGain: c.headGain });
73
+ async function B(i, d = {}) {
74
+ const e = await S(i, d.size ?? 640);
75
+ return N(e, { headGain: d.headGain });
56
76
  }
57
77
  export {
58
- D as createVrmAvatarRenderer,
59
- g as createVrmStage,
60
- M as vrmAvatarRenderer
78
+ B as createVrmAvatarRenderer,
79
+ S as createVrmStage,
80
+ C as frameVrmBust,
81
+ N as vrmAvatarRenderer
61
82
  };
@@ -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,M,m){"use strict";function L(e){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(i,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return i.default=e,Object.freeze(i)}const o=L(f);function w(e,i){return{render(t,r,d,h,c){if(e.applyAndRender(r,i),c){const a=c.radius*5.2;t.drawImage(e.canvas,c.x-a/2,c.y-a*.42,a,a)}else{const a=Math.min(d,h);t.drawImage(e.canvas,(d-a)/2,(h-a)/2,a,a)}},dispose(){e.dispose()}}}async function V(e,i=512){const t=document.createElement("canvas");t.width=i,t.height=i;const r=new o.WebGLRenderer({canvas:t,alpha:!0,antialias:!0});r.setClearColor(0,0);const d=new o.Scene;d.add(new o.AmbientLight(16777215,1.1));const h=new o.DirectionalLight(16777215,1.4);h.position.set(.5,1.2,1.5),d.add(h);const c=new o.PerspectiveCamera(28,1,.1,20),a=new M.GLTFLoader;a.register(n=>new m.VRMLoaderPlugin(n));const b=await a.parseAsync(e,""),l=b.userData.vrm;m.VRMUtils.removeUnnecessaryVertices(b.scene),m.VRMUtils.combineSkeletons(b.scene),m.VRMUtils.rotateVRM0(l),d.add(l.scene);const y=l.humanoid?.getNormalizedBoneNode("head"),R=new o.Vector3(0,1.35,0);y&&y.getWorldPosition(R),c.position.set(0,R.y+.03,.85),c.lookAt(0,R.y+.01,0);const v=new o.Object3D;v.position.set(0,R.y,2),d.add(v),l.lookAt&&(l.lookAt.target=v);const j=new o.Clock;return{canvas:t,applyAndRender(n,A){const k=A?.headGain??.9,p=l.expressionManager;if(p){const T=p.expressionMap??{},u=x=>!!T[x];u("blinkLeft")||u("blinkRight")?(p.setValue("blinkLeft",n.blinkLeft),p.setValue("blinkRight",n.blinkRight)):u("blink")&&p.setValue("blink",(n.blinkLeft+n.blinkRight)/2),u("aa")&&p.setValue("aa",Math.max(0,n.jawOpen)),u("happy")&&p.setValue("happy",Math.max(0,n.smile)),u("angry")&&p.setValue("angry",Math.max(0,-n.smile)*.6)}y&&y.rotation.set(-n.headPitch*k,n.headYaw*k,-n.headRoll*k),v.position.set(n.pupilX*1.2,R.y-n.pupilY*.8,2),l.update(j.getDelta()),r.render(d,c)},dispose(){m.VRMUtils.deepDispose(l.scene),r.dispose()}}}async function g(e,i={}){const t=await V(e,i.size??640);return w(t,{headGain:i.headGain})}s.createVrmAvatarRenderer=g,s.createVrmStage=V,s.vrmAvatarRenderer=w,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}));
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"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streaming-cdn/rtc-web",
3
- "version": "1.3.25",
3
+ "version": "1.3.27",
4
4
  "type": "module",
5
5
  "main": "dist/rtc-web.umd.js",
6
6
  "module": "dist/rtc-web.es.js",