@asiyst/sdk 0.1.27 → 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 CHANGED
@@ -97,7 +97,7 @@ var ALL_ACTION_KINDS = [
97
97
  // src/core/constants.ts
98
98
  function resolveSdkVersion() {
99
99
  {
100
- return "0.1.26";
100
+ return "0.1.28";
101
101
  }
102
102
  }
103
103
  var SDK_VERSION = resolveSdkVersion();
@@ -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;
@@ -2242,18 +2243,23 @@ var FbxRenderer = class {
2242
2243
  this.canvas.setAttribute("role", "presentation");
2243
2244
  this.canvas.style.opacity = "0";
2244
2245
  this.canvas.style.transition = "opacity 0.25s ease";
2246
+ this.canvas.style.background = "transparent";
2245
2247
  const glContext = this.canvas.getContext("webgl2") || this.canvas.getContext("webgl");
2246
2248
  if (!glContext) {
2247
2249
  throw new Error("WebGLRenderingContext is not available or supported in this browser environment");
2248
2250
  }
2249
2251
  const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
2250
- const width = options?.width || (isMobile ? 180 : 240);
2251
- const height = options?.height || (isMobile ? 360 : 460);
2252
+ const width = options?.width || (isMobile ? 140 : 190);
2253
+ const height = options?.height || (isMobile ? 280 : 360);
2252
2254
  const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
2253
2255
  this.canvas.width = Math.round(width * dpr);
2254
2256
  this.canvas.height = Math.round(height * dpr);
2255
2257
  this.canvas.style.width = `${width}px`;
2256
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";
2257
2263
  try {
2258
2264
  this.renderer = new THREE__namespace.WebGLRenderer({
2259
2265
  canvas: this.canvas,
@@ -2261,6 +2267,7 @@ var FbxRenderer = class {
2261
2267
  antialias: true,
2262
2268
  powerPreference: "high-performance"
2263
2269
  });
2270
+ this.renderer.setClearColor(0, 0);
2264
2271
  this.renderer.setPixelRatio(Math.min(dpr, 2));
2265
2272
  this.renderer.setSize(width, height, false);
2266
2273
  this.renderer.outputColorSpace = THREE__namespace.SRGBColorSpace;
@@ -2279,6 +2286,13 @@ var FbxRenderer = class {
2279
2286
  keyLight.castShadow = true;
2280
2287
  keyLight.shadow.mapSize.width = 512;
2281
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;
2282
2296
  this.scene.add(keyLight);
2283
2297
  const fillLight = new THREE__namespace.DirectionalLight(15459032, 1.2);
2284
2298
  fillLight.position.set(-3, 2, 2);
@@ -2287,7 +2301,13 @@ var FbxRenderer = class {
2287
2301
  rimLight.position.set(0, 4, -3);
2288
2302
  this.scene.add(rimLight);
2289
2303
  const shadowGeo = new THREE__namespace.PlaneGeometry(3, 3);
2290
- const shadowMat = new THREE__namespace.ShadowMaterial({ opacity: 0.15 });
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;
2291
2311
  const shadowPlane = new THREE__namespace.Mesh(shadowGeo, shadowMat);
2292
2312
  shadowPlane.rotation.x = -Math.PI / 2;
2293
2313
  shadowPlane.position.y = 0;
@@ -2339,14 +2359,18 @@ var FbxRenderer = class {
2339
2359
  rawObject.position.set(-rawCenter.x, -rawBox.min.y, -rawCenter.z);
2340
2360
  const targetVisualHeight = 1.8;
2341
2361
  const targetScale = targetVisualHeight / rawHeight;
2362
+ this.baseScale = targetScale;
2342
2363
  this.modelRoot = new THREE__namespace.Group();
2343
2364
  this.modelRoot.add(rawObject);
2344
2365
  this.modelRoot.scale.setScalar(targetScale);
2345
2366
  this.scene.add(this.modelRoot);
2346
- const visualCenterY = targetVisualHeight * 0.52;
2367
+ const visualCenterY = targetVisualHeight * 0.5;
2347
2368
  const fovRadians = this.camera.fov * Math.PI / 180;
2348
- const fitDist = Math.max(2.4, targetVisualHeight / 2 / Math.tan(fovRadians / 2) * 1.25);
2349
- this.camera.position.set(0, visualCenterY + 0.1, fitDist);
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);
2350
2374
  this.camera.lookAt(0, visualCenterY, 0);
2351
2375
  rawObject.traverse((child) => {
2352
2376
  const mesh = child;
@@ -2355,24 +2379,41 @@ var FbxRenderer = class {
2355
2379
  mesh.receiveShadow = true;
2356
2380
  }
2357
2381
  });
2382
+ options?.metricsTracker?.record("sceneInitComplete");
2358
2383
  this.rawObject = rawObject;
2359
2384
  this.mixer = new THREE__namespace.AnimationMixer(rawObject);
2360
2385
  this.allAnimations = [...modelAnimations];
2361
- if (modelAnimations.length > 0) {
2362
- const idleClip = modelAnimations.find((c) => c.name.toLowerCase().includes("idle")) || modelAnimations[0];
2363
- if (idleClip) {
2364
- this.currentAction = this.mixer.clipAction(idleClip);
2365
- this.currentAction.play();
2386
+ const externalAnims = options?.config?.animations || options?.config?.avatar?.animations || [];
2387
+ if (externalAnims.length > 0) {
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
+ }
2398
+ }
2399
+ } else {
2400
+ void this.loadExternalAnimations(externalAnims, options?.config?.animation);
2366
2401
  }
2367
2402
  }
2403
+ this.startInitialIdleAnimation(options?.config);
2404
+ if (this.mixer) {
2405
+ this.mixer.update(0);
2406
+ }
2368
2407
  container.replaceChildren();
2369
2408
  container.appendChild(this.canvas);
2370
2409
  try {
2371
2410
  this.renderer.render(this.scene, this.camera);
2372
2411
  this.initialRenderCompleted = true;
2412
+ options?.metricsTracker?.record("firstRenderedFrame");
2373
2413
  if (this.canvas) {
2374
2414
  this.canvas.style.opacity = "1";
2375
2415
  }
2416
+ options?.metricsTracker?.record("firstVisibleCorrectlyFramed");
2376
2417
  } catch (renderErr) {
2377
2418
  const msg = renderErr instanceof Error ? renderErr.message : String(renderErr);
2378
2419
  throw new Error(`Initial FBX WebGL render failed: ${msg}`);
@@ -2380,9 +2421,6 @@ var FbxRenderer = class {
2380
2421
  this.startLoop();
2381
2422
  this.setFacing(this.facing);
2382
2423
  this.setPose(this.currentPose);
2383
- if (options?.config?.animations && options.config.animations.length > 0) {
2384
- void this.loadExternalAnimations(options.config.animations);
2385
- }
2386
2424
  if (typeof window !== "undefined") {
2387
2425
  this.resizeListener = () => this.handleResize();
2388
2426
  window.addEventListener("resize", this.resizeListener);
@@ -2390,7 +2428,7 @@ var FbxRenderer = class {
2390
2428
  return {
2391
2429
  meshCount,
2392
2430
  vertexCount: totalVertices,
2393
- animationCount: modelAnimations.length
2431
+ animationCount: this.allAnimations.length
2394
2432
  };
2395
2433
  }
2396
2434
  setFacing(direction) {
@@ -2401,11 +2439,10 @@ var FbxRenderer = class {
2401
2439
  }
2402
2440
  setPose(pose) {
2403
2441
  this.currentPose = pose;
2404
- if (!this.modelRoot) return;
2405
2442
  if (this.playAnimation(pose)) {
2406
2443
  return;
2407
2444
  }
2408
- if (this.mixer && this.allAnimations.length > 1) {
2445
+ if (this.mixer && this.allAnimations.length > 0) {
2409
2446
  let targetClip;
2410
2447
  if (pose === "speak") {
2411
2448
  targetClip = this.allAnimations.find(
@@ -2415,8 +2452,20 @@ var FbxRenderer = class {
2415
2452
  targetClip = this.allAnimations.find(
2416
2453
  (c) => c.name.toLowerCase().includes("think")
2417
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
+ );
2418
2467
  } else {
2419
- targetClip = this.allAnimations.find((c) => c.name.toLowerCase().includes("idle")) || this.allAnimations[0];
2468
+ targetClip = this.allAnimations.find((c) => c.name.toLowerCase().includes("idle")) || this.animationMetadataList[0]?.clip || this.allAnimations[0];
2420
2469
  }
2421
2470
  if (targetClip) {
2422
2471
  const newAction = this.mixer.clipAction(targetClip);
@@ -2427,26 +2476,36 @@ var FbxRenderer = class {
2427
2476
  }
2428
2477
  this.currentAction = newAction;
2429
2478
  return;
2479
+ } else if (!this.currentAction?.isRunning()) {
2480
+ this.currentAction?.play();
2481
+ return;
2430
2482
  }
2483
+ return;
2431
2484
  }
2432
2485
  }
2486
+ if (!this.modelRoot) return;
2487
+ this.modelRoot.scale.setScalar(this.baseScale);
2433
2488
  switch (pose) {
2434
2489
  case "point":
2435
- this.modelRoot.rotation.z = -0.15;
2436
- this.modelRoot.rotation.x = 0.08;
2490
+ this.modelRoot.rotation.z = -0.06;
2491
+ this.modelRoot.rotation.x = 0.03;
2437
2492
  break;
2438
2493
  case "think":
2439
- this.modelRoot.rotation.z = 0.12;
2440
- this.modelRoot.rotation.x = -0.1;
2494
+ this.modelRoot.rotation.z = 0.05;
2495
+ this.modelRoot.rotation.x = -0.04;
2441
2496
  break;
2442
2497
  case "speak":
2443
2498
  this.modelRoot.rotation.y = this.facing === "left" ? -0.22 : 0.22;
2444
- this.modelRoot.rotation.x = 0.04;
2499
+ this.modelRoot.rotation.x = 0.03;
2445
2500
  break;
2446
2501
  case "celebrate":
2447
2502
  this.modelRoot.rotation.z = 0;
2448
- this.modelRoot.rotation.x = -0.15;
2449
- this.modelRoot.scale.multiplyScalar(1.05);
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;
2450
2509
  break;
2451
2510
  default:
2452
2511
  this.modelRoot.rotation.z = 0;
@@ -2455,88 +2514,172 @@ var FbxRenderer = class {
2455
2514
  break;
2456
2515
  }
2457
2516
  }
2458
- async loadExternalAnimations(animations) {
2517
+ startInitialIdleAnimation(config) {
2518
+ if (!this.mixer) return false;
2519
+ const targetQuery = config?.animation?.trim();
2520
+ if (targetQuery && this.playAnimation(targetQuery)) {
2521
+ return true;
2522
+ }
2523
+ const idleByIntent = this.animationMetadataList.find(
2524
+ (m) => m.intent?.toLowerCase() === "idle"
2525
+ );
2526
+ if (idleByIntent && this.playAnimation(idleByIntent.id || idleByIntent.name)) {
2527
+ return true;
2528
+ }
2529
+ const idleByName = this.animationMetadataList.find(
2530
+ (m) => m.name.toLowerCase().includes("idle") || m.clipName && m.clipName.toLowerCase().includes("idle")
2531
+ );
2532
+ if (idleByName && this.playAnimation(idleByName.id || idleByName.name)) {
2533
+ return true;
2534
+ }
2535
+ const embeddedIdle = this.allAnimations.find(
2536
+ (c) => c.name.toLowerCase().includes("idle")
2537
+ );
2538
+ if (embeddedIdle) {
2539
+ const action = this.mixer.clipAction(embeddedIdle);
2540
+ if (this.currentAction !== action) {
2541
+ action.reset().fadeIn(0.25).play();
2542
+ if (this.currentAction) this.currentAction.fadeOut(0.25);
2543
+ this.currentAction = action;
2544
+ }
2545
+ return true;
2546
+ }
2547
+ if (this.animationMetadataList.length > 0) {
2548
+ const firstMeta = this.animationMetadataList[0];
2549
+ if (this.playAnimation(firstMeta.id || firstMeta.name)) {
2550
+ return true;
2551
+ }
2552
+ }
2553
+ if (this.allAnimations.length > 0) {
2554
+ const firstClip = this.allAnimations[0];
2555
+ const action = this.mixer.clipAction(firstClip);
2556
+ if (this.currentAction !== action) {
2557
+ action.reset().fadeIn(0.25).play();
2558
+ if (this.currentAction) this.currentAction.fadeOut(0.25);
2559
+ this.currentAction = action;
2560
+ }
2561
+ return true;
2562
+ }
2563
+ return false;
2564
+ }
2565
+ async loadExternalAnimations(animations, targetAnimationName) {
2459
2566
  if (!this.rawObject || !this.mixer) return;
2460
- for (const anim of animations) {
2461
- if (!anim.assetUrl) continue;
2462
- try {
2463
- const loaded = await this.assetLoader.load(anim.assetUrl);
2464
- let extractedClips = [];
2465
- if (loaded.format === "fbx") {
2466
- const loader = new FBXLoader_js.FBXLoader();
2467
- if (loaded.resourcePath) {
2468
- loader.setResourcePath(loaded.resourcePath);
2469
- }
2470
- const parsed = loader.parse(loaded.buffer, loaded.resourcePath || "");
2471
- extractedClips = parsed.animations || [];
2472
- } else if (loaded.format === "glb") {
2473
- const loader = new GLTFLoader_js.GLTFLoader();
2474
- const gltf = await new Promise((resolve, reject) => {
2475
- const glbBuffer = loaded.bin.buffer.slice(
2476
- loaded.bin.byteOffset,
2477
- loaded.bin.byteOffset + loaded.bin.byteLength
2478
- );
2479
- loader.parse(glbBuffer, loaded.url, resolve, reject);
2480
- });
2481
- extractedClips = gltf.animations || [];
2482
- }
2483
- for (const rawClip of extractedClips) {
2484
- const retargeted = this.retargetClip(rawClip, this.rawObject);
2485
- if (!retargeted) continue;
2486
- retargeted.name = anim.clipName || anim.name || rawClip.name;
2487
- this.allAnimations.push(retargeted);
2488
- this.animationMetadataList.push({
2489
- id: anim.id,
2490
- name: anim.name,
2491
- intent: anim.intent,
2492
- clipName: anim.clipName,
2493
- loopMode: anim.loopMode,
2494
- clip: retargeted
2495
- });
2496
- const animIntent = anim.intent?.toLowerCase();
2497
- const animName = anim.name.toLowerCase();
2498
- if (animIntent === this.currentPose || this.currentPose === "idle" && (animIntent === "idle" || animName === "idle")) {
2499
- this.playAnimation(anim.id || anim.name || this.currentPose, anim.loopMode);
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
+ );
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
+ }
2500
2619
  }
2501
- }
2502
- } catch (err) {
2503
- if (typeof console !== "undefined" && typeof console.warn === "function") {
2504
- const msg = err instanceof Error ? err.message : String(err);
2505
- console.warn(`[asiyst] Failed to load external animation "${anim.name}": ${msg}`);
2506
- }
2620
+ })
2621
+ );
2622
+ }
2623
+ if (this.currentPose === "idle" || targetAnimationName) {
2624
+ this.startInitialIdleAnimation({ animation: targetAnimationName });
2625
+ if (this.mixer) {
2626
+ this.mixer.update(0);
2507
2627
  }
2508
2628
  }
2509
2629
  }
2510
2630
  retargetClip(clip, targetObject) {
2511
2631
  const targetNodeNames = /* @__PURE__ */ new Set();
2512
- const boneMap = /* @__PURE__ */ new Map();
2632
+ const boneLookup = /* @__PURE__ */ new Map();
2633
+ const cleanBoneName = (name) => {
2634
+ return name.replace(/^.*[:|/]/, "").replace(/^(mixamorig\d*|bip01|armature|root)[:_ ]?/i, "").replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
2635
+ };
2513
2636
  targetObject.traverse((node) => {
2514
2637
  if (node.name) {
2515
2638
  targetNodeNames.add(node.name);
2516
- const clean = node.name.replace(/^.*[:|/]/, "").toLowerCase();
2517
- boneMap.set(clean, node.name);
2518
- boneMap.set(node.name.toLowerCase(), node.name);
2639
+ const lower = node.name.toLowerCase();
2640
+ const simpleClean = node.name.replace(/^.*[:|/]/, "").toLowerCase();
2641
+ const stripped = cleanBoneName(node.name);
2642
+ if (!boneLookup.has(lower)) boneLookup.set(lower, node.name);
2643
+ if (!boneLookup.has(simpleClean)) boneLookup.set(simpleClean, node.name);
2644
+ if (stripped && !boneLookup.has(stripped)) boneLookup.set(stripped, node.name);
2519
2645
  }
2520
2646
  });
2647
+ const isRootOrHips = (name) => {
2648
+ const clean = cleanBoneName(name);
2649
+ return clean === "hips" || clean === "pelvis" || clean === "root";
2650
+ };
2521
2651
  const validTracks = [];
2522
2652
  for (const track of clip.tracks) {
2523
2653
  const dotIdx = track.name.lastIndexOf(".");
2524
2654
  if (dotIdx === -1) continue;
2525
2655
  const nodePart = track.name.substring(0, dotIdx);
2526
2656
  const propPart = track.name.substring(dotIdx);
2657
+ let matchedNodeName;
2527
2658
  if (targetNodeNames.has(nodePart)) {
2528
- validTracks.push(track);
2659
+ matchedNodeName = nodePart;
2529
2660
  } else {
2530
- const clean = nodePart.replace(/^.*[:|/]/, "").toLowerCase();
2531
- const matched = boneMap.get(clean);
2532
- if (matched) {
2661
+ const lower = nodePart.toLowerCase();
2662
+ const simpleClean = nodePart.replace(/^.*[:|/]/, "").toLowerCase();
2663
+ const stripped = cleanBoneName(nodePart);
2664
+ matchedNodeName = boneLookup.get(lower) || boneLookup.get(simpleClean) || boneLookup.get(stripped);
2665
+ }
2666
+ if (matchedNodeName) {
2667
+ if (propPart.toLowerCase().startsWith(".position") && !isRootOrHips(matchedNodeName)) {
2668
+ continue;
2669
+ }
2670
+ if (matchedNodeName === nodePart) {
2671
+ validTracks.push(track);
2672
+ } else {
2533
2673
  const clonedTrack = track.clone();
2534
- clonedTrack.name = `${matched}${propPart}`;
2674
+ clonedTrack.name = `${matchedNodeName}${propPart}`;
2535
2675
  validTracks.push(clonedTrack);
2536
2676
  }
2537
2677
  }
2538
2678
  }
2539
- if (validTracks.length === 0) {
2679
+ if (validTracks.length === 0 || clip.duration <= 0) {
2680
+ if (typeof console !== "undefined" && typeof console.warn === "function") {
2681
+ console.warn(`[asiyst] External animation "${clip.name}" has no compatible bone tracks for this avatar skeleton.`);
2682
+ }
2540
2683
  return null;
2541
2684
  }
2542
2685
  return new THREE__namespace.AnimationClip(clip.name, clip.duration, validTracks);
@@ -2581,6 +2724,8 @@ var FbxRenderer = class {
2581
2724
  this.currentAction.fadeOut(crossFadeDuration);
2582
2725
  }
2583
2726
  this.currentAction = action;
2727
+ } else if (!action.isRunning()) {
2728
+ action.reset().play();
2584
2729
  }
2585
2730
  return true;
2586
2731
  }
@@ -2610,9 +2755,17 @@ var FbxRenderer = class {
2610
2755
  }
2611
2756
  startLoop() {
2612
2757
  if (typeof requestAnimationFrame === "undefined") return;
2758
+ if (this.animFrameId !== null && typeof cancelAnimationFrame !== "undefined") {
2759
+ cancelAnimationFrame(this.animFrameId);
2760
+ this.animFrameId = null;
2761
+ }
2613
2762
  this.lastTime = typeof performance !== "undefined" ? performance.now() : Date.now();
2614
2763
  const tick = (now) => {
2615
2764
  if (!this.renderer || !this.scene || !this.camera) return;
2765
+ if (typeof document !== "undefined" && document.hidden) {
2766
+ this.animFrameId = requestAnimationFrame(tick);
2767
+ return;
2768
+ }
2616
2769
  const current = now || (typeof performance !== "undefined" ? performance.now() : Date.now());
2617
2770
  const delta = Math.min(Math.max((current - this.lastTime) / 1e3, 0), 0.1);
2618
2771
  this.lastTime = current;
@@ -2682,14 +2835,23 @@ var FbxRenderer = class {
2682
2835
  handleResize() {
2683
2836
  if (!this.canvas || !this.renderer || !this.camera) return;
2684
2837
  const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
2685
- const width = isMobile ? 180 : 240;
2686
- const height = isMobile ? 360 : 460;
2838
+ const width = isMobile ? 140 : 190;
2839
+ const height = isMobile ? 280 : 360;
2687
2840
  const dpr = typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1;
2688
2841
  this.canvas.width = Math.round(width * dpr);
2689
2842
  this.canvas.height = Math.round(height * dpr);
2690
2843
  this.canvas.style.width = `${width}px`;
2691
2844
  this.canvas.style.height = `${height}px`;
2692
- this.camera.aspect = width / height;
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);
2693
2855
  this.camera.updateProjectionMatrix();
2694
2856
  this.renderer.setPixelRatio(Math.min(dpr, 2));
2695
2857
  this.renderer.setSize(width, height, false);
@@ -2714,40 +2876,63 @@ var AVATAR_CSS = `
2714
2876
  flex-direction: column;
2715
2877
  align-items: center;
2716
2878
  gap: 4px;
2717
- pointer-events: auto;
2879
+ pointer-events: none;
2718
2880
  user-select: none;
2719
2881
  }
2720
2882
  .asiyst-avatar.asiyst-animate {
2721
2883
  transition: left 420ms cubic-bezier(0.22, 1, 0.36, 1), top 420ms cubic-bezier(0.22, 1, 0.36, 1);
2722
2884
  }
2723
2885
  .asiyst-figure {
2724
- border-radius: 28px;
2725
2886
  display: grid;
2726
2887
  place-items: center;
2888
+ position: relative;
2889
+ cursor: pointer;
2890
+ border: 0 !important;
2891
+ padding: 0;
2892
+ margin: 0;
2893
+ outline: none !important;
2894
+ background: transparent !important;
2895
+ box-shadow: none !important;
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;
2911
+ }
2912
+ .asiyst-figure.asiyst-compact-launcher {
2913
+ border-radius: 28px;
2727
2914
  color: #fff;
2728
2915
  font: 700 14px/1.2 system-ui, sans-serif;
2729
2916
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.28);
2730
- position: relative;
2731
2917
  overflow: hidden;
2732
- cursor: pointer;
2733
- border: none;
2734
- padding: 0;
2735
- outline: none;
2736
- background: #2563eb;
2737
- transition: width 0.3s ease, height 0.3s ease, background 0.3s ease;
2918
+ background: #2563eb !important;
2919
+ pointer-events: auto;
2738
2920
  }
2739
2921
  .asiyst-figure.asiyst-3d-active {
2740
- width: 240px !important;
2741
- height: 460px !important;
2922
+ width: 190px !important;
2923
+ height: 360px !important;
2742
2924
  background: transparent !important;
2925
+ border: 0 !important;
2743
2926
  border-radius: 0 !important;
2744
2927
  box-shadow: none !important;
2928
+ outline: none !important;
2745
2929
  overflow: visible !important;
2930
+ pointer-events: none;
2746
2931
  }
2747
2932
  @media (max-width: 640px) {
2748
2933
  .asiyst-figure.asiyst-3d-active {
2749
- width: 180px !important;
2750
- height: 360px !important;
2934
+ width: 140px !important;
2935
+ height: 280px !important;
2751
2936
  }
2752
2937
  }
2753
2938
  .asiyst-avatar-viewport {
@@ -2756,16 +2941,23 @@ var AVATAR_CSS = `
2756
2941
  height: 100%;
2757
2942
  display: grid;
2758
2943
  place-items: center;
2944
+ border: 0 !important;
2945
+ outline: none !important;
2946
+ background: transparent !important;
2759
2947
  border-radius: inherit;
2760
2948
  overflow: visible;
2761
- pointer-events: auto;
2949
+ pointer-events: none;
2762
2950
  }
2763
2951
  .asiyst-avatar-canvas {
2764
2952
  width: 100%;
2765
2953
  height: 100%;
2766
2954
  object-fit: contain;
2767
2955
  display: block;
2768
- pointer-events: auto;
2956
+ border: 0 !important;
2957
+ outline: none !important;
2958
+ background: transparent !important;
2959
+ box-shadow: none !important;
2960
+ pointer-events: none;
2769
2961
  }
2770
2962
  .asiyst-avatar-graphic {
2771
2963
  width: 100%;
@@ -2901,7 +3093,7 @@ var AVATAR_CSS = `
2901
3093
  var CssAvatarRenderer = class {
2902
3094
  constructor() {
2903
3095
  this.size = 96;
2904
- this.hidden = false;
3096
+ this.hidden = true;
2905
3097
  this.facing = "right";
2906
3098
  this.pose = "idle";
2907
3099
  this.accentColor = "#2563eb";
@@ -2915,6 +3107,9 @@ var CssAvatarRenderer = class {
2915
3107
  this.isAssetLoadedFlag = false;
2916
3108
  this.isFallbackFlag = false;
2917
3109
  }
3110
+ setMetricsTracker(tracker) {
3111
+ this.metricsTracker = tracker;
3112
+ }
2918
3113
  mount(container, config) {
2919
3114
  const doc = container.ownerDocument;
2920
3115
  const style = doc.createElement("style");
@@ -2923,6 +3118,9 @@ var CssAvatarRenderer = class {
2923
3118
  this.root = doc.createElement("div");
2924
3119
  this.root.className = "asiyst-avatar asiyst-animate";
2925
3120
  this.root.setAttribute("role", "img");
3121
+ if (this.hidden) {
3122
+ this.root.style.display = "none";
3123
+ }
2926
3124
  this.nameTagEl = doc.createElement("div");
2927
3125
  this.nameTagEl.className = "asiyst-name-tag";
2928
3126
  const sparkle = doc.createElement("span");
@@ -2985,7 +3183,7 @@ var CssAvatarRenderer = class {
2985
3183
  this.size = config.size;
2986
3184
  this.accentColor = config.theme.accent ?? "#2563eb";
2987
3185
  this.avatarName = config.avatarName;
2988
- const has3dAsset = Boolean(config.assetUrl || config.thumbnailUrl);
3186
+ const has3dAsset = Boolean(config.assetUrl || config.thumbnailUrl || config.avatarId);
2989
3187
  this.has3dAssetConfigured = has3dAsset;
2990
3188
  if (config.assetUrl || config.thumbnailUrl) {
2991
3189
  this.activeAssetUrl = config.assetUrl ?? config.thumbnailUrl ?? void 0;
@@ -3005,10 +3203,14 @@ var CssAvatarRenderer = class {
3005
3203
  if (has3dAsset) {
3006
3204
  if (this.figure) {
3007
3205
  this.figure.classList.add("asiyst-3d-active");
3206
+ this.figure.classList.remove("asiyst-compact-launcher");
3008
3207
  this.figure.style.width = "";
3009
3208
  this.figure.style.height = "";
3010
3209
  this.figure.style.background = "transparent";
3011
3210
  }
3211
+ if (this.nameTagEl) {
3212
+ this.nameTagEl.style.display = this.isAssetLoadedFlag ? "inline-flex" : "none";
3213
+ }
3012
3214
  if (this.chatActionBtn) {
3013
3215
  this.chatActionBtn.style.display = this.isAssetLoadedFlag && !this.isPanelOpen ? "inline-flex" : "none";
3014
3216
  }
@@ -3016,16 +3218,20 @@ var CssAvatarRenderer = class {
3016
3218
  if (this.renderState === "error") {
3017
3219
  this.renderFallback(true);
3018
3220
  } else {
3019
- this.renderLoader();
3221
+ this.viewport.replaceChildren();
3020
3222
  }
3021
3223
  }
3022
3224
  } else {
3023
3225
  if (this.figure) {
3024
3226
  this.figure.classList.remove("asiyst-3d-active");
3227
+ this.figure.classList.add("asiyst-compact-launcher");
3025
3228
  this.figure.style.width = `${config.size}px`;
3026
3229
  this.figure.style.height = `${config.size}px`;
3027
3230
  this.figure.style.background = this.accentColor;
3028
3231
  }
3232
+ if (this.nameTagEl) {
3233
+ this.nameTagEl.style.display = "none";
3234
+ }
3029
3235
  if (this.chatActionBtn) {
3030
3236
  this.chatActionBtn.style.display = "none";
3031
3237
  }
@@ -3040,7 +3246,10 @@ var CssAvatarRenderer = class {
3040
3246
  this.chatActionBtn.style.display = open ? "none" : "inline-flex";
3041
3247
  }
3042
3248
  }
3043
- async loadAsset(config) {
3249
+ async loadAsset(config, metricsTracker) {
3250
+ if (metricsTracker) {
3251
+ this.metricsTracker = metricsTracker;
3252
+ }
3044
3253
  const assetUrl = config.assetUrl ?? config.thumbnailUrl;
3045
3254
  if (!assetUrl) {
3046
3255
  this.renderState = "idle";
@@ -3057,14 +3266,31 @@ var CssAvatarRenderer = class {
3057
3266
  if (this.figure) {
3058
3267
  this.figure.setAttribute("data-state", "loading");
3059
3268
  this.figure.classList.add("asiyst-3d-active");
3269
+ this.figure.classList.remove("asiyst-compact-launcher");
3060
3270
  this.figure.style.width = "";
3061
3271
  this.figure.style.height = "";
3062
3272
  this.figure.style.background = "transparent";
3063
3273
  }
3064
- this.renderLoader();
3274
+ if (this.nameTagEl) {
3275
+ this.nameTagEl.style.display = "none";
3276
+ }
3277
+ if (this.chatActionBtn) {
3278
+ this.chatActionBtn.style.display = "none";
3279
+ }
3280
+ if (this.viewport) {
3281
+ this.renderLoader();
3282
+ }
3065
3283
  try {
3284
+ this.metricsTracker?.record("assetRequestStart");
3066
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
+ });
3067
3292
  await this.renderLoadedAsset(asset, config);
3293
+ this.metricsTracker?.record("parseAndDecodeComplete");
3068
3294
  this.renderState = "ready";
3069
3295
  this.isAssetLoadedFlag = true;
3070
3296
  this.isFallbackFlag = false;
@@ -3072,10 +3298,14 @@ var CssAvatarRenderer = class {
3072
3298
  if (this.figure) {
3073
3299
  this.figure.setAttribute("data-state", "ready");
3074
3300
  this.figure.classList.add("asiyst-3d-active");
3301
+ this.figure.classList.remove("asiyst-compact-launcher");
3075
3302
  this.figure.style.width = "";
3076
3303
  this.figure.style.height = "";
3077
3304
  this.figure.style.background = "transparent";
3078
3305
  }
3306
+ if (this.nameTagEl) {
3307
+ this.nameTagEl.style.display = "inline-flex";
3308
+ }
3079
3309
  if (this.chatActionBtn) {
3080
3310
  this.chatActionBtn.style.display = this.isPanelOpen ? "none" : "inline-flex";
3081
3311
  }
@@ -3088,6 +3318,14 @@ var CssAvatarRenderer = class {
3088
3318
  this.isFallbackFlag = true;
3089
3319
  if (this.figure) {
3090
3320
  this.figure.setAttribute("data-state", "error");
3321
+ this.figure.classList.remove("asiyst-3d-active");
3322
+ this.figure.classList.add("asiyst-compact-launcher");
3323
+ this.figure.style.width = `${this.size}px`;
3324
+ this.figure.style.height = `${this.size}px`;
3325
+ this.figure.style.background = this.accentColor;
3326
+ }
3327
+ if (this.nameTagEl) {
3328
+ this.nameTagEl.style.display = "none";
3091
3329
  }
3092
3330
  if (this.chatActionBtn) {
3093
3331
  this.chatActionBtn.style.display = "none";
@@ -3116,14 +3354,20 @@ var CssAvatarRenderer = class {
3116
3354
  }
3117
3355
  if (asset.format === "fbx" || asset.format === "glb") {
3118
3356
  const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
3119
- const width = isMobile ? 180 : 240;
3120
- const height = isMobile ? 360 : 460;
3357
+ const width = isMobile ? 140 : 190;
3358
+ const height = isMobile ? 280 : 360;
3121
3359
  this.fbxRenderer = new FbxRenderer();
3122
3360
  this.renderMetrics = await this.fbxRenderer.mount(this.viewport, asset, {
3123
3361
  accentColor: this.accentColor,
3124
3362
  config,
3125
3363
  width,
3126
- 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
3127
3371
  });
3128
3372
  this.fbxRenderer.setFacing(this.facing);
3129
3373
  this.fbxRenderer.setPose(this.pose);
@@ -3214,7 +3458,7 @@ var CssAvatarRenderer = class {
3214
3458
  getSize() {
3215
3459
  if (this.isAssetLoadedFlag || this.has3dAssetConfigured) {
3216
3460
  const isMobile = typeof window !== "undefined" && window.innerWidth <= 640;
3217
- return { width: isMobile ? 180 : 240, height: isMobile ? 390 : 490 };
3461
+ return { width: isMobile ? 140 : 190, height: isMobile ? 310 : 390 };
3218
3462
  }
3219
3463
  return { width: this.size, height: this.size + 28 };
3220
3464
  }
@@ -4074,9 +4318,9 @@ var ConversationPanel = class {
4074
4318
  this.style.textContent = `
4075
4319
  .asiyst-panel {
4076
4320
  position: fixed;
4077
- right: 256px;
4321
+ right: 216px;
4078
4322
  bottom: 20px;
4079
- width: min(380px, calc(100vw - 280px));
4323
+ width: min(380px, calc(100vw - 240px));
4080
4324
  max-height: min(560px, 75vh);
4081
4325
  background: #ffffff;
4082
4326
  color: #0f172a;
@@ -4460,10 +4704,59 @@ function createSdkLifecycleEmitter(sink) {
4460
4704
  return new LifecycleEmitter(new UnsupportedLifecycleSink());
4461
4705
  }
4462
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
+
4463
4755
  // src/core/Runtime.ts
4464
4756
  var AsiystRuntime = class {
4465
4757
  constructor(options, doc, win) {
4466
4758
  this.events = new EventBus();
4759
+ this.metricsTracker = new AvatarMetricsTracker();
4467
4760
  this.map = new WebsiteMap();
4468
4761
  this.observer = new DomObserver(() => this.rescan());
4469
4762
  this.lifecycle = createSdkLifecycleEmitter();
@@ -4511,6 +4804,9 @@ var AsiystRuntime = class {
4511
4804
  this.renderer = new CssAvatarRenderer();
4512
4805
  this.renderer.onOpenChat = () => this.open();
4513
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);
4514
4810
  this.highlights = new HighlightLayer(this.host.overlay, win);
4515
4811
  this.movement = new MovementEngine(win, doc, this.renderer, this.resolver, this.events, () => this.config.get());
4516
4812
  const live = createLiveRegion(this.host.shadow);
@@ -4549,7 +4845,6 @@ var AsiystRuntime = class {
4549
4845
  this.movement.start();
4550
4846
  this.analytics.start();
4551
4847
  this.rescan();
4552
- this.avatar.show();
4553
4848
  const figure = this.renderer.getFigure();
4554
4849
  if (figure) {
4555
4850
  this.figureClickListener = () => this.open();
@@ -4562,7 +4857,10 @@ var AsiystRuntime = class {
4562
4857
  }
4563
4858
  async start() {
4564
4859
  this.events.emit("asiyst:initialized", { projectId: this.options.projectId });
4860
+ this.avatar.show();
4861
+ this.movement.goToAnchor();
4565
4862
  const cfg = await isolateAsync(() => this.config.refresh(), this.config.get());
4863
+ this.metricsTracker.record("configRetrieved");
4566
4864
  const domainCheck = validateWebsiteDomain(cfg, window.location.href);
4567
4865
  if (!domainCheck.allowed) {
4568
4866
  this.connectionStatus = "disconnected";
@@ -4574,7 +4872,6 @@ var AsiystRuntime = class {
4574
4872
  return;
4575
4873
  }
4576
4874
  this.avatar.applyConfig(cfg);
4577
- this.avatar.show();
4578
4875
  this.movement.goToAnchor();
4579
4876
  this.lifecycle.emit("sdk.verification_started", {
4580
4877
  projectId: this.options.projectId,
@@ -4600,7 +4897,15 @@ var AsiystRuntime = class {
4600
4897
  });
4601
4898
  const assetTarget = cfg.assetUrl ?? cfg.thumbnailUrl;
4602
4899
  if (assetTarget) {
4603
- await this.loadAvatarAsset(cfg, assetTarget);
4900
+ try {
4901
+ await this.loadAvatarAsset(cfg, assetTarget);
4902
+ } finally {
4903
+ this.avatar.show();
4904
+ this.movement.goToAnchor();
4905
+ }
4906
+ } else {
4907
+ this.avatar.show();
4908
+ this.movement.goToAnchor();
4604
4909
  }
4605
4910
  this.startConfigRevalidationScheduler();
4606
4911
  }
@@ -4614,7 +4919,7 @@ var AsiystRuntime = class {
4614
4919
  assetUrl: assetTarget
4615
4920
  });
4616
4921
  try {
4617
- const loaded = await this.renderer.loadAsset(cfg);
4922
+ const loaded = await this.renderer.loadAsset(cfg, this.metricsTracker);
4618
4923
  if (loaded) {
4619
4924
  this.movement.goToAnchor();
4620
4925
  const format = this.renderer.getLoadedFormat();
@@ -4633,15 +4938,19 @@ var AsiystRuntime = class {
4633
4938
  publishedVersion: cfg.publishedVersion
4634
4939
  });
4635
4940
  if (isRendered) {
4941
+ const metrics = this.metricsTracker.getMetrics();
4942
+ const durationMs = metrics?.durations.timeToFirstVisibleMs;
4636
4943
  this.events.emit("asiyst:avatar:rendered", {
4637
4944
  avatarId: this.options.avatarId ?? cfg.avatarId,
4638
- format
4945
+ format,
4946
+ durationMs
4639
4947
  });
4640
4948
  void this.cloud.sendTelemetryEvent("avatar_rendered", {
4641
4949
  avatarId: this.options.avatarId ?? cfg.avatarId ?? cfg.avatarName,
4642
4950
  avatarName: cfg.avatarName,
4643
4951
  format,
4644
- publishedVersion: cfg.publishedVersion
4952
+ publishedVersion: cfg.publishedVersion,
4953
+ durationMs
4645
4954
  });
4646
4955
  }
4647
4956
  return true;
@@ -4761,6 +5070,9 @@ var AsiystRuntime = class {
4761
5070
  getRenderer() {
4762
5071
  return this.renderer;
4763
5072
  }
5073
+ getAvatarPerformanceMetrics() {
5074
+ return this.metricsTracker.getMetrics();
5075
+ }
4764
5076
  avatarApi() {
4765
5077
  return this.avatar;
4766
5078
  }
@@ -5087,6 +5399,9 @@ var Asiyst = {
5087
5399
  isRuntimeConnected() {
5088
5400
  return requireRuntime().getConnectionStatus() === "connected";
5089
5401
  },
5402
+ getAvatarPerformanceMetrics() {
5403
+ return requireRuntime().getAvatarPerformanceMetrics();
5404
+ },
5090
5405
  avatar: {
5091
5406
  show() {
5092
5407
  withIsolation(() => requireRuntime().avatarApi().show());
@@ -5150,6 +5465,7 @@ exports.Asiyst = Asiyst;
5150
5465
  exports.AsiystError = AsiystError;
5151
5466
  exports.AssetLoader = AssetLoader;
5152
5467
  exports.AuthenticationError = AuthenticationError;
5468
+ exports.AvatarMetricsTracker = AvatarMetricsTracker;
5153
5469
  exports.ConfigurationError = ConfigurationError;
5154
5470
  exports.CssAvatarRenderer = CssAvatarRenderer;
5155
5471
  exports.FbxRenderer = FbxRenderer;