MCPcopy Create free account
hub / github.com/achrefelouafi/GrassSystemThreeJS / disposeMaterial

Function disposeMaterial

src/model.js:204–218  ·  view source on GitHub ↗
(mat)

Source from the content-addressed store, hash-verified

202 }
203
204 function disposeMaterial(mat) {
205 if (!mat) return;
206 // Only dispose textures this model owns — the shared moss maps live in the
207 // ground uniforms and must survive a model swap.
208 const shared = new Set([
209 moss.uMossMap.value,
210 moss.uMossRoughnessMap.value,
211 moss.uMossNormalMap.value,
212 moss.uMossAoMap.value,
213 ]);
214 for (const v of Object.values(mat)) {
215 if (v && v.isTexture && !shared.has(v)) v.dispose();
216 }
217 mat.dispose();
218 }
219
220 function setModel(root) {
221 if (current) {

Callers 1

setModelFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected