three-zoo 0.5.2 → 0.5.4

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/README.md CHANGED
@@ -16,9 +16,11 @@
16
16
  ## Features
17
17
 
18
18
  - 📷 **DualFovCamera** - Independent horizontal and vertical FOV control with auto-fitting
19
- - 🔍 **SceneTraversal** - Find and manipulate objects and materials in scene graphs
20
- - 🎭 **SkinnedMeshBaker** - Convert animated meshes to static geometry for optimization
21
19
  - ☀️ **Sun** - Intuitive spherical positioning for directional lights with HDR integration
20
+ - 🔍 **SceneTraversal** - Find and manipulate objects and materials in scene graphs
21
+ - 🎭 **SkinnedMeshBaker** - Convert animated meshes to static geometry
22
+ - 🎨 **StandardToLambertConverter** - Convert PBR materials to Lambert with visual compensation
23
+ - ✨ **StandardToBasicConverter** - Convert PBR materials to unlit Basic materials
22
24
 
23
25
  ## Installation
24
26
 
@@ -26,27 +28,6 @@
26
28
  npm install three-zoo
27
29
  ```
28
30
 
29
- ## Quick Start
30
-
31
- ```typescript
32
- import { DualFovCamera, SceneTraversal, Sun } from 'three-zoo';
33
-
34
- // Camera with independent FOV control
35
- const camera = new DualFovCamera(90, 60);
36
- camera.fitVerticalFovToMesh(characterMesh);
37
- camera.lookAtMeshCenterOfMass(characterMesh);
38
-
39
- // Scene traversal and manipulation
40
- const enemies = SceneTraversal.filterObjects(scene, /^enemy_/);
41
- const glassMaterials = SceneTraversal.filterMaterials(scene, /glass/i);
42
-
43
- // Intuitive sun positioning
44
- const sun = new Sun();
45
- sun.elevation = Math.PI / 4;
46
- sun.azimuth = Math.PI / 2;
47
- sun.configureShadowsForBoundingBox(sceneBounds);
48
- ```
49
-
50
31
  ## DualFovCamera
51
32
 
52
33
  Advanced camera with independent horizontal and vertical field of view:
@@ -67,6 +48,25 @@ camera.fitVerticalFovToMesh(skinnedMesh);
67
48
  camera.lookAtMeshCenterOfMass(skinnedMesh);
68
49
  ```
69
50
 
51
+ ## Sun
52
+
53
+ Directional light with spherical positioning:
54
+
55
+ ```typescript
56
+ const sun = new Sun();
57
+
58
+ // Spherical coordinates
59
+ sun.elevation = Math.PI / 4; // 45° above horizon
60
+ sun.azimuth = Math.PI / 2; // 90° rotation
61
+ sun.distance = 100; // Distance from origin
62
+
63
+ // Automatic shadow configuration
64
+ sun.configureShadowsForBoundingBox(sceneBounds);
65
+
66
+ // Position from HDR environment map
67
+ sun.setDirectionFromHDRTexture(hdrTexture, 50);
68
+ ```
69
+
70
70
  ## SceneTraversal
71
71
 
72
72
  Navigate and manipulate Three.js scene graphs:
@@ -106,23 +106,37 @@ const frameMesh = SkinnedMeshBaker.bakeAnimationFrame(
106
106
  );
107
107
  ```
108
108
 
109
- ## Sun
109
+ ## Material Converters
110
110
 
111
- Directional light with spherical positioning:
111
+ Convert PBR StandardMaterials to simpler material types while preserving visual appearance:
112
112
 
113
- ```typescript
114
- const sun = new Sun();
113
+ ### StandardToLambertConverter
115
114
 
116
- // Spherical coordinates
117
- sun.elevation = Math.PI / 4; // 45° above horizon
118
- sun.azimuth = Math.PI / 2; // 90° rotation
119
- sun.distance = 100; // Distance from origin
115
+ ```typescript
116
+ // Basic conversion
117
+ const lambertMaterial = StandardToLambertConverter.convert(standardMaterial);
118
+
119
+ // With custom options
120
+ const lambertMaterial = StandardToLambertConverter.convert(standardMaterial, {
121
+ preserveName: true,
122
+ roughnessColorFactor: 0.9,
123
+ disposeOriginal: true
124
+ });
125
+ ```
120
126
 
121
- // Automatic shadow configuration
122
- sun.configureShadowsForBoundingBox(sceneBounds);
127
+ ### StandardToBasicConverter
123
128
 
124
- // Position from HDR environment map
125
- sun.setDirectionFromHDRTexture(hdrTexture, 50);
129
+ ```typescript
130
+ // Convert to unlit material
131
+ const basicMaterial = StandardToBasicConverter.convert(standardMaterial);
132
+
133
+ // With brightness compensation
134
+ const basicMaterial = StandardToBasicConverter.convert(standardMaterial, {
135
+ brightnessFactor: 1.5,
136
+ combineEmissive: true,
137
+ preserveName: true,
138
+ disposeOriginal: false
139
+ });
126
140
  ```
127
141
 
128
142
  ## Requirements
@@ -0,0 +1,74 @@
1
+ import type { MeshStandardMaterial } from "three";
2
+ import { MeshBasicMaterial } from "three";
3
+ /**
4
+ * Configuration options for the StandardToBasicConverter
5
+ *
6
+ * @interface StandardToBasicConverterOptions
7
+ */
8
+ export interface StandardToBasicConverterOptions {
9
+ /**
10
+ * Whether to preserve the original material's name
11
+ * @defaultValue true
12
+ */
13
+ preserveName: boolean;
14
+ /**
15
+ * Whether to copy user data from the original material
16
+ * @defaultValue true
17
+ */
18
+ copyUserData: boolean;
19
+ /**
20
+ * Whether to dispose the original material after conversion
21
+ * @defaultValue false
22
+ */
23
+ disposeOriginal: boolean;
24
+ /**
25
+ * Whether to apply emissive color to the base color for brightness compensation
26
+ * @defaultValue true
27
+ */
28
+ combineEmissive: boolean;
29
+ /**
30
+ * Factor for brightness adjustment to compensate for loss of lighting
31
+ * @defaultValue 1.3
32
+ */
33
+ brightnessFactor: number;
34
+ }
35
+ /**
36
+ * Converts Three.js MeshStandardMaterial to MeshBasicMaterial
37
+ *
38
+ * This converter handles the translation from PBR (Physically Based Rendering)
39
+ * StandardMaterial to the unlit BasicMaterial. Since BasicMaterial doesn't respond
40
+ * to lighting, this converter applies various compensation techniques to maintain
41
+ * visual similarity, including brightness adjustments and emissive color combination.
42
+ */
43
+ export declare class StandardToBasicConverter {
44
+ /**
45
+ * Converts a MeshStandardMaterial to MeshBasicMaterial
46
+ *
47
+ * This method performs a comprehensive conversion from PBR StandardMaterial to
48
+ * unlit BasicMaterial while attempting to preserve visual similarity through
49
+ * brightness compensation and intelligent property mapping.
50
+ *
51
+ * @param standardMaterial - The source MeshStandardMaterial to convert
52
+ * @param options - Configuration options for the conversion
53
+ * @returns A new MeshBasicMaterial with properties mapped from the standard material
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * const standardMaterial = new MeshStandardMaterial({
58
+ * color: 0x00ff00,
59
+ * metalness: 0.5,
60
+ * emissive: 0x111111,
61
+ * emissiveIntensity: 0.2
62
+ * });
63
+ *
64
+ * const basicMaterial = StandardToBasicConverter.convert(standardMaterial, {
65
+ * brightnessFactor: 1.4,
66
+ * combineEmissive: true
67
+ * });
68
+ * ```
69
+ *
70
+ * @see {@link StandardToBasicConverterOptions} for available configuration options
71
+ */
72
+ static convert(standardMaterial: MeshStandardMaterial, options?: Partial<StandardToBasicConverterOptions>): MeshBasicMaterial;
73
+ }
74
+ export default StandardToBasicConverter;
@@ -0,0 +1,64 @@
1
+ import type { MeshStandardMaterial } from "three";
2
+ import { MeshLambertMaterial } from "three";
3
+ /**
4
+ * Configuration options for the StandardToLambertConverter
5
+ *
6
+ * @interface StandardToLambertConverterOptions
7
+ */
8
+ export interface StandardToLambertConverterOptions {
9
+ /**
10
+ * Whether to preserve the original material's name
11
+ * @defaultValue true
12
+ */
13
+ preserveName: boolean;
14
+ /**
15
+ * Whether to copy user data from the original material
16
+ * @defaultValue true
17
+ */
18
+ copyUserData: boolean;
19
+ /**
20
+ * Whether to dispose the original material after conversion
21
+ * @defaultValue false
22
+ */
23
+ disposeOriginal: boolean;
24
+ /**
25
+ * Custom color adjustment factor for roughness compensation
26
+ * @defaultValue 0.8
27
+ */
28
+ roughnessColorFactor: number;
29
+ }
30
+ /**
31
+ * Converts Three.js MeshStandardMaterial to MeshLambertMaterial
32
+ *
33
+ * This converter handles the translation between PBR (Physically Based Rendering)
34
+ * properties of StandardMaterial and the simpler Lambertian reflectance model
35
+ * used by LambertMaterial. The conversion preserves visual similarity by applying
36
+ * color compensation based on metalness and roughness values.
37
+ */
38
+ export declare class StandardToLambertConverter {
39
+ /**
40
+ * Converts a MeshStandardMaterial to MeshLambertMaterial
41
+ *
42
+ * This method performs a comprehensive conversion from PBR StandardMaterial to
43
+ * the simpler Lambert lighting model while attempting to preserve visual similarity
44
+ * through intelligent color compensation.
45
+ *
46
+ * @param material - The source MeshStandardMaterial to convert
47
+ * @param options - Configuration options for the conversion
48
+ * @returns A new MeshLambertMaterial with properties mapped from the standard material
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * const standardMaterial = new MeshStandardMaterial({
53
+ * color: 0xff0000,
54
+ * metalness: 0.8,
55
+ * roughness: 0.2
56
+ * });
57
+ *
58
+ * const lambertMaterial = StandardToLambertConverter.convert(standardMaterial);
59
+ * ```
60
+ *
61
+ * @see {@link StandardToLambertConverterOptions} for available configuration options
62
+ */
63
+ static convert(material: MeshStandardMaterial, options?: Partial<StandardToLambertConverterOptions>): MeshLambertMaterial;
64
+ }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from "./DualFovCamera";
2
2
  export * from "./SceneTraversal";
3
3
  export * from "./SkinnedMeshBaker";
4
+ export * from "./StandardToBasicConverter";
5
+ export * from "./StandardToLambertConverter";
4
6
  export * from "./Sun";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { PerspectiveCamera, MathUtils, Vector3, Mesh, BufferAttribute, AnimationMixer, DirectionalLight, Box3, Spherical, RGBAFormat } from 'three';
1
+ import { PerspectiveCamera, MathUtils, Vector3, Mesh, BufferAttribute, AnimationMixer, MeshBasicMaterial, MeshLambertMaterial, DirectionalLight, Box3, Spherical, RGBAFormat } from 'three';
2
2
 
3
3
  /** Default horizontal field of view in degrees */
4
4
  const DEFAULT_HORIZONTAL_FOV = 90;
@@ -550,6 +550,411 @@ class SkinnedMeshBaker {
550
550
  }
551
551
  }
552
552
 
553
+ /**
554
+ * Converts Three.js MeshStandardMaterial to MeshBasicMaterial
555
+ *
556
+ * This converter handles the translation from PBR (Physically Based Rendering)
557
+ * StandardMaterial to the unlit BasicMaterial. Since BasicMaterial doesn't respond
558
+ * to lighting, this converter applies various compensation techniques to maintain
559
+ * visual similarity, including brightness adjustments and emissive color combination.
560
+ */
561
+ class StandardToBasicConverter {
562
+ /**
563
+ * Converts a MeshStandardMaterial to MeshBasicMaterial
564
+ *
565
+ * This method performs a comprehensive conversion from PBR StandardMaterial to
566
+ * unlit BasicMaterial while attempting to preserve visual similarity through
567
+ * brightness compensation and intelligent property mapping.
568
+ *
569
+ * @param standardMaterial - The source MeshStandardMaterial to convert
570
+ * @param options - Configuration options for the conversion
571
+ * @returns A new MeshBasicMaterial with properties mapped from the standard material
572
+ *
573
+ * @example
574
+ * ```typescript
575
+ * const standardMaterial = new MeshStandardMaterial({
576
+ * color: 0x00ff00,
577
+ * metalness: 0.5,
578
+ * emissive: 0x111111,
579
+ * emissiveIntensity: 0.2
580
+ * });
581
+ *
582
+ * const basicMaterial = StandardToBasicConverter.convert(standardMaterial, {
583
+ * brightnessFactor: 1.4,
584
+ * combineEmissive: true
585
+ * });
586
+ * ```
587
+ *
588
+ * @see {@link StandardToBasicConverterOptions} for available configuration options
589
+ */
590
+ static convert(standardMaterial, options = {}) {
591
+ const config = {
592
+ preserveName: true,
593
+ copyUserData: true,
594
+ disposeOriginal: false,
595
+ combineEmissive: true,
596
+ brightnessFactor: 1.3,
597
+ ...options,
598
+ };
599
+ // Create new Basic material
600
+ const basicMaterial = new MeshBasicMaterial();
601
+ // Copy basic material properties
602
+ this.copyBasicProperties(standardMaterial, basicMaterial, config);
603
+ // Handle color properties with lighting compensation
604
+ this.convertColorProperties(standardMaterial, basicMaterial, config);
605
+ // Handle texture maps
606
+ this.convertTextureMaps(standardMaterial, basicMaterial);
607
+ // Handle transparency and alpha
608
+ this.convertTransparencyProperties(standardMaterial, basicMaterial);
609
+ // Cleanup if requested
610
+ if (config.disposeOriginal) {
611
+ standardMaterial.dispose();
612
+ }
613
+ basicMaterial.needsUpdate = true;
614
+ return basicMaterial;
615
+ }
616
+ /**
617
+ * Copies basic material properties from source to target material
618
+ *
619
+ * Transfers common material properties including rendering settings,
620
+ * visibility, fog interaction, wireframe settings, and user data.
621
+ *
622
+ * @param source - The source MeshStandardMaterial
623
+ * @param target - The target MeshBasicMaterial
624
+ * @param config - The resolved configuration options
625
+ * @internal
626
+ */
627
+ static copyBasicProperties(source, target, config) {
628
+ if (config.preserveName) {
629
+ target.name = source.name;
630
+ }
631
+ target.side = source.side;
632
+ target.visible = source.visible;
633
+ target.fog = source.fog;
634
+ target.wireframe = source.wireframe;
635
+ target.wireframeLinewidth = source.wireframeLinewidth;
636
+ target.vertexColors = source.vertexColors;
637
+ if (config.copyUserData) {
638
+ target.userData = { ...source.userData };
639
+ }
640
+ }
641
+ /**
642
+ * Converts color-related properties with lighting compensation
643
+ *
644
+ * Applies brightness compensation and optional emissive color combination
645
+ * to account for BasicMaterial's lack of lighting response. Metallic materials
646
+ * receive additional brightness adjustment, and colors are clamped to valid ranges.
647
+ *
648
+ * @param source - The source MeshStandardMaterial
649
+ * @param target - The target MeshBasicMaterial
650
+ * @param config - The resolved configuration options
651
+ * @internal
652
+ */
653
+ static convertColorProperties(source, target, config) {
654
+ // Base color conversion with brightness compensation
655
+ target.color = source.color.clone();
656
+ // Apply brightness compensation since BasicMaterial doesn't respond to lighting
657
+ target.color.multiplyScalar(config.brightnessFactor);
658
+ // Adjust for metalness - metallic materials tend to be darker without lighting
659
+ if (source.metalness > 0) {
660
+ const metalnessBrightness = 1 + source.metalness * 0.3;
661
+ target.color.multiplyScalar(metalnessBrightness);
662
+ }
663
+ // Combine emissive color if requested
664
+ if (config.combineEmissive) {
665
+ const emissiveContribution = source.emissive
666
+ .clone()
667
+ .multiplyScalar(source.emissiveIntensity * 0.5);
668
+ target.color.add(emissiveContribution);
669
+ }
670
+ // Ensure color doesn't exceed valid range
671
+ target.color.r = Math.min(target.color.r, 1.0);
672
+ target.color.g = Math.min(target.color.g, 1.0);
673
+ target.color.b = Math.min(target.color.b, 1.0);
674
+ }
675
+ /**
676
+ * Converts and maps texture properties from Standard to Basic material
677
+ *
678
+ * Handles the transfer of compatible texture maps including diffuse, alpha,
679
+ * environment, light, and AO maps. The metalness map is repurposed as a
680
+ * specular map for some reflective effect, and environment map reflectivity
681
+ * is set based on the original material's metalness value.
682
+ *
683
+ * @param source - The source MeshStandardMaterial
684
+ * @param target - The target MeshBasicMaterial
685
+ * @internal
686
+ */
687
+ static convertTextureMaps(source, target) {
688
+ // Main diffuse/albedo map
689
+ if (source.map) {
690
+ target.map = source.map;
691
+ }
692
+ // Alpha map
693
+ if (source.alphaMap) {
694
+ target.alphaMap = source.alphaMap;
695
+ }
696
+ // Environment map (BasicMaterial supports this for reflections)
697
+ if (source.envMap) {
698
+ target.envMap = source.envMap;
699
+ // Use metalness to determine reflectivity
700
+ target.reflectivity = source.metalness;
701
+ }
702
+ // Light map (BasicMaterial supports this)
703
+ if (source.lightMap) {
704
+ target.lightMap = source.lightMap;
705
+ target.lightMapIntensity = source.lightMapIntensity;
706
+ }
707
+ // AO map (BasicMaterial supports this)
708
+ if (source.aoMap) {
709
+ target.aoMap = source.aoMap;
710
+ target.aoMapIntensity = source.aoMapIntensity;
711
+ }
712
+ // Specular map (BasicMaterial supports this)
713
+ if (source.metalnessMap) {
714
+ // Use metalness map as specular map for some reflective effect
715
+ target.specularMap = source.metalnessMap;
716
+ }
717
+ // Copy UV transforms
718
+ this.copyUVTransforms(source, target);
719
+ }
720
+ /**
721
+ * Copies UV transformation properties for texture maps
722
+ *
723
+ * Transfers UV offset, repeat, rotation, and center properties from the
724
+ * source material's main texture map to the target material's map.
725
+ *
726
+ * @param source - The source MeshStandardMaterial
727
+ * @param target - The target MeshBasicMaterial
728
+ * @internal
729
+ */
730
+ static copyUVTransforms(source, target) {
731
+ // Main texture UV transform
732
+ if (source.map && target.map) {
733
+ target.map.offset.copy(source.map.offset);
734
+ target.map.repeat.copy(source.map.repeat);
735
+ target.map.rotation = source.map.rotation;
736
+ target.map.center.copy(source.map.center);
737
+ }
738
+ }
739
+ /**
740
+ * Converts transparency and rendering properties
741
+ *
742
+ * Transfers transparency, opacity, alpha testing, depth testing,
743
+ * depth writing, and blending mode settings from source to target.
744
+ *
745
+ * @param source - The source MeshStandardMaterial
746
+ * @param target - The target MeshBasicMaterial
747
+ * @internal
748
+ */
749
+ static convertTransparencyProperties(source, target) {
750
+ target.transparent = source.transparent;
751
+ target.opacity = source.opacity;
752
+ target.alphaTest = source.alphaTest;
753
+ target.depthTest = source.depthTest;
754
+ target.depthWrite = source.depthWrite;
755
+ target.blending = source.blending;
756
+ }
757
+ }
758
+
759
+ /**
760
+ * Converts Three.js MeshStandardMaterial to MeshLambertMaterial
761
+ *
762
+ * This converter handles the translation between PBR (Physically Based Rendering)
763
+ * properties of StandardMaterial and the simpler Lambertian reflectance model
764
+ * used by LambertMaterial. The conversion preserves visual similarity by applying
765
+ * color compensation based on metalness and roughness values.
766
+ */
767
+ class StandardToLambertConverter {
768
+ /**
769
+ * Converts a MeshStandardMaterial to MeshLambertMaterial
770
+ *
771
+ * This method performs a comprehensive conversion from PBR StandardMaterial to
772
+ * the simpler Lambert lighting model while attempting to preserve visual similarity
773
+ * through intelligent color compensation.
774
+ *
775
+ * @param material - The source MeshStandardMaterial to convert
776
+ * @param options - Configuration options for the conversion
777
+ * @returns A new MeshLambertMaterial with properties mapped from the standard material
778
+ *
779
+ * @example
780
+ * ```typescript
781
+ * const standardMaterial = new MeshStandardMaterial({
782
+ * color: 0xff0000,
783
+ * metalness: 0.8,
784
+ * roughness: 0.2
785
+ * });
786
+ *
787
+ * const lambertMaterial = StandardToLambertConverter.convert(standardMaterial);
788
+ * ```
789
+ *
790
+ * @see {@link StandardToLambertConverterOptions} for available configuration options
791
+ */
792
+ static convert(material, options = {}) {
793
+ const config = {
794
+ preserveName: true,
795
+ copyUserData: true,
796
+ disposeOriginal: false,
797
+ roughnessColorFactor: 0.8,
798
+ ...options,
799
+ };
800
+ // Create new Lambert material
801
+ const lambertMaterial = new MeshLambertMaterial();
802
+ // Copy basic material properties
803
+ this.copyBasicProperties(material, lambertMaterial, config);
804
+ // Handle color properties with roughness compensation
805
+ this.convertColorProperties(material, lambertMaterial, config);
806
+ // Handle texture maps
807
+ this.convertTextureMaps(material, lambertMaterial);
808
+ // Handle transparency and alpha
809
+ this.convertTransparencyProperties(material, lambertMaterial);
810
+ // Cleanup if requested
811
+ if (config.disposeOriginal) {
812
+ material.dispose();
813
+ }
814
+ lambertMaterial.needsUpdate = true;
815
+ return lambertMaterial;
816
+ }
817
+ /**
818
+ * Copies basic material properties from source to target material
819
+ *
820
+ * Transfers common material properties including rendering settings,
821
+ * visibility, fog interaction, wireframe settings, and user data.
822
+ *
823
+ * @param source - The source MeshStandardMaterial
824
+ * @param target - The target MeshLambertMaterial
825
+ * @param config - The resolved configuration options
826
+ * @internal
827
+ */
828
+ static copyBasicProperties(source, target, config) {
829
+ if (config.preserveName) {
830
+ target.name = source.name;
831
+ }
832
+ target.side = source.side;
833
+ target.visible = source.visible;
834
+ target.fog = source.fog;
835
+ target.wireframe = source.wireframe;
836
+ target.wireframeLinewidth = source.wireframeLinewidth;
837
+ target.vertexColors = source.vertexColors;
838
+ target.flatShading = source.flatShading;
839
+ if (config.copyUserData) {
840
+ target.userData = { ...source.userData };
841
+ }
842
+ }
843
+ /**
844
+ * Converts color-related properties with PBR compensation
845
+ *
846
+ * Applies intelligent color adjustments to compensate for the loss of
847
+ * metalness and roughness information when converting to Lambert material.
848
+ * Metallic materials are darkened and rough materials receive additional
849
+ * darkening based on the roughnessColorFactor.
850
+ *
851
+ * @param source - The source MeshStandardMaterial
852
+ * @param target - The target MeshLambertMaterial
853
+ * @param config - The resolved configuration options
854
+ * @internal
855
+ */
856
+ static convertColorProperties(source, target, config) {
857
+ target.color = source.color.clone();
858
+ // Adjust color based on metalness and roughness for better visual match
859
+ if (source.metalness > 0) {
860
+ // Metallic materials tend to be darker in Lambert shading
861
+ const metalnessFactor = 1 - source.metalness * 0.3;
862
+ target.color.multiplyScalar(metalnessFactor);
863
+ }
864
+ if (source.roughness > 0.5) {
865
+ // Rough materials appear slightly darker
866
+ const roughnessFactor = config.roughnessColorFactor + source.roughness * 0.2;
867
+ target.color.multiplyScalar(roughnessFactor);
868
+ }
869
+ target.emissive = source.emissive.clone();
870
+ target.emissiveIntensity = source.emissiveIntensity;
871
+ }
872
+ /**
873
+ * Converts and maps texture properties from Standard to Lambert material
874
+ *
875
+ * Handles the transfer of compatible texture maps including diffuse, normal,
876
+ * emissive, AO, light maps, and environment maps. The environment map
877
+ * reflectivity is set based on the original material's metalness value.
878
+ *
879
+ * @param source - The source MeshStandardMaterial
880
+ * @param target - The target MeshLambertMaterial
881
+ * @internal
882
+ */
883
+ static convertTextureMaps(source, target) {
884
+ // Diffuse/Albedo map
885
+ if (source.map) {
886
+ target.map = source.map;
887
+ }
888
+ // Emissive map
889
+ if (source.emissiveMap) {
890
+ target.emissiveMap = source.emissiveMap;
891
+ }
892
+ // Normal map (Lambert materials support normal mapping)
893
+ if (source.normalMap) {
894
+ target.normalMap = source.normalMap;
895
+ target.normalScale = source.normalScale.clone();
896
+ }
897
+ // Light map
898
+ if (source.lightMap) {
899
+ target.lightMap = source.lightMap;
900
+ target.lightMapIntensity = source.lightMapIntensity;
901
+ }
902
+ // AO map
903
+ if (source.aoMap) {
904
+ target.aoMap = source.aoMap;
905
+ target.aoMapIntensity = source.aoMapIntensity;
906
+ }
907
+ // Environment map (for reflections)
908
+ if (source.envMap) {
909
+ target.envMap = source.envMap;
910
+ target.reflectivity = Math.min(source.metalness + 0.1, 1.0);
911
+ }
912
+ // Alpha map
913
+ if (source.alphaMap) {
914
+ target.alphaMap = source.alphaMap;
915
+ }
916
+ // Copy UV transforms
917
+ this.copyUVTransforms(source, target);
918
+ }
919
+ /**
920
+ * Copies UV transformation properties for texture maps
921
+ *
922
+ * Transfers UV offset, repeat, rotation, and center properties from the
923
+ * source material's main texture map to the target material's map.
924
+ *
925
+ * @param source - The source MeshStandardMaterial
926
+ * @param target - The target MeshLambertMaterial
927
+ * @internal
928
+ */
929
+ static copyUVTransforms(source, target) {
930
+ // Main texture UV transform
931
+ if (source.map && target.map) {
932
+ target.map.offset.copy(source.map.offset);
933
+ target.map.repeat.copy(source.map.repeat);
934
+ target.map.rotation = source.map.rotation;
935
+ target.map.center.copy(source.map.center);
936
+ }
937
+ }
938
+ /**
939
+ * Converts transparency and rendering properties
940
+ *
941
+ * Transfers transparency, opacity, alpha testing, depth testing,
942
+ * depth writing, and blending mode settings from source to target.
943
+ *
944
+ * @param source - The source MeshStandardMaterial
945
+ * @param target - The target MeshLambertMaterial
946
+ * @internal
947
+ */
948
+ static convertTransparencyProperties(source, target) {
949
+ target.transparent = source.transparent;
950
+ target.opacity = source.opacity;
951
+ target.alphaTest = source.alphaTest;
952
+ target.depthTest = source.depthTest;
953
+ target.depthWrite = source.depthWrite;
954
+ target.blending = source.blending;
955
+ }
956
+ }
957
+
553
958
  /** Number of color channels in RGBA format */
554
959
  const RGBA_CHANNEL_COUNT = 4;
555
960
  /** Number of color channels in RGB format */
@@ -711,5 +1116,5 @@ class Sun extends DirectionalLight {
711
1116
  }
712
1117
  }
713
1118
 
714
- export { DualFovCamera, SceneTraversal, SkinnedMeshBaker, Sun };
1119
+ export { DualFovCamera, SceneTraversal, SkinnedMeshBaker, StandardToBasicConverter, StandardToLambertConverter, Sun };
715
1120
  //# sourceMappingURL=index.js.map