Skip to content

Class: Res

Resource management classes for textures, materials, models, and preset bodies.

Constructors

Properties

Methods

Constructors

constructor

new Res(): Res

Returns

Res

Defined in

src/assets/Res.ts:50

Properties

normalTexture

normalTexture: Uint8ArrayTexture

normal texture

Defined in

src/assets/Res.ts:435


maskTexture

maskTexture: Uint8ArrayTexture

Defined in

src/assets/Res.ts:436


whiteTexture

whiteTexture: Uint8ArrayTexture

Defined in

src/assets/Res.ts:437


blackTexture

blackTexture: Uint8ArrayTexture

Defined in

src/assets/Res.ts:438


redTexture

redTexture: Uint8ArrayTexture

Defined in

src/assets/Res.ts:439


blueTexture

blueTexture: Uint8ArrayTexture

Defined in

src/assets/Res.ts:440


greenTexture

greenTexture: Uint8ArrayTexture

Defined in

src/assets/Res.ts:441


yellowTexture

yellowTexture: Uint8ArrayTexture

Defined in

src/assets/Res.ts:442


grayTexture

grayTexture: Uint8ArrayTexture

Defined in

src/assets/Res.ts:443


defaultSky

defaultSky: HDRTextureCube

Defined in

src/assets/Res.ts:445


defaultGUITexture

defaultGUITexture: GUITexture

Defined in

src/assets/Res.ts:447


defaultGUISprite

defaultGUISprite: GUISprite

Defined in

src/assets/Res.ts:448


defaultMaterial

defaultMaterial: LitMaterial

Defined in

src/assets/Res.ts:449

Methods

getGltf

getGltf(url): GLTF_Info

Parameters

NameType
urlstring

Returns

GLTF_Info

Defined in

src/assets/Res.ts:62


addObj

addObj(url, obj): void

add a obj with reference of url

Parameters

NameTypeDescription
urlstringfile path
objany-

Returns

void

Defined in

src/assets/Res.ts:71


getObj

getObj(url): any

get obj by url

Parameters

NameTypeDescription
urlstringfile path

Returns

any

Defined in

src/assets/Res.ts:80


addTexture

addTexture(url, texture): void

add a texture with reference of url

Parameters

NameTypeDescription
urlstringfile path
textureTexturesource texture

Returns

void

Defined in

src/assets/Res.ts:89


getTexture

getTexture(url): Texture

get texture by url

Parameters

NameTypeDescription
urlstringfile path

Returns

Texture

Defined in

src/assets/Res.ts:98


addGeometry

addGeometry(url, geo): void

Parameters

NameType
urlstring
geoGeometryBase

Returns

void

Defined in

src/assets/Res.ts:102


getGeometry

getGeometry(url): GeometryBase

Parameters

NameType
urlstring

Returns

GeometryBase

Defined in

src/assets/Res.ts:106


addMat

addMat(name, mat): Map<string, Material>

add a material with reference of name

Parameters

NameTypeDescription
namestringmaterial name
matMaterialtarget material

Returns

Map<string, Material>

Defined in

src/assets/Res.ts:115


getMat

getMat(name): Material

get material by name

Parameters

NameTypeDescription
namestringmaterial name

Returns

Material

Defined in

src/assets/Res.ts:124


addPrefab

addPrefab(name, rootScene): void

add prefab with reference name

Parameters

NameTypeDescription
namestringprefab name
rootSceneObject3Droot object of prefab

Returns

void

Defined in

src/assets/Res.ts:133


getPrefab

getPrefab(name): Object3D

get prefab by name

Parameters

NameTypeDescription
namestringprefab name

Returns

Object3D

Defined in

src/assets/Res.ts:142


addAtlas

addAtlas(name, atlas): void

Parameters

NameType
namestring
atlasGUIAtlasTexture

Returns

void

Defined in

src/assets/Res.ts:147


getAtlas

getAtlas(name): GUIAtlasTexture

Parameters

NameType
namestring

Returns

GUIAtlasTexture

Defined in

src/assets/Res.ts:152


getGUISprite

getGUISprite(id): GUISprite

Parameters

NameType
idstring

Returns

GUISprite

Defined in

src/assets/Res.ts:156


load

load<T>(url, c, loaderFunctions?): Promise<any>

Type parameters

NameType
Textends ParserBase

Parameters

NameType
urlstring
cParser<T>
loaderFunctions?LoaderFunctions

Returns

Promise<any>

Defined in

src/assets/Res.ts:165


loadGltf

loadGltf(url, loaderFunctions?): Promise<Object3D>

load a gltf file

Parameters

NameTypeDescription
urlstringthe url of file
loaderFunctions?LoaderFunctionscallback

Returns

Promise<Object3D>

Defined in

src/assets/Res.ts:178


loadObj

loadObj(url, loaderFunctions?): Promise<Object3D>

load obj file

Parameters

NameTypeDescription
urlstringobj file path
loaderFunctions?LoaderFunctionscallback

Returns

Promise<Object3D>

Defined in

src/assets/Res.ts:205


loadB3DM

loadB3DM(url, loaderFunctions?, userData?): Promise<Object3D>

load b3dm file by url

Parameters

NameTypeDescription
urlstringpath of file
loaderFunctions?LoaderFunctionscallback
userData?any-

Returns

Promise<Object3D>

Defined in

src/assets/Res.ts:228


loadI3DM

loadI3DM(url, loaderFunctions?, userData?): Promise<Object3D>

load i3dm file by url

Parameters

NameTypeDescription
urlstringpath of i3dm file
loaderFunctions?LoaderFunctionscallback
userData?any-

Returns

Promise<Object3D>

Defined in

src/assets/Res.ts:245


loadTexture

loadTexture(url, loaderFunctions?, flipY?): Promise<Texture>

load texture by url

Parameters

NameTypeDescription
urlstringtexture path
loaderFunctions?LoaderFunctionscallback
flipY?booleanuse flip y or not

Returns

Promise<Texture>

Defined in

src/assets/Res.ts:263


loadBitmapTextures

loadBitmapTextures(urls, count?, loaderFunctions?, flipY?): Promise<BitmapTexture2D[]>

Parameters

NameTypeDefault value
urlsstring[]undefined
countnumber5
loaderFunctions?LoaderFunctionsundefined
flipY?booleanundefined

Returns

Promise<BitmapTexture2D[]>

Defined in

src/assets/Res.ts:296


loadHDRTexture

loadHDRTexture(url, loaderFunctions?): Promise<Texture>

load a hdr texture

Parameters

NameTypeDescription
urlstringtexture url
loaderFunctions?LoaderFunctionscallback

Returns

Promise<Texture>

Defined in

src/assets/Res.ts:313


loadHDRTextureCube

loadHDRTextureCube(url, loaderFunctions?): Promise<Texture>

load hdr cube texture

Parameters

NameTypeDescription
urlstringfile url
loaderFunctions?LoaderFunctionscallback

Returns

Promise<Texture>

Defined in

src/assets/Res.ts:331


loadLDRTextureCube

loadLDRTextureCube(url, loaderFunctions?): Promise<Texture>

load ldr cube texture

Parameters

NameTypeDescription
urlstringfile path
loaderFunctions?LoaderFunctionscallback

Returns

Promise<Texture>

Defined in

src/assets/Res.ts:347


loadTextureCubeMaps

loadTextureCubeMaps(urls): Promise<Texture>

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

NameType
urlsstring[]

Returns

Promise<Texture>

Defined in

src/assets/Res.ts:363


loadTextureCubeStd

loadTextureCubeStd(url, loaderFunctions?): Promise<Texture>

load texture data from url. the image is assembled from six images into cross shaped image.

Parameters

NameTypeDescription
urlstringthe path of image
loaderFunctions?LoaderFunctions-

Returns

Promise<Texture>

Defined in

src/assets/Res.ts:380


loadJSON

loadJSON(url, loaderFunctions?): Promise<void | object>

load json data from url.

Parameters

NameTypeDescription
urlstringthe path of image
loaderFunctions?LoaderFunctions-

Returns

Promise<void | object>

Defined in

src/assets/Res.ts:394


loadFont

loadFont(url, loaderFunctions?, userData?): Promise<FontInfo>

load font file by url

Parameters

NameTypeDescription
urlstringfont file url
loaderFunctions?LoaderFunctionscallback
userData?any-

Returns

Promise<FontInfo>

Defined in

src/assets/Res.ts:412


loadAtlas

loadAtlas(url, loaderFunctions?): Promise<FontInfo>

load a atlas file by url

Parameters

NameTypeDescription
urlstringfile path
loaderFunctions?LoaderFunctionscallback

Returns

Promise<FontInfo>

Defined in

src/assets/Res.ts:426


createTexture

createTexture(width, height, r, g, b, a, name?): Uint8ArrayTexture

create a texture

Parameters

NameTypeDescription
widthnumberwidth of texture
heightnumberheight of texture
rnumbercomponent-red
gnumbercomponent-green
bnumbercomponent-blue
anumbercomponent-alpha(0 for transparent,1 for opaque)
name?stringname string

Returns

Uint8ArrayTexture

Defined in

src/assets/Res.ts:462


fillColor

fillColor(array, w, h, r, g, b, a): void

fill slod color to this texture

Parameters

NameTypeDescription
arrayanydata of texture
wnumberwidth of texture
hnumberheight of texture
rnumbercomponent-red
gnumbercomponent-green
bnumbercomponent-blue
anumbercomponent-alpha(0 for transparent,1 for opaque)

Returns

void

Defined in

src/assets/Res.ts:486


initDefault

initDefault(): void

Initialize a common texture object. Provide a universal solid color texture object.

Returns

void

Defined in

src/assets/Res.ts:501

Released under the MIT License