Simplify texture disposal logic in material rendering
This commit is contained in:
@@ -11,9 +11,7 @@ import type { LoadedImageAsset } from "../assets/image-assets";
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
createStarterMaterialSignature,
|
createStarterMaterialSignature,
|
||||||
createStarterMaterialTextureSet,
|
createStarterMaterialTextureSet
|
||||||
disposeStarterMaterialTextureSet,
|
|
||||||
type StarterMaterialTextureSet
|
|
||||||
} from "./starter-material-textures";
|
} from "./starter-material-textures";
|
||||||
import type {
|
import type {
|
||||||
CustomMaterialDef,
|
CustomMaterialDef,
|
||||||
@@ -184,25 +182,6 @@ export function createMaterialTextureSet(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function disposeMaterialTextureSet(textureSet: MaterialTextureSet): void {
|
export function disposeMaterialTextureSet(textureSet: MaterialTextureSet): void {
|
||||||
if (textureSet.specular !== null || textureSet.metallic !== null) {
|
|
||||||
const starterCandidate: StarterMaterialTextureSet = {
|
|
||||||
baseColor: textureSet.baseColor as Texture,
|
|
||||||
normal: textureSet.normal as Texture,
|
|
||||||
roughness: textureSet.roughness as Texture,
|
|
||||||
metallic: textureSet.metallic,
|
|
||||||
specular: textureSet.specular
|
|
||||||
};
|
|
||||||
|
|
||||||
if (
|
|
||||||
starterCandidate.baseColor !== null &&
|
|
||||||
starterCandidate.normal !== null &&
|
|
||||||
starterCandidate.roughness !== null
|
|
||||||
) {
|
|
||||||
disposeStarterMaterialTextureSet(starterCandidate);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const textures = new Set<Texture>();
|
const textures = new Set<Texture>();
|
||||||
|
|
||||||
for (const texture of [
|
for (const texture of [
|
||||||
|
|||||||
Reference in New Issue
Block a user