Function
Static Public Summary | ||
public |
angleDifference(a: number, b: number): number Calculate closest turn angle difference. |
|
public |
Calculate cubic bezier curve value at given time with four curve parameters. |
|
public |
convertGlobalPointToLocalPoint(target: vec3, globalVec: vec3, globalTransform: mat4) Converts global vec3 coordinate into local vec2 coordinate. |
|
public |
convertLocalPointToGlobalPoint(target: vec3, localVec: vec3, globalTransform: mat4) Converts local vec3 coordinate into global vec2 coordinate. |
|
public |
findMapKeyOfValue(map: *, value: *): string | null Search for key of given map value. |
|
public |
getMipmapScale(level: number): number Calculate mipmap scale at given level. |
|
public |
Calculate nearest power-of-two. |
|
public |
isGlobalPointInGlobalBoundingBox(globalVec: vec2, w: number, h: number, ox: number, oy: number, globalTransform: mat4): boolean Tells if given global vec2 coordinate is contained by given bounding box in given global transform space. |
|
public |
isLocalPointInLocalBoundingBox(localVec: vec2, w: number, h: number, ox: number, oy: number): boolean Tells if given local vec2 coordinate is contained by given bounding box. |
|
public |
Checks if all arguments are power-of-two. |
|
public |
lazyInitialization(config: *): EventsController Function used to initialize Oxygen Core engine without any effort. |
|
public |
propsEnumStringify(values: *): string Stringify key-value map into enumeration-like representation. |
|
public |
stringToRGBA(value: string): [number] Converts hexadecimal color string into four element array of color channels values. |
|
public |
waitForSeconds(seconds: number): Promise Produces promise that waits given amount of seconds, then resolves itself. |
Static Public
public angleDifference(a: number, b: number): number source
import {angleDifference} from 'oxygen-core/utils'
Calculate closest turn angle difference.
Example:
angleDifference(10, 350) === -20
public bezierCubic(t: number, a: number, b: number, c: number, d: number): number source
import {bezierCubic} from 'oxygen-core/utils'
Calculate cubic bezier curve value at given time with four curve parameters.
public convertGlobalPointToLocalPoint(target: vec3, globalVec: vec3, globalTransform: mat4) source
import {convertGlobalPointToLocalPoint} from 'oxygen-core/utils'
Converts global vec3 coordinate into local vec2 coordinate.
Params:
Name | Type | Attribute | Description |
target | vec3 | Result vec3 value. |
|
globalVec | vec3 | Global vec3 value. |
|
globalTransform | mat4 | Object mat4 transform. |
Example:
const result = vec3.create();
const pos = vec3.fromValues(1, 1, 0);
const transform = mat4.identity();
convertGlobalPointToLocalPoint(result, pos, transform);
public convertLocalPointToGlobalPoint(target: vec3, localVec: vec3, globalTransform: mat4) source
import {convertLocalPointToGlobalPoint} from 'oxygen-core/utils'
Converts local vec3 coordinate into global vec2 coordinate.
Params:
Name | Type | Attribute | Description |
target | vec3 | Result vec3 value. |
|
localVec | vec3 | Local vec3 value. |
|
globalTransform | mat4 | Object mat4 transform. |
Example:
const result = vec3.create();
const pos = vec3.fromValues(1, 1, 0);
const transform = mat4.identity();
convertLocalPointToGlobalPoint(result, pos, transform);
public findMapKeyOfValue(map: *, value: *): string | null source
import {findMapKeyOfValue} from 'oxygen-core/utils'
Search for key of given map value.
Params:
Name | Type | Attribute | Description |
map | * | map collection object. |
|
value | * | value you're looking for. |
Example:
const found = findMapKeyOfValue({ hello: 'world' }, 'world');
public getMipmapScale(level: number): number source
import {getMipmapScale} from 'oxygen-core/utils'
Calculate mipmap scale at given level.
Params:
Name | Type | Attribute | Description |
level | number | Level value (0 means base level, full scale). |
public getPOT(v: number, upper: boolean): number source
import {getPOT} from 'oxygen-core/utils'
Calculate nearest power-of-two.
public isGlobalPointInGlobalBoundingBox(globalVec: vec2, w: number, h: number, ox: number, oy: number, globalTransform: mat4): boolean source
import {isGlobalPointInGlobalBoundingBox} from 'oxygen-core/utils'
Tells if given global vec2 coordinate is contained by given bounding box in given global transform space.
Example:
const pos = vec2.fromValues(2, 2);
const transform = mat4.identity();
isGlobalPointInGlobalBoundingBox(pos, 2, 2, 1, 1, transform) === true
public isLocalPointInLocalBoundingBox(localVec: vec2, w: number, h: number, ox: number, oy: number): boolean source
import {isLocalPointInLocalBoundingBox} from 'oxygen-core/utils'
Tells if given local vec2 coordinate is contained by given bounding box.
public isPOT(args: number[]): boolean source
import {isPOT} from 'oxygen-core/utils'
Checks if all arguments are power-of-two.
Params:
Name | Type | Attribute | Description |
args | number[] | Values. |
public lazyInitialization(config: *): EventsController source
import {lazyInitialization} from 'oxygen-core'
Function used to initialize Oxygen Core engine without any effort.
Params:
Name | Type | Attribute | Description |
config | * | engine configuration options. |
Example:
lazyInitialization({
entities: { triggerEvents: true },
asset: { pathPrefix: 'assets/' },
render: { screen: 'screen-0' },
input: { triggerEvents: true },
store: { id: 'my-game-id' },
events: { transform: true, update: true, view: true, gamepads: true }
});
public propsEnumStringify(values: *): string source
import {propsEnumStringify} from 'oxygen-core/utils'
Stringify key-value map into enumeration-like representation.
Params:
Name | Type | Attribute | Description |
values | * | Map collection. |
Example:
const enum = propsEnumStringify({ hello: 'world', ohayo: 'gosaimasu' });
public stringToRGBA(value: string): [number] source
import {stringToRGBA} from 'oxygen-core/utils'
Converts hexadecimal color string into four element array of color channels values.
Params:
Name | Type | Attribute | Description |
value | string | Hexadecimal color string. |
Return:
[number] | Four element array of color channels. |
Example:
const color = stringToRGBA('AABBCCFF');
public waitForSeconds(seconds: number): Promise source
import {waitForSeconds} from 'oxygen-core/utils'
Produces promise that waits given amount of seconds, then resolves itself.
Params:
Name | Type | Attribute | Description |
seconds | number | Number of seconds to wait. |
Example:
waitForSeconds(1.5).then(() => console.log('hello!'));