@streaming-cdn/rtc-web 1.3.27 → 1.4.0

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.27
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,15 @@ 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
+
360
369
  ## 1.3.27 notes
361
370
 
362
371
  - **VRM busts no longer clip at the canvas sides.** Characters ship in
package/dist/index.d.ts CHANGED
@@ -324,12 +324,20 @@ export declare class RtcIncomingClient extends EventTarget {
324
324
  private readonly seenInvitationIds;
325
325
  private readonly invitationExpiryTimers;
326
326
  private startCallRequest;
327
+ /** Bumped by disconnect() so a request still in flight cannot re-claim the call slot it just freed. */
328
+ private callGeneration;
327
329
  private lastDisconnect;
328
330
  constructor(options: RtcIncomingClientOptions);
329
331
  connect(): this;
330
332
  setMount(target: HTMLElement | string | null): void;
331
333
  /** Binds media lifetime to a call. Terminal call states automatically leave and destroy it. */
332
334
  attachMediaClient(callId: string, media: RtcClient): () => void;
335
+ /**
336
+ * Arms the self-release timer for a call that holds the single call slot but
337
+ * has no media attached. Every path that claims the slot arms this, so no
338
+ * failure can hold it for the life of the page.
339
+ */
340
+ private armCallWatchdog;
333
341
  /**
334
342
  * Rings everyone in `targets` as a single call and connects whoever answers
335
343
  * first; the rest stop ringing on their own. `target` still works and means a
@@ -395,4 +403,4 @@ export declare class RtcIncomingClient extends EventTarget {
395
403
  private emit;
396
404
  }
397
405
  export declare function createRtcIncomingClient(options: RtcIncomingClientOptions): RtcIncomingClient;
398
- export declare const version = "1.3.25";
406
+ export declare const version = "1.4.0";
@@ -1,82 +1,87 @@
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 };
1
+ import * as p from "three";
2
+ import { GLTFLoader as L } from "three/examples/jsm/loaders/GLTFLoader.js";
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 N(i, d) {
8
+ function S(a, d) {
9
9
  let e = null;
10
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;
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
17
  };
18
18
  return {
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);
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);
25
25
  } else {
26
- const o = Math.min(r, h);
27
- n.drawImage(u, (r - o * t) / 2, (h - o) / 2, o * t, o);
26
+ const r = Math.min(s, l);
27
+ o.drawImage(y, (s - r * t) / 2, (l - r) / 2, r * t, r);
28
28
  }
29
29
  },
30
30
  dispose() {
31
- i.dispose();
31
+ a.dispose();
32
32
  }
33
33
  };
34
34
  }
35
- async function S(i, d = 512) {
35
+ async function W(a, d = 512) {
36
36
  const e = document.createElement("canvas");
37
37
  e.width = d, e.height = d;
38
- const c = new m.WebGLRenderer({ canvas: e, alpha: !0, antialias: !0 });
38
+ const c = new p.WebGLRenderer({ canvas: e, alpha: !0, antialias: !0 });
39
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);
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
+ }
50
55
  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();
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();
58
63
  return {
59
64
  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);
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);
65
70
  }
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);
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);
67
72
  },
68
73
  dispose() {
69
- k.deepDispose(t.scene), c.dispose();
74
+ R.deepDispose(t.scene), c.dispose();
70
75
  }
71
76
  };
72
77
  }
73
- async function B(i, d = {}) {
74
- const e = await S(i, d.size ?? 640);
75
- return N(e, { headGain: d.headGain });
78
+ async function G(a, d = {}) {
79
+ const e = await W(a, d.size ?? 640);
80
+ return S(e, { headGain: d.headGain });
76
81
  }
77
82
  export {
78
- B as createVrmAvatarRenderer,
79
- S as createVrmStage,
83
+ G as createVrmAvatarRenderer,
84
+ W as createVrmStage,
80
85
  C as frameVrmBust,
81
- N as vrmAvatarRenderer
86
+ S as vrmAvatarRenderer
82
87
  };
@@ -1 +1 @@
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"})}));
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"})}));