@streaming-cdn/rtc-web 1.3.27 → 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 +10 -1
- package/dist/rtc-web-avatar-vrm.es.js +59 -54
- 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.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
|
|
@@ -1,82 +1,87 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import { GLTFLoader as
|
|
3
|
-
import { VRMLoaderPlugin as
|
|
4
|
-
function C(
|
|
5
|
-
const d =
|
|
6
|
-
return { windowHeight: c, lookY:
|
|
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
|
|
8
|
+
function S(a, d) {
|
|
9
9
|
let e = null;
|
|
10
10
|
const c = () => {
|
|
11
|
-
const
|
|
12
|
-
(!e || e.width !==
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
return
|
|
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(
|
|
20
|
-
|
|
21
|
-
const t =
|
|
22
|
-
if (
|
|
23
|
-
const
|
|
24
|
-
|
|
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
|
|
27
|
-
|
|
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
|
-
|
|
31
|
+
a.dispose();
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
async function
|
|
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
|
|
38
|
+
const c = new p.WebGLRenderer({ canvas: e, alpha: !0, antialias: !0 });
|
|
39
39
|
c.setClearColor(0, 0);
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
e.width = Math.round(d *
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
const
|
|
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(
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
const
|
|
64
|
-
|
|
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
|
-
|
|
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
|
-
|
|
74
|
+
R.deepDispose(t.scene), c.dispose();
|
|
70
75
|
}
|
|
71
76
|
};
|
|
72
77
|
}
|
|
73
|
-
async function
|
|
74
|
-
const e = await
|
|
75
|
-
return
|
|
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
|
-
|
|
79
|
-
|
|
83
|
+
G as createVrmAvatarRenderer,
|
|
84
|
+
W as createVrmStage,
|
|
80
85
|
C as frameVrmBust,
|
|
81
|
-
|
|
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(
|
|
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"})}));
|