0.0.1 • Published 1 year ago
pex-loaders v0.0.1
pex-loaders
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>
- .loadDraco(data, [options]) ⇒ Promise.<object>
- .loadExr(ctx, data, [options], [texture]) ⇒ Promise.<ctx.texture2D>
- .loadHdr(ctx, data, [texture]) ⇒ Promise.<ctx.texture2D>
- .loadKtx2(data, [options]) ⇒ Promise.<object>
- .loadUltraHdr(ctx, data, [texture]) ⇒ Promise.<ctx.texture2D>
pex-loaders.loadBasis(data, options) ⇒ Promise.<object>
Load a basis file or array buffer as texture options
Kind: static method of pex-loaders
Param | Type |
---|---|
data | string | ArrayBuffer |
options | BasisOptions |
pex-loaders.loadDraco(data, options) ⇒ Promise.<object>
Load a draco file or array buffer as a texture
Kind: static method of pex-loaders
Param | Type |
---|---|
data | string | ArrayBuffer |
options | DracoOptions |
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
Param | Type | Description |
---|---|---|
ctx | ctx | |
data | string | ArrayBuffer | |
options | ExrOptions | |
texture | ctx.texture2D | Optionally 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
Param | Type | Description |
---|---|---|
ctx | ctx | |
data | string | ArrayBuffer | |
texture | ctx.texture2D | Optionally pass an already created texture resource. |
pex-loaders.loadKtx2(data, options) ⇒ Promise.<object>
Load a ktx2 file or array buffer as texture options
- KTX: http://github.khronos.org/KTX-Specification/
- DFD: https://www.khronos.org/registry/DataFormat/specs/1.3/dataformat.1.3.html#basicdescriptor
Kind: static method of pex-loaders
Param | Type |
---|---|
data | string | ArrayBuffer |
options | Ktx2Options |
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
Param | Type | Description |
---|---|---|
ctx | ctx | |
data | string | ArrayBuffer | |
texture | ctx.texture2D | Optionally pass an already created texture resource. |
BasisOptions
Kind: global typedef Properties
Name | Type | Default |
---|---|---|
gl | WebGLRenderingContext | WebGL2RenderingContext | |
transcoderPath | string | "'assets/decoders/basis/'" |
transcodeConfig | object | {} |
workerLimit | number | 4 |
workerConfig | object | { astcSupported, etc1Supported, etc2Supported, dxtSupported, bptcSupported, pvrtcSupported } |
DracoOptions
Kind: global typedef Properties
Name | Type | Default |
---|---|---|
transcoderPath | string | "'assets/decoders/draco/'" |
transcodeConfig | object | {} |
workerLimit | number | 4 |
workerConfig | object | {} |
ExrOptions
Kind: global typedef Properties
Name | Type | Default | Description |
---|---|---|---|
type | number | 1016 | Half Float WebGL type. Also supports Float (1015). |
Ktx2Options
Kind: global typedef Properties
Name | Type | Default |
---|---|---|
basisOptions | BasisOptions | {} |
License
MIT. See license file.
1.0.0-alpha.4
1 year ago
1.0.0-alpha.3
1 year ago
1.0.0-alpha.2
1 year ago
1.0.0-alpha.1
1 year ago
1.0.0-alpha.0
1 year ago
0.0.1
3 years ago