three-zoo 0.5.4 → 0.5.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.
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,14 +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
22
- - 🎨 **StandardToLambertConverter** - Convert PBR materials to Lambert with visual compensation
23
- - ✨ **StandardToBasicConverter** - Convert PBR materials to unlit Basic materials
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
24
24
 
25
25
  ## Installation
26
26
 
@@ -30,60 +30,60 @@ npm install three-zoo
30
30
 
31
31
  ## DualFovCamera
32
32
 
33
- Advanced camera with independent horizontal and vertical field of view:
33
+ A camera that lets you control horizontal and vertical field of view separately:
34
34
 
35
35
  ```typescript
36
36
  const camera = new DualFovCamera(90, 60);
37
37
 
38
- // Independent FOV control
38
+ // Set FOV values independently
39
39
  camera.horizontalFov = 100;
40
40
  camera.verticalFov = 70;
41
41
 
42
- // Auto-fit objects in view
42
+ // Fit objects in view
43
43
  camera.fitVerticalFovToPoints(vertices);
44
44
  camera.fitVerticalFovToBox(boundingBox);
45
45
  camera.fitVerticalFovToMesh(skinnedMesh);
46
46
 
47
- // Smart camera positioning
47
+ // Position camera based on mesh center
48
48
  camera.lookAtMeshCenterOfMass(skinnedMesh);
49
49
  ```
50
50
 
51
51
  ## Sun
52
52
 
53
- Directional light with spherical positioning:
53
+ A directional light with spherical positioning:
54
54
 
55
55
  ```typescript
56
56
  const sun = new Sun();
57
57
 
58
- // Spherical coordinates
58
+ // Position using spherical coordinates
59
59
  sun.elevation = Math.PI / 4; // 45° above horizon
60
60
  sun.azimuth = Math.PI / 2; // 90° rotation
61
61
  sun.distance = 100; // Distance from origin
62
62
 
63
- // Automatic shadow configuration
63
+ // Set up shadows for a bounding box
64
64
  sun.configureShadowsForBoundingBox(sceneBounds);
65
65
 
66
- // Position from HDR environment map
66
+ // Position based on HDR environment map
67
67
  sun.setDirectionFromHDRTexture(hdrTexture, 50);
68
68
  ```
69
69
 
70
70
  ## SceneTraversal
71
71
 
72
- Navigate and manipulate Three.js scene graphs:
72
+ Functions for working with Three.js scene graphs:
73
73
 
74
74
  ```typescript
75
75
  // Find by name
76
76
  const player = SceneTraversal.getObjectByName(scene, 'Player');
77
77
  const metal = SceneTraversal.getMaterialByName(scene, 'MetalMaterial');
78
78
 
79
- // Filter with patterns
79
+ // Find with patterns
80
80
  const enemies = SceneTraversal.filterObjects(scene, /^enemy_/);
81
81
  const glassMats = SceneTraversal.filterMaterials(scene, /glass/i);
82
82
 
83
- // Find material users
83
+ // Find objects using specific materials
84
84
  const glassObjects = SceneTraversal.findMaterialUsers(scene, /glass/i);
85
85
 
86
- // Batch operations
86
+ // Process all materials in a scene
87
87
  SceneTraversal.enumerateMaterials(scene, (material) => {
88
88
  if ('roughness' in material) material.roughness = 0.8;
89
89
  });
@@ -108,7 +108,7 @@ const frameMesh = SkinnedMeshBaker.bakeAnimationFrame(
108
108
 
109
109
  ## Material Converters
110
110
 
111
- Convert PBR StandardMaterials to simpler material types while preserving visual appearance:
111
+ Convert PBR materials to simpler types. Useful for performance optimization:
112
112
 
113
113
  ### StandardToLambertConverter
114
114
 
@@ -116,7 +116,7 @@ Convert PBR StandardMaterials to simpler material types while preserving visual
116
116
  // Basic conversion
117
117
  const lambertMaterial = StandardToLambertConverter.convert(standardMaterial);
118
118
 
119
- // With custom options
119
+ // With options
120
120
  const lambertMaterial = StandardToLambertConverter.convert(standardMaterial, {
121
121
  preserveName: true,
122
122
  roughnessColorFactor: 0.9,
@@ -130,7 +130,7 @@ const lambertMaterial = StandardToLambertConverter.convert(standardMaterial, {
130
130
  // Convert to unlit material
131
131
  const basicMaterial = StandardToBasicConverter.convert(standardMaterial);
132
132
 
133
- // With brightness compensation
133
+ // With brightness adjustment
134
134
  const basicMaterial = StandardToBasicConverter.convert(standardMaterial, {
135
135
  brightnessFactor: 1.5,
136
136
  combineEmissive: true,
@@ -146,7 +146,7 @@ const basicMaterial = StandardToBasicConverter.convert(standardMaterial, {
146
146
 
147
147
  ## Contributing
148
148
 
149
- 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.
150
150
 
151
151
  ## License
152
152
 
@@ -1,9 +1,7 @@
1
1
  import type { Box3, SkinnedMesh } from "three";
2
2
  import { PerspectiveCamera, Vector3 } from "three";
3
3
  /**
4
- * A camera that supports independent horizontal and vertical FOV settings.
5
- * Extends Three.js PerspectiveCamera to allow separate control over horizontal
6
- * and vertical fields of view.
4
+ * Camera with independent horizontal and vertical FOV settings.
7
5
  */
8
6
  export declare class DualFovCamera extends PerspectiveCamera {
9
7
  /** Internal storage for horizontal field of view in degrees */
@@ -11,131 +9,93 @@ export declare class DualFovCamera extends PerspectiveCamera {
11
9
  /** Internal storage for vertical field of view in degrees */
12
10
  private verticalFovInternal;
13
11
  /**
14
- * Creates a new DualFovCamera instance with independent horizontal and vertical FOV control.
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.
12
+ * @param horizontalFov - Horizontal FOV in degrees (clamped 1-179°)
13
+ * @param verticalFov - Vertical FOV in degrees (clamped 1-179°)
14
+ * @param aspect - Aspect ratio (width/height)
15
+ * @param near - Near clipping plane distance
16
+ * @param far - Far clipping plane distance
21
17
  */
22
18
  constructor(horizontalFov?: number, verticalFov?: number, aspect?: number, near?: number, far?: number);
23
19
  /**
24
- * Gets the current horizontal field of view in degrees.
25
- *
26
- * @returns The horizontal FOV value between 1° and 179°
20
+ * @returns Horizontal FOV in degrees
27
21
  */
28
22
  get horizontalFov(): number;
29
23
  /**
30
- * Gets the current vertical field of view in degrees.
31
- *
32
- * @returns The vertical FOV value between 1° and 179°
24
+ * @returns Vertical FOV in degrees
33
25
  */
34
26
  get verticalFov(): number;
35
27
  /**
36
- * Sets the horizontal field of view in degrees.
37
- *
38
- * @param value - The horizontal FOV value in degrees. Will be clamped between 1° and 179°.
28
+ * @param value - Horizontal FOV in degrees (clamped 1-179°)
39
29
  */
40
30
  set horizontalFov(value: number);
41
31
  /**
42
- * Sets the vertical field of view in degrees.
43
- *
44
- * @param value - The vertical FOV value in degrees. Will be clamped between 1° and 179°.
32
+ * @param value - Vertical FOV in degrees (clamped 1-179°)
45
33
  */
46
34
  set verticalFov(value: number);
47
35
  /**
48
- * Updates both horizontal and vertical field of view values simultaneously.
36
+ * Sets both FOV values.
49
37
  *
50
- * @param horizontal - Horizontal FOV in degrees. Will be clamped between and 179°.
51
- * @param vertical - Vertical FOV in degrees. Will be clamped between and 179°.
38
+ * @param horizontal - Horizontal FOV in degrees (clamped 1-179°)
39
+ * @param vertical - Vertical FOV in degrees (clamped 1-179°)
52
40
  */
53
41
  setFov(horizontal: number, vertical: number): void;
54
42
  /**
55
- * Copies the field of view settings from another DualFovCamera instance.
43
+ * Copies FOV settings from another DualFovCamera.
56
44
  *
57
- * @param source - The DualFovCamera instance to copy FOV settings from.
45
+ * @param source - Source camera to copy from
58
46
  */
59
47
  copyFovSettings(source: DualFovCamera): void;
60
48
  /**
61
- * Updates the projection matrix based on current FOV settings and aspect ratio.
62
- *
63
- * The behavior differs based on orientation:
64
- * - **Landscape mode (aspect > 1)**: Preserves horizontal FOV, calculates vertical FOV
65
- * - **Portrait mode (aspect ≤ 1)**: Preserves vertical FOV, calculates horizontal FOV
49
+ * Updates projection matrix based on FOV and aspect ratio.
66
50
  *
67
- * This method is automatically called when FOV values or aspect ratio changes.
51
+ * Landscape (aspect > 1): preserves horizontal FOV.
52
+ * Portrait (aspect ≤ 1): preserves vertical FOV.
68
53
  *
69
54
  * @override
70
55
  */
71
56
  updateProjectionMatrix(): void;
72
57
  /**
73
- * Gets the actual horizontal field of view after aspect ratio adjustments.
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.
58
+ * Gets actual horizontal FOV after aspect ratio adjustments.
77
59
  *
78
- * @returns The actual horizontal FOV in degrees
60
+ * @returns Horizontal FOV in degrees
79
61
  */
80
62
  getActualHorizontalFov(): number;
81
63
  /**
82
- * Gets the actual vertical field of view after aspect ratio adjustments.
64
+ * Gets actual vertical FOV after aspect ratio adjustments.
83
65
  *
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.
86
- *
87
- * @returns The actual vertical FOV in degrees
66
+ * @returns Vertical FOV in degrees
88
67
  */
89
68
  getActualVerticalFov(): number;
90
69
  /**
91
- * Adjusts the vertical field of view to fit all specified points within the camera's view.
92
- *
93
- * This method calculates the required vertical FOV to ensure all provided vertices
94
- * are visible within the vertical bounds of the camera's frustum.
70
+ * Adjusts vertical FOV to fit points within camera view.
95
71
  *
96
- * @param vertices - Array of 3D points (in world coordinates) that should fit within the camera's vertical view
72
+ * @param vertices - Array of 3D points in world coordinates
97
73
  */
98
74
  fitVerticalFovToPoints(vertices: Vector3[]): void;
99
75
  /**
100
- * Adjusts the vertical field of view to fit a bounding box within the camera's view.
76
+ * Adjusts vertical FOV to fit bounding box within camera view.
101
77
  *
102
- * This method calculates the required vertical FOV to ensure the entire bounding box
103
- * is visible within the vertical bounds of the camera's frustum.
104
- *
105
- * @param box - The 3D bounding box (in world coordinates) that should fit within the camera's vertical view
78
+ * @param box - 3D bounding box in world coordinates
106
79
  */
107
80
  fitVerticalFovToBox(box: Box3): void;
108
81
  /**
109
- * Adjusts the vertical field of view to fit a skinned mesh within the camera's view.
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.
82
+ * Adjusts vertical FOV to fit skinned mesh within camera view.
83
+ * Updates skeleton and applies bone transformations.
114
84
  *
115
- * @param skinnedMesh - The skinned mesh (with active skeleton) that should fit within the camera's vertical view
85
+ * @param skinnedMesh - Skinned mesh with active skeleton
116
86
  */
117
87
  fitVerticalFovToMesh(skinnedMesh: SkinnedMesh): void;
118
88
  /**
119
- * Points the camera to look at the center of mass of a skinned mesh.
89
+ * Points camera to look at skinned mesh center of mass.
90
+ * Uses iterative clustering to find main vertex concentration.
120
91
  *
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
123
- * to look at that point.
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.
128
- *
129
- * @param skinnedMesh - The skinned mesh (with active skeleton) whose center of mass should be the camera's target
92
+ * @param skinnedMesh - Skinned mesh with active skeleton
130
93
  */
131
94
  lookAtMeshCenterOfMass(skinnedMesh: SkinnedMesh): void;
132
95
  /**
133
- * Creates a deep copy of this DualFovCamera instance.
134
- *
135
- * The cloned camera will have identical FOV settings, position, rotation,
136
- * and all other camera properties.
96
+ * Creates a copy of this camera with identical settings.
137
97
  *
138
- * @returns A new DualFovCamera instance that is an exact copy of this one
98
+ * @returns New DualFovCamera instance
139
99
  * @override
140
100
  */
141
101
  clone(): this;
@@ -1,114 +1,87 @@
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.
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.
4
+ * Constructor type for runtime type checking.
8
5
  *
9
6
  * @template T - The type that the constructor creates
10
7
  */
11
8
  export type Constructor<T> = abstract new (...args: never[]) => T;
12
9
  /**
13
- * Utility class for finding and modifying objects in a Three.js scene graph.
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.
10
+ * Static methods for traversing Three.js scene hierarchies.
18
11
  *
19
- * All methods perform depth-first traversal of the scene graph starting from
20
- * the provided root object and recursively processing all children.
12
+ * All methods use depth-first traversal.
21
13
  */
22
14
  export declare class SceneTraversal {
23
15
  /**
24
- * Finds the first object in the scene hierarchy with an exact name match.
25
- *
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.
16
+ * Finds first object with exact name match.
29
17
  *
30
- * @param object - The root Object3D to start searching from
31
- * @param name - The exact name to search for (case-sensitive)
32
- * @returns The first matching Object3D, or null if no match is found
33
-
18
+ * @param object - Root object to start from
19
+ * @param name - Name to search for (case-sensitive)
20
+ * @returns First matching object or null
34
21
  */
35
22
  static getObjectByName(object: Object3D, name: string): Object3D | null;
36
23
  /**
37
- * Finds the first material in the scene hierarchy with an exact name match.
24
+ * Finds first material with exact name match from mesh objects.
38
25
  *
39
- * Performs a depth-first search through the scene graph, examining materials
40
- * 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.
43
- *
44
- * @param object - The root Object3D to start searching from
45
- * @param name - The exact material name to search for (case-sensitive)
46
- * @returns The first matching Material, or null if no match is found
47
-
26
+ * @param object - Root object to start from
27
+ * @param name - Material name to search for (case-sensitive)
28
+ * @returns First matching material or null
48
29
  */
49
30
  static getMaterialByName(object: Object3D, name: string): Material | null;
50
31
  /**
51
- * Processes all objects of a specific type in the scene hierarchy.
32
+ * Executes callback for all objects of specified type.
52
33
  *
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.).
34
+ * @template T - Type of objects to process
35
+ * @param object - Root object to start from
36
+ * @param type - Constructor to filter by
37
+ * @param callback - Function to execute for each matching object
38
+ */
39
+ static enumerateObjectsByType<T extends Object3D>(object: Object3D, type: Constructor<T>, callback: (instance: T) => void): void;
40
+ /**
41
+ * Executes callback for all materials of specified type from mesh objects.
56
42
  *
57
- * @template T - The type of objects to process
58
- * @param object - The root Object3D to start searching from
59
- * @param type - The constructor/class to filter by (e.g., DirectionalLight, Mesh)
60
- * @param callback - Function to execute for each matching object instance
61
-
43
+ * @template T - Type of materials to process
44
+ * @param object - Root object to start from
45
+ * @param type - Constructor to filter by
46
+ * @param callback - Function to execute for each matching material
62
47
  */
63
- static enumerateObjectsByType<T>(object: Object3D, type: Constructor<T>, callback: (instance: T) => void): void;
48
+ static enumerateMaterialsByType<T extends Material>(object: Object3D, type: Constructor<T>, callback: (material: T) => void): void;
64
49
  /**
65
- * Processes all materials found in mesh objects within the scene hierarchy.
50
+ * Executes callback for all objects in hierarchy.
66
51
  *
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.
52
+ * @param object - Root object to start from
53
+ * @param callback - Function to execute for each object
54
+ */
55
+ static enumerateObjects(object: Object3D, callback: (object: Object3D) => void): void;
56
+ /**
57
+ * Executes callback for all materials from mesh objects.
70
58
  *
71
- * @param object - The root Object3D to start searching from
72
- * @param callback - Function to execute for each material found
73
-
59
+ * @param object - Root object to start from
60
+ * @param callback - Function to execute for each material
74
61
  */
75
62
  static enumerateMaterials(object: Object3D, callback: (material: Material) => void): void;
76
63
  /**
77
- * Finds all objects in the scene hierarchy that match the specified filter criteria.
78
- *
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.
64
+ * Returns all objects matching filter criteria.
82
65
  *
83
- * @param object - The root Object3D to start searching from
84
- * @param filter - Either a RegExp to test against object names, or a predicate function
85
- * @returns Array of all matching Object3D instances
86
-
66
+ * @param object - Root object to start from
67
+ * @param filter - RegExp for object names or predicate function
68
+ * @returns Array of matching objects
87
69
  */
88
70
  static filterObjects(object: Object3D, filter: RegExp | ((object: Object3D) => boolean)): Object3D[];
89
71
  /**
90
- * Finds all materials in the scene hierarchy whose names match a regular expression pattern.
72
+ * Returns all materials matching filter criteria from mesh objects.
91
73
  *
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.
95
- *
96
- * @param object - The root Object3D to start searching from
97
- * @param name - Regular expression pattern to test against material names
98
- * @returns Array of all matching Material instances
99
-
74
+ * @param object - Root object to start from
75
+ * @param filter - RegExp for material names or predicate function
76
+ * @returns Array of matching materials
100
77
  */
101
- static filterMaterials(object: Object3D, name: RegExp): Material[];
78
+ static filterMaterials(object: Object3D, filter: RegExp | ((object: Material) => boolean)): Material[];
102
79
  /**
103
- * Finds all objects (mesh users) that use materials with names matching a regular expression pattern.
104
- *
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.
80
+ * Returns all mesh objects that use any of the specified materials.
108
81
  *
109
- * @param object - The root Object3D to start searching from
110
- * @param materialName - Regular expression pattern to test against material names
111
- * @returns Array of all Mesh objects that use materials with matching names
82
+ * @param object - Root object to start from
83
+ * @param materials - Array of materials to search for
84
+ * @returns Array of mesh objects using the materials
112
85
  */
113
- static findMaterialUsers(object: Object3D, materialName: RegExp): Mesh[];
86
+ static findMaterialUsers(object: Object3D, materials: Material[]): Mesh[];
114
87
  }
@@ -1,23 +1,22 @@
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 skinned mesh to static mesh in current pose.
8
7
  *
9
8
  * @param skinnedMesh - Mesh to convert
10
- * @returns Static mesh with baked vertex positions
9
+ * @returns Static mesh with baked positions
11
10
  */
12
11
  static bakePose(skinnedMesh: SkinnedMesh): Mesh;
13
12
  /**
14
- * Bake a single frame from an animation into a static mesh.
13
+ * Bakes animation frame to static mesh.
15
14
  *
16
- * @param armature - Root object with bones (usually from GLTF)
15
+ * @param armature - Root object with bones
17
16
  * @param skinnedMesh - Mesh to convert
18
- * @param timeOffset - Time in seconds within the animation
19
- * @param clip - Animation to get the pose from
20
- * @returns Static mesh with baked vertex positions
17
+ * @param timeOffset - Time in seconds within animation
18
+ * @param clip - Animation clip for pose
19
+ * @returns Static mesh with baked positions
21
20
  */
22
21
  static bakeAnimationFrame(armature: Object3D, skinnedMesh: SkinnedMesh, timeOffset: number, clip: AnimationClip): Mesh;
23
22
  }
@@ -1,73 +1,45 @@
1
1
  import type { MeshStandardMaterial } from "three";
2
2
  import { MeshBasicMaterial } from "three";
3
3
  /**
4
- * Configuration options for the StandardToBasicConverter
5
- *
6
- * @interface StandardToBasicConverterOptions
4
+ * Configuration options for material conversion.
7
5
  */
8
6
  export interface StandardToBasicConverterOptions {
9
7
  /**
10
- * Whether to preserve the original material's name
8
+ * Preserve original material name.
11
9
  * @defaultValue true
12
10
  */
13
11
  preserveName: boolean;
14
12
  /**
15
- * Whether to copy user data from the original material
13
+ * Copy user data from original material.
16
14
  * @defaultValue true
17
15
  */
18
16
  copyUserData: boolean;
19
17
  /**
20
- * Whether to dispose the original material after conversion
18
+ * Dispose original material after conversion.
21
19
  * @defaultValue false
22
20
  */
23
21
  disposeOriginal: boolean;
24
22
  /**
25
- * Whether to apply emissive color to the base color for brightness compensation
23
+ * Apply emissive color to base color for brightness compensation.
26
24
  * @defaultValue true
27
25
  */
28
26
  combineEmissive: boolean;
29
27
  /**
30
- * Factor for brightness adjustment to compensate for loss of lighting
28
+ * Brightness adjustment factor to compensate for loss of lighting.
31
29
  * @defaultValue 1.3
32
30
  */
33
31
  brightnessFactor: number;
34
32
  }
35
33
  /**
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.
34
+ * Converts MeshStandardMaterial to MeshBasicMaterial with brightness compensation.
42
35
  */
43
36
  export declare class StandardToBasicConverter {
44
37
  /**
45
- * Converts a MeshStandardMaterial to MeshBasicMaterial
38
+ * Converts MeshStandardMaterial to MeshBasicMaterial.
46
39
  *
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
40
+ * @param standardMaterial - Source material to convert
41
+ * @param options - Conversion options
42
+ * @returns New MeshBasicMaterial with mapped properties
71
43
  */
72
44
  static convert(standardMaterial: MeshStandardMaterial, options?: Partial<StandardToBasicConverterOptions>): MeshBasicMaterial;
73
45
  }