@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 CHANGED
@@ -1,4 +1,4 @@
1
- # RTC Web SDK 1.3.26
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
@@ -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 d from "three";
1
+ import * as p from "three";
2
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 };
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 C(n, o) {
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(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(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 a = Math.min(c, p);
16
- t.drawImage(n.canvas, (c - a) / 2, (p - a) / 2, a, a);
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
- n.dispose();
31
+ a.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 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: 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);
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
- 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);
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
- w.deepDispose(i.scene), r.dispose();
74
+ R.deepDispose(t.scene), c.dispose();
56
75
  }
57
76
  };
58
77
  }
59
- async function B(n, o = {}) {
60
- const t = await G(n, o.size ?? 640);
61
- return C(t, { headGain: o.headGain });
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
- B as createVrmAvatarRenderer,
65
- G as createVrmStage,
66
- A as frameVrmBust,
67
- C as vrmAvatarRenderer
83
+ G as createVrmAvatarRenderer,
84
+ W as createVrmStage,
85
+ C as frameVrmBust,
86
+ S as vrmAvatarRenderer
68
87
  };
@@ -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(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"})}));
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.28",
4
4
  "type": "module",
5
5
  "main": "dist/rtc-web.umd.js",
6
6
  "module": "dist/rtc-web.es.js",