@onerjs/loaders 8.36.5 → 8.36.6

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 (37) hide show
  1. package/glTF/2.0/Extensions/KHR_materials_coat.d.ts +2 -2
  2. package/glTF/2.0/Extensions/KHR_materials_coat.js +2 -2
  3. package/glTF/2.0/Extensions/KHR_materials_coat.js.map +1 -1
  4. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.d.ts +1 -1
  5. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.js +1 -1
  6. package/glTF/2.0/Extensions/KHR_materials_diffuse_roughness.js.map +1 -1
  7. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js +2 -2
  8. package/glTF/2.0/Extensions/KHR_materials_diffuse_transmission.js.map +1 -1
  9. package/glTF/2.0/Extensions/KHR_materials_dispersion.js +3 -2
  10. package/glTF/2.0/Extensions/KHR_materials_dispersion.js.map +1 -1
  11. package/glTF/2.0/Extensions/KHR_materials_fuzz.d.ts +2 -1
  12. package/glTF/2.0/Extensions/KHR_materials_fuzz.js +2 -1
  13. package/glTF/2.0/Extensions/KHR_materials_fuzz.js.map +1 -1
  14. package/glTF/2.0/Extensions/KHR_materials_transmission.js +25 -22
  15. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  16. package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
  17. package/glTF/2.0/Extensions/KHR_materials_volume.js +9 -3
  18. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
  19. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.d.ts +45 -0
  20. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.js +110 -0
  21. package/glTF/2.0/Extensions/KHR_materials_volume_scatter.js.map +1 -0
  22. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
  23. package/glTF/2.0/Extensions/index.d.ts +1 -0
  24. package/glTF/2.0/Extensions/index.js +1 -0
  25. package/glTF/2.0/Extensions/index.js.map +1 -1
  26. package/glTF/2.0/materialLoadingAdapter.d.ts +43 -1
  27. package/glTF/2.0/materialLoadingAdapter.js.map +1 -1
  28. package/glTF/2.0/openpbrMaterialLoadingAdapter.d.ts +98 -16
  29. package/glTF/2.0/openpbrMaterialLoadingAdapter.js +172 -35
  30. package/glTF/2.0/openpbrMaterialLoadingAdapter.js.map +1 -1
  31. package/glTF/2.0/pbrMaterialLoadingAdapter.d.ts +97 -8
  32. package/glTF/2.0/pbrMaterialLoadingAdapter.js +165 -19
  33. package/glTF/2.0/pbrMaterialLoadingAdapter.js.map +1 -1
  34. package/glTF/glTFValidation.d.ts +6 -0
  35. package/glTF/glTFValidation.js +6 -0
  36. package/glTF/glTFValidation.js.map +1 -1
  37. package/package.json +3 -3
@@ -2,13 +2,15 @@ import type { OpenPBRMaterial } from "@onerjs/core/Materials/PBR/openpbrMaterial
2
2
  import type { Material } from "@onerjs/core/Materials/material.js";
3
3
  import type { BaseTexture } from "@onerjs/core/Materials/Textures/baseTexture.js";
4
4
  import type { Nullable } from "@onerjs/core/types.js";
5
- import type { Color3 } from "@onerjs/core/Maths/math.color.js";
5
+ import { Color3 } from "@onerjs/core/Maths/math.color.js";
6
6
  import type { IMaterialLoadingAdapter } from "./materialLoadingAdapter.js";
7
+ import { Vector3 } from "@onerjs/core/Maths/math.vector.js";
7
8
  /**
8
9
  * Material Loading Adapter for OpenPBR materials that provides a unified OpenPBR-like interface.
9
10
  */
10
11
  export declare class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAdapter {
11
12
  private _material;
13
+ private _extinctionCoefficient;
12
14
  /**
13
15
  * Creates a new instance of the OpenPBRMaterialLoadingAdapter.
14
16
  * @param material - The OpenPBR material to adapt.
@@ -371,55 +373,87 @@ export declare class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAd
371
373
  * @returns Currently returns null as coat anisotropy is not yet available
372
374
  */
373
375
  get geometryCoatTangentTexture(): Nullable<BaseTexture>;
376
+ /**
377
+ * Configures transmission for OpenPBR material.
378
+ */
379
+ configureTransmission(): void;
374
380
  /**
375
381
  * Sets the transmission weight.
376
- * TODO: Implementation pending OpenPBR transmission feature availability.
377
382
  * @param value The transmission weight value (0-1)
378
383
  */
379
384
  set transmissionWeight(value: number);
380
385
  /**
381
386
  * Sets the transmission weight texture.
382
- * TODO: Implementation pending OpenPBR transmission feature availability.
383
387
  * @param value The transmission weight texture or null
384
388
  */
385
389
  set transmissionWeightTexture(value: Nullable<BaseTexture>);
386
390
  /**
387
391
  * Gets the transmission weight.
388
- * TODO: Implementation pending OpenPBR transmission feature availability.
389
392
  * @returns Currently returns 0 as transmission is not yet available
390
393
  */
391
394
  get transmissionWeight(): number;
392
395
  /**
393
- * Gets the transmission dispersion Abbe number.
396
+ * Sets the transmission scatter coefficient.
397
+ * @param value The scatter coefficient as a Vector3
398
+ */
399
+ set transmissionScatter(value: Color3);
400
+ /**
401
+ * Gets the transmission scatter coefficient.
402
+ * @returns The scatter coefficient as a Vector3
403
+ */
404
+ get transmissionScatter(): Color3;
405
+ set transmissionScatterTexture(value: Nullable<BaseTexture>);
406
+ get transmissionScatterTexture(): Nullable<BaseTexture>;
407
+ /**
408
+ * Sets the transmission scattering anisotropy.
409
+ * @param value The anisotropy intensity value (-1 to 1)
410
+ */
411
+ set transmissionScatterAnisotropy(value: number);
412
+ /**
413
+ * Sets the transmission dispersion Abbe number.
394
414
  * @param value The Abbe number value
395
415
  */
396
416
  set transmissionDispersionAbbeNumber(value: number);
397
417
  /**
398
- * Configures transmission for OpenPBR material.
399
- * TODO: Implementation pending OpenPBR transmission feature availability.
418
+ * Sets the transmission dispersion scale.
419
+ * @param value The dispersion scale value
400
420
  */
401
- configureTransmission(): void;
421
+ set transmissionDispersionScale(value: number);
402
422
  /**
403
- * Sets the attenuation distance for volume scattering.
404
- * TODO: Implementation pending OpenPBR volume feature availability.
423
+ * Sets the attenuation distance.
405
424
  * @param value The attenuation distance value
406
425
  */
407
426
  set transmissionDepth(value: number);
408
427
  /**
409
- * Sets the attenuation color for volume scattering.
410
- * TODO: Implementation pending OpenPBR volume feature availability.
428
+ * Gets the attenuation distance.
429
+ */
430
+ get transmissionDepth(): number;
431
+ /**
432
+ * Sets the attenuation color.
411
433
  * @param value The attenuation color as a Color3
412
434
  */
413
435
  set transmissionColor(value: Color3);
414
436
  /**
415
- * Sets the thickness texture for volume scattering.
416
- * TODO: Implementation pending OpenPBR volume feature availability.
437
+ * Gets the attenuation color.
438
+ */
439
+ get transmissionColor(): Color3;
440
+ /**
441
+ * Gets the refraction background texture
442
+ * @returns The refraction background texture or null
443
+ */
444
+ get refractionBackgroundTexture(): Nullable<BaseTexture>;
445
+ /**
446
+ * Sets the refraction background texture
447
+ * @param value The refraction background texture or null
448
+ */
449
+ set refractionBackgroundTexture(value: Nullable<BaseTexture>);
450
+ /**
451
+ * Sets the thickness texture.
417
452
  * @param value The thickness texture or null
418
453
  */
419
454
  set volumeThicknessTexture(value: Nullable<BaseTexture>);
420
455
  /**
421
- * Sets the thickness factor for volume scattering.
422
- * TODO: Implementation pending OpenPBR volume feature availability.
456
+ * Sets the thickness factor.
423
457
  * @param value The thickness value
424
458
  */
425
459
  set volumeThickness(value: number);
@@ -427,6 +461,15 @@ export declare class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAd
427
461
  * Configures subsurface properties for PBR material
428
462
  */
429
463
  configureSubsurface(): void;
464
+ /**
465
+ * Sets the extinction coefficient of the volume.
466
+ * @param value The extinction coefficient as a Vector3
467
+ */
468
+ set extinctionCoefficient(value: Vector3);
469
+ /**
470
+ * Gets the extinction coefficient of the volume.
471
+ */
472
+ get extinctionCoefficient(): Vector3;
430
473
  /**
431
474
  * Sets the subsurface weight
432
475
  */
@@ -446,6 +489,45 @@ export declare class OpenPBRMaterialLoadingAdapter implements IMaterialLoadingAd
446
489
  * @param value The subsurface tint texture or null
447
490
  */
448
491
  set subsurfaceColorTexture(value: Nullable<BaseTexture>);
492
+ /**
493
+ * Sets the surface tint of the material (when using subsurface scattering)
494
+ */
495
+ set subsurfaceConstantTint(value: Color3);
496
+ /**
497
+ * Gets the surface tint of the material (when using subsurface scattering)
498
+ */
499
+ get subsurfaceConstantTint(): Color3;
500
+ /**
501
+ * Sets the surface tint texture of the material (when using subsurface scattering)
502
+ */
503
+ set subsurfaceConstantTintTexture(value: Nullable<BaseTexture>);
504
+ /**
505
+ * Gets the subsurface radius for subsurface scattering.
506
+ * subsurfaceRadiusScale * subsurfaceRadius gives the mean free path per color channel.
507
+ */
508
+ get subsurfaceRadius(): number;
509
+ /**
510
+ * Sets the subsurface radius for subsurface scattering.
511
+ * subsurfaceRadiusScale * subsurfaceRadius gives the mean free path per color channel.
512
+ * @param value The subsurface radius value
513
+ */
514
+ set subsurfaceRadius(value: number);
515
+ /**
516
+ * Gets the subsurface radius scale for subsurface scattering.
517
+ * subsurfaceRadiusScale * subsurfaceRadius gives the mean free path per color channel.
518
+ */
519
+ get subsurfaceRadiusScale(): Color3;
520
+ /**
521
+ * Sets the subsurface radius scale for subsurface scattering.
522
+ * subsurfaceRadiusScale * subsurfaceRadius gives the mean free path per color channel.
523
+ * @param value The subsurface radius scale as a Color3
524
+ */
525
+ set subsurfaceRadiusScale(value: Color3);
526
+ /**
527
+ * Sets the subsurface scattering anisotropy.
528
+ * @param value The anisotropy intensity value
529
+ */
530
+ set subsurfaceScatterAnisotropy(value: number);
449
531
  /**
450
532
  * Configures fuzz for OpenPBR.
451
533
  * Enables fuzz and sets up proper configuration.
@@ -1,3 +1,5 @@
1
+ import { Color3 } from "@onerjs/core/Maths/math.color.js";
2
+ import { Vector3 } from "@onerjs/core/Maths/math.vector.js";
1
3
  /**
2
4
  * Material Loading Adapter for OpenPBR materials that provides a unified OpenPBR-like interface.
3
5
  */
@@ -7,6 +9,7 @@ export class OpenPBRMaterialLoadingAdapter {
7
9
  * @param material - The OpenPBR material to adapt.
8
10
  */
9
11
  constructor(material) {
12
+ this._extinctionCoefficient = Vector3.Zero();
10
13
  this._material = material;
11
14
  }
12
15
  /**
@@ -555,86 +558,148 @@ export class OpenPBRMaterialLoadingAdapter {
555
558
  // ========================================
556
559
  // TRANSMISSION LAYER
557
560
  // ========================================
561
+ /**
562
+ * Configures transmission for OpenPBR material.
563
+ */
564
+ configureTransmission() {
565
+ // OpenPBR transmission will be configured differently when available
566
+ }
558
567
  /**
559
568
  * Sets the transmission weight.
560
- * TODO: Implementation pending OpenPBR transmission feature availability.
561
569
  * @param value The transmission weight value (0-1)
562
570
  */
563
571
  set transmissionWeight(value) {
564
- // TODO: Implement when OpenPBR transmission is available
565
- // this._material.transmissionWeight = value;
572
+ this._material.transmissionWeight = value;
573
+ // If the transmission weight is greater than 0, let's check if the base color
574
+ // is set and use that for a surface tint in OpenPBR. This may later be
575
+ // overridden by the volume properties but, without volume, this will give us
576
+ // glTF compatibility in OpenPBR.
577
+ this._material.transmissionColor = this._material.baseColor;
578
+ this._material.transmissionColorTexture = this._material.baseColorTexture;
579
+ this._material.transmissionDepth = 0.0;
566
580
  }
567
581
  /**
568
582
  * Sets the transmission weight texture.
569
- * TODO: Implementation pending OpenPBR transmission feature availability.
570
583
  * @param value The transmission weight texture or null
571
584
  */
572
585
  set transmissionWeightTexture(value) {
573
- // TODO: Implement when OpenPBR transmission is available
574
- // this._material.transmissionWeightTexture = value;
586
+ this._material.transmissionWeightTexture = value;
575
587
  }
576
588
  /**
577
589
  * Gets the transmission weight.
578
- * TODO: Implementation pending OpenPBR transmission feature availability.
579
590
  * @returns Currently returns 0 as transmission is not yet available
580
591
  */
581
592
  get transmissionWeight() {
582
- // TODO: Implement when OpenPBR transmission is available
583
- // return this._material.transmissionWeight;
584
- return 0;
593
+ return this._material.transmissionWeight;
594
+ }
595
+ /**
596
+ * Sets the transmission scatter coefficient.
597
+ * @param value The scatter coefficient as a Vector3
598
+ */
599
+ set transmissionScatter(value) {
600
+ this._material.transmissionScatter = value;
585
601
  }
586
602
  /**
587
- * Gets the transmission dispersion Abbe number.
603
+ * Gets the transmission scatter coefficient.
604
+ * @returns The scatter coefficient as a Vector3
605
+ */
606
+ get transmissionScatter() {
607
+ return this._material.transmissionScatter;
608
+ }
609
+ set transmissionScatterTexture(value) {
610
+ this._material.transmissionScatterTexture = value;
611
+ }
612
+ get transmissionScatterTexture() {
613
+ return this._material.transmissionScatterTexture;
614
+ }
615
+ /**
616
+ * Sets the transmission scattering anisotropy.
617
+ * @param value The anisotropy intensity value (-1 to 1)
618
+ */
619
+ set transmissionScatterAnisotropy(value) {
620
+ this._material.transmissionScatterAnisotropy = value;
621
+ }
622
+ /**
623
+ * Sets the transmission dispersion Abbe number.
588
624
  * @param value The Abbe number value
589
625
  */
590
626
  set transmissionDispersionAbbeNumber(value) {
591
- // TODO: Implement when OpenPBR transmission dispersion is available
627
+ this._material.transmissionDispersionAbbeNumber = value;
592
628
  }
593
629
  /**
594
- * Configures transmission for OpenPBR material.
595
- * TODO: Implementation pending OpenPBR transmission feature availability.
630
+ * Sets the transmission dispersion scale.
631
+ * @param value The dispersion scale value
596
632
  */
597
- configureTransmission() {
598
- // OpenPBR transmission will be configured differently when available
633
+ set transmissionDispersionScale(value) {
634
+ this._material.transmissionDispersionScale = value;
599
635
  }
600
- // ========================================
601
- // VOLUME PROPERTIES (Subsurface Scattering)
602
- // ========================================
603
636
  /**
604
- * Sets the attenuation distance for volume scattering.
605
- * TODO: Implementation pending OpenPBR volume feature availability.
637
+ * Sets the attenuation distance.
606
638
  * @param value The attenuation distance value
607
639
  */
608
640
  set transmissionDepth(value) {
609
- // TODO: Implement when OpenPBR volume properties are available
610
- // this._material.attenuationDistance = value;
641
+ // If the value is being set to the default max value, and the current transmission depth is 0,
642
+ // we assume that attenuation color isn't used and keep it at 0 to allow
643
+ // us to use constant transmission color to handle glTF's surface tint from base color.
644
+ if (value !== Number.MAX_VALUE || this._material.transmissionDepth !== 0) {
645
+ this._material.transmissionDepth = value;
646
+ }
647
+ else {
648
+ this._material.transmissionDepth = 0;
649
+ }
650
+ }
651
+ /**
652
+ * Gets the attenuation distance.
653
+ */
654
+ get transmissionDepth() {
655
+ return this._material.transmissionDepth;
611
656
  }
612
657
  /**
613
- * Sets the attenuation color for volume scattering.
614
- * TODO: Implementation pending OpenPBR volume feature availability.
658
+ * Sets the attenuation color.
615
659
  * @param value The attenuation color as a Color3
616
660
  */
617
661
  set transmissionColor(value) {
618
- // TODO: Implement when OpenPBR volume properties are available
619
- // this._material.attenuationColor = value;
662
+ // Only set the transmission color if it's not white (default)
663
+ // This allows us to retain the base color as the transmission color,
664
+ // if that was previously set.
665
+ if (!value.equals(Color3.White())) {
666
+ this._material.transmissionColor = value;
667
+ }
668
+ }
669
+ /**
670
+ * Gets the attenuation color.
671
+ */
672
+ get transmissionColor() {
673
+ return this._material.transmissionColor;
674
+ }
675
+ /**
676
+ * Gets the refraction background texture
677
+ * @returns The refraction background texture or null
678
+ */
679
+ get refractionBackgroundTexture() {
680
+ return this._material.backgroundRefractionTexture;
681
+ }
682
+ /**
683
+ * Sets the refraction background texture
684
+ * @param value The refraction background texture or null
685
+ */
686
+ set refractionBackgroundTexture(value) {
687
+ this._material.backgroundRefractionTexture = value;
620
688
  }
621
689
  /**
622
- * Sets the thickness texture for volume scattering.
623
- * TODO: Implementation pending OpenPBR volume feature availability.
690
+ * Sets the thickness texture.
624
691
  * @param value The thickness texture or null
625
692
  */
626
693
  set volumeThicknessTexture(value) {
627
- // TODO: Implement when OpenPBR volume properties are available
628
- // this._material.thicknessTexture = value;
694
+ this._material.geometryThicknessTexture = value;
695
+ this._material._useGeometryThicknessFromGreenChannel = true;
629
696
  }
630
697
  /**
631
- * Sets the thickness factor for volume scattering.
632
- * TODO: Implementation pending OpenPBR volume feature availability.
698
+ * Sets the thickness factor.
633
699
  * @param value The thickness value
634
700
  */
635
701
  set volumeThickness(value) {
636
- // TODO: Implement when OpenPBR volume properties are available
637
- // this._material.thickness = value;
702
+ this._material.geometryThickness = value;
638
703
  }
639
704
  // ========================================
640
705
  // SUBSURFACE PROPERTIES (Subsurface Scattering)
@@ -645,6 +710,19 @@ export class OpenPBRMaterialLoadingAdapter {
645
710
  configureSubsurface() {
646
711
  // TODO
647
712
  }
713
+ /**
714
+ * Sets the extinction coefficient of the volume.
715
+ * @param value The extinction coefficient as a Vector3
716
+ */
717
+ set extinctionCoefficient(value) {
718
+ this._extinctionCoefficient = value;
719
+ }
720
+ /**
721
+ * Gets the extinction coefficient of the volume.
722
+ */
723
+ get extinctionCoefficient() {
724
+ return this._extinctionCoefficient;
725
+ }
648
726
  /**
649
727
  * Sets the subsurface weight
650
728
  */
@@ -675,6 +753,65 @@ export class OpenPBRMaterialLoadingAdapter {
675
753
  set subsurfaceColorTexture(value) {
676
754
  // TODO
677
755
  }
756
+ /**
757
+ * Sets the surface tint of the material (when using subsurface scattering)
758
+ */
759
+ set subsurfaceConstantTint(value) {
760
+ // There is no equivalent in OpenPBR
761
+ // Maybe multiply this by subsurfaceColor?
762
+ }
763
+ /**
764
+ * Gets the surface tint of the material (when using subsurface scattering)
765
+ */
766
+ get subsurfaceConstantTint() {
767
+ return Color3.White();
768
+ }
769
+ /**
770
+ * Sets the surface tint texture of the material (when using subsurface scattering)
771
+ */
772
+ set subsurfaceConstantTintTexture(value) {
773
+ // There is no equivalent in OpenPBR
774
+ // Maybe multiply this by subsurfaceColorTexture?
775
+ }
776
+ /**
777
+ * Gets the subsurface radius for subsurface scattering.
778
+ * subsurfaceRadiusScale * subsurfaceRadius gives the mean free path per color channel.
779
+ */
780
+ get subsurfaceRadius() {
781
+ // TODO
782
+ return 0;
783
+ }
784
+ /**
785
+ * Sets the subsurface radius for subsurface scattering.
786
+ * subsurfaceRadiusScale * subsurfaceRadius gives the mean free path per color channel.
787
+ * @param value The subsurface radius value
788
+ */
789
+ set subsurfaceRadius(value) {
790
+ // TODO
791
+ }
792
+ /**
793
+ * Gets the subsurface radius scale for subsurface scattering.
794
+ * subsurfaceRadiusScale * subsurfaceRadius gives the mean free path per color channel.
795
+ */
796
+ get subsurfaceRadiusScale() {
797
+ // TODO
798
+ return Color3.White();
799
+ }
800
+ /**
801
+ * Sets the subsurface radius scale for subsurface scattering.
802
+ * subsurfaceRadiusScale * subsurfaceRadius gives the mean free path per color channel.
803
+ * @param value The subsurface radius scale as a Color3
804
+ */
805
+ set subsurfaceRadiusScale(value) {
806
+ // TODO
807
+ }
808
+ /**
809
+ * Sets the subsurface scattering anisotropy.
810
+ * @param value The anisotropy intensity value
811
+ */
812
+ set subsurfaceScatterAnisotropy(value) {
813
+ // TODO
814
+ }
678
815
  // ========================================
679
816
  // FUZZ LAYER (Sheen)
680
817
  // ========================================