UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

38 lines (27 loc) 949 B
import { TextureAttachmentsByMaterialType } from "./TextureAttachmensByMaterialType.js"; /** * * @param {Material} material * @param {function(THREE.Texture, TextureAttachment)} callback * @param {*} [thisArg] */ export function traverseMaterialTextures(material, callback, thisArg) { //patch textures const materialType = material.type; /** * * @type {TextureAttachment[]} */ const attachments = TextureAttachmentsByMaterialType[materialType]; if (attachments !== undefined) { const attachment_count = attachments.length; for (let i = 0; i < attachment_count; i++) { const attachment = attachments[i]; const texture = attachment.read(material); if (texture === null || texture === undefined) { continue; } callback.call(thisArg, texture, attachment); } } }