lythreeframe 1.2.69 → 1.3.0
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/dist/bundle.cjs.js
CHANGED
|
@@ -3073,18 +3073,38 @@ class Actor extends BaseObject {
|
|
|
3073
3073
|
}
|
|
3074
3074
|
|
|
3075
3075
|
class ThreeObjectLibrary {
|
|
3076
|
+
static disposeMaterialTextures(material) {
|
|
3077
|
+
Object.keys(material).forEach((key) => {
|
|
3078
|
+
const value = material[key];
|
|
3079
|
+
if (value && typeof value === 'object' && 'isTexture' in value) {
|
|
3080
|
+
value.dispose();
|
|
3081
|
+
}
|
|
3082
|
+
});
|
|
3083
|
+
}
|
|
3076
3084
|
static disposeMeshMaterial(mesh) {
|
|
3077
3085
|
let mats = Array.isArray(mesh.material) ? mesh.material : [mesh.material];
|
|
3078
3086
|
mats.forEach((elem) => {
|
|
3087
|
+
ThreeObjectLibrary.disposeMaterialTextures(elem);
|
|
3079
3088
|
elem.dispose();
|
|
3080
3089
|
});
|
|
3081
3090
|
}
|
|
3082
|
-
static
|
|
3091
|
+
static disposeMeshResource(mesh, recursive = false) {
|
|
3092
|
+
ThreeObjectLibrary.disposeMeshMaterial(mesh);
|
|
3083
3093
|
mesh.geometry.dispose();
|
|
3094
|
+
if (recursive) {
|
|
3095
|
+
mesh.children.forEach((child) => {
|
|
3096
|
+
if (child instanceof webgpu.Mesh) {
|
|
3097
|
+
ThreeObjectLibrary.disposeMeshResource(child, true);
|
|
3098
|
+
}
|
|
3099
|
+
});
|
|
3100
|
+
}
|
|
3084
3101
|
}
|
|
3085
|
-
static
|
|
3086
|
-
|
|
3087
|
-
|
|
3102
|
+
static disposeObject3DResource(object) {
|
|
3103
|
+
object.traverse((child) => {
|
|
3104
|
+
if (child instanceof webgpu.Mesh) {
|
|
3105
|
+
ThreeObjectLibrary.disposeMeshResource(child);
|
|
3106
|
+
}
|
|
3107
|
+
});
|
|
3088
3108
|
}
|
|
3089
3109
|
}
|
|
3090
3110
|
|
package/dist/bundle.esm.js
CHANGED
|
@@ -3071,18 +3071,38 @@ class Actor extends BaseObject {
|
|
|
3071
3071
|
}
|
|
3072
3072
|
|
|
3073
3073
|
class ThreeObjectLibrary {
|
|
3074
|
+
static disposeMaterialTextures(material) {
|
|
3075
|
+
Object.keys(material).forEach((key) => {
|
|
3076
|
+
const value = material[key];
|
|
3077
|
+
if (value && typeof value === 'object' && 'isTexture' in value) {
|
|
3078
|
+
value.dispose();
|
|
3079
|
+
}
|
|
3080
|
+
});
|
|
3081
|
+
}
|
|
3074
3082
|
static disposeMeshMaterial(mesh) {
|
|
3075
3083
|
let mats = Array.isArray(mesh.material) ? mesh.material : [mesh.material];
|
|
3076
3084
|
mats.forEach((elem) => {
|
|
3085
|
+
ThreeObjectLibrary.disposeMaterialTextures(elem);
|
|
3077
3086
|
elem.dispose();
|
|
3078
3087
|
});
|
|
3079
3088
|
}
|
|
3080
|
-
static
|
|
3089
|
+
static disposeMeshResource(mesh, recursive = false) {
|
|
3090
|
+
ThreeObjectLibrary.disposeMeshMaterial(mesh);
|
|
3081
3091
|
mesh.geometry.dispose();
|
|
3092
|
+
if (recursive) {
|
|
3093
|
+
mesh.children.forEach((child) => {
|
|
3094
|
+
if (child instanceof Mesh) {
|
|
3095
|
+
ThreeObjectLibrary.disposeMeshResource(child, true);
|
|
3096
|
+
}
|
|
3097
|
+
});
|
|
3098
|
+
}
|
|
3082
3099
|
}
|
|
3083
|
-
static
|
|
3084
|
-
|
|
3085
|
-
|
|
3100
|
+
static disposeObject3DResource(object) {
|
|
3101
|
+
object.traverse((child) => {
|
|
3102
|
+
if (child instanceof Mesh) {
|
|
3103
|
+
ThreeObjectLibrary.disposeMeshResource(child);
|
|
3104
|
+
}
|
|
3105
|
+
});
|
|
3086
3106
|
}
|
|
3087
3107
|
}
|
|
3088
3108
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Mesh } from "three/webgpu";
|
|
1
|
+
import { Mesh, Object3D } from "three/webgpu";
|
|
2
2
|
export declare class ThreeObjectLibrary {
|
|
3
|
+
static disposeMaterialTextures(material: any): void;
|
|
3
4
|
static disposeMeshMaterial(mesh: Mesh): void;
|
|
4
|
-
static
|
|
5
|
-
static
|
|
5
|
+
static disposeMeshResource(mesh: Mesh, recursive?: boolean): void;
|
|
6
|
+
static disposeObject3DResource(object: Object3D): void;
|
|
6
7
|
}
|