@heliguy-xyz/splat-viewer 1.0.0-rc.8 → 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.
@@ -140044,6 +140044,9 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140044
140044
  this._sceneConfigManager = null;
140045
140045
  // Event system
140046
140046
  this._eventListeners = new Map();
140047
+ // Splat rendering configuration (mirrors key SuperSplat options)
140048
+ this._splatCenterSize = null;
140049
+ this._sphericalHarmonicsBands = null;
140047
140050
  this.canvas = options.canvas || null;
140048
140051
  this.enableStats = options.enableStats || false;
140049
140052
  this.autoFocus = options.autoFocus !== false;
@@ -140171,6 +140174,8 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140171
140174
  // This ensures the loading spinner stays visible until the model is actually rendered
140172
140175
  return await new Promise(resolve => {
140173
140176
  this.app.once('frameupdate', () => {
140177
+ // Apply any pending splat rendering configuration
140178
+ this._applySplatRenderingConfigToEntity(result.entity);
140174
140179
  if (this.autoFocus) {
140175
140180
  this.focus(result.entity);
140176
140181
  setTimeout(() => {
@@ -140261,6 +140266,8 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140261
140266
  // This ensures the loading spinner stays visible until the model is actually rendered
140262
140267
  return await new Promise(resolve => {
140263
140268
  this.app.once('frameupdate', () => {
140269
+ // Apply any pending splat rendering configuration
140270
+ this._applySplatRenderingConfigToEntity(entity);
140264
140271
  if (this.autoFocus) {
140265
140272
  this.focus(entity);
140266
140273
  setTimeout(() => {
@@ -140394,7 +140401,12 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140394
140401
  if (!this._modelManager) {
140395
140402
  throw new Error('SplatViewerCore.addModel: ModelManager not initialized');
140396
140403
  }
140397
- 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;
140398
140410
  }
140399
140411
  /**
140400
140412
  * Remove a specific model from the scene
@@ -140456,6 +140468,25 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140456
140468
  }
140457
140469
  return this._modelManager.getSceneStats();
140458
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
+ }
140459
140490
  /**
140460
140491
  * Set visibility for a specific model by ID
140461
140492
  * @param modelId ID of the model
@@ -140479,6 +140510,153 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
140479
140510
  this._modelManager.setModelsVisibleByName(name, visible);
140480
140511
  }
140481
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
+ }
140659
+ // ==========================================
140482
140660
  // Transform System API
140483
140661
  // ==========================================
140484
140662
  /**
@@ -141759,6 +141937,13 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
141759
141937
  this._core.on('background-color-changed', (event) => {
141760
141938
  this.dispatchEvent(createCustomEvent('background-color-changed', event.detail));
141761
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
+ });
141762
141947
  // Multi-model management events
141763
141948
  this._core.on('model-added', (event) => {
141764
141949
  this.dispatchEvent(createCustomEvent('model-added', event.detail));
@@ -142046,6 +142231,26 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
142046
142231
  }
142047
142232
  await this._core.animateCameraFOV(targetFOV, duration);
142048
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
+ }
142049
142254
  setBackgroundColor(color) {
142050
142255
  if (!this._core) {
142051
142256
  throw new Error('SplatViewerElement: Core not initialized. Call connectedCallback first.');
@@ -142064,6 +142269,44 @@ fn fragmentMain(input: FragmentInput) -> FragmentOutput {
142064
142269
  }
142065
142270
  await this._core.animateBackgroundColor(targetColor, duration);
142066
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
+ }
142067
142310
  // ==========================================
142068
142311
  // Transform System API
142069
142312
  // ==========================================