@preference-sl/pref-viewer 2.11.0-beta.4 → 2.11.0-beta.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@preference-sl/pref-viewer",
3
- "version": "2.11.0-beta.4",
3
+ "version": "2.11.0-beta.5",
4
4
  "description": "Web Component to preview GLTF models with Babylon.js",
5
5
  "author": "Alex Moreno Palacio <amoreno@preference.es>",
6
6
  "scripts": {
@@ -294,29 +294,42 @@ export default class BabylonJSController {
294
294
  return false;
295
295
  }
296
296
 
297
- let createIBLShadowPipeline = function (scene) {
297
+ /**
298
+ * Creates and configures the IBL shadow render pipeline for the Babylon.js scene.
299
+ * Sets recommended options for resolution, sampling, opacity, and disables debug passes.
300
+ * Accepts an optional camera array for pipeline targeting.
301
+ * @private
302
+ * @param {Scene} scene - The Babylon.js scene instance.
303
+ * @param {Camera[]} [cameras] - Optional array of cameras to target with the pipeline.
304
+ * @returns {IblShadowsRenderPipeline} The configured IBL shadow pipeline.
305
+ */
306
+ let createIBLShadowPipeline = function (scene, cameras = [scene.activeCamera]) {
298
307
  const pipeline = new IblShadowsRenderPipeline(
299
308
  "iblShadowsPipeline",
300
309
  scene,
301
310
  {
302
- resolutionExp: 7,
303
- sampleDirections: 2,
311
+ resolutionExp: 8, // Higher resolution for better shadow quality
312
+ sampleDirections: 4, // More sample directions for smoother shadows
304
313
  ssShadowsEnabled: true,
305
- shadowRemanence: 0.8,
314
+ shadowRemanence: 0.85,
306
315
  triPlanarVoxelization: true,
307
- shadowOpacity: 0.8,
316
+ shadowOpacity: 0.85,
308
317
  },
309
- [scene.activeCamera]
318
+ cameras
310
319
  );
311
- pipeline.allowDebugPasses = false;
312
- pipeline.gbufferDebugEnabled = true;
313
- pipeline.importanceSamplingDebugEnabled = false;
314
- pipeline.voxelDebugEnabled = false;
315
- pipeline.voxelDebugDisplayMip = 1;
316
- pipeline.voxelDebugAxis = 2;
317
- pipeline.voxelTracingDebugEnabled = false;
318
- pipeline.spatialBlurPassDebugEnabled = false;
319
- pipeline.accumulationPassDebugEnabled = false;
320
+ // Disable all debug passes for performance
321
+ const pipelineProps = {
322
+ allowDebugPasses: false,
323
+ gbufferDebugEnabled: false,
324
+ importanceSamplingDebugEnabled: false,
325
+ voxelDebugEnabled: false,
326
+ voxelDebugDisplayMip: 0,
327
+ voxelDebugAxis: 0,
328
+ voxelTracingDebugEnabled: false,
329
+ spatialBlurPassDebugEnabled: false,
330
+ accumulationPassDebugEnabled: false,
331
+ };
332
+ Object.assign(pipeline, pipelineProps);
320
333
  return pipeline;
321
334
  };
322
335
 
@@ -583,7 +596,7 @@ export default class BabylonJSController {
583
596
  * @param {boolean} isVisible - True to show the container, false to hide it.
584
597
  * @returns {void}
585
598
  */
586
- #updateVisibilityAttributeInComponentes(name, isVisible) {
599
+ #updateVisibilityAttributeInComponents(name, isVisible) {
587
600
  // Cache references to parent custom elements
588
601
  this.#getPrefViewer3DComponent();
589
602
  this.#getPrefViewerComponent();
@@ -600,13 +613,16 @@ export default class BabylonJSController {
600
613
  * Adds the asset container to the Babylon.js scene if it should be shown and is not already visible.
601
614
  * @private
602
615
  * @param {ContainerData} container - The container object containing asset state and metadata.
616
+ * @param {boolean} [updateVisibility=true] - If true, updates the visibility attribute in parent components.
603
617
  * @returns {boolean} True if the container was added, false otherwise.
604
618
  */
605
- #addContainer(container) {
619
+ #addContainer(container, updateVisibility = true) {
606
620
  if (!container.assetContainer || container.state.isVisible || !container.state.mustBeShown) {
607
621
  return false;
608
622
  }
609
- this.#updateVisibilityAttributeInComponentes(container.state.name, true);
623
+ if (updateVisibility) {
624
+ this.#updateVisibilityAttributeInComponents(container.state.name, true);
625
+ }
610
626
  container.assetContainer.addAllToScene();
611
627
  container.state.visible = true;
612
628
  return true;
@@ -616,13 +632,16 @@ export default class BabylonJSController {
616
632
  * Removes the asset container from the Babylon.js scene if it is currently visible.
617
633
  * @private
618
634
  * @param {ContainerData} container - The container object containing asset state and metadata.
635
+ * @param {boolean} [updateVisibility=true] - If true, updates the visibility attribute in parent components.
619
636
  * @returns {boolean} True if the container was removed, false otherwise.
620
637
  */
621
- #removeContainer(container) {
638
+ #removeContainer(container, updateVisibility = true) {
622
639
  if (!container.assetContainer || !container.state.isVisible) {
623
640
  return false;
624
641
  }
625
- this.#updateVisibilityAttributeInComponentes(container.state.name, false);
642
+ if (updateVisibility) {
643
+ this.#updateVisibilityAttributeInComponents(container.state.name, false);
644
+ }
626
645
  container.assetContainer.removeAllFromScene();
627
646
  container.state.visible = false;
628
647
  return true;
@@ -637,14 +656,15 @@ export default class BabylonJSController {
637
656
  */
638
657
  #replaceContainer(container, newAssetContainer) {
639
658
  if (container.assetContainer) {
640
- this.#removeContainer(container);
659
+ this.#removeContainer(container, false);
641
660
  container.assetContainer.dispose();
642
661
  container.assetContainer = null;
643
662
  }
644
663
  this.#scene.getEngine().releaseEffects();
645
664
  container.assetContainer = newAssetContainer;
646
- return this.#addContainer(container);
665
+ return this.#addContainer(container, false);
647
666
  }
667
+
648
668
  /**
649
669
  * Sets the visibility of wall and floor meshes in the model container based on the provided value or environment visibility.
650
670
  * @private
@@ -755,8 +775,8 @@ export default class BabylonJSController {
755
775
  if (container.state.name === "model") {
756
776
  assetContainer.lights = [];
757
777
  }
758
- const replacedAndAdded = this.#replaceContainer(container, assetContainer);
759
- if (replacedAndAdded && container.state.name === "model") {
778
+ const replaced = this.#replaceContainer(container, assetContainer);
779
+ if (replaced && container.state.name === "model") {
760
780
  this.#babylonJSAnimationController = new BabylonJSAnimationController(this.#scene);
761
781
  }
762
782
  container.state.setSuccess(true);