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 +24 -24
- package/dist/DualFovCamera.d.ts +34 -74
- package/dist/SceneTraversal.d.ts +48 -75
- package/dist/SkinnedMeshBaker.d.ts +8 -9
- package/dist/StandardToBasicConverter.d.ts +11 -39
- package/dist/StandardToLambertConverter.d.ts +10 -34
- package/dist/Sun.d.ts +12 -36
- package/dist/index.js +203 -334
- 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
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { Box3, SkinnedMesh } from "three";
|
|
2
2
|
import { PerspectiveCamera, Vector3 } from "three";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
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
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
36
|
+
* Sets both FOV values.
|
|
49
37
|
*
|
|
50
|
-
* @param horizontal - Horizontal FOV in degrees
|
|
51
|
-
* @param vertical - Vertical FOV in degrees
|
|
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
|
|
43
|
+
* Copies FOV settings from another DualFovCamera.
|
|
56
44
|
*
|
|
57
|
-
* @param source -
|
|
45
|
+
* @param source - Source camera to copy from
|
|
58
46
|
*/
|
|
59
47
|
copyFovSettings(source: DualFovCamera): void;
|
|
60
48
|
/**
|
|
61
|
-
* Updates
|
|
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
|
-
*
|
|
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
|
|
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
|
|
60
|
+
* @returns Horizontal FOV in degrees
|
|
79
61
|
*/
|
|
80
62
|
getActualHorizontalFov(): number;
|
|
81
63
|
/**
|
|
82
|
-
* Gets
|
|
64
|
+
* Gets actual vertical FOV after aspect ratio adjustments.
|
|
83
65
|
*
|
|
84
|
-
*
|
|
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
|
|
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
|
|
72
|
+
* @param vertices - Array of 3D points in world coordinates
|
|
97
73
|
*/
|
|
98
74
|
fitVerticalFovToPoints(vertices: Vector3[]): void;
|
|
99
75
|
/**
|
|
100
|
-
* Adjusts
|
|
76
|
+
* Adjusts vertical FOV to fit bounding box within camera view.
|
|
101
77
|
*
|
|
102
|
-
*
|
|
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
|
|
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 -
|
|
85
|
+
* @param skinnedMesh - Skinned mesh with active skeleton
|
|
116
86
|
*/
|
|
117
87
|
fitVerticalFovToMesh(skinnedMesh: SkinnedMesh): void;
|
|
118
88
|
/**
|
|
119
|
-
* Points
|
|
89
|
+
* Points camera to look at skinned mesh center of mass.
|
|
90
|
+
* Uses iterative clustering to find main vertex concentration.
|
|
120
91
|
*
|
|
121
|
-
*
|
|
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
|
|
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
|
|
98
|
+
* @returns New DualFovCamera instance
|
|
139
99
|
* @override
|
|
140
100
|
*/
|
|
141
101
|
clone(): this;
|
package/dist/SceneTraversal.d.ts
CHANGED
|
@@ -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
|
|
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
|
-
*
|
|
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
|
|
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
|
|
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 -
|
|
31
|
-
* @param name -
|
|
32
|
-
* @returns
|
|
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
|
|
24
|
+
* Finds first material with exact name match from mesh objects.
|
|
38
25
|
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
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
|
-
*
|
|
32
|
+
* Executes callback for all objects of specified type.
|
|
52
33
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
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 -
|
|
58
|
-
* @param object -
|
|
59
|
-
* @param type -
|
|
60
|
-
* @param callback - Function to execute for each matching
|
|
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
|
|
48
|
+
static enumerateMaterialsByType<T extends Material>(object: Object3D, type: Constructor<T>, callback: (material: T) => void): void;
|
|
64
49
|
/**
|
|
65
|
-
*
|
|
50
|
+
* Executes callback for all objects in hierarchy.
|
|
66
51
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
|
|
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 -
|
|
72
|
-
* @param callback - Function to execute for each material
|
|
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
|
-
*
|
|
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 -
|
|
84
|
-
* @param filter -
|
|
85
|
-
* @returns Array of
|
|
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
|
-
*
|
|
72
|
+
* Returns all materials matching filter criteria from mesh objects.
|
|
91
73
|
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
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,
|
|
78
|
+
static filterMaterials(object: Object3D, filter: RegExp | ((object: Material) => boolean)): Material[];
|
|
102
79
|
/**
|
|
103
|
-
*
|
|
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 -
|
|
110
|
-
* @param
|
|
111
|
-
* @returns Array of
|
|
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,
|
|
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
|
-
/**
|
|
3
|
+
/** Converts skinned meshes to static meshes. */
|
|
4
4
|
export declare class SkinnedMeshBaker {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
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
|
|
9
|
+
* @returns Static mesh with baked positions
|
|
11
10
|
*/
|
|
12
11
|
static bakePose(skinnedMesh: SkinnedMesh): Mesh;
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
13
|
+
* Bakes animation frame to static mesh.
|
|
15
14
|
*
|
|
16
|
-
* @param armature - Root object with bones
|
|
15
|
+
* @param armature - Root object with bones
|
|
17
16
|
* @param skinnedMesh - Mesh to convert
|
|
18
|
-
* @param timeOffset - Time in seconds within
|
|
19
|
-
* @param clip - Animation
|
|
20
|
-
* @returns Static mesh with baked
|
|
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
|
|
5
|
-
*
|
|
6
|
-
* @interface StandardToBasicConverterOptions
|
|
4
|
+
* Configuration options for material conversion.
|
|
7
5
|
*/
|
|
8
6
|
export interface StandardToBasicConverterOptions {
|
|
9
7
|
/**
|
|
10
|
-
*
|
|
8
|
+
* Preserve original material name.
|
|
11
9
|
* @defaultValue true
|
|
12
10
|
*/
|
|
13
11
|
preserveName: boolean;
|
|
14
12
|
/**
|
|
15
|
-
*
|
|
13
|
+
* Copy user data from original material.
|
|
16
14
|
* @defaultValue true
|
|
17
15
|
*/
|
|
18
16
|
copyUserData: boolean;
|
|
19
17
|
/**
|
|
20
|
-
*
|
|
18
|
+
* Dispose original material after conversion.
|
|
21
19
|
* @defaultValue false
|
|
22
20
|
*/
|
|
23
21
|
disposeOriginal: boolean;
|
|
24
22
|
/**
|
|
25
|
-
*
|
|
23
|
+
* Apply emissive color to base color for brightness compensation.
|
|
26
24
|
* @defaultValue true
|
|
27
25
|
*/
|
|
28
26
|
combineEmissive: boolean;
|
|
29
27
|
/**
|
|
30
|
-
*
|
|
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
|
|
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
|
|
38
|
+
* Converts MeshStandardMaterial to MeshBasicMaterial.
|
|
46
39
|
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
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
|
}
|