three-zoo 0.5.4 → 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 +24 -24
- package/dist/DualFovCamera.d.ts +43 -44
- package/dist/SceneTraversal.d.ts +28 -38
- package/dist/SkinnedMeshBaker.d.ts +5 -5
- package/dist/StandardToBasicConverter.d.ts +8 -14
- package/dist/StandardToLambertConverter.d.ts +7 -13
- package/dist/Sun.d.ts +18 -19
- package/dist/index.js +149 -178
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +1 -1
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
|
|
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
|
-
##
|
|
16
|
+
## What's included
|
|
17
17
|
|
|
18
|
-
- 📷 **DualFovCamera** -
|
|
19
|
-
- ☀️ **Sun** -
|
|
20
|
-
- 🔍 **SceneTraversal** -
|
|
21
|
-
- 🎭 **SkinnedMeshBaker** -
|
|
22
|
-
- 🎨 **StandardToLambertConverter** -
|
|
23
|
-
- ✨ **StandardToBasicConverter** -
|
|
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
|
-
|
|
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
|
-
//
|
|
38
|
+
// Set FOV values independently
|
|
39
39
|
camera.horizontalFov = 100;
|
|
40
40
|
camera.verticalFov = 70;
|
|
41
41
|
|
|
42
|
-
//
|
|
42
|
+
// Fit objects in view
|
|
43
43
|
camera.fitVerticalFovToPoints(vertices);
|
|
44
44
|
camera.fitVerticalFovToBox(boundingBox);
|
|
45
45
|
camera.fitVerticalFovToMesh(skinnedMesh);
|
|
46
46
|
|
|
47
|
-
//
|
|
47
|
+
// Position camera based on mesh center
|
|
48
48
|
camera.lookAtMeshCenterOfMass(skinnedMesh);
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
## Sun
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
A directional light with spherical positioning:
|
|
54
54
|
|
|
55
55
|
```typescript
|
|
56
56
|
const sun = new Sun();
|
|
57
57
|
|
|
58
|
-
//
|
|
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
|
-
//
|
|
63
|
+
// Set up shadows for a bounding box
|
|
64
64
|
sun.configureShadowsForBoundingBox(sceneBounds);
|
|
65
65
|
|
|
66
|
-
// Position
|
|
66
|
+
// Position based on HDR environment map
|
|
67
67
|
sun.setDirectionFromHDRTexture(hdrTexture, 50);
|
|
68
68
|
```
|
|
69
69
|
|
|
70
70
|
## SceneTraversal
|
|
71
71
|
|
|
72
|
-
|
|
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
|
-
//
|
|
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
|
|
83
|
+
// Find objects using specific materials
|
|
84
84
|
const glassObjects = SceneTraversal.findMaterialUsers(scene, /glass/i);
|
|
85
85
|
|
|
86
|
-
//
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
149
|
+
Feel free to submit issues and pull requests if you find these utilities helpful.
|
|
150
150
|
|
|
151
151
|
## License
|
|
152
152
|
|
package/dist/DualFovCamera.d.ts
CHANGED
|
@@ -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
|
|
14
|
+
* Creates a new DualFovCamera instance.
|
|
15
15
|
*
|
|
16
|
-
* @param horizontalFov - Horizontal field of view in degrees.
|
|
17
|
-
* @param verticalFov - Vertical field of view in degrees.
|
|
18
|
-
* @param aspect - Camera aspect ratio (width/height).
|
|
19
|
-
* @param near - Near clipping plane distance.
|
|
20
|
-
* @param far - Far clipping plane distance.
|
|
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
|
|
24
|
+
* Gets the horizontal field of view in degrees.
|
|
25
25
|
*
|
|
26
|
-
* @returns The horizontal FOV value
|
|
26
|
+
* @returns The horizontal FOV value
|
|
27
27
|
*/
|
|
28
28
|
get horizontalFov(): number;
|
|
29
29
|
/**
|
|
30
|
-
* Gets the
|
|
30
|
+
* Gets the vertical field of view in degrees.
|
|
31
31
|
*
|
|
32
|
-
* @returns The vertical FOV value
|
|
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.
|
|
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.
|
|
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
|
-
*
|
|
48
|
+
* Sets both horizontal and vertical field of view values.
|
|
49
49
|
*
|
|
50
|
-
* @param horizontal - Horizontal FOV in degrees.
|
|
51
|
-
* @param vertical - Vertical FOV in degrees.
|
|
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
|
|
55
|
+
* Copies the field of view settings from another DualFovCamera.
|
|
56
56
|
*
|
|
57
|
-
* @param source - The DualFovCamera
|
|
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
|
-
*
|
|
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
|
|
73
|
+
* Gets the horizontal field of view after aspect ratio adjustments.
|
|
74
74
|
*
|
|
75
|
-
* In landscape mode,
|
|
76
|
-
* In portrait mode,
|
|
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
|
|
78
|
+
* @returns The horizontal FOV in degrees
|
|
79
79
|
*/
|
|
80
80
|
getActualHorizontalFov(): number;
|
|
81
81
|
/**
|
|
82
|
-
* Gets the
|
|
82
|
+
* Gets the vertical field of view after aspect ratio adjustments.
|
|
83
83
|
*
|
|
84
|
-
* In portrait mode,
|
|
85
|
-
* In landscape mode,
|
|
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
|
|
87
|
+
* @returns The vertical FOV in degrees
|
|
88
88
|
*/
|
|
89
89
|
getActualVerticalFov(): number;
|
|
90
90
|
/**
|
|
91
|
-
* Adjusts the vertical field of view to fit
|
|
91
|
+
* Adjusts the vertical field of view to fit specified points within the camera's view.
|
|
92
92
|
*
|
|
93
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
112
|
-
* and
|
|
113
|
-
*
|
|
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
|
|
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
|
-
*
|
|
122
|
-
* calculates the center of mass using a clustering algorithm, and
|
|
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
|
|
126
|
-
* main concentration of vertices
|
|
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
|
|
128
|
+
* @param skinnedMesh - The skinned mesh with active skeleton
|
|
130
129
|
*/
|
|
131
130
|
lookAtMeshCenterOfMass(skinnedMesh: SkinnedMesh): void;
|
|
132
131
|
/**
|
|
133
|
-
* Creates a
|
|
132
|
+
* Creates a copy of this DualFovCamera.
|
|
134
133
|
*
|
|
135
|
-
* The cloned camera
|
|
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
|
|
137
|
+
* @returns A new DualFovCamera instance
|
|
139
138
|
* @override
|
|
140
139
|
*/
|
|
141
140
|
clone(): this;
|
package/dist/SceneTraversal.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Material, Object3D } from "three";
|
|
2
2
|
import { Mesh } from "three";
|
|
3
3
|
/**
|
|
4
|
-
* Constructor type for
|
|
4
|
+
* Constructor type for scene traversal operations.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
-
*
|
|
16
|
-
* searching for
|
|
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
|
|
20
|
-
*
|
|
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
|
|
27
|
-
* root object. Returns the first object
|
|
28
|
-
*
|
|
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
|
|
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
|
|
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
|
|
54
|
-
* for every object that is an instance of the specified type.
|
|
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
|
|
68
|
-
* the
|
|
69
|
-
* materials and material arrays
|
|
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
|
|
70
|
+
* Finds all objects in the scene hierarchy that match filter criteria.
|
|
78
71
|
*
|
|
79
|
-
* Performs
|
|
80
|
-
* a regular expression pattern (applied to
|
|
81
|
-
* a
|
|
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
|
|
82
|
+
* Finds all materials in the scene hierarchy whose names match a pattern.
|
|
91
83
|
*
|
|
92
|
-
* Performs
|
|
93
|
-
* whose name property matches the
|
|
94
|
-
* single materials and material arrays
|
|
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
|
|
94
|
+
* Finds all mesh objects that use materials with names matching a pattern.
|
|
104
95
|
*
|
|
105
|
-
* Performs
|
|
106
|
-
* whose materials have names that match the
|
|
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
|
-
/**
|
|
3
|
+
/** Converts skinned meshes to static meshes */
|
|
4
4
|
export declare class SkinnedMeshBaker {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
* The resulting mesh
|
|
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
|
-
*
|
|
14
|
+
* Bakes a single frame from an animation into a static mesh.
|
|
15
15
|
*
|
|
16
|
-
* @param armature - Root object with bones
|
|
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
|
|
@@ -1,9 +1,7 @@
|
|
|
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 the StandardToBasicConverter.
|
|
7
5
|
*/
|
|
8
6
|
export interface StandardToBasicConverterOptions {
|
|
9
7
|
/**
|
|
@@ -33,20 +31,18 @@ export interface StandardToBasicConverterOptions {
|
|
|
33
31
|
brightnessFactor: number;
|
|
34
32
|
}
|
|
35
33
|
/**
|
|
36
|
-
* Converts Three.js MeshStandardMaterial to MeshBasicMaterial
|
|
34
|
+
* Converts Three.js MeshStandardMaterial to MeshBasicMaterial.
|
|
37
35
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* visual similarity, including brightness adjustments and emissive color combination.
|
|
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.
|
|
42
39
|
*/
|
|
43
40
|
export declare class StandardToBasicConverter {
|
|
44
41
|
/**
|
|
45
|
-
* Converts a MeshStandardMaterial to MeshBasicMaterial
|
|
42
|
+
* Converts a MeshStandardMaterial to MeshBasicMaterial.
|
|
46
43
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* brightness compensation and intelligent property mapping.
|
|
44
|
+
* Performs conversion from PBR StandardMaterial to unlit BasicMaterial
|
|
45
|
+
* with brightness compensation and property mapping.
|
|
50
46
|
*
|
|
51
47
|
* @param standardMaterial - The source MeshStandardMaterial to convert
|
|
52
48
|
* @param options - Configuration options for the conversion
|
|
@@ -66,8 +62,6 @@ export declare class StandardToBasicConverter {
|
|
|
66
62
|
* combineEmissive: true
|
|
67
63
|
* });
|
|
68
64
|
* ```
|
|
69
|
-
*
|
|
70
|
-
* @see {@link StandardToBasicConverterOptions} for available configuration options
|
|
71
65
|
*/
|
|
72
66
|
static convert(standardMaterial: MeshStandardMaterial, options?: Partial<StandardToBasicConverterOptions>): MeshBasicMaterial;
|
|
73
67
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { MeshStandardMaterial } from "three";
|
|
2
2
|
import { MeshLambertMaterial } from "three";
|
|
3
3
|
/**
|
|
4
|
-
* Configuration options for the StandardToLambertConverter
|
|
5
|
-
*
|
|
6
|
-
* @interface StandardToLambertConverterOptions
|
|
4
|
+
* Configuration options for the StandardToLambertConverter.
|
|
7
5
|
*/
|
|
8
6
|
export interface StandardToLambertConverterOptions {
|
|
9
7
|
/**
|
|
@@ -28,20 +26,18 @@ export interface StandardToLambertConverterOptions {
|
|
|
28
26
|
roughnessColorFactor: number;
|
|
29
27
|
}
|
|
30
28
|
/**
|
|
31
|
-
* Converts Three.js MeshStandardMaterial to MeshLambertMaterial
|
|
29
|
+
* Converts Three.js MeshStandardMaterial to MeshLambertMaterial.
|
|
32
30
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* used by LambertMaterial. The conversion preserves visual similarity by applying
|
|
31
|
+
* Handles translation between PBR properties of StandardMaterial and
|
|
32
|
+
* the Lambertian reflectance model used by LambertMaterial. Applies
|
|
36
33
|
* color compensation based on metalness and roughness values.
|
|
37
34
|
*/
|
|
38
35
|
export declare class StandardToLambertConverter {
|
|
39
36
|
/**
|
|
40
|
-
* Converts a MeshStandardMaterial to MeshLambertMaterial
|
|
37
|
+
* Converts a MeshStandardMaterial to MeshLambertMaterial.
|
|
41
38
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* through intelligent color compensation.
|
|
39
|
+
* Performs conversion from PBR StandardMaterial to Lambert lighting model
|
|
40
|
+
* with color compensation based on metalness and roughness values.
|
|
45
41
|
*
|
|
46
42
|
* @param material - The source MeshStandardMaterial to convert
|
|
47
43
|
* @param options - Configuration options for the conversion
|
|
@@ -57,8 +53,6 @@ export declare class StandardToLambertConverter {
|
|
|
57
53
|
*
|
|
58
54
|
* const lambertMaterial = StandardToLambertConverter.convert(standardMaterial);
|
|
59
55
|
* ```
|
|
60
|
-
*
|
|
61
|
-
* @see {@link StandardToLambertConverterOptions} for available configuration options
|
|
62
56
|
*/
|
|
63
57
|
static convert(material: MeshStandardMaterial, options?: Partial<StandardToLambertConverterOptions>): MeshLambertMaterial;
|
|
64
58
|
}
|