Class: Res
Resource management classes for textures, materials, models, and preset bodies.
Constructors
Properties
- normalTexture
- maskTexture
- whiteTexture
- blackTexture
- redTexture
- blueTexture
- greenTexture
- yellowTexture
- grayTexture
- defaultSky
- defaultGUITexture
- defaultGUISprite
- defaultMaterial
Methods
- getGltf
- addObj
- getObj
- addTexture
- getTexture
- addGeometry
- getGeometry
- addMat
- getMat
- addPrefab
- getPrefab
- addAtlas
- getAtlas
- getGUISprite
- load
- loadGltf
- loadObj
- loadB3DM
- loadI3DM
- loadTexture
- loadBitmapTextures
- loadHDRTexture
- loadHDRTextureCube
- loadLDRTextureCube
- loadTextureCubeMaps
- loadTextureCubeStd
- loadJSON
- loadFont
- loadAtlas
- createTexture
- fillColor
- initDefault
Constructors
constructor
• new Res(): Res
Returns
Defined in
Properties
normalTexture
• normalTexture: Uint8ArrayTexture
normal texture
Defined in
maskTexture
• maskTexture: Uint8ArrayTexture
Defined in
whiteTexture
• whiteTexture: Uint8ArrayTexture
Defined in
blackTexture
• blackTexture: Uint8ArrayTexture
Defined in
redTexture
• redTexture: Uint8ArrayTexture
Defined in
blueTexture
• blueTexture: Uint8ArrayTexture
Defined in
greenTexture
• greenTexture: Uint8ArrayTexture
Defined in
yellowTexture
• yellowTexture: Uint8ArrayTexture
Defined in
grayTexture
• grayTexture: Uint8ArrayTexture
Defined in
defaultSky
• defaultSky: HDRTextureCube
Defined in
defaultGUITexture
• defaultGUITexture: GUITexture
Defined in
defaultGUISprite
• defaultGUISprite: GUISprite
Defined in
defaultMaterial
• defaultMaterial: LitMaterial
Defined in
Methods
getGltf
▸ getGltf(url): GLTF_Info
Parameters
| Name | Type |
|---|---|
url | string |
Returns
GLTF_Info
Defined in
addObj
▸ addObj(url, obj): void
add a obj with reference of url
Parameters
| Name | Type | Description |
|---|---|---|
url | string | file path |
obj | any | - |
Returns
void
Defined in
getObj
▸ getObj(url): any
get obj by url
Parameters
| Name | Type | Description |
|---|---|---|
url | string | file path |
Returns
any
Defined in
addTexture
▸ addTexture(url, texture): void
add a texture with reference of url
Parameters
| Name | Type | Description |
|---|---|---|
url | string | file path |
texture | Texture | source texture |
Returns
void
Defined in
getTexture
▸ getTexture(url): Texture
get texture by url
Parameters
| Name | Type | Description |
|---|---|---|
url | string | file path |
Returns
Defined in
addGeometry
▸ addGeometry(url, geo): void
Parameters
| Name | Type |
|---|---|
url | string |
geo | GeometryBase |
Returns
void
Defined in
getGeometry
▸ getGeometry(url): GeometryBase
Parameters
| Name | Type |
|---|---|
url | string |
Returns
Defined in
addMat
▸ addMat(name, mat): Map<string, Material>
add a material with reference of name
Parameters
| Name | Type | Description |
|---|---|---|
name | string | material name |
mat | Material | target material |
Returns
Map<string, Material>
Defined in
getMat
▸ getMat(name): Material
get material by name
Parameters
| Name | Type | Description |
|---|---|---|
name | string | material name |
Returns
Defined in
addPrefab
▸ addPrefab(name, rootScene): void
add prefab with reference name
Parameters
| Name | Type | Description |
|---|---|---|
name | string | prefab name |
rootScene | Object3D | root object of prefab |
Returns
void
Defined in
getPrefab
▸ getPrefab(name): Object3D
get prefab by name
Parameters
| Name | Type | Description |
|---|---|---|
name | string | prefab name |
Returns
Defined in
addAtlas
▸ addAtlas(name, atlas): void
Parameters
| Name | Type |
|---|---|
name | string |
atlas | GUIAtlasTexture |
Returns
void
Defined in
getAtlas
▸ getAtlas(name): GUIAtlasTexture
Parameters
| Name | Type |
|---|---|
name | string |
Returns
Defined in
getGUISprite
▸ getGUISprite(id): GUISprite
Parameters
| Name | Type |
|---|---|
id | string |
Returns
Defined in
load
▸ load<T>(url, c, loaderFunctions?): Promise<any>
Type parameters
| Name | Type |
|---|---|
T | extends ParserBase |
Parameters
| Name | Type |
|---|---|
url | string |
c | Parser<T> |
loaderFunctions? | LoaderFunctions |
Returns
Promise<any>
Defined in
loadGltf
▸ loadGltf(url, loaderFunctions?): Promise<Object3D>
load a gltf file
Parameters
| Name | Type | Description |
|---|---|---|
url | string | the url of file |
loaderFunctions? | LoaderFunctions | callback |
Returns
Promise<Object3D>
Defined in
loadObj
▸ loadObj(url, loaderFunctions?): Promise<Object3D>
load obj file
Parameters
| Name | Type | Description |
|---|---|---|
url | string | obj file path |
loaderFunctions? | LoaderFunctions | callback |
Returns
Promise<Object3D>
Defined in
loadB3DM
▸ loadB3DM(url, loaderFunctions?, userData?): Promise<Object3D>
load b3dm file by url
Parameters
| Name | Type | Description |
|---|---|---|
url | string | path of file |
loaderFunctions? | LoaderFunctions | callback |
userData? | any | - |
Returns
Promise<Object3D>
Defined in
loadI3DM
▸ loadI3DM(url, loaderFunctions?, userData?): Promise<Object3D>
load i3dm file by url
Parameters
| Name | Type | Description |
|---|---|---|
url | string | path of i3dm file |
loaderFunctions? | LoaderFunctions | callback |
userData? | any | - |
Returns
Promise<Object3D>
Defined in
loadTexture
▸ loadTexture(url, loaderFunctions?, flipY?): Promise<Texture>
load texture by url
Parameters
| Name | Type | Description |
|---|---|---|
url | string | texture path |
loaderFunctions? | LoaderFunctions | callback |
flipY? | boolean | use flip y or not |
Returns
Promise<Texture>
Defined in
loadBitmapTextures
▸ loadBitmapTextures(urls, count?, loaderFunctions?, flipY?): Promise<BitmapTexture2D[]>
Parameters
| Name | Type | Default value |
|---|---|---|
urls | string[] | undefined |
count | number | 5 |
loaderFunctions? | LoaderFunctions | undefined |
flipY? | boolean | undefined |
Returns
Promise<BitmapTexture2D[]>
Defined in
loadHDRTexture
▸ loadHDRTexture(url, loaderFunctions?): Promise<Texture>
load a hdr texture
Parameters
| Name | Type | Description |
|---|---|---|
url | string | texture url |
loaderFunctions? | LoaderFunctions | callback |
Returns
Promise<Texture>
Defined in
loadHDRTextureCube
▸ loadHDRTextureCube(url, loaderFunctions?): Promise<Texture>
load hdr cube texture
Parameters
| Name | Type | Description |
|---|---|---|
url | string | file url |
loaderFunctions? | LoaderFunctions | callback |
Returns
Promise<Texture>
Defined in
loadLDRTextureCube
▸ loadLDRTextureCube(url, loaderFunctions?): Promise<Texture>
load ldr cube texture
Parameters
| Name | Type | Description |
|---|---|---|
url | string | file path |
loaderFunctions? | LoaderFunctions | callback |
Returns
Promise<Texture>
Defined in
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
| Name | Type |
|---|---|
urls | string[] |
Returns
Promise<Texture>
Defined in
loadTextureCubeStd
▸ loadTextureCubeStd(url, loaderFunctions?): Promise<Texture>
load texture data from url. the image is assembled from six images into cross shaped image.
Parameters
| Name | Type | Description |
|---|---|---|
url | string | the path of image |
loaderFunctions? | LoaderFunctions | - |
Returns
Promise<Texture>
Defined in
loadJSON
▸ loadJSON(url, loaderFunctions?): Promise<void | object>
load json data from url.
Parameters
| Name | Type | Description |
|---|---|---|
url | string | the path of image |
loaderFunctions? | LoaderFunctions | - |
Returns
Promise<void | object>
Defined in
loadFont
▸ loadFont(url, loaderFunctions?, userData?): Promise<FontInfo>
load font file by url
Parameters
| Name | Type | Description |
|---|---|---|
url | string | font file url |
loaderFunctions? | LoaderFunctions | callback |
userData? | any | - |
Returns
Promise<FontInfo>
Defined in
loadAtlas
▸ loadAtlas(url, loaderFunctions?): Promise<FontInfo>
load a atlas file by url
Parameters
| Name | Type | Description |
|---|---|---|
url | string | file path |
loaderFunctions? | LoaderFunctions | callback |
Returns
Promise<FontInfo>
Defined in
createTexture
▸ createTexture(width, height, r, g, b, a, name?): Uint8ArrayTexture
create a texture
Parameters
| Name | Type | Description |
|---|---|---|
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
Defined in
fillColor
▸ fillColor(array, w, h, r, g, b, a): void
fill slod color to this texture
Parameters
| Name | Type | Description |
|---|---|---|
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
Defined in
initDefault
▸ initDefault(): void
Initialize a common texture object. Provide a universal solid color texture object.
Returns
void

