@heliguy-xyz/splat-viewer 1.0.0-rc.7 → 1.0.0-rc.9

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.
Files changed (29) hide show
  1. package/dist/web-component/ModelManager.d.ts +12 -0
  2. package/dist/web-component/ModelManager.d.ts.map +1 -1
  3. package/dist/web-component/SplatViewerCore.d.ts +47 -0
  4. package/dist/web-component/SplatViewerCore.d.ts.map +1 -1
  5. package/dist/web-component/SplatViewerElement.d.ts +40 -0
  6. package/dist/web-component/SplatViewerElement.d.ts.map +1 -1
  7. package/dist/web-component/splat-viewer.esm.js +337 -1
  8. package/dist/web-component/splat-viewer.esm.min.js +2 -2
  9. package/dist/web-component/splat-viewer.js +337 -1
  10. package/dist/web-component/splat-viewer.min.js +2 -2
  11. package/dist/web-component/types/ModelManager.d.ts +12 -0
  12. package/dist/web-component/types/ModelManager.d.ts.map +1 -1
  13. package/dist/web-component/types/SplatViewerCore.d.ts +47 -0
  14. package/dist/web-component/types/SplatViewerCore.d.ts.map +1 -1
  15. package/dist/web-component/types/SplatViewerElement.d.ts +40 -0
  16. package/dist/web-component/types/SplatViewerElement.d.ts.map +1 -1
  17. package/dist/web-component/types/core.d.ts +9 -1
  18. package/dist/web-component/types/core.d.ts.map +1 -1
  19. package/dist/web-component/types/enhanced-viewer.d.ts +41 -1
  20. package/dist/web-component/types/enhanced-viewer.d.ts.map +1 -1
  21. package/dist/web-component/types/events.d.ts +20 -1
  22. package/dist/web-component/types/events.d.ts.map +1 -1
  23. package/dist/web-component/types/types/core.d.ts +9 -1
  24. package/dist/web-component/types/types/core.d.ts.map +1 -1
  25. package/dist/web-component/types/types/enhanced-viewer.d.ts +41 -1
  26. package/dist/web-component/types/types/enhanced-viewer.d.ts.map +1 -1
  27. package/dist/web-component/types/types/events.d.ts +20 -1
  28. package/dist/web-component/types/types/events.d.ts.map +1 -1
  29. package/package.json +1 -1
@@ -105357,6 +105357,7 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
105357
105357
  transform,
105358
105358
  metadata,
105359
105359
  loadStartTime,
105360
+ visible: true,
105360
105361
  };
105361
105362
  if (blobUrl !== undefined) {
105362
105363
  modelInfo.blobUrl = blobUrl;
@@ -105560,6 +105561,54 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
105560
105561
  model.transform = transform;
105561
105562
  model.metadata.transform = transform;
105562
105563
  }
105564
+ /**
105565
+ * Set visibility for a specific model by ID
105566
+ * @param modelId ID of the model
105567
+ * @param visible True to show, false to hide
105568
+ */
105569
+ setModelVisible(modelId, visible) {
105570
+ const model = this.models.get(modelId);
105571
+ if (!model) {
105572
+ throw new Error(`Model with ID "${modelId}" not found`);
105573
+ }
105574
+ // Apply visibility to underlying entity
105575
+ if (model.entity) {
105576
+ model.entity.enabled = visible;
105577
+ }
105578
+ model.visible = visible;
105579
+ // Emit model-visibility-changed event
105580
+ if (this._eventEmitter) {
105581
+ this._eventEmitter('model-visibility-changed', {
105582
+ modelId: model.id,
105583
+ name: model.name,
105584
+ visible,
105585
+ });
105586
+ }
105587
+ }
105588
+ /**
105589
+ * Set visibility for all models matching a given name
105590
+ * @param name Model name to match (case-sensitive)
105591
+ * @param visible True to show, false to hide
105592
+ */
105593
+ setModelsVisibleByName(name, visible) {
105594
+ for (const model of this.models.values()) {
105595
+ if (model.name === name) {
105596
+ // Apply visibility to entity
105597
+ if (model.entity) {
105598
+ model.entity.enabled = visible;
105599
+ }
105600
+ model.visible = visible;
105601
+ // Emit model-visibility-changed event for each affected model
105602
+ if (this._eventEmitter) {
105603
+ this._eventEmitter('model-visibility-changed', {
105604
+ modelId: model.id,
105605
+ name: model.name,
105606
+ visible,
105607
+ });
105608
+ }
105609
+ }
105610
+ }
105611
+ }
105563
105612
  }
105564
105613
 
105565
105614
  // Core type definitions for the Web Component
@@ -139995,6 +140044,9 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
139995
140044
  this._sceneConfigManager = null;
139996
140045
  // Event system
139997
140046
  this._eventListeners = new Map();
140047
+ // Splat rendering configuration (mirrors key SuperSplat options)
140048
+ this._splatCenterSize = null;
140049
+ this._sphericalHarmonicsBands = null;
139998
140050
  this.canvas = options.canvas || null;
139999
140051
  this.enableStats = options.enableStats || false;
140000
140052
  this.autoFocus = options.autoFocus !== false;
@@ -140122,6 +140174,8 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140122
140174
  // This ensures the loading spinner stays visible until the model is actually rendered
140123
140175
  return await new Promise(resolve => {
140124
140176
  this.app.once('frameupdate', () => {
140177
+ // Apply any pending splat rendering configuration
140178
+ this._applySplatRenderingConfigToEntity(result.entity);
140125
140179
  if (this.autoFocus) {
140126
140180
  this.focus(result.entity);
140127
140181
  setTimeout(() => {
@@ -140212,6 +140266,8 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140212
140266
  // This ensures the loading spinner stays visible until the model is actually rendered
140213
140267
  return await new Promise(resolve => {
140214
140268
  this.app.once('frameupdate', () => {
140269
+ // Apply any pending splat rendering configuration
140270
+ this._applySplatRenderingConfigToEntity(entity);
140215
140271
  if (this.autoFocus) {
140216
140272
  this.focus(entity);
140217
140273
  setTimeout(() => {
@@ -140345,7 +140401,12 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140345
140401
  if (!this._modelManager) {
140346
140402
  throw new Error('SplatViewerCore.addModel: ModelManager not initialized');
140347
140403
  }
140348
- return await this._modelManager.addModel(source, options);
140404
+ const info = await this._modelManager.addModel(source, options);
140405
+ // Apply any pending splat rendering configuration to the new model entity
140406
+ if (info?.entity) {
140407
+ this._applySplatRenderingConfigToEntity(info.entity);
140408
+ }
140409
+ return info;
140349
140410
  }
140350
140411
  /**
140351
140412
  * Remove a specific model from the scene
@@ -140407,6 +140468,194 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140407
140468
  }
140408
140469
  return this._modelManager.getSceneStats();
140409
140470
  }
140471
+ /**
140472
+ * Set fly camera base movement speed (convenience over setFlyCameraConfig)
140473
+ * @param speed Units per second (must be > 0)
140474
+ */
140475
+ setFlyCameraSpeed(speed) {
140476
+ if (speed <= 0 || !isFinite(speed)) {
140477
+ console.warn('SplatViewerCore.setFlyCameraSpeed: speed must be > 0');
140478
+ return;
140479
+ }
140480
+ this.setFlyCameraConfig({ moveSpeed: speed });
140481
+ }
140482
+ /**
140483
+ * Get current fly camera base movement speed
140484
+ * @returns Speed in units per second, or null if fly camera not initialized
140485
+ */
140486
+ getFlyCameraSpeed() {
140487
+ const cfg = this.getFlyCameraConfig();
140488
+ return cfg ? cfg.moveSpeed : null;
140489
+ }
140490
+ /**
140491
+ * Set visibility for a specific model by ID
140492
+ * @param modelId ID of the model
140493
+ * @param visible True to show, false to hide
140494
+ */
140495
+ setModelVisible(modelId, visible) {
140496
+ if (!this._modelManager) {
140497
+ throw new Error('SplatViewerCore.setModelVisible: ModelManager not initialized');
140498
+ }
140499
+ this._modelManager.setModelVisible(modelId, visible);
140500
+ }
140501
+ /**
140502
+ * Set visibility for all models matching a given name
140503
+ * @param name Model name to match (case-sensitive)
140504
+ * @param visible True to show, false to hide
140505
+ */
140506
+ setModelsVisibleByName(name, visible) {
140507
+ if (!this._modelManager) {
140508
+ throw new Error('SplatViewerCore.setModelsVisibleByName: ModelManager not initialized');
140509
+ }
140510
+ this._modelManager.setModelsVisibleByName(name, visible);
140511
+ }
140512
+ // ==========================================
140513
+ // Splat Rendering Configuration
140514
+ // ==========================================
140515
+ /**
140516
+ * Set rendered centers size for all splat models.
140517
+ * This maps onto underlying gsplat / renderer properties when available.
140518
+ * @param size Positive size value (implementation-specific units)
140519
+ */
140520
+ setSplatCenterSize(size) {
140521
+ if (!isFinite(size) || size <= 0) {
140522
+ console.warn('SplatViewerCore.setSplatCenterSize: size must be > 0');
140523
+ return;
140524
+ }
140525
+ const previousSize = this._splatCenterSize;
140526
+ this._splatCenterSize = size;
140527
+ this._forEachSplatEntity(entity => {
140528
+ this._applySplatRenderingConfigToEntity(entity);
140529
+ });
140530
+ // Emit event for UI integrations
140531
+ this.emit({
140532
+ type: 'splat-center-size-changed',
140533
+ detail: {
140534
+ size,
140535
+ previousSize: previousSize ?? size,
140536
+ },
140537
+ });
140538
+ }
140539
+ /**
140540
+ * Get current centers size value last set via API.
140541
+ * Returns null if not configured yet.
140542
+ */
140543
+ getSplatCenterSize() {
140544
+ return this._splatCenterSize;
140545
+ }
140546
+ /**
140547
+ * Set spherical harmonics bands for all splat models.
140548
+ * @param bands Integer band count (0-3)
140549
+ */
140550
+ setSphericalHarmonicsBands(bands) {
140551
+ if (!isFinite(bands)) {
140552
+ console.warn('SplatViewerCore.setSphericalHarmonicsBands: bands must be a finite number');
140553
+ return;
140554
+ }
140555
+ const clamped = Math.max(0, Math.min(3, Math.round(bands)));
140556
+ const previousBands = this._sphericalHarmonicsBands;
140557
+ this._sphericalHarmonicsBands = clamped;
140558
+ this._forEachSplatEntity(entity => {
140559
+ this._applySplatRenderingConfigToEntity(entity);
140560
+ });
140561
+ // Emit event for UI integrations
140562
+ this.emit({
140563
+ type: 'spherical-harmonics-bands-changed',
140564
+ detail: {
140565
+ bands: clamped,
140566
+ previousBands: previousBands ?? clamped,
140567
+ },
140568
+ });
140569
+ }
140570
+ /**
140571
+ * Get current spherical harmonics bands setting last configured via API.
140572
+ * Returns null if not configured yet.
140573
+ */
140574
+ getSphericalHarmonicsBands() {
140575
+ return this._sphericalHarmonicsBands;
140576
+ }
140577
+ // Apply stored rendering configuration to a specific splat entity
140578
+ _applySplatRenderingConfigToEntity(entity) {
140579
+ const anyEntity = entity;
140580
+ const comp = anyEntity.gsplat;
140581
+ if (!comp)
140582
+ return;
140583
+ // Centers size – try several known/likely property names
140584
+ if (this._splatCenterSize != null) {
140585
+ const size = this._splatCenterSize;
140586
+ if ('centerSize' in comp)
140587
+ comp.centerSize = size;
140588
+ if ('centersSize' in comp)
140589
+ comp.centersSize = size;
140590
+ if ('pointSize' in comp)
140591
+ comp.pointSize = size;
140592
+ if (comp.settings) {
140593
+ if ('centerSize' in comp.settings)
140594
+ comp.settings.centerSize = size;
140595
+ if ('centersSize' in comp.settings)
140596
+ comp.settings.centersSize = size;
140597
+ if ('pointSize' in comp.settings)
140598
+ comp.settings.pointSize = size;
140599
+ }
140600
+ if (comp.instance) {
140601
+ if ('centerSize' in comp.instance)
140602
+ comp.instance.centerSize = size;
140603
+ if ('centersSize' in comp.instance)
140604
+ comp.instance.centersSize = size;
140605
+ if ('pointSize' in comp.instance)
140606
+ comp.instance.pointSize = size;
140607
+ if (comp.instance.renderOptions) {
140608
+ const ro = comp.instance.renderOptions;
140609
+ if ('centerSize' in ro)
140610
+ ro.centerSize = size;
140611
+ if ('centersSize' in ro)
140612
+ ro.centersSize = size;
140613
+ if ('pointSize' in ro)
140614
+ ro.pointSize = size;
140615
+ }
140616
+ }
140617
+ }
140618
+ // Spherical harmonics bands – prefer integer band count properties
140619
+ if (this._sphericalHarmonicsBands != null) {
140620
+ const bands = this._sphericalHarmonicsBands;
140621
+ if ('shBands' in comp)
140622
+ comp.shBands = bands;
140623
+ if ('shBandCount' in comp)
140624
+ comp.shBandCount = bands;
140625
+ if ('sphericalHarmonicsBands' in comp)
140626
+ comp.sphericalHarmonicsBands = bands;
140627
+ if (comp.settings) {
140628
+ if ('shBands' in comp.settings)
140629
+ comp.settings.shBands = bands;
140630
+ if ('shBandCount' in comp.settings)
140631
+ comp.settings.shBandCount = bands;
140632
+ if ('sphericalHarmonicsBands' in comp.settings)
140633
+ comp.settings.sphericalHarmonicsBands = bands;
140634
+ }
140635
+ if (comp.instance) {
140636
+ if ('shBands' in comp.instance)
140637
+ comp.instance.shBands = bands;
140638
+ if ('shBandCount' in comp.instance)
140639
+ comp.instance.shBandCount = bands;
140640
+ if ('sphericalHarmonicsBands' in comp.instance)
140641
+ comp.instance.sphericalHarmonicsBands = bands;
140642
+ }
140643
+ }
140644
+ }
140645
+ // Helper: iterate over all splat entities managed by this core
140646
+ _forEachSplatEntity(fn) {
140647
+ if (this.entities.splat) {
140648
+ fn(this.entities.splat);
140649
+ }
140650
+ if (this._modelManager) {
140651
+ const models = this._modelManager.getModels();
140652
+ for (const m of models) {
140653
+ if (m.entity) {
140654
+ fn(m.entity);
140655
+ }
140656
+ }
140657
+ }
140658
+ }
140410
140659
  // ==========================================
140411
140660
  // Transform System API
140412
140661
  // ==========================================
@@ -141688,6 +141937,13 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
141688
141937
  this._core.on('background-color-changed', (event) => {
141689
141938
  this.dispatchEvent(createCustomEvent('background-color-changed', event.detail));
141690
141939
  });
141940
+ // Splat rendering configuration events
141941
+ this._core.on('splat-center-size-changed', (event) => {
141942
+ this.dispatchEvent(createCustomEvent('splat-center-size-changed', event.detail));
141943
+ });
141944
+ this._core.on('spherical-harmonics-bands-changed', (event) => {
141945
+ this.dispatchEvent(createCustomEvent('spherical-harmonics-bands-changed', event.detail));
141946
+ });
141691
141947
  // Multi-model management events
141692
141948
  this._core.on('model-added', (event) => {
141693
141949
  this.dispatchEvent(createCustomEvent('model-added', event.detail));
@@ -141899,6 +142155,28 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
141899
142155
  }
141900
142156
  return this._core.getSceneStats();
141901
142157
  }
142158
+ /**
142159
+ * Set visibility for a specific model by ID
142160
+ * @param modelId ID of the model
142161
+ * @param visible True to show, false to hide
142162
+ */
142163
+ setModelVisible(modelId, visible) {
142164
+ if (!this._core) {
142165
+ throw new Error('SplatViewerElement: Core not initialized. Call connectedCallback first.');
142166
+ }
142167
+ this._core.setModelVisible(modelId, visible);
142168
+ }
142169
+ /**
142170
+ * Set visibility for all models matching a given name
142171
+ * @param name Model name to match (case-sensitive)
142172
+ * @param visible True to show, false to hide
142173
+ */
142174
+ setModelsVisibleByName(name, visible) {
142175
+ if (!this._core) {
142176
+ throw new Error('SplatViewerElement: Core not initialized. Call connectedCallback first.');
142177
+ }
142178
+ this._core.setModelsVisibleByName(name, visible);
142179
+ }
141902
142180
  // ==========================================
141903
142181
  // Camera Mode / Fly Camera API
141904
142182
  // ==========================================
@@ -141953,6 +142231,26 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
141953
142231
  }
141954
142232
  await this._core.animateCameraFOV(targetFOV, duration);
141955
142233
  }
142234
+ /**
142235
+ * Set fly camera base movement speed (convenience over setFlyCameraConfig)
142236
+ * @param speed Units per second (must be > 0)
142237
+ */
142238
+ setFlyCameraSpeed(speed) {
142239
+ if (!this._core) {
142240
+ throw new Error('SplatViewerElement: Core not initialized. Call connectedCallback first.');
142241
+ }
142242
+ this._core.setFlyCameraSpeed(speed);
142243
+ }
142244
+ /**
142245
+ * Get current fly camera base movement speed
142246
+ * @returns Speed in units per second, or null if fly camera not initialized
142247
+ */
142248
+ getFlyCameraSpeed() {
142249
+ if (!this._core) {
142250
+ throw new Error('SplatViewerElement: Core not initialized. Call connectedCallback first.');
142251
+ }
142252
+ return this._core.getFlyCameraSpeed();
142253
+ }
141956
142254
  setBackgroundColor(color) {
141957
142255
  if (!this._core) {
141958
142256
  throw new Error('SplatViewerElement: Core not initialized. Call connectedCallback first.');
@@ -141971,6 +142269,44 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
141971
142269
  }
141972
142270
  await this._core.animateBackgroundColor(targetColor, duration);
141973
142271
  }
142272
+ /**
142273
+ * Set rendered centers size for all splat models
142274
+ * @param size Positive size value (implementation-specific units)
142275
+ */
142276
+ setSplatCenterSize(size) {
142277
+ if (!this._core) {
142278
+ throw new Error('SplatViewerElement: Core not initialized. Call connectedCallback first.');
142279
+ }
142280
+ this._core.setSplatCenterSize(size);
142281
+ }
142282
+ /**
142283
+ * Get current centers size value last set via API
142284
+ */
142285
+ getSplatCenterSize() {
142286
+ if (!this._core) {
142287
+ throw new Error('SplatViewerElement: Core not initialized. Call connectedCallback first.');
142288
+ }
142289
+ return this._core.getSplatCenterSize();
142290
+ }
142291
+ /**
142292
+ * Set spherical harmonics bands for all splat models
142293
+ * @param bands Integer band count (0-3)
142294
+ */
142295
+ setSphericalHarmonicsBands(bands) {
142296
+ if (!this._core) {
142297
+ throw new Error('SplatViewerElement: Core not initialized. Call connectedCallback first.');
142298
+ }
142299
+ this._core.setSphericalHarmonicsBands(bands);
142300
+ }
142301
+ /**
142302
+ * Get current spherical harmonics bands setting last configured via API
142303
+ */
142304
+ getSphericalHarmonicsBands() {
142305
+ if (!this._core) {
142306
+ throw new Error('SplatViewerElement: Core not initialized. Call connectedCallback first.');
142307
+ }
142308
+ return this._core.getSphericalHarmonicsBands();
142309
+ }
141974
142310
  // ==========================================
141975
142311
  // Transform System API
141976
142312
  // ==========================================