Class: Res
Defined in: src/assets/Res.ts:33
Resource management classes for textures, materials, models, and preset bodies.
Constructors
Constructor
new Res(
ctx?):Res
Defined in: src/assets/Res.ts:50
Parameters
ctx?
Returns
Res
Properties
_ctx
readonly_ctx:Context3D
Defined in: src/assets/Res.ts:45
Context this Res instance is bound to. Parsers launched via this Res thread this ctx through so their default-texture lookups resolve against the same device.
normalTexture
normalTexture:
Uint8ArrayTexture
Defined in: src/assets/Res.ts:431
Default flat normal-map texture.
maskTexture
maskTexture:
Uint8ArrayTexture
Defined in: src/assets/Res.ts:433
Default mask texture.
whiteTexture
whiteTexture:
Uint8ArrayTexture
Defined in: src/assets/Res.ts:435
Default solid white texture.
blackTexture
blackTexture:
Uint8ArrayTexture
Defined in: src/assets/Res.ts:437
Default solid black texture.
redTexture
redTexture:
Uint8ArrayTexture
Defined in: src/assets/Res.ts:439
Default solid red texture.
blueTexture
blueTexture:
Uint8ArrayTexture
Defined in: src/assets/Res.ts:441
Default solid blue texture.
greenTexture
greenTexture:
Uint8ArrayTexture
Defined in: src/assets/Res.ts:443
Default solid green texture.
yellowTexture
yellowTexture:
Uint8ArrayTexture
Defined in: src/assets/Res.ts:445
Default solid yellow texture.
grayTexture
grayTexture:
Uint8ArrayTexture
Defined in: src/assets/Res.ts:447
Default solid gray texture.
defaultSky
defaultSky:
HDRTextureCube
Defined in: src/assets/Res.ts:450
Default sky cube texture.
defaultMaterial
defaultMaterial:
LitMaterial
Defined in: src/assets/Res.ts:453
Default lit material.
Methods
getGltf()
getGltf(
url):GLTF_Info
Defined in: src/assets/Res.ts:67
get a parsed glTF info object by url
Parameters
url
string
file path
Returns
GLTF_Info
the cached GLTF_Info, or undefined if not loaded
addObj()
addObj(
url,obj):void
Defined in: src/assets/Res.ts:76
add a obj with reference of url
Parameters
url
string
file path
obj
any
Returns
void
getObj()
getObj(
url):any
Defined in: src/assets/Res.ts:85
get obj by url
Parameters
url
string
file path
Returns
any
addTexture()
addTexture(
url,texture):void
Defined in: src/assets/Res.ts:94
add a texture with reference of url
Parameters
url
string
file path
texture
source texture
Returns
void
getTexture()
getTexture(
url):Texture
Defined in: src/assets/Res.ts:103
get texture by url
Parameters
url
string
file path
Returns
addGeometry()
addGeometry(
url,geo):void
Defined in: src/assets/Res.ts:107
Parameters
url
string
geo
Returns
void
getGeometry()
getGeometry(
url):GeometryBase
Defined in: src/assets/Res.ts:111
Parameters
url
string
Returns
addMat()
addMat(
name,mat):Map<string,Material>
Defined in: src/assets/Res.ts:120
add a material with reference of name
Parameters
name
string
material name
mat
target material
Returns
Map<string, Material>
getMat()
getMat(
name):Material
Defined in: src/assets/Res.ts:129
get material by name
Parameters
name
string
material name
Returns
addPrefab()
addPrefab(
name,rootScene):void
Defined in: src/assets/Res.ts:138
add prefab with reference name
Parameters
name
string
prefab name
rootScene
root object of prefab
Returns
void
getPrefab()
getPrefab(
name):Object3D
Defined in: src/assets/Res.ts:147
get prefab by name
Parameters
name
string
prefab name
Returns
load()
load<
T>(url,c,loaderFunctions?):Promise<T["data"]>
Defined in: src/assets/Res.ts:159
load a file with a custom parser and return its parsed data
Type Parameters
T
T extends ParserBase
Parameters
url
string
the url of file
c
Parser<T>
the parser class to use
loaderFunctions?
optional load callbacks
Returns
Promise<T["data"]>
the parser's data
loadGltf()
loadGltf(
url,loaderFunctions?):Promise<Object3D>
Defined in: src/assets/Res.ts:172
load a gltf file
Parameters
url
string
the url of file
loaderFunctions?
callback
Returns
Promise<Object3D>
loadObj()
loadObj(
url,loaderFunctions?):Promise<Object3D>
Defined in: src/assets/Res.ts:199
load obj file
Parameters
url
string
obj file path
loaderFunctions?
callback
Returns
Promise<Object3D>
loadB3DM()
loadB3DM(
url,loaderFunctions?,userData?):Promise<Object3D>
Defined in: src/assets/Res.ts:222
load b3dm file by url
Parameters
url
string
path of file
loaderFunctions?
callback
userData?
any
Returns
Promise<Object3D>
loadI3DM()
loadI3DM(
url,loaderFunctions?,userData?):Promise<Object3D>
Defined in: src/assets/Res.ts:239
load i3dm file by url
Parameters
url
string
path of i3dm file
loaderFunctions?
callback
userData?
any
Returns
Promise<Object3D>
loadTexture()
loadTexture(
url,loaderFunctions?,flipY?,colorSpace?):Promise<Texture>
Defined in: src/assets/Res.ts:267
load texture by url
Parameters
url
string
texture path
loaderFunctions?
callback
flipY?
boolean
use flip y or not
colorSpace?
TextureColorSpace = 'linear'
'srgb' to load as rgba8unorm-srgb (use for baseColor / emissive / decal maps that store sRGB-encoded color); 'linear' (default) keeps legacy rgba8unorm behavior — required for normal maps, metallic-roughness packs, AO, masks, height / displacement, and any other non-color buffer. The default stays 'linear' for back-compat until the sRGB pipeline migration is complete; pass 'srgb' explicitly from glTF / sample call sites that load color.
Returns
Promise<Texture>
loadBitmapTextures()
loadBitmapTextures(
urls,count?,loaderFunctions?,flipY?):Promise<BitmapTexture2D[]>
Defined in: src/assets/Res.ts:309
Parameters
urls
string[]
count?
number = 5
loaderFunctions?
flipY?
boolean
Returns
Promise<BitmapTexture2D[]>
loadHDRTexture()
loadHDRTexture(
url,loaderFunctions?):Promise<Texture>
Defined in: src/assets/Res.ts:326
load a hdr texture
Parameters
url
string
texture url
loaderFunctions?
callback
Returns
Promise<Texture>
loadHDRTextureCube()
loadHDRTextureCube(
url,loaderFunctions?):Promise<Texture>
Defined in: src/assets/Res.ts:344
load hdr cube texture
Parameters
url
string
file url
loaderFunctions?
callback
Returns
Promise<Texture>
loadLDRTextureCube()
loadLDRTextureCube(
url,loaderFunctions?):Promise<Texture>
Defined in: src/assets/Res.ts:360
load ldr cube texture
Parameters
url
string
file path
loaderFunctions?
callback
Returns
Promise<Texture>
loadTextureCubeMaps()
loadTextureCubeMaps(
urls):Promise<Texture>
Defined in: src/assets/Res.ts:376
load texture data from array of web url. make sure there are six images in a group, and the order is: [+X, -X, +Y, -Y, +Z, -Z]
Parameters
urls
string[]
Returns
Promise<Texture>
loadTextureCubeStd()
loadTextureCubeStd(
url,loaderFunctions?):Promise<Texture>
Defined in: src/assets/Res.ts:393
load texture data from url. the image is assembled from six images into cross shaped image.
Parameters
url
string
the path of image
loaderFunctions?
Returns
Promise<Texture>
loadJSON()
loadJSON(
url,loaderFunctions?):Promise<void|object>
Defined in: src/assets/Res.ts:407
load json data from url.
Parameters
url
string
the path of image
loaderFunctions?
Returns
Promise<void | object>
loadAtlas()
loadAtlas(
url,loaderFunctions?):Promise<TextureAtlas>
Defined in: src/assets/Res.ts:424
Load a texture atlas (PNG + JSON) by URL. Returns a TextureAtlas whose get(id) yields TextureAtlasRegion instances — feed those directly into Sprite.texture = region to render a sub-image.
Parameters
url
string
loaderFunctions?
Returns
Promise<TextureAtlas>
createTexture()
createTexture(
width,height,r,g,b,a,name?):Uint8ArrayTexture
Defined in: src/assets/Res.ts:466
create a texture
Parameters
width
number
width of texture
height
number
height of texture
r
number
component-red
g
number
component-green
b
number
component-blue
a
number
component-alpha(0 for transparent,1 for opaque)
name?
string
name string
Returns
fillColor()
fillColor(
array,w,h,r,g,b,a):void
Defined in: src/assets/Res.ts:490
fill slod color to this texture
Parameters
array
any
data of texture
w
number
width of texture
h
number
height of texture
r
number
component-red
g
number
component-green
b
number
component-blue
a
number
component-alpha(0 for transparent,1 for opaque)
Returns
void
fillColor()
staticfillColor(array,w,h,r,g,b,a):void
Defined in: src/assets/Res.ts:495
Pure data fill — no GPU state, safe to call without a Res instance.
Parameters
array
any
w
number
h
number
r
number
g
number
b
number
a
number
Returns
void
initDefault()
initDefault(
ctx?):void
Defined in: src/assets/Res.ts:512
Initialize a common texture object. Provide a universal solid color texture object.
Parameters
ctx?
Optional Context3D — when provided, default materials bind to it so the caller doesn't need engine.use().
Returns
void

