UNPKG

lingo3d

Version:

Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor

31 lines 1.57 kB
import createSharedPool from "./utils/createSharedPool"; import { deg2Rad } from "@lincode/math"; import { getExtensionType } from "@lincode/filetypes"; import { uuidTextureMap } from "../collections/idCollections"; import loadTexture from "../display/utils/loaders/loadTexture"; import loadVideoTexture from "../display/utils/loaders/loadVideoTexture"; import { isSelector } from "../utils/isSelector"; const initMap = (map, textureRepeat, textureFlipY, textureRotation) => { typeof textureRepeat === "number" ? map.repeat.set(textureRepeat, textureRepeat) : map.repeat.set(textureRepeat.x, textureRepeat.y); if (map.userData.needsUpdate) map.needsUpdate = true; map.userData.needsUpdate = true; map.flipY = map.userData.flipY = map.userData.flipped ? !textureFlipY : textureFlipY; map.rotation = textureRotation * deg2Rad; return map; }; export const [requestTexture, releaseTexture] = createSharedPool((params) => { const [texture, textureRepeat, textureFlipY, textureRotation] = params; if (uuidTextureMap.has(texture)) return uuidTextureMap.get(texture); if (isSelector(texture)) return initMap(loadVideoTexture(texture), textureRepeat, textureFlipY, textureRotation); if (getExtensionType(texture) === "video") return initMap(loadVideoTexture(texture), textureRepeat, textureFlipY, textureRotation); return initMap(loadTexture(texture), textureRepeat, textureFlipY, textureRotation); }, (texture) => texture.dispose()); //# sourceMappingURL=texturePool.js.map