Methods
Helper for warning developers about deprecated features & settings. A stack track for warnings is given; useful for tracking-down where deprecated methods/properties/classes are being used within the code.
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
version |
string |
The version where the feature became deprecated |
||
message |
string |
Message should include what is deprecated, where, and the new solution |
||
ignoreDepth |
number |
<optional> |
3 |
The number of steps to ignore at the top of the error stack this is mostly to ignore internal deprecation calls. |
detectVideoAlphaMode () Promise<ALPHA_MODES>
Helper for detecting the correct alpha mode for video textures.
For some reason, some browsers/devices/WebGL implementations premultiply the alpha
of a video before and then a second time if UNPACK_PREMULTIPLY_ALPHA_WEBGL
is true. So the video is premultiplied twice if the alpha mode is UNPACK.
In this case we need the alpha mode to be PMA. This function detects
the upload behavior by uploading a white 2x2 webm with 50% alpha
without UNPACK_PREMULTIPLY_ALPHA_WEBGL and then checking whether
the uploaded pixels are premultiplied.
Returns:
| Type | Description |
|---|---|
| Promise<ALPHA_MODES> | The correct alpha mode for video textures. |
get the resolution / device pixel ratio of an asset by looking for the prefix used by spritesheets and image urls
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
url |
string |
the image path |
||
defaultValue |
number |
<optional> |
1 |
the defaultValue if no filename prefix is set. |
Returns:
| Type | Description |
|---|---|
| number | resolution / device pixel ratio of an asset |
Helper for checking for WebGL support.
| Name | Type | Attributes | Description |
|---|---|---|---|
failIfMajorPerformanceCaveat |
boolean |
<optional> |
Returns:
| Type | Description |
|---|---|
| boolean | Is WebGL supported. |
Helper for checking for WebGPU support.
| Name | Type | Description |
|---|---|---|
options |
GPURequestAdapterOptions |
Returns:
| Type | Description |
|---|---|
| Promise<boolean> | Is WebGPU supported. |
Remove items from a javascript array without generating garbage
| Name | Type | Description |
|---|---|---|
arr |
Array<any> |
Array to remove elements from |
startIdx |
number |
starting index |
removeCount |
number |
how many to remove |