@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 CHANGED
@@ -1,4 +1,4 @@
1
- # RTC Web SDK 1.3.26
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
@@ -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 d from "three";
2
- import { GLTFLoader as L } from "three/examples/jsm/loaders/GLTFLoader.js";
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 };
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 C(n, o) {
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(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);
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 a = Math.min(c, p);
16
- t.drawImage(n.canvas, (c - a) / 2, (p - 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);
17
28
  }
18
29
  },
19
30
  dispose() {
20
- n.dispose();
31
+ i.dispose();
21
32
  }
22
33
  };
23
34
  }
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();
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: 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);
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(-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);
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
- w.deepDispose(i.scene), r.dispose();
69
+ k.deepDispose(t.scene), c.dispose();
56
70
  }
57
71
  };
58
72
  }
59
- async function B(n, o = {}) {
60
- const t = await G(n, o.size ?? 640);
61
- return C(t, { headGain: o.headGain });
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
- G as createVrmStage,
66
- A as frameVrmBust,
67
- C as vrmAvatarRenderer
79
+ S as createVrmStage,
80
+ C as frameVrmBust,
81
+ N as vrmAvatarRenderer
68
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,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"})}));
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.26",
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",