0.0.1 • Published 1 year ago

pex-loaders v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

pex-loaders

npm version stability-stable npm minzipped size dependencies types Conventional Commits styled with prettier linted with eslint license

Resource loader for PEX.

Installation

npm install pex-loaders

Usage

import { loadUltraHdr } from "pex-loaders";

const getEnvMap = async (ctx, url) => {
  if (url.endsWith(".jpg")) return await loadUltraHdr(ctx, url);
  if (url.endsWith(".hdr")) return await loadHdr(ctx, url);
  if (url.endsWith(".exr")) return await loadExr(ctx, url);

  throw new Error("Unsupported env map file type");
};

API

Modules

Typedefs

pex-loaders

pex-loaders.loadBasis(data, options) ⇒ Promise.<object>

Load a basis file or array buffer as texture options

Kind: static method of pex-loaders

ParamType
datastring | ArrayBuffer
optionsBasisOptions

pex-loaders.loadDraco(data, options) ⇒ Promise.<object>

Load a draco file or array buffer as a texture

Kind: static method of pex-loaders

ParamType
datastring | ArrayBuffer
optionsDracoOptions

pex-loaders.loadExr(ctx, data, options, texture) ⇒ Promise.<ctx.texture2D>

Load an EXR file or array buffer as a texture

Kind: static method of pex-loaders

ParamTypeDescription
ctxctx
datastring | ArrayBuffer
optionsExrOptions
texturectx.texture2DOptionally pass an already created texture resource.

pex-loaders.loadHdr(ctx, data, texture) ⇒ Promise.<ctx.texture2D>

Load an HDR file or array buffer as a texture

Kind: static method of pex-loaders

ParamTypeDescription
ctxctx
datastring | ArrayBuffer
texturectx.texture2DOptionally pass an already created texture resource.

pex-loaders.loadKtx2(data, options) ⇒ Promise.<object>

Load a ktx2 file or array buffer as texture options

Kind: static method of pex-loaders

ParamType
datastring | ArrayBuffer
optionsKtx2Options

pex-loaders.loadUltraHdr(ctx, data, texture) ⇒ Promise.<ctx.texture2D>

Load an Ultra HDR (aka gain map) file or array buffer as a texture

Kind: static method of pex-loaders

ParamTypeDescription
ctxctx
datastring | ArrayBuffer
texturectx.texture2DOptionally pass an already created texture resource.

BasisOptions

Kind: global typedef Properties

NameTypeDefault
glWebGLRenderingContext | WebGL2RenderingContext
transcoderPathstring"'assets/decoders/basis/'"
transcodeConfigobject{}
workerLimitnumber4
workerConfigobject{ astcSupported, etc1Supported, etc2Supported, dxtSupported, bptcSupported, pvrtcSupported }

DracoOptions

Kind: global typedef Properties

NameTypeDefault
transcoderPathstring"'assets/decoders/draco/'"
transcodeConfigobject{}
workerLimitnumber4
workerConfigobject{}

ExrOptions

Kind: global typedef Properties

NameTypeDefaultDescription
typenumber1016Half Float WebGL type. Also supports Float (1015).

Ktx2Options

Kind: global typedef Properties

NameTypeDefault
basisOptionsBasisOptions{}

License

MIT. See license file.