@spatialwalk/avatarkit 1.0.0-beta.92 → 1.0.0-beta.93

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.
@@ -9495,7 +9495,7 @@ const _AnimationPlayer = class _AnimationPlayer {
9495
9495
  if (this.streamingPlayer) {
9496
9496
  return;
9497
9497
  }
9498
- const { StreamingAudioPlayer } = await import("./StreamingAudioPlayer-eQ2RRq5U.js");
9498
+ const { StreamingAudioPlayer } = await import("./StreamingAudioPlayer-DWVeTI7D.js");
9499
9499
  const { AvatarSDK: AvatarSDK2 } = await Promise.resolve().then(() => AvatarSDK$1);
9500
9500
  const audioFormat = AvatarSDK2.getAudioFormat();
9501
9501
  this.streamingPlayer = new StreamingAudioPlayer({
@@ -15678,6 +15678,9 @@ class WebGPURenderer {
15678
15678
  __publicField(this, "blitUniformBuffer", null);
15679
15679
  __publicField(this, "blitQuadBuffer", null);
15680
15680
  __publicField(this, "blitSampler", null);
15681
+ // 记录上次 configure 时的 canvas 尺寸,用于检测 resize
15682
+ __publicField(this, "configuredWidth", 0);
15683
+ __publicField(this, "configuredHeight", 0);
15681
15684
  this.canvas = canvas;
15682
15685
  this.backgroundColor = backgroundColor || [0, 0, 0, 0];
15683
15686
  this.alpha = alpha;
@@ -15698,15 +15701,34 @@ class WebGPURenderer {
15698
15701
  throw new Error("WebGPU: Failed to get canvas context");
15699
15702
  }
15700
15703
  this.presentationFormat = navigator.gpu.getPreferredCanvasFormat();
15704
+ this.configureContext();
15705
+ this.createUniformBuffer();
15706
+ this.createQuadVertexBuffer();
15707
+ await this.createRenderPipeline();
15708
+ await this.createBlitPipeline();
15709
+ }
15710
+ /**
15711
+ * 配置 WebGPU context 并记录尺寸
15712
+ */
15713
+ configureContext() {
15714
+ if (!this.context || !this.device)
15715
+ return;
15701
15716
  this.context.configure({
15702
15717
  device: this.device,
15703
15718
  format: this.presentationFormat,
15704
15719
  alphaMode: this.alpha ? "premultiplied" : "opaque"
15705
15720
  });
15706
- this.createUniformBuffer();
15707
- this.createQuadVertexBuffer();
15708
- await this.createRenderPipeline();
15709
- await this.createBlitPipeline();
15721
+ this.configuredWidth = this.canvas.width;
15722
+ this.configuredHeight = this.canvas.height;
15723
+ }
15724
+ /**
15725
+ * 检测 canvas 尺寸变化,必要时重新 configure context
15726
+ * 防止 tab 切换等场景下 surface 尺寸与 canvas 尺寸不一致导致渲染错位
15727
+ */
15728
+ ensureContextSize() {
15729
+ if (this.canvas.width !== this.configuredWidth || this.canvas.height !== this.configuredHeight) {
15730
+ this.configureContext();
15731
+ }
15710
15732
  }
15711
15733
  /**
15712
15734
  * 创建 Uniform Buffer
@@ -16126,6 +16148,7 @@ class WebGPURenderer {
16126
16148
  return;
16127
16149
  if (this.splatCount === 0 || !this.storageBindGroup)
16128
16150
  return;
16151
+ this.ensureContextSize();
16129
16152
  const [width, height] = screenSize;
16130
16153
  const needsTransform = transform && (transform.x !== 0 || transform.y !== 0 || transform.scale !== 1);
16131
16154
  this.updateUniforms(viewMatrix, projectionMatrix, screenSize);
@@ -16358,6 +16381,14 @@ class RenderSystem {
16358
16381
  __publicField(this, "offsetX", 0);
16359
16382
  __publicField(this, "offsetY", 0);
16360
16383
  __publicField(this, "scale", 1);
16384
+ /**
16385
+ * Load packed Splat data (zero-copy, GPU format)
16386
+ * Directly receives WASM packed data
16387
+ *
16388
+ * @param packedData Float32Array [pos3, color4, cov6] x N points
16389
+ */
16390
+ // @debug: dump first frame flag
16391
+ __publicField(this, "_dumpedFirstFrame", false);
16361
16392
  this.options = options;
16362
16393
  this.canvas = options.canvas;
16363
16394
  this.backgroundColor = options.backgroundColor || [0, 0, 0, 0];
@@ -16401,15 +16432,28 @@ class RenderSystem {
16401
16432
  logger.log("✅ Using WebGL renderer");
16402
16433
  this.updateCameraAspect();
16403
16434
  }
16404
- /**
16405
- * Load packed Splat data (zero-copy, GPU format)
16406
- * Directly receives WASM packed data
16407
- *
16408
- * @param packedData Float32Array [pos3, color4, cov6] x N points
16409
- */
16410
16435
  loadSplatsFromPackedData(packedData) {
16411
16436
  if (!this.renderer)
16412
16437
  throw new Error("Renderer not initialized");
16438
+ if (!this._dumpedFirstFrame) {
16439
+ this._dumpedFirstFrame = true;
16440
+ const pointCount = Math.floor(packedData.length / 13);
16441
+ console.log(`[DEBUG] First frame packed data: ${pointCount} points, ${packedData.length} floats`);
16442
+ for (let i2 = 0; i2 < Math.min(5, pointCount); i2++) {
16443
+ const o2 = i2 * 13;
16444
+ console.log(`[DEBUG] Point ${i2}: pos(${packedData[o2]}, ${packedData[o2 + 1]}, ${packedData[o2 + 2]}) color(${packedData[o2 + 3]}, ${packedData[o2 + 4]}, ${packedData[o2 + 5]}, ${packedData[o2 + 6]}) covA(${packedData[o2 + 7]}, ${packedData[o2 + 8]}, ${packedData[o2 + 9]}) covB(${packedData[o2 + 10]}, ${packedData[o2 + 11]}, ${packedData[o2 + 12]})`);
16445
+ }
16446
+ const copy = new ArrayBuffer(packedData.byteLength);
16447
+ new Uint8Array(copy).set(new Uint8Array(packedData.buffer, packedData.byteOffset, packedData.byteLength));
16448
+ const blob = new Blob([copy], { type: "application/octet-stream" });
16449
+ const url = URL.createObjectURL(blob);
16450
+ const a2 = document.createElement("a");
16451
+ a2.href = url;
16452
+ a2.download = "core_packed_first_frame.bin";
16453
+ a2.click();
16454
+ URL.revokeObjectURL(url);
16455
+ console.log("[DEBUG] Packed data downloaded as core_packed_first_frame.bin");
16456
+ }
16413
16457
  this.originalPackedData = packedData;
16414
16458
  }
16415
16459
  /**
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { b, c, m, f, d, j, g, C, i, D, E, k, h, L, R, n } from "./index-C2higMlc.js";
1
+ import { b, c, m, f, d, j, g, C, i, D, E, k, h, L, R, n } from "./index-CDywZ8iv.js";
2
2
  export {
3
3
  b as Avatar,
4
4
  c as AvatarController,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@spatialwalk/avatarkit",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.92",
4
+ "version": "1.0.0-beta.93",
5
5
  "packageManager": "pnpm@10.18.2",
6
6
  "description": "AvatarKit SDK - 3D Gaussian Splatting Avatar Rendering SDK",
7
7
  "author": "AvatarKit Team",
Binary file