UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

39 lines (29 loc) 937 B
import { Asset } from "../../Asset.js"; import { cloneTexture } from "./cloneTexture.js"; import { TextureLoader as ThreeTextureLoader } from "three"; const textureLoader = new ThreeTextureLoader(); /** * * @param {Texture} texture * @return {number} */ export function computeTextureByteSize(texture) { const image = texture.image; if (image instanceof ImageData) { return image.array.length; } else { //TODO do actual computation //don't know return 1; } } export function loadStandardImageTexture(path, success, failure, progress) { textureLoader.load(path, function (texture) { texture.flipY = false; const byteSize = computeTextureByteSize(texture); const asset = new Asset(function () { return cloneTexture(texture); }, byteSize); success(asset); }, progress, failure); }