three-zoo 0.5.3 → 0.5.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/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  <p align="center">
2
2
  <h1 align="center">🦁 three-zoo</h1>
3
3
  <p align="center">
4
- A modest collection of Three.js utilities designed to simplify common 3D development tasks.
4
+ A small collection of Three.js utilities I use in my daily work with 3D development.
5
5
  </p>
6
6
  </p>
7
7
 
@@ -13,12 +13,14 @@
13
13
  <a href="https://threejs.org/"><img src="https://img.shields.io/badge/Three.js-%5E0.175.0-green" alt="Three.js"></a>
14
14
  </p>
15
15
 
16
- ## Features
16
+ ## What's included
17
17
 
18
- - 📷 **DualFovCamera** - Independent horizontal and vertical FOV control with auto-fitting
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
18
+ - 📷 **DualFovCamera** - Camera with separate horizontal and vertical FOV controls
19
+ - ☀️ **Sun** - Directional light with spherical positioning
20
+ - 🔍 **SceneTraversal** - Helper functions for finding objects and materials in scenes
21
+ - 🎭 **SkinnedMeshBaker** - Converts animated meshes to static geometry
22
+ - 🎨 **StandardToLambertConverter** - Converts PBR materials to Lambert materials
23
+ - ✨ **StandardToBasicConverter** - Converts PBR materials to Basic materials
22
24
 
23
25
  ## Installation
24
26
 
@@ -28,60 +30,60 @@ npm install three-zoo
28
30
 
29
31
  ## DualFovCamera
30
32
 
31
- Advanced camera with independent horizontal and vertical field of view:
33
+ A camera that lets you control horizontal and vertical field of view separately:
32
34
 
33
35
  ```typescript
34
36
  const camera = new DualFovCamera(90, 60);
35
37
 
36
- // Independent FOV control
38
+ // Set FOV values independently
37
39
  camera.horizontalFov = 100;
38
40
  camera.verticalFov = 70;
39
41
 
40
- // Auto-fit objects in view
42
+ // Fit objects in view
41
43
  camera.fitVerticalFovToPoints(vertices);
42
44
  camera.fitVerticalFovToBox(boundingBox);
43
45
  camera.fitVerticalFovToMesh(skinnedMesh);
44
46
 
45
- // Smart camera positioning
47
+ // Position camera based on mesh center
46
48
  camera.lookAtMeshCenterOfMass(skinnedMesh);
47
49
  ```
48
50
 
49
51
  ## Sun
50
52
 
51
- Directional light with spherical positioning:
53
+ A directional light with spherical positioning:
52
54
 
53
55
  ```typescript
54
56
  const sun = new Sun();
55
57
 
56
- // Spherical coordinates
58
+ // Position using spherical coordinates
57
59
  sun.elevation = Math.PI / 4; // 45° above horizon
58
60
  sun.azimuth = Math.PI / 2; // 90° rotation
59
61
  sun.distance = 100; // Distance from origin
60
62
 
61
- // Automatic shadow configuration
63
+ // Set up shadows for a bounding box
62
64
  sun.configureShadowsForBoundingBox(sceneBounds);
63
65
 
64
- // Position from HDR environment map
66
+ // Position based on HDR environment map
65
67
  sun.setDirectionFromHDRTexture(hdrTexture, 50);
66
68
  ```
67
69
 
68
70
  ## SceneTraversal
69
71
 
70
- Navigate and manipulate Three.js scene graphs:
72
+ Functions for working with Three.js scene graphs:
71
73
 
72
74
  ```typescript
73
75
  // Find by name
74
76
  const player = SceneTraversal.getObjectByName(scene, 'Player');
75
77
  const metal = SceneTraversal.getMaterialByName(scene, 'MetalMaterial');
76
78
 
77
- // Filter with patterns
79
+ // Find with patterns
78
80
  const enemies = SceneTraversal.filterObjects(scene, /^enemy_/);
79
81
  const glassMats = SceneTraversal.filterMaterials(scene, /glass/i);
80
82
 
81
- // Find material users
83
+ // Find objects using specific materials
82
84
  const glassObjects = SceneTraversal.findMaterialUsers(scene, /glass/i);
83
85
 
84
- // Batch operations
86
+ // Process all materials in a scene
85
87
  SceneTraversal.enumerateMaterials(scene, (material) => {
86
88
  if ('roughness' in material) material.roughness = 0.8;
87
89
  });
@@ -104,6 +106,39 @@ const frameMesh = SkinnedMeshBaker.bakeAnimationFrame(
104
106
  );
105
107
  ```
106
108
 
109
+ ## Material Converters
110
+
111
+ Convert PBR materials to simpler types. Useful for performance optimization:
112
+
113
+ ### StandardToLambertConverter
114
+
115
+ ```typescript
116
+ // Basic conversion
117
+ const lambertMaterial = StandardToLambertConverter.convert(standardMaterial);
118
+
119
+ // With options
120
+ const lambertMaterial = StandardToLambertConverter.convert(standardMaterial, {
121
+ preserveName: true,
122
+ roughnessColorFactor: 0.9,
123
+ disposeOriginal: true
124
+ });
125
+ ```
126
+
127
+ ### StandardToBasicConverter
128
+
129
+ ```typescript
130
+ // Convert to unlit material
131
+ const basicMaterial = StandardToBasicConverter.convert(standardMaterial);
132
+
133
+ // With brightness adjustment
134
+ const basicMaterial = StandardToBasicConverter.convert(standardMaterial, {
135
+ brightnessFactor: 1.5,
136
+ combineEmissive: true,
137
+ preserveName: true,
138
+ disposeOriginal: false
139
+ });
140
+ ```
141
+
107
142
  ## Requirements
108
143
 
109
144
  - Three.js ^0.175.0 (peer dependency)
@@ -111,7 +146,7 @@ const frameMesh = SkinnedMeshBaker.bakeAnimationFrame(
111
146
 
112
147
  ## Contributing
113
148
 
114
- Contributions are welcome! Please feel free to submit issues and pull requests.
149
+ Feel free to submit issues and pull requests if you find these utilities helpful.
115
150
 
116
151
  ## License
117
152
 
@@ -11,50 +11,50 @@ export declare class DualFovCamera extends PerspectiveCamera {
11
11
  /** Internal storage for vertical field of view in degrees */
12
12
  private verticalFovInternal;
13
13
  /**
14
- * Creates a new DualFovCamera instance with independent horizontal and vertical FOV control.
14
+ * Creates a new DualFovCamera instance.
15
15
  *
16
- * @param horizontalFov - Horizontal field of view in degrees. Must be between 1° and 179°. Defaults to 90°.
17
- * @param verticalFov - Vertical field of view in degrees. Must be between 1° and 179°. Defaults to 90°.
18
- * @param aspect - Camera aspect ratio (width/height). Defaults to 1.
19
- * @param near - Near clipping plane distance. Must be greater than 0. Defaults to 1.
20
- * @param far - Far clipping plane distance. Must be greater than near plane. Defaults to 1000.
16
+ * @param horizontalFov - Horizontal field of view in degrees. Clamped between 1° and 179°.
17
+ * @param verticalFov - Vertical field of view in degrees. Clamped between 1° and 179°.
18
+ * @param aspect - Camera aspect ratio (width/height).
19
+ * @param near - Near clipping plane distance.
20
+ * @param far - Far clipping plane distance.
21
21
  */
22
22
  constructor(horizontalFov?: number, verticalFov?: number, aspect?: number, near?: number, far?: number);
23
23
  /**
24
- * Gets the current horizontal field of view in degrees.
24
+ * Gets the horizontal field of view in degrees.
25
25
  *
26
- * @returns The horizontal FOV value between 1° and 179°
26
+ * @returns The horizontal FOV value
27
27
  */
28
28
  get horizontalFov(): number;
29
29
  /**
30
- * Gets the current vertical field of view in degrees.
30
+ * Gets the vertical field of view in degrees.
31
31
  *
32
- * @returns The vertical FOV value between 1° and 179°
32
+ * @returns The vertical FOV value
33
33
  */
34
34
  get verticalFov(): number;
35
35
  /**
36
36
  * Sets the horizontal field of view in degrees.
37
37
  *
38
- * @param value - The horizontal FOV value in degrees. Will be clamped between 1° and 179°.
38
+ * @param value - The horizontal FOV value in degrees. Clamped between 1° and 179°.
39
39
  */
40
40
  set horizontalFov(value: number);
41
41
  /**
42
42
  * Sets the vertical field of view in degrees.
43
43
  *
44
- * @param value - The vertical FOV value in degrees. Will be clamped between 1° and 179°.
44
+ * @param value - The vertical FOV value in degrees. Clamped between 1° and 179°.
45
45
  */
46
46
  set verticalFov(value: number);
47
47
  /**
48
- * Updates both horizontal and vertical field of view values simultaneously.
48
+ * Sets both horizontal and vertical field of view values.
49
49
  *
50
- * @param horizontal - Horizontal FOV in degrees. Will be clamped between 1° and 179°.
51
- * @param vertical - Vertical FOV in degrees. Will be clamped between 1° and 179°.
50
+ * @param horizontal - Horizontal FOV in degrees. Clamped between 1° and 179°.
51
+ * @param vertical - Vertical FOV in degrees. Clamped between 1° and 179°.
52
52
  */
53
53
  setFov(horizontal: number, vertical: number): void;
54
54
  /**
55
- * Copies the field of view settings from another DualFovCamera instance.
55
+ * Copies the field of view settings from another DualFovCamera.
56
56
  *
57
- * @param source - The DualFovCamera instance to copy FOV settings from.
57
+ * @param source - The DualFovCamera to copy FOV settings from.
58
58
  */
59
59
  copyFovSettings(source: DualFovCamera): void;
60
60
  /**
@@ -64,78 +64,77 @@ export declare class DualFovCamera extends PerspectiveCamera {
64
64
  * - **Landscape mode (aspect > 1)**: Preserves horizontal FOV, calculates vertical FOV
65
65
  * - **Portrait mode (aspect ≤ 1)**: Preserves vertical FOV, calculates horizontal FOV
66
66
  *
67
- * This method is automatically called when FOV values or aspect ratio changes.
67
+ * Called when FOV values or aspect ratio changes.
68
68
  *
69
69
  * @override
70
70
  */
71
71
  updateProjectionMatrix(): void;
72
72
  /**
73
- * Gets the actual horizontal field of view after aspect ratio adjustments.
73
+ * Gets the horizontal field of view after aspect ratio adjustments.
74
74
  *
75
- * In landscape mode, this returns the set horizontal FOV.
76
- * In portrait mode, this calculates the actual horizontal FOV based on the vertical FOV and aspect ratio.
75
+ * In landscape mode, returns the set horizontal FOV.
76
+ * In portrait mode, calculates the horizontal FOV from vertical FOV and aspect ratio.
77
77
  *
78
- * @returns The actual horizontal FOV in degrees
78
+ * @returns The horizontal FOV in degrees
79
79
  */
80
80
  getActualHorizontalFov(): number;
81
81
  /**
82
- * Gets the actual vertical field of view after aspect ratio adjustments.
82
+ * Gets the vertical field of view after aspect ratio adjustments.
83
83
  *
84
- * In portrait mode, this returns the set vertical FOV.
85
- * In landscape mode, this calculates the actual vertical FOV based on the horizontal FOV and aspect ratio.
84
+ * In portrait mode, returns the set vertical FOV.
85
+ * In landscape mode, calculates the vertical FOV from horizontal FOV and aspect ratio.
86
86
  *
87
- * @returns The actual vertical FOV in degrees
87
+ * @returns The vertical FOV in degrees
88
88
  */
89
89
  getActualVerticalFov(): number;
90
90
  /**
91
- * Adjusts the vertical field of view to fit all specified points within the camera's view.
91
+ * Adjusts the vertical field of view to fit specified points within the camera's view.
92
92
  *
93
- * This method calculates the required vertical FOV to ensure all provided vertices
93
+ * Calculates the required vertical FOV to ensure all provided vertices
94
94
  * are visible within the vertical bounds of the camera's frustum.
95
95
  *
96
- * @param vertices - Array of 3D points (in world coordinates) that should fit within the camera's vertical view
96
+ * @param vertices - Array of 3D points in world coordinates
97
97
  */
98
98
  fitVerticalFovToPoints(vertices: Vector3[]): void;
99
99
  /**
100
100
  * Adjusts the vertical field of view to fit a bounding box within the camera's view.
101
101
  *
102
- * This method calculates the required vertical FOV to ensure the entire bounding box
102
+ * Calculates the required vertical FOV to ensure the bounding box
103
103
  * is visible within the vertical bounds of the camera's frustum.
104
104
  *
105
- * @param box - The 3D bounding box (in world coordinates) that should fit within the camera's vertical view
105
+ * @param box - The 3D bounding box in world coordinates
106
106
  */
107
107
  fitVerticalFovToBox(box: Box3): void;
108
108
  /**
109
109
  * Adjusts the vertical field of view to fit a skinned mesh within the camera's view.
110
110
  *
111
- * This method updates the mesh's skeleton, applies bone transformations to all vertices,
112
- * and then calculates the required vertical FOV to ensure the entire deformed mesh
113
- * is visible within the vertical bounds of the camera's frustum.
111
+ * Updates the mesh's skeleton, applies bone transformations to vertices,
112
+ * and calculates the required vertical FOV to fit the deformed mesh
113
+ * within the vertical bounds of the camera's frustum.
114
114
  *
115
- * @param skinnedMesh - The skinned mesh (with active skeleton) that should fit within the camera's vertical view
115
+ * @param skinnedMesh - The skinned mesh with active skeleton
116
116
  */
117
117
  fitVerticalFovToMesh(skinnedMesh: SkinnedMesh): void;
118
118
  /**
119
119
  * Points the camera to look at the center of mass of a skinned mesh.
120
120
  *
121
- * This method updates the mesh's skeleton, applies bone transformations to all vertices,
122
- * calculates the center of mass using a clustering algorithm, and then orients the camera
121
+ * Updates the mesh's skeleton, applies bone transformations to vertices,
122
+ * calculates the center of mass using a clustering algorithm, and orients the camera
123
123
  * to look at that point.
124
124
  *
125
- * The center of mass calculation uses an iterative clustering approach to find the
126
- * main concentration of vertices, which provides better results than a simple average
127
- * for complex meshes.
125
+ * The center of mass calculation uses iterative clustering to find the
126
+ * main concentration of vertices.
128
127
  *
129
- * @param skinnedMesh - The skinned mesh (with active skeleton) whose center of mass should be the camera's target
128
+ * @param skinnedMesh - The skinned mesh with active skeleton
130
129
  */
131
130
  lookAtMeshCenterOfMass(skinnedMesh: SkinnedMesh): void;
132
131
  /**
133
- * Creates a deep copy of this DualFovCamera instance.
132
+ * Creates a copy of this DualFovCamera.
134
133
  *
135
- * The cloned camera will have identical FOV settings, position, rotation,
134
+ * The cloned camera has identical FOV settings, position, rotation,
136
135
  * and all other camera properties.
137
136
  *
138
- * @returns A new DualFovCamera instance that is an exact copy of this one
137
+ * @returns A new DualFovCamera instance
139
138
  * @override
140
139
  */
141
140
  clone(): this;
@@ -1,10 +1,10 @@
1
1
  import type { Material, Object3D } from "three";
2
2
  import { Mesh } from "three";
3
3
  /**
4
- * Constructor type for type-safe scene traversal operations.
4
+ * Constructor type for scene traversal operations.
5
5
  *
6
- * This type represents any constructor function that can be used to create instances of type T.
7
- * It's used for runtime type checking when filtering objects by their constructor type.
6
+ * Represents a constructor function that creates instances of type T.
7
+ * Used for runtime type checking when filtering objects by constructor type.
8
8
  *
9
9
  * @template T - The type that the constructor creates
10
10
  */
@@ -12,99 +12,89 @@ export type Constructor<T> = abstract new (...args: never[]) => T;
12
12
  /**
13
13
  * Utility class for finding and modifying objects in a Three.js scene graph.
14
14
  *
15
- * This class provides static methods for traversing Three.js scene hierarchies,
16
- * searching for specific objects or materials, and performing batch operations
17
- * on collections of scene objects.
15
+ * Provides static methods for traversing Three.js scene hierarchies,
16
+ * searching for objects or materials, and performing batch operations.
18
17
  *
19
- * All methods perform depth-first traversal of the scene graph starting from
20
- * the provided root object and recursively processing all children.
18
+ * All methods perform depth-first traversal starting from the provided
19
+ * root object and recursively processing all children.
21
20
  */
22
21
  export declare class SceneTraversal {
23
22
  /**
24
23
  * Finds the first object in the scene hierarchy with an exact name match.
25
24
  *
26
- * Performs a depth-first search through the scene graph starting from the provided
27
- * root object. Returns the first object encountered whose name property exactly
28
- * matches the search string.
25
+ * Performs depth-first search through the scene graph starting from the
26
+ * root object. Returns the first object whose name property matches
27
+ * the search string.
29
28
  *
30
29
  * @param object - The root Object3D to start searching from
31
30
  * @param name - The exact name to search for (case-sensitive)
32
31
  * @returns The first matching Object3D, or null if no match is found
33
-
34
32
  */
35
33
  static getObjectByName(object: Object3D, name: string): Object3D | null;
36
34
  /**
37
35
  * Finds the first material in the scene hierarchy with an exact name match.
38
36
  *
39
- * Performs a depth-first search through the scene graph, examining materials
37
+ * Performs depth-first search through the scene graph, examining materials
40
38
  * attached to Mesh objects. Handles both single materials and material arrays.
41
- * Returns the first material encountered whose name property exactly matches
42
- * the search string.
39
+ * Returns the first material whose name property matches the search string.
43
40
  *
44
41
  * @param object - The root Object3D to start searching from
45
42
  * @param name - The exact material name to search for (case-sensitive)
46
43
  * @returns The first matching Material, or null if no match is found
47
-
48
44
  */
49
45
  static getMaterialByName(object: Object3D, name: string): Material | null;
50
46
  /**
51
47
  * Processes all objects of a specific type in the scene hierarchy.
52
48
  *
53
- * Performs a depth-first traversal and executes the provided callback function
54
- * for every object that is an instance of the specified type. This is useful
55
- * for batch operations on specific object types (e.g., all lights, all meshes, etc.).
49
+ * Performs depth-first traversal and executes the callback function
50
+ * for every object that is an instance of the specified type.
56
51
  *
57
52
  * @template T - The type of objects to process
58
53
  * @param object - The root Object3D to start searching from
59
54
  * @param type - The constructor/class to filter by (e.g., DirectionalLight, Mesh)
60
55
  * @param callback - Function to execute for each matching object instance
61
-
62
56
  */
63
57
  static enumerateObjectsByType<T>(object: Object3D, type: Constructor<T>, callback: (instance: T) => void): void;
64
58
  /**
65
59
  * Processes all materials found in mesh objects within the scene hierarchy.
66
60
  *
67
- * Performs a depth-first traversal, finding all Mesh objects and executing
68
- * the provided callback function for each material. Handles both single
69
- * materials and material arrays properly.
61
+ * Performs depth-first traversal, finding all Mesh objects and executing
62
+ * the callback function for each material. Handles both single
63
+ * materials and material arrays.
70
64
  *
71
65
  * @param object - The root Object3D to start searching from
72
66
  * @param callback - Function to execute for each material found
73
-
74
67
  */
75
68
  static enumerateMaterials(object: Object3D, callback: (material: Material) => void): void;
76
69
  /**
77
- * Finds all objects in the scene hierarchy that match the specified filter criteria.
70
+ * Finds all objects in the scene hierarchy that match filter criteria.
78
71
  *
79
- * Performs a depth-first search and collects all objects that either match
80
- * a regular expression pattern (applied to the object's name) or satisfy
81
- * a custom predicate function.
72
+ * Performs depth-first search and collects all objects that either match
73
+ * a regular expression pattern (applied to object names) or satisfy
74
+ * a predicate function.
82
75
  *
83
76
  * @param object - The root Object3D to start searching from
84
77
  * @param filter - Either a RegExp to test against object names, or a predicate function
85
78
  * @returns Array of all matching Object3D instances
86
-
87
79
  */
88
80
  static filterObjects(object: Object3D, filter: RegExp | ((object: Object3D) => boolean)): Object3D[];
89
81
  /**
90
- * Finds all materials in the scene hierarchy whose names match a regular expression pattern.
82
+ * Finds all materials in the scene hierarchy whose names match a pattern.
91
83
  *
92
- * Performs a depth-first search through all Mesh objects and collects materials
93
- * whose name property matches the provided regular expression. Handles both
94
- * single materials and material arrays properly.
84
+ * Performs depth-first search through all Mesh objects and collects materials
85
+ * whose name property matches the regular expression. Handles both
86
+ * single materials and material arrays.
95
87
  *
96
88
  * @param object - The root Object3D to start searching from
97
89
  * @param name - Regular expression pattern to test against material names
98
90
  * @returns Array of all matching Material instances
99
-
100
91
  */
101
92
  static filterMaterials(object: Object3D, name: RegExp): Material[];
102
93
  /**
103
- * Finds all objects (mesh users) that use materials with names matching a regular expression pattern.
94
+ * Finds all mesh objects that use materials with names matching a pattern.
104
95
  *
105
- * Performs a depth-first search through all Mesh objects and collects the mesh objects
106
- * whose materials have names that match the provided regular expression. This is useful
107
- * for finding all objects that use specific material types or naming patterns.
96
+ * Performs depth-first search through all Mesh objects and collects mesh objects
97
+ * whose materials have names that match the regular expression.
108
98
  *
109
99
  * @param object - The root Object3D to start searching from
110
100
  * @param materialName - Regular expression pattern to test against material names
@@ -1,19 +1,19 @@
1
1
  import type { AnimationClip, Object3D, SkinnedMesh } from "three";
2
2
  import { Mesh } from "three";
3
- /** Convert skinned meshes to regular static meshes */
3
+ /** Converts skinned meshes to static meshes */
4
4
  export declare class SkinnedMeshBaker {
5
5
  /**
6
- * Convert a skinned mesh to a regular mesh in its current pose.
7
- * The resulting mesh will have no bones but look identical.
6
+ * Converts a skinned mesh to a static mesh in its current pose.
7
+ * The resulting mesh has no bones but looks identical.
8
8
  *
9
9
  * @param skinnedMesh - Mesh to convert
10
10
  * @returns Static mesh with baked vertex positions
11
11
  */
12
12
  static bakePose(skinnedMesh: SkinnedMesh): Mesh;
13
13
  /**
14
- * Bake a single frame from an animation into a static mesh.
14
+ * Bakes a single frame from an animation into a static mesh.
15
15
  *
16
- * @param armature - Root object with bones (usually from GLTF)
16
+ * @param armature - Root object with bones
17
17
  * @param skinnedMesh - Mesh to convert
18
18
  * @param timeOffset - Time in seconds within the animation
19
19
  * @param clip - Animation to get the pose from
@@ -0,0 +1,68 @@
1
+ import type { MeshStandardMaterial } from "three";
2
+ import { MeshBasicMaterial } from "three";
3
+ /**
4
+ * Configuration options for the StandardToBasicConverter.
5
+ */
6
+ export interface StandardToBasicConverterOptions {
7
+ /**
8
+ * Whether to preserve the original material's name
9
+ * @defaultValue true
10
+ */
11
+ preserveName: boolean;
12
+ /**
13
+ * Whether to copy user data from the original material
14
+ * @defaultValue true
15
+ */
16
+ copyUserData: boolean;
17
+ /**
18
+ * Whether to dispose the original material after conversion
19
+ * @defaultValue false
20
+ */
21
+ disposeOriginal: boolean;
22
+ /**
23
+ * Whether to apply emissive color to the base color for brightness compensation
24
+ * @defaultValue true
25
+ */
26
+ combineEmissive: boolean;
27
+ /**
28
+ * Factor for brightness adjustment to compensate for loss of lighting
29
+ * @defaultValue 1.3
30
+ */
31
+ brightnessFactor: number;
32
+ }
33
+ /**
34
+ * Converts Three.js MeshStandardMaterial to MeshBasicMaterial.
35
+ *
36
+ * Handles translation from PBR StandardMaterial to unlit BasicMaterial.
37
+ * Since BasicMaterial doesn't respond to lighting, applies compensation
38
+ * techniques including brightness adjustments and emissive color combination.
39
+ */
40
+ export declare class StandardToBasicConverter {
41
+ /**
42
+ * Converts a MeshStandardMaterial to MeshBasicMaterial.
43
+ *
44
+ * Performs conversion from PBR StandardMaterial to unlit BasicMaterial
45
+ * with brightness compensation and property mapping.
46
+ *
47
+ * @param standardMaterial - The source MeshStandardMaterial to convert
48
+ * @param options - Configuration options for the conversion
49
+ * @returns A new MeshBasicMaterial with properties mapped from the standard material
50
+ *
51
+ * @example
52
+ * ```typescript
53
+ * const standardMaterial = new MeshStandardMaterial({
54
+ * color: 0x00ff00,
55
+ * metalness: 0.5,
56
+ * emissive: 0x111111,
57
+ * emissiveIntensity: 0.2
58
+ * });
59
+ *
60
+ * const basicMaterial = StandardToBasicConverter.convert(standardMaterial, {
61
+ * brightnessFactor: 1.4,
62
+ * combineEmissive: true
63
+ * });
64
+ * ```
65
+ */
66
+ static convert(standardMaterial: MeshStandardMaterial, options?: Partial<StandardToBasicConverterOptions>): MeshBasicMaterial;
67
+ }
68
+ export default StandardToBasicConverter;
@@ -0,0 +1,58 @@
1
+ import type { MeshStandardMaterial } from "three";
2
+ import { MeshLambertMaterial } from "three";
3
+ /**
4
+ * Configuration options for the StandardToLambertConverter.
5
+ */
6
+ export interface StandardToLambertConverterOptions {
7
+ /**
8
+ * Whether to preserve the original material's name
9
+ * @defaultValue true
10
+ */
11
+ preserveName: boolean;
12
+ /**
13
+ * Whether to copy user data from the original material
14
+ * @defaultValue true
15
+ */
16
+ copyUserData: boolean;
17
+ /**
18
+ * Whether to dispose the original material after conversion
19
+ * @defaultValue false
20
+ */
21
+ disposeOriginal: boolean;
22
+ /**
23
+ * Custom color adjustment factor for roughness compensation
24
+ * @defaultValue 0.8
25
+ */
26
+ roughnessColorFactor: number;
27
+ }
28
+ /**
29
+ * Converts Three.js MeshStandardMaterial to MeshLambertMaterial.
30
+ *
31
+ * Handles translation between PBR properties of StandardMaterial and
32
+ * the Lambertian reflectance model used by LambertMaterial. Applies
33
+ * color compensation based on metalness and roughness values.
34
+ */
35
+ export declare class StandardToLambertConverter {
36
+ /**
37
+ * Converts a MeshStandardMaterial to MeshLambertMaterial.
38
+ *
39
+ * Performs conversion from PBR StandardMaterial to Lambert lighting model
40
+ * with color compensation based on metalness and roughness values.
41
+ *
42
+ * @param material - The source MeshStandardMaterial to convert
43
+ * @param options - Configuration options for the conversion
44
+ * @returns A new MeshLambertMaterial with properties mapped from the standard material
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const standardMaterial = new MeshStandardMaterial({
49
+ * color: 0xff0000,
50
+ * metalness: 0.8,
51
+ * roughness: 0.2
52
+ * });
53
+ *
54
+ * const lambertMaterial = StandardToLambertConverter.convert(standardMaterial);
55
+ * ```
56
+ */
57
+ static convert(material: MeshStandardMaterial, options?: Partial<StandardToLambertConverterOptions>): MeshLambertMaterial;
58
+ }