@asiyst/sdk 0.1.28 → 0.1.29
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/dist/index.cjs +275 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -2
- package/dist/index.d.ts +44 -2
- package/dist/index.js +275 -88
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2231,6 +2231,7 @@ var FbxRenderer = class {
|
|
|
2231
2231
|
this.facing = "right";
|
|
2232
2232
|
this.currentPose = "idle";
|
|
2233
2233
|
this.initialRenderCompleted = false;
|
|
2234
|
+
this.baseScale = 1;
|
|
2234
2235
|
}
|
|
2235
2236
|
async mount(container, asset, options) {
|
|
2236
2237
|
const doc = container.ownerDocument;
|
|
@@ -2248,13 +2249,17 @@ var FbxRenderer = class {
|
|
|
2248
2249
|
throw new Error("WebGLRenderingContext is not available or supported in this browser environment");
|
|
2249
2250
|
}
|
|
2250
2251
|
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
2251
|
-
const width = options?.width || (isMobile ?
|
|
2252
|
-
const height = options?.height || (isMobile ?
|
|
2252
|
+
const width = options?.width || (isMobile ? 140 : 190);
|
|
2253
|
+
const height = options?.height || (isMobile ? 280 : 360);
|
|
2253
2254
|
const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
2254
2255
|
this.canvas.width = Math.round(width * dpr);
|
|
2255
2256
|
this.canvas.height = Math.round(height * dpr);
|
|
2256
2257
|
this.canvas.style.width = `${width}px`;
|
|
2257
2258
|
this.canvas.style.height = `${height}px`;
|
|
2259
|
+
this.canvas.style.pointerEvents = "none";
|
|
2260
|
+
this.canvas.style.border = "none";
|
|
2261
|
+
this.canvas.style.outline = "none";
|
|
2262
|
+
this.canvas.style.boxShadow = "none";
|
|
2258
2263
|
try {
|
|
2259
2264
|
this.renderer = new THREE__namespace.WebGLRenderer({
|
|
2260
2265
|
canvas: this.canvas,
|
|
@@ -2281,6 +2286,13 @@ var FbxRenderer = class {
|
|
|
2281
2286
|
keyLight.castShadow = true;
|
|
2282
2287
|
keyLight.shadow.mapSize.width = 512;
|
|
2283
2288
|
keyLight.shadow.mapSize.height = 512;
|
|
2289
|
+
keyLight.shadow.camera.near = 0.5;
|
|
2290
|
+
keyLight.shadow.camera.far = 15;
|
|
2291
|
+
keyLight.shadow.camera.left = -1.5;
|
|
2292
|
+
keyLight.shadow.camera.right = 1.5;
|
|
2293
|
+
keyLight.shadow.camera.top = 2.5;
|
|
2294
|
+
keyLight.shadow.camera.bottom = -0.5;
|
|
2295
|
+
keyLight.shadow.bias = -5e-4;
|
|
2284
2296
|
this.scene.add(keyLight);
|
|
2285
2297
|
const fillLight = new THREE__namespace.DirectionalLight(15459032, 1.2);
|
|
2286
2298
|
fillLight.position.set(-3, 2, 2);
|
|
@@ -2289,7 +2301,13 @@ var FbxRenderer = class {
|
|
|
2289
2301
|
rimLight.position.set(0, 4, -3);
|
|
2290
2302
|
this.scene.add(rimLight);
|
|
2291
2303
|
const shadowGeo = new THREE__namespace.PlaneGeometry(3, 3);
|
|
2292
|
-
const shadowMat = new THREE__namespace.ShadowMaterial({
|
|
2304
|
+
const shadowMat = new THREE__namespace.ShadowMaterial({
|
|
2305
|
+
opacity: 0.12,
|
|
2306
|
+
depthWrite: false
|
|
2307
|
+
});
|
|
2308
|
+
shadowMat.polygonOffset = true;
|
|
2309
|
+
shadowMat.polygonOffsetFactor = -1;
|
|
2310
|
+
shadowMat.polygonOffsetUnits = -4;
|
|
2293
2311
|
const shadowPlane = new THREE__namespace.Mesh(shadowGeo, shadowMat);
|
|
2294
2312
|
shadowPlane.rotation.x = -Math.PI / 2;
|
|
2295
2313
|
shadowPlane.position.y = 0;
|
|
@@ -2341,14 +2359,18 @@ var FbxRenderer = class {
|
|
|
2341
2359
|
rawObject.position.set(-rawCenter.x, -rawBox.min.y, -rawCenter.z);
|
|
2342
2360
|
const targetVisualHeight = 1.8;
|
|
2343
2361
|
const targetScale = targetVisualHeight / rawHeight;
|
|
2362
|
+
this.baseScale = targetScale;
|
|
2344
2363
|
this.modelRoot = new THREE__namespace.Group();
|
|
2345
2364
|
this.modelRoot.add(rawObject);
|
|
2346
2365
|
this.modelRoot.scale.setScalar(targetScale);
|
|
2347
2366
|
this.scene.add(this.modelRoot);
|
|
2348
|
-
const visualCenterY = targetVisualHeight * 0.
|
|
2367
|
+
const visualCenterY = targetVisualHeight * 0.5;
|
|
2349
2368
|
const fovRadians = this.camera.fov * Math.PI / 180;
|
|
2350
|
-
const
|
|
2351
|
-
|
|
2369
|
+
const aspect = width / height;
|
|
2370
|
+
const fitDistV = targetVisualHeight * 1.35 / 2 / Math.tan(fovRadians / 2);
|
|
2371
|
+
const fitDistH = 1.1 / 2 / (aspect * Math.tan(fovRadians / 2));
|
|
2372
|
+
const fitDist = Math.max(fitDistV, fitDistH, 2.85);
|
|
2373
|
+
this.camera.position.set(0, visualCenterY, fitDist);
|
|
2352
2374
|
this.camera.lookAt(0, visualCenterY, 0);
|
|
2353
2375
|
rawObject.traverse((child) => {
|
|
2354
2376
|
const mesh = child;
|
|
@@ -2357,20 +2379,25 @@ var FbxRenderer = class {
|
|
|
2357
2379
|
mesh.receiveShadow = true;
|
|
2358
2380
|
}
|
|
2359
2381
|
});
|
|
2382
|
+
options?.metricsTracker?.record("sceneInitComplete");
|
|
2360
2383
|
this.rawObject = rawObject;
|
|
2361
2384
|
this.mixer = new THREE__namespace.AnimationMixer(rawObject);
|
|
2362
2385
|
this.allAnimations = [...modelAnimations];
|
|
2363
2386
|
const externalAnims = options?.config?.animations || options?.config?.avatar?.animations || [];
|
|
2364
2387
|
if (externalAnims.length > 0) {
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
console
|
|
2388
|
+
if (modelAnimations.length === 0) {
|
|
2389
|
+
try {
|
|
2390
|
+
await Promise.race([
|
|
2391
|
+
this.loadExternalAnimations(externalAnims, options?.config?.animation),
|
|
2392
|
+
new Promise((resolve) => setTimeout(resolve, 2500))
|
|
2393
|
+
]);
|
|
2394
|
+
} catch (animErr) {
|
|
2395
|
+
if (typeof console !== "undefined" && typeof console.warn === "function") {
|
|
2396
|
+
console.warn("[asiyst] External animation loading notice:", animErr);
|
|
2397
|
+
}
|
|
2373
2398
|
}
|
|
2399
|
+
} else {
|
|
2400
|
+
void this.loadExternalAnimations(externalAnims, options?.config?.animation);
|
|
2374
2401
|
}
|
|
2375
2402
|
}
|
|
2376
2403
|
this.startInitialIdleAnimation(options?.config);
|
|
@@ -2382,9 +2409,11 @@ var FbxRenderer = class {
|
|
|
2382
2409
|
try {
|
|
2383
2410
|
this.renderer.render(this.scene, this.camera);
|
|
2384
2411
|
this.initialRenderCompleted = true;
|
|
2412
|
+
options?.metricsTracker?.record("firstRenderedFrame");
|
|
2385
2413
|
if (this.canvas) {
|
|
2386
2414
|
this.canvas.style.opacity = "1";
|
|
2387
2415
|
}
|
|
2416
|
+
options?.metricsTracker?.record("firstVisibleCorrectlyFramed");
|
|
2388
2417
|
} catch (renderErr) {
|
|
2389
2418
|
const msg = renderErr instanceof Error ? renderErr.message : String(renderErr);
|
|
2390
2419
|
throw new Error(`Initial FBX WebGL render failed: ${msg}`);
|
|
@@ -2423,6 +2452,18 @@ var FbxRenderer = class {
|
|
|
2423
2452
|
targetClip = this.allAnimations.find(
|
|
2424
2453
|
(c) => c.name.toLowerCase().includes("think")
|
|
2425
2454
|
);
|
|
2455
|
+
} else if (pose === "walk") {
|
|
2456
|
+
targetClip = this.allAnimations.find(
|
|
2457
|
+
(c) => c.name.toLowerCase().includes("walk") || c.name.toLowerCase().includes("run")
|
|
2458
|
+
);
|
|
2459
|
+
} else if (pose === "point") {
|
|
2460
|
+
targetClip = this.allAnimations.find(
|
|
2461
|
+
(c) => c.name.toLowerCase().includes("point")
|
|
2462
|
+
);
|
|
2463
|
+
} else if (pose === "celebrate") {
|
|
2464
|
+
targetClip = this.allAnimations.find(
|
|
2465
|
+
(c) => c.name.toLowerCase().includes("celebrat") || c.name.toLowerCase().includes("wave") || c.name.toLowerCase().includes("cheer") || c.name.toLowerCase().includes("jump")
|
|
2466
|
+
);
|
|
2426
2467
|
} else {
|
|
2427
2468
|
targetClip = this.allAnimations.find((c) => c.name.toLowerCase().includes("idle")) || this.animationMetadataList[0]?.clip || this.allAnimations[0];
|
|
2428
2469
|
}
|
|
@@ -2443,23 +2484,28 @@ var FbxRenderer = class {
|
|
|
2443
2484
|
}
|
|
2444
2485
|
}
|
|
2445
2486
|
if (!this.modelRoot) return;
|
|
2487
|
+
this.modelRoot.scale.setScalar(this.baseScale);
|
|
2446
2488
|
switch (pose) {
|
|
2447
2489
|
case "point":
|
|
2448
|
-
this.modelRoot.rotation.z = -0.
|
|
2449
|
-
this.modelRoot.rotation.x = 0.
|
|
2490
|
+
this.modelRoot.rotation.z = -0.06;
|
|
2491
|
+
this.modelRoot.rotation.x = 0.03;
|
|
2450
2492
|
break;
|
|
2451
2493
|
case "think":
|
|
2452
|
-
this.modelRoot.rotation.z = 0.
|
|
2453
|
-
this.modelRoot.rotation.x = -0.
|
|
2494
|
+
this.modelRoot.rotation.z = 0.05;
|
|
2495
|
+
this.modelRoot.rotation.x = -0.04;
|
|
2454
2496
|
break;
|
|
2455
2497
|
case "speak":
|
|
2456
2498
|
this.modelRoot.rotation.y = this.facing === "left" ? -0.22 : 0.22;
|
|
2457
|
-
this.modelRoot.rotation.x = 0.
|
|
2499
|
+
this.modelRoot.rotation.x = 0.03;
|
|
2458
2500
|
break;
|
|
2459
2501
|
case "celebrate":
|
|
2460
2502
|
this.modelRoot.rotation.z = 0;
|
|
2461
|
-
this.modelRoot.rotation.x = -0.
|
|
2462
|
-
|
|
2503
|
+
this.modelRoot.rotation.x = -0.06;
|
|
2504
|
+
break;
|
|
2505
|
+
case "walk":
|
|
2506
|
+
this.modelRoot.rotation.z = 0;
|
|
2507
|
+
this.modelRoot.rotation.x = 0.03;
|
|
2508
|
+
this.modelRoot.rotation.y = this.facing === "left" ? -0.35 : 0.35;
|
|
2463
2509
|
break;
|
|
2464
2510
|
default:
|
|
2465
2511
|
this.modelRoot.rotation.z = 0;
|
|
@@ -2518,49 +2564,61 @@ var FbxRenderer = class {
|
|
|
2518
2564
|
}
|
|
2519
2565
|
async loadExternalAnimations(animations, targetAnimationName) {
|
|
2520
2566
|
if (!this.rawObject || !this.mixer) return;
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
const
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
if (loaded.resourcePath) {
|
|
2529
|
-
loader.setResourcePath(loaded.resourcePath);
|
|
2530
|
-
}
|
|
2531
|
-
const parsed = loader.parse(loaded.buffer, loaded.resourcePath || "");
|
|
2532
|
-
extractedClips = parsed.animations || [];
|
|
2533
|
-
} else if (loaded.format === "glb") {
|
|
2534
|
-
const loader = new GLTFLoader_js.GLTFLoader();
|
|
2535
|
-
const gltf = await new Promise((resolve, reject) => {
|
|
2536
|
-
const glbBuffer = loaded.bin.buffer.slice(
|
|
2537
|
-
loaded.bin.byteOffset,
|
|
2538
|
-
loaded.bin.byteOffset + loaded.bin.byteLength
|
|
2539
|
-
);
|
|
2540
|
-
loader.parse(glbBuffer, loaded.url, resolve, reject);
|
|
2541
|
-
});
|
|
2542
|
-
extractedClips = gltf.animations || [];
|
|
2543
|
-
}
|
|
2544
|
-
for (const rawClip of extractedClips) {
|
|
2545
|
-
const retargeted = this.retargetClip(rawClip, this.rawObject);
|
|
2546
|
-
if (!retargeted) continue;
|
|
2547
|
-
retargeted.name = anim.clipName || anim.name || rawClip.name;
|
|
2548
|
-
this.allAnimations.push(retargeted);
|
|
2549
|
-
this.animationMetadataList.push({
|
|
2550
|
-
id: anim.id,
|
|
2551
|
-
name: anim.name,
|
|
2552
|
-
intent: anim.intent,
|
|
2553
|
-
clipName: anim.clipName,
|
|
2554
|
-
loopMode: anim.loopMode,
|
|
2555
|
-
clip: retargeted
|
|
2556
|
-
});
|
|
2557
|
-
}
|
|
2558
|
-
} catch (err) {
|
|
2559
|
-
if (typeof console !== "undefined" && typeof console.warn === "function") {
|
|
2560
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
2561
|
-
console.warn(`[asiyst] Failed to load external animation "${anim.name}": ${msg}`);
|
|
2562
|
-
}
|
|
2567
|
+
const pending = animations.filter(
|
|
2568
|
+
(anim) => {
|
|
2569
|
+
if (!anim.assetUrl) return false;
|
|
2570
|
+
const key = (anim.id || anim.name).toLowerCase();
|
|
2571
|
+
return !this.animationMetadataList.some(
|
|
2572
|
+
(m) => m.id && m.id.toLowerCase() === key || m.name.toLowerCase() === key
|
|
2573
|
+
);
|
|
2563
2574
|
}
|
|
2575
|
+
);
|
|
2576
|
+
if (pending.length > 0) {
|
|
2577
|
+
await Promise.allSettled(
|
|
2578
|
+
pending.map(async (anim) => {
|
|
2579
|
+
try {
|
|
2580
|
+
const loaded = await this.assetLoader.load(anim.assetUrl);
|
|
2581
|
+
let extractedClips = [];
|
|
2582
|
+
if (loaded.format === "fbx") {
|
|
2583
|
+
const loader = new FBXLoader_js.FBXLoader();
|
|
2584
|
+
if (loaded.resourcePath) {
|
|
2585
|
+
loader.setResourcePath(loaded.resourcePath);
|
|
2586
|
+
}
|
|
2587
|
+
const parsed = loader.parse(loaded.buffer, loaded.resourcePath || "");
|
|
2588
|
+
extractedClips = parsed.animations || [];
|
|
2589
|
+
} else if (loaded.format === "glb") {
|
|
2590
|
+
const loader = new GLTFLoader_js.GLTFLoader();
|
|
2591
|
+
const gltf = await new Promise((resolve, reject) => {
|
|
2592
|
+
const glbBuffer = loaded.bin.buffer.slice(
|
|
2593
|
+
loaded.bin.byteOffset,
|
|
2594
|
+
loaded.bin.byteOffset + loaded.bin.byteLength
|
|
2595
|
+
);
|
|
2596
|
+
loader.parse(glbBuffer, loaded.url, resolve, reject);
|
|
2597
|
+
});
|
|
2598
|
+
extractedClips = gltf.animations || [];
|
|
2599
|
+
}
|
|
2600
|
+
for (const rawClip of extractedClips) {
|
|
2601
|
+
const retargeted = this.retargetClip(rawClip, this.rawObject);
|
|
2602
|
+
if (!retargeted) continue;
|
|
2603
|
+
retargeted.name = anim.clipName || anim.name || rawClip.name;
|
|
2604
|
+
this.allAnimations.push(retargeted);
|
|
2605
|
+
this.animationMetadataList.push({
|
|
2606
|
+
id: anim.id,
|
|
2607
|
+
name: anim.name,
|
|
2608
|
+
intent: anim.intent,
|
|
2609
|
+
clipName: anim.clipName,
|
|
2610
|
+
loopMode: anim.loopMode,
|
|
2611
|
+
clip: retargeted
|
|
2612
|
+
});
|
|
2613
|
+
}
|
|
2614
|
+
} catch (err) {
|
|
2615
|
+
if (typeof console !== "undefined" && typeof console.warn === "function") {
|
|
2616
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
2617
|
+
console.warn(`[asiyst] Failed to load external animation "${anim.name}": ${msg}`);
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
})
|
|
2621
|
+
);
|
|
2564
2622
|
}
|
|
2565
2623
|
if (this.currentPose === "idle" || targetAnimationName) {
|
|
2566
2624
|
this.startInitialIdleAnimation({ animation: targetAnimationName });
|
|
@@ -2697,9 +2755,17 @@ var FbxRenderer = class {
|
|
|
2697
2755
|
}
|
|
2698
2756
|
startLoop() {
|
|
2699
2757
|
if (typeof requestAnimationFrame === "undefined") return;
|
|
2758
|
+
if (this.animFrameId !== null && typeof cancelAnimationFrame !== "undefined") {
|
|
2759
|
+
cancelAnimationFrame(this.animFrameId);
|
|
2760
|
+
this.animFrameId = null;
|
|
2761
|
+
}
|
|
2700
2762
|
this.lastTime = typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
2701
2763
|
const tick = (now) => {
|
|
2702
2764
|
if (!this.renderer || !this.scene || !this.camera) return;
|
|
2765
|
+
if (typeof document !== "undefined" && document.hidden) {
|
|
2766
|
+
this.animFrameId = requestAnimationFrame(tick);
|
|
2767
|
+
return;
|
|
2768
|
+
}
|
|
2703
2769
|
const current = now || (typeof performance !== "undefined" ? performance.now() : Date.now());
|
|
2704
2770
|
const delta = Math.min(Math.max((current - this.lastTime) / 1e3, 0), 0.1);
|
|
2705
2771
|
this.lastTime = current;
|
|
@@ -2769,14 +2835,23 @@ var FbxRenderer = class {
|
|
|
2769
2835
|
handleResize() {
|
|
2770
2836
|
if (!this.canvas || !this.renderer || !this.camera) return;
|
|
2771
2837
|
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
2772
|
-
const width = isMobile ?
|
|
2773
|
-
const height = isMobile ?
|
|
2838
|
+
const width = isMobile ? 140 : 190;
|
|
2839
|
+
const height = isMobile ? 280 : 360;
|
|
2774
2840
|
const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
|
|
2775
2841
|
this.canvas.width = Math.round(width * dpr);
|
|
2776
2842
|
this.canvas.height = Math.round(height * dpr);
|
|
2777
2843
|
this.canvas.style.width = `${width}px`;
|
|
2778
2844
|
this.canvas.style.height = `${height}px`;
|
|
2779
|
-
|
|
2845
|
+
const aspect = width / height;
|
|
2846
|
+
this.camera.aspect = aspect;
|
|
2847
|
+
const targetVisualHeight = 1.8;
|
|
2848
|
+
const visualCenterY = targetVisualHeight * 0.5;
|
|
2849
|
+
const fovRadians = this.camera.fov * Math.PI / 180;
|
|
2850
|
+
const fitDistV = targetVisualHeight * 1.35 / 2 / Math.tan(fovRadians / 2);
|
|
2851
|
+
const fitDistH = 1.1 / 2 / (aspect * Math.tan(fovRadians / 2));
|
|
2852
|
+
const fitDist = Math.max(fitDistV, fitDistH, 2.85);
|
|
2853
|
+
this.camera.position.set(0, visualCenterY, fitDist);
|
|
2854
|
+
this.camera.lookAt(0, visualCenterY, 0);
|
|
2780
2855
|
this.camera.updateProjectionMatrix();
|
|
2781
2856
|
this.renderer.setPixelRatio(Math.min(dpr, 2));
|
|
2782
2857
|
this.renderer.setSize(width, height, false);
|
|
@@ -2801,7 +2876,7 @@ var AVATAR_CSS = `
|
|
|
2801
2876
|
flex-direction: column;
|
|
2802
2877
|
align-items: center;
|
|
2803
2878
|
gap: 4px;
|
|
2804
|
-
pointer-events:
|
|
2879
|
+
pointer-events: none;
|
|
2805
2880
|
user-select: none;
|
|
2806
2881
|
}
|
|
2807
2882
|
.asiyst-avatar.asiyst-animate {
|
|
@@ -2812,11 +2887,27 @@ var AVATAR_CSS = `
|
|
|
2812
2887
|
place-items: center;
|
|
2813
2888
|
position: relative;
|
|
2814
2889
|
cursor: pointer;
|
|
2815
|
-
border:
|
|
2890
|
+
border: 0 !important;
|
|
2816
2891
|
padding: 0;
|
|
2817
|
-
|
|
2818
|
-
|
|
2892
|
+
margin: 0;
|
|
2893
|
+
outline: none !important;
|
|
2894
|
+
background: transparent !important;
|
|
2895
|
+
box-shadow: none !important;
|
|
2819
2896
|
overflow: visible;
|
|
2897
|
+
-webkit-appearance: none;
|
|
2898
|
+
appearance: none;
|
|
2899
|
+
-webkit-tap-highlight-color: transparent;
|
|
2900
|
+
}
|
|
2901
|
+
.asiyst-figure:focus,
|
|
2902
|
+
.asiyst-figure:focus-visible,
|
|
2903
|
+
.asiyst-figure:active {
|
|
2904
|
+
outline: none !important;
|
|
2905
|
+
border: 0 !important;
|
|
2906
|
+
box-shadow: none !important;
|
|
2907
|
+
}
|
|
2908
|
+
.asiyst-figure::-moz-focus-inner {
|
|
2909
|
+
border: 0 !important;
|
|
2910
|
+
padding: 0;
|
|
2820
2911
|
}
|
|
2821
2912
|
.asiyst-figure.asiyst-compact-launcher {
|
|
2822
2913
|
border-radius: 28px;
|
|
@@ -2824,20 +2915,24 @@ var AVATAR_CSS = `
|
|
|
2824
2915
|
font: 700 14px/1.2 system-ui, sans-serif;
|
|
2825
2916
|
box-shadow: 0 10px 30px rgba(15, 23, 42, 0.28);
|
|
2826
2917
|
overflow: hidden;
|
|
2827
|
-
background: #2563eb;
|
|
2918
|
+
background: #2563eb !important;
|
|
2919
|
+
pointer-events: auto;
|
|
2828
2920
|
}
|
|
2829
2921
|
.asiyst-figure.asiyst-3d-active {
|
|
2830
|
-
width:
|
|
2831
|
-
height:
|
|
2922
|
+
width: 190px !important;
|
|
2923
|
+
height: 360px !important;
|
|
2832
2924
|
background: transparent !important;
|
|
2925
|
+
border: 0 !important;
|
|
2833
2926
|
border-radius: 0 !important;
|
|
2834
2927
|
box-shadow: none !important;
|
|
2928
|
+
outline: none !important;
|
|
2835
2929
|
overflow: visible !important;
|
|
2930
|
+
pointer-events: none;
|
|
2836
2931
|
}
|
|
2837
2932
|
@media (max-width: 640px) {
|
|
2838
2933
|
.asiyst-figure.asiyst-3d-active {
|
|
2839
|
-
width:
|
|
2840
|
-
height:
|
|
2934
|
+
width: 140px !important;
|
|
2935
|
+
height: 280px !important;
|
|
2841
2936
|
}
|
|
2842
2937
|
}
|
|
2843
2938
|
.asiyst-avatar-viewport {
|
|
@@ -2846,16 +2941,23 @@ var AVATAR_CSS = `
|
|
|
2846
2941
|
height: 100%;
|
|
2847
2942
|
display: grid;
|
|
2848
2943
|
place-items: center;
|
|
2944
|
+
border: 0 !important;
|
|
2945
|
+
outline: none !important;
|
|
2946
|
+
background: transparent !important;
|
|
2849
2947
|
border-radius: inherit;
|
|
2850
2948
|
overflow: visible;
|
|
2851
|
-
pointer-events:
|
|
2949
|
+
pointer-events: none;
|
|
2852
2950
|
}
|
|
2853
2951
|
.asiyst-avatar-canvas {
|
|
2854
2952
|
width: 100%;
|
|
2855
2953
|
height: 100%;
|
|
2856
2954
|
object-fit: contain;
|
|
2857
2955
|
display: block;
|
|
2858
|
-
|
|
2956
|
+
border: 0 !important;
|
|
2957
|
+
outline: none !important;
|
|
2958
|
+
background: transparent !important;
|
|
2959
|
+
box-shadow: none !important;
|
|
2960
|
+
pointer-events: none;
|
|
2859
2961
|
}
|
|
2860
2962
|
.asiyst-avatar-graphic {
|
|
2861
2963
|
width: 100%;
|
|
@@ -3005,6 +3107,9 @@ var CssAvatarRenderer = class {
|
|
|
3005
3107
|
this.isAssetLoadedFlag = false;
|
|
3006
3108
|
this.isFallbackFlag = false;
|
|
3007
3109
|
}
|
|
3110
|
+
setMetricsTracker(tracker) {
|
|
3111
|
+
this.metricsTracker = tracker;
|
|
3112
|
+
}
|
|
3008
3113
|
mount(container, config) {
|
|
3009
3114
|
const doc = container.ownerDocument;
|
|
3010
3115
|
const style = doc.createElement("style");
|
|
@@ -3141,7 +3246,10 @@ var CssAvatarRenderer = class {
|
|
|
3141
3246
|
this.chatActionBtn.style.display = open ? "none" : "inline-flex";
|
|
3142
3247
|
}
|
|
3143
3248
|
}
|
|
3144
|
-
async loadAsset(config) {
|
|
3249
|
+
async loadAsset(config, metricsTracker) {
|
|
3250
|
+
if (metricsTracker) {
|
|
3251
|
+
this.metricsTracker = metricsTracker;
|
|
3252
|
+
}
|
|
3145
3253
|
const assetUrl = config.assetUrl ?? config.thumbnailUrl;
|
|
3146
3254
|
if (!assetUrl) {
|
|
3147
3255
|
this.renderState = "idle";
|
|
@@ -3173,8 +3281,16 @@ var CssAvatarRenderer = class {
|
|
|
3173
3281
|
this.renderLoader();
|
|
3174
3282
|
}
|
|
3175
3283
|
try {
|
|
3284
|
+
this.metricsTracker?.record("assetRequestStart");
|
|
3176
3285
|
const asset = await this.assetLoader.load(assetUrl, { timeoutMs: 6e4 });
|
|
3286
|
+
this.metricsTracker?.record("assetDownloadComplete");
|
|
3287
|
+
const byteSize = asset.buffer?.byteLength ?? asset.bin?.byteLength ?? asset.size;
|
|
3288
|
+
this.metricsTracker?.setAssetInfo({
|
|
3289
|
+
format: asset.format,
|
|
3290
|
+
byteSize: typeof byteSize === "number" ? byteSize : void 0
|
|
3291
|
+
});
|
|
3177
3292
|
await this.renderLoadedAsset(asset, config);
|
|
3293
|
+
this.metricsTracker?.record("parseAndDecodeComplete");
|
|
3178
3294
|
this.renderState = "ready";
|
|
3179
3295
|
this.isAssetLoadedFlag = true;
|
|
3180
3296
|
this.isFallbackFlag = false;
|
|
@@ -3238,14 +3354,20 @@ var CssAvatarRenderer = class {
|
|
|
3238
3354
|
}
|
|
3239
3355
|
if (asset.format === "fbx" || asset.format === "glb") {
|
|
3240
3356
|
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
3241
|
-
const width = isMobile ?
|
|
3242
|
-
const height = isMobile ?
|
|
3357
|
+
const width = isMobile ? 140 : 190;
|
|
3358
|
+
const height = isMobile ? 280 : 360;
|
|
3243
3359
|
this.fbxRenderer = new FbxRenderer();
|
|
3244
3360
|
this.renderMetrics = await this.fbxRenderer.mount(this.viewport, asset, {
|
|
3245
3361
|
accentColor: this.accentColor,
|
|
3246
3362
|
config,
|
|
3247
3363
|
width,
|
|
3248
|
-
height
|
|
3364
|
+
height,
|
|
3365
|
+
metricsTracker: this.metricsTracker
|
|
3366
|
+
});
|
|
3367
|
+
this.metricsTracker?.setAssetInfo({
|
|
3368
|
+
meshCount: this.renderMetrics.meshCount,
|
|
3369
|
+
vertexCount: this.renderMetrics.vertexCount,
|
|
3370
|
+
animationCount: this.renderMetrics.animationCount
|
|
3249
3371
|
});
|
|
3250
3372
|
this.fbxRenderer.setFacing(this.facing);
|
|
3251
3373
|
this.fbxRenderer.setPose(this.pose);
|
|
@@ -3336,7 +3458,7 @@ var CssAvatarRenderer = class {
|
|
|
3336
3458
|
getSize() {
|
|
3337
3459
|
if (this.isAssetLoadedFlag || this.has3dAssetConfigured) {
|
|
3338
3460
|
const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
|
|
3339
|
-
return { width: isMobile ?
|
|
3461
|
+
return { width: isMobile ? 140 : 190, height: isMobile ? 310 : 390 };
|
|
3340
3462
|
}
|
|
3341
3463
|
return { width: this.size, height: this.size + 28 };
|
|
3342
3464
|
}
|
|
@@ -4196,9 +4318,9 @@ var ConversationPanel = class {
|
|
|
4196
4318
|
this.style.textContent = `
|
|
4197
4319
|
.asiyst-panel {
|
|
4198
4320
|
position: fixed;
|
|
4199
|
-
right:
|
|
4321
|
+
right: 216px;
|
|
4200
4322
|
bottom: 20px;
|
|
4201
|
-
width: min(380px, calc(100vw -
|
|
4323
|
+
width: min(380px, calc(100vw - 240px));
|
|
4202
4324
|
max-height: min(560px, 75vh);
|
|
4203
4325
|
background: #ffffff;
|
|
4204
4326
|
color: #0f172a;
|
|
@@ -4582,10 +4704,59 @@ function createSdkLifecycleEmitter(sink) {
|
|
|
4582
4704
|
return new LifecycleEmitter(new UnsupportedLifecycleSink());
|
|
4583
4705
|
}
|
|
4584
4706
|
|
|
4707
|
+
// src/avatar/AvatarMetrics.ts
|
|
4708
|
+
var AvatarMetricsTracker = class {
|
|
4709
|
+
constructor() {
|
|
4710
|
+
this.timestamps = {};
|
|
4711
|
+
this.assetInfo = {};
|
|
4712
|
+
}
|
|
4713
|
+
record(step, timestamp = typeof performance !== "undefined" ? performance.now() : Date.now()) {
|
|
4714
|
+
if (!this.timestamps[step]) {
|
|
4715
|
+
this.timestamps[step] = timestamp;
|
|
4716
|
+
}
|
|
4717
|
+
}
|
|
4718
|
+
setAssetInfo(info) {
|
|
4719
|
+
this.assetInfo = { ...this.assetInfo, ...info };
|
|
4720
|
+
}
|
|
4721
|
+
getMetrics() {
|
|
4722
|
+
const t = this.timestamps;
|
|
4723
|
+
const base = t.sdkInit ?? t.containerCreated ?? 0;
|
|
4724
|
+
const downloadStart = t.assetRequestStart ?? base;
|
|
4725
|
+
const downloadEnd = t.assetDownloadComplete ?? downloadStart;
|
|
4726
|
+
const parseEnd = t.parseAndDecodeComplete ?? downloadEnd;
|
|
4727
|
+
const sceneEnd = t.sceneInitComplete ?? parseEnd;
|
|
4728
|
+
const firstRender = t.firstRenderedFrame ?? sceneEnd;
|
|
4729
|
+
const firstVisible = t.firstVisibleCorrectlyFramed ?? firstRender;
|
|
4730
|
+
return {
|
|
4731
|
+
timestamps: {
|
|
4732
|
+
sdkInit: t.sdkInit ?? base,
|
|
4733
|
+
containerCreated: t.containerCreated ?? base,
|
|
4734
|
+
configRetrieved: t.configRetrieved ?? base,
|
|
4735
|
+
assetRequestStart: downloadStart,
|
|
4736
|
+
assetDownloadComplete: downloadEnd,
|
|
4737
|
+
parseAndDecodeComplete: parseEnd,
|
|
4738
|
+
sceneInitComplete: sceneEnd,
|
|
4739
|
+
firstRenderedFrame: firstRender,
|
|
4740
|
+
firstVisibleCorrectlyFramed: firstVisible
|
|
4741
|
+
},
|
|
4742
|
+
durations: {
|
|
4743
|
+
configRetrievalMs: Math.max(0, (t.configRetrieved ?? base) - base),
|
|
4744
|
+
downloadDurationMs: Math.max(0, downloadEnd - downloadStart),
|
|
4745
|
+
parseDurationMs: Math.max(0, parseEnd - downloadEnd),
|
|
4746
|
+
sceneInitDurationMs: Math.max(0, sceneEnd - parseEnd),
|
|
4747
|
+
firstRenderDurationMs: Math.max(0, firstRender - sceneEnd),
|
|
4748
|
+
timeToFirstVisibleMs: Math.max(0, firstVisible - base)
|
|
4749
|
+
},
|
|
4750
|
+
asset: { ...this.assetInfo }
|
|
4751
|
+
};
|
|
4752
|
+
}
|
|
4753
|
+
};
|
|
4754
|
+
|
|
4585
4755
|
// src/core/Runtime.ts
|
|
4586
4756
|
var AsiystRuntime = class {
|
|
4587
4757
|
constructor(options, doc, win) {
|
|
4588
4758
|
this.events = new EventBus();
|
|
4759
|
+
this.metricsTracker = new AvatarMetricsTracker();
|
|
4589
4760
|
this.map = new WebsiteMap();
|
|
4590
4761
|
this.observer = new DomObserver(() => this.rescan());
|
|
4591
4762
|
this.lifecycle = createSdkLifecycleEmitter();
|
|
@@ -4633,6 +4804,9 @@ var AsiystRuntime = class {
|
|
|
4633
4804
|
this.renderer = new CssAvatarRenderer();
|
|
4634
4805
|
this.renderer.onOpenChat = () => this.open();
|
|
4635
4806
|
this.renderer.mount(this.host.chrome, this.config.get());
|
|
4807
|
+
this.metricsTracker.record("sdkInit");
|
|
4808
|
+
this.metricsTracker.record("containerCreated");
|
|
4809
|
+
this.renderer.setMetricsTracker(this.metricsTracker);
|
|
4636
4810
|
this.highlights = new HighlightLayer(this.host.overlay, win);
|
|
4637
4811
|
this.movement = new MovementEngine(win, doc, this.renderer, this.resolver, this.events, () => this.config.get());
|
|
4638
4812
|
const live = createLiveRegion(this.host.shadow);
|
|
@@ -4683,7 +4857,10 @@ var AsiystRuntime = class {
|
|
|
4683
4857
|
}
|
|
4684
4858
|
async start() {
|
|
4685
4859
|
this.events.emit("asiyst:initialized", { projectId: this.options.projectId });
|
|
4860
|
+
this.avatar.show();
|
|
4861
|
+
this.movement.goToAnchor();
|
|
4686
4862
|
const cfg = await isolateAsync(() => this.config.refresh(), this.config.get());
|
|
4863
|
+
this.metricsTracker.record("configRetrieved");
|
|
4687
4864
|
const domainCheck = validateWebsiteDomain(cfg, window.location.href);
|
|
4688
4865
|
if (!domainCheck.allowed) {
|
|
4689
4866
|
this.connectionStatus = "disconnected";
|
|
@@ -4742,7 +4919,7 @@ var AsiystRuntime = class {
|
|
|
4742
4919
|
assetUrl: assetTarget
|
|
4743
4920
|
});
|
|
4744
4921
|
try {
|
|
4745
|
-
const loaded = await this.renderer.loadAsset(cfg);
|
|
4922
|
+
const loaded = await this.renderer.loadAsset(cfg, this.metricsTracker);
|
|
4746
4923
|
if (loaded) {
|
|
4747
4924
|
this.movement.goToAnchor();
|
|
4748
4925
|
const format = this.renderer.getLoadedFormat();
|
|
@@ -4761,15 +4938,19 @@ var AsiystRuntime = class {
|
|
|
4761
4938
|
publishedVersion: cfg.publishedVersion
|
|
4762
4939
|
});
|
|
4763
4940
|
if (isRendered) {
|
|
4941
|
+
const metrics = this.metricsTracker.getMetrics();
|
|
4942
|
+
const durationMs = metrics?.durations.timeToFirstVisibleMs;
|
|
4764
4943
|
this.events.emit("asiyst:avatar:rendered", {
|
|
4765
4944
|
avatarId: this.options.avatarId ?? cfg.avatarId,
|
|
4766
|
-
format
|
|
4945
|
+
format,
|
|
4946
|
+
durationMs
|
|
4767
4947
|
});
|
|
4768
4948
|
void this.cloud.sendTelemetryEvent("avatar_rendered", {
|
|
4769
4949
|
avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
|
|
4770
4950
|
avatarName: cfg.avatarName,
|
|
4771
4951
|
format,
|
|
4772
|
-
publishedVersion: cfg.publishedVersion
|
|
4952
|
+
publishedVersion: cfg.publishedVersion,
|
|
4953
|
+
durationMs
|
|
4773
4954
|
});
|
|
4774
4955
|
}
|
|
4775
4956
|
return true;
|
|
@@ -4889,6 +5070,9 @@ var AsiystRuntime = class {
|
|
|
4889
5070
|
getRenderer() {
|
|
4890
5071
|
return this.renderer;
|
|
4891
5072
|
}
|
|
5073
|
+
getAvatarPerformanceMetrics() {
|
|
5074
|
+
return this.metricsTracker.getMetrics();
|
|
5075
|
+
}
|
|
4892
5076
|
avatarApi() {
|
|
4893
5077
|
return this.avatar;
|
|
4894
5078
|
}
|
|
@@ -5215,6 +5399,9 @@ var Asiyst = {
|
|
|
5215
5399
|
isRuntimeConnected() {
|
|
5216
5400
|
return requireRuntime().getConnectionStatus() === "connected";
|
|
5217
5401
|
},
|
|
5402
|
+
getAvatarPerformanceMetrics() {
|
|
5403
|
+
return requireRuntime().getAvatarPerformanceMetrics();
|
|
5404
|
+
},
|
|
5218
5405
|
avatar: {
|
|
5219
5406
|
show() {
|
|
5220
5407
|
withIsolation(() => requireRuntime().avatarApi().show());
|
|
@@ -5278,6 +5465,7 @@ exports.Asiyst = Asiyst;
|
|
|
5278
5465
|
exports.AsiystError = AsiystError;
|
|
5279
5466
|
exports.AssetLoader = AssetLoader;
|
|
5280
5467
|
exports.AuthenticationError = AuthenticationError;
|
|
5468
|
+
exports.AvatarMetricsTracker = AvatarMetricsTracker;
|
|
5281
5469
|
exports.ConfigurationError = ConfigurationError;
|
|
5282
5470
|
exports.CssAvatarRenderer = CssAvatarRenderer;
|
|
5283
5471
|
exports.FbxRenderer = FbxRenderer;
|