Global
Members
-
-
renderkitModelBlendMode the blend modes to use for renderkitModelUpdateBlendMode
Type:
-
number
Properties:
Name Type Default Description NONE
number
0
NORMAL
number
1
INTERPOLATION
number
2
ADDITIVE
number
3
ALPHAMODULATE
number
4
STAMP
number
5
MULTIPLY
number
6
SCREEN
number
7
LIGHTEN
number
8
DARKEN
number
9
SOFTDODGE
number
10
SOFTBURN
number
11
COLORDODGE
number
12
COLORBURN
number
13
WARMBURN
number
14
HEAVYBURN
number
15
SUPERBURN
number
16
INVERSEBURN
number
17
DIFFERENCE
number
18
EXCLUSION
number
19
PLASMA
number
20
ERASER
number
21
ALPHAOVERLAY
number
22
-
Methods
-
renderkit_model_create_triangle_full_array(renderkit, buffer)
-
renderkitModelCreateTriangleFullArray //big endian
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used buffer
buffer
JS ArrayBuffer, big endian, per face, 3*[normal float XYZ, verts float XYZ, texturecoord float UV, color Uint32] -
renderkitCameraGet(renderkit)
-
renderkitCameraGet gets the camera properties as a JSON formatted string
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust Returns:
camera_vectors - returns the JSON formatted string with the Eye, LookAt and UpVector- Type
-
string
-
renderkitCameraSetGround(renderkit, color)
-
renderkitCameraSetGround sets the ground plane color. This is a plane which cuts the origin and the y axis is the upvector
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust color
string
The full 32 bit color representation including alpha (opaque white = 0xFFFFFFFF) -
renderkitCameraSetPano(renderkit, filename)
-
renderkitCameraSetPano sets the environment with a type of skybox known as a panosphere or spherical panorama (rather than 6 seperate images)
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust filename
string
The panosphere image to use -
renderkitCameraUpdateEffect(renderkit, effect_name)
-
renderkitCameraUpdateEffect this sets the default shader for the camera.
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust effect_name
string
The name of the effect to load from project or global pool -
renderkitCameraUpdateEye(renderkit, x, y, z)
-
renderkitCameraUpdateEye this describes the eye position in world space. This is where the camera will start looking from.
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust x
real
y
real
z
real
-
renderkitCameraUpdateEyeTween(renderkit, x, y, z, ms, type)
-
renderkitCameraUpdateEyeTween this animates the eye position in world space. This is where the camera will start looking from.
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust x
real
y
real
z
real
ms
int
the number of milliseconds for the tween type
int
The allowable values of tween are 0:none, 1:linear, 2:ease_in, 3:ease_out, 4:ease_both, 5:ease_rev, 6:cubic_in, 7:cubic_out, 8:cubic_in_out, 9:cubic_out_in, 10:ease_in_strong, 11:ease_out_strong, 12:ease_both_strong, 13:ease_both_strong_rev ,14:quint_in, 15:quint_out, 16:quint_in_out, 17:quint_out_in, 18:sine_in, 19:sine_out, 20:sine_in_out, 21:sine_out_in, 22:expo_in, 23:expo_out, 24:expo_in_out, 25:expo_out_in, 26:circ_in, 27:circ_out, 28:circ_in_out, 29:circ_out_in, 30:elastic_in, 31:elastic_out, 32:elastic_in_out, 33:elastic_out_in, 32:elastic_both, 34:back_in, 35:back_out, 36:back_in_out, 37:back_out_in, 36:back_both, 38:bounce_in, 39:bounce_out, 40:bounce_in_out, 41:bounce_out_in, 40:bounce_both, 42:curve_in, 43:curve_out, 44:curve_sine, 45:curve_cosine -
renderkitCameraUpdateFOV(renderkit, fov)
-
renderkitCameraUpdateFOV sets the field of view of the camera. This is the angle describing how much of the world the camera can see.
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust fov
real
90 is a comfortable FOV for a device. 60 is a zoom and 120 is a wide angle view which will start to show distortion. -
renderkitCameraUpdateFOVTween(renderkit, FOV, ms, type)
-
renderkitCameraUpdateFOVTween this animates the camera field of view.
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust FOV
real
the field of view in degrees for the current camera, 60 degrees is a common amount ms
int
the number of milliseconds for the tween type
int
The allowable values of tween are 0:none, 1:linear, 2:ease_in, 3:ease_out, 4:ease_both, 5:ease_rev, 6:cubic_in, 7:cubic_out, 8:cubic_in_out, 9:cubic_out_in, 10:ease_in_strong, 11:ease_out_strong, 12:ease_both_strong, 13:ease_both_strong_rev ,14:quint_in, 15:quint_out, 16:quint_in_out, 17:quint_out_in, 18:sine_in, 19:sine_out, 20:sine_in_out, 21:sine_out_in, 22:expo_in, 23:expo_out, 24:expo_in_out, 25:expo_out_in, 26:circ_in, 27:circ_out, 28:circ_in_out, 29:circ_out_in, 30:elastic_in, 31:elastic_out, 32:elastic_in_out, 33:elastic_out_in, 32:elastic_both, 34:back_in, 35:back_out, 36:back_in_out, 37:back_out_in, 36:back_both, 38:bounce_in, 39:bounce_out, 40:bounce_in_out, 41:bounce_out_in, 40:bounce_both, 42:curve_in, 43:curve_out, 44:curve_sine, 45:curve_cosine -
renderkitCameraUpdateFrustum(renderkit, near, far)
-
renderkitCameraUpdateFrustrum this adjusts the range of the clipping and zbuffer accuracy. This can be managed to closely match the scale of the world so the zbuffer on mobile devices is used to best effect.
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust near
real
the closest point for calculating the z buffer e.g. 0.01 far
real
the furthest point for calculating the z buffer e.g. 100 -
renderkitCameraUpdateLookat(renderkit, x, y, z)
-
renderkitCameraUpdateLookat this describes the lookat position in world space. This is where the camera will look at.
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust x
real
y
real
z
real
-
renderkitCameraUpdateLookatTween(renderkit, x, y, z, ms, type)
-
renderkitCameraUpdateLookatTween this animates the lookat position in world space. This is where the camera will look at.
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust x
real
y
real
z
real
ms
int
the number of milliseconds for the tween type
int
The allowable values of tween are 0:none, 1:linear, 2:ease_in, 3:ease_out, 4:ease_both, 5:ease_rev, 6:cubic_in, 7:cubic_out, 8:cubic_in_out, 9:cubic_out_in, 10:ease_in_strong, 11:ease_out_strong, 12:ease_both_strong, 13:ease_both_strong_rev ,14:quint_in, 15:quint_out, 16:quint_in_out, 17:quint_out_in, 18:sine_in, 19:sine_out, 20:sine_in_out, 21:sine_out_in, 22:expo_in, 23:expo_out, 24:expo_in_out, 25:expo_out_in, 26:circ_in, 27:circ_out, 28:circ_in_out, 29:circ_out_in, 30:elastic_in, 31:elastic_out, 32:elastic_in_out, 33:elastic_out_in, 32:elastic_both, 34:back_in, 35:back_out, 36:back_in_out, 37:back_out_in, 36:back_both, 38:bounce_in, 39:bounce_out, 40:bounce_in_out, 41:bounce_out_in, 40:bounce_both, 42:curve_in, 43:curve_out, 44:curve_sine, 45:curve_cosine -
renderkitCameraUpdateMove(renderkit, forwardback, leftright, updown)
-
renderkitCameraUpdateMove Moves the camera in three axis relative to it's current orientation
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust forwardback
real
0 is no movement, negative values are back and positive forward leftright
real
0 is no movement, negative values are left and positive right updown
real
0 is no movement, negative values are down and positive up -
renderkitCameraUpdateMoveTween(renderkit, forwardback, leftright, updown, ms, type)
-
renderkitCameraUpdateMoveTween Moves the camera in three axis relative to it's current orientation
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust forwardback
real
0 is no movement, negative values are back and positive forward leftright
real
0 is no movement, negative values are left and positive right updown
real
0 is no movement, negative values are down and positive up ms
int
the number of milliseconds for the tween type
int
The allowable values of tween are 0:none, 1:linear, 2:ease_in, 3:ease_out, 4:ease_both, 5:ease_rev, 6:cubic_in, 7:cubic_out, 8:cubic_in_out, 9:cubic_out_in, 10:ease_in_strong, 11:ease_out_strong, 12:ease_both_strong, 13:ease_both_strong_rev ,14:quint_in, 15:quint_out, 16:quint_in_out, 17:quint_out_in, 18:sine_in, 19:sine_out, 20:sine_in_out, 21:sine_out_in, 22:expo_in, 23:expo_out, 24:expo_in_out, 25:expo_out_in, 26:circ_in, 27:circ_out, 28:circ_in_out, 29:circ_out_in, 30:elastic_in, 31:elastic_out, 32:elastic_in_out, 33:elastic_out_in, 32:elastic_both, 34:back_in, 35:back_out, 36:back_in_out, 37:back_out_in, 36:back_both, 38:bounce_in, 39:bounce_out, 40:bounce_in_out, 41:bounce_out_in, 40:bounce_both, 42:curve_in, 43:curve_out, 44:curve_sine, 45:curve_cosine -
renderkitCameraUpdateUpvector(renderkit, x, y, z)
-
renderkitCameraUpdateUpvector this describes the rotation of the camera along its axis, e.g. the direction which is up. This is usually kept with the y axis being up, but can be altered for rolling and pitching the camera.
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust x
real
y
real
z
real
-
renderkitCameraUpdateUpvectorTween(renderkit, x, y, z, ms, type)
-
renderkitCameraUpdateUpvectorTween this animates the eye upvector in world space. This is where the camera will look from.
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust x
real
y
real
z
real
ms
int
the number of milliseconds for the tween type
int
The allowable values of tween are 0:none, 1:linear, 2:ease_in, 3:ease_out, 4:ease_both, 5:ease_rev, 6:cubic_in, 7:cubic_out, 8:cubic_in_out, 9:cubic_out_in, 10:ease_in_strong, 11:ease_out_strong, 12:ease_both_strong, 13:ease_both_strong_rev ,14:quint_in, 15:quint_out, 16:quint_in_out, 17:quint_out_in, 18:sine_in, 19:sine_out, 20:sine_in_out, 21:sine_out_in, 22:expo_in, 23:expo_out, 24:expo_in_out, 25:expo_out_in, 26:circ_in, 27:circ_out, 28:circ_in_out, 29:circ_out_in, 30:elastic_in, 31:elastic_out, 32:elastic_in_out, 33:elastic_out_in, 32:elastic_both, 34:back_in, 35:back_out, 36:back_in_out, 37:back_out_in, 36:back_both, 38:bounce_in, 39:bounce_out, 40:bounce_in_out, 41:bounce_out_in, 40:bounce_both, 42:curve_in, 43:curve_out, 44:curve_sine, 45:curve_cosine -
renderkitCleanup(renderkit)
-
renderkitCleanup cleans up and removes any shapes, sprites, maps or models
Parameters:
Name Type Description renderkit
renderkit
The renderkit to cleanup -
renderkitIntersectRayQuad(rayPosx,rayPosy,rayPosz,rayDirx,rayDiry,rayDirz, px1,py1,pz1,px2,py2,pz2,px3,py3,pz3, cull_backface)
-
renderkitIntersectRayQuad returns -1 for no intersection, or a JSON string containing the coordinates
Parameters:
Name Type Description rayPosx,rayPosy,rayPosz,rayDirx,rayDiry,rayDirz
real
the position and direction determine the ray cast at the quad px1,py1,pz1,px2,py2,pz2,px3,py3,pz3
real
position of the first three corners of the quad cull_backface
boolean
off by default, determine if you can hit the quad from either side Returns:
-1 or the uv as a ratio and the xyz intesection position in world space -
renderkitIntersectRaySphere(rayPosx,rayPosy,rayPosz,rayDirx,rayDiry,rayDirz, spherePosx,spherePosy,spherePosz, sphereRadius)
-
renderkitIntersectRaySphere returns -1 for no intersection, or the distance to the first point
Parameters:
Name Type Description rayPosx,rayPosy,rayPosz,rayDirx,rayDiry,rayDirz
real
the position and direction determine the ray cast at the sphere spherePosx,spherePosy,spherePosz
real
position of the sphere sphereRadius
real
radius of the sphere Returns:
-1 or the intesection position -
renderkitLightUpdateColor(renderkit, lightid, color)
-
renderkitLightUpdateColor this sets the light color.
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust lightid
int
Valid light ID's are 0, 1 or 2 (note : only some shaders use the lights) color
string
The full 32 bit color representation including alpha (opaque white = 0xFFFFFFFF) -
renderkitLightUpdateColorTween(renderkit, lightid, color, ms, type)
-
renderkitLightUpdateColorTween this animates the light color over time
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust lightid
int
Valid light ID's are 0,1 or 2 (note : only some shaders use the lights) color
string
The full 32 bit color representation including alpha (opaque white = 0xFFFFFFFF) ms
int
the number of milliseconds for the tween type
int
The allowable values of tween are 0:none, 1:linear, 2:ease_in, 3:ease_out, 4:ease_both, 5:ease_rev, 6:cubic_in, 7:cubic_out, 8:cubic_in_out, 9:cubic_out_in, 10:ease_in_strong, 11:ease_out_strong, 12:ease_both_strong, 13:ease_both_strong_rev ,14:quint_in, 15:quint_out, 16:quint_in_out, 17:quint_out_in, 18:sine_in, 19:sine_out, 20:sine_in_out, 21:sine_out_in, 22:expo_in, 23:expo_out, 24:expo_in_out, 25:expo_out_in, 26:circ_in, 27:circ_out, 28:circ_in_out, 29:circ_out_in, 30:elastic_in, 31:elastic_out, 32:elastic_in_out, 33:elastic_out_in, 32:elastic_both, 34:back_in, 35:back_out, 36:back_in_out, 37:back_out_in, 36:back_both, 38:bounce_in, 39:bounce_out, 40:bounce_in_out, 41:bounce_out_in, 40:bounce_both, 42:curve_in, 43:curve_out, 44:curve_sine, 45:curve_cosine -
renderkitLightUpdateDir(renderkit, lightid, x, y, z)
-
renderkitLightUpdateDir this updates the light direction.
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust lightid
int
Valid light ID's are 0, 1 or 2 (note : only some shaders use the lights) x
real
y
real
z
real
-
renderkitLightUpdateDirTween(renderkit, lightid, x, y, z, ms, type)
-
renderkitLightUpdateDirTween this animates the light direction.
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust lightid
int
Valid light ID's are 0, 1 or 2 (note : only some shaders use the lights) x
real
y
real
z
real
ms
int
the number of milliseconds for the tween type
int
The allowable values of tween are 0:none, 1:linear, 2:ease_in, 3:ease_out, 4:ease_both, 5:ease_rev, 6:cubic_in, 7:cubic_out, 8:cubic_in_out, 9:cubic_out_in, 10:ease_in_strong, 11:ease_out_strong, 12:ease_both_strong, 13:ease_both_strong_rev ,14:quint_in, 15:quint_out, 16:quint_in_out, 17:quint_out_in, 18:sine_in, 19:sine_out, 20:sine_in_out, 21:sine_out_in, 22:expo_in, 23:expo_out, 24:expo_in_out, 25:expo_out_in, 26:circ_in, 27:circ_out, 28:circ_in_out, 29:circ_out_in, 30:elastic_in, 31:elastic_out, 32:elastic_in_out, 33:elastic_out_in, 32:elastic_both, 34:back_in, 35:back_out, 36:back_in_out, 37:back_out_in, 36:back_both, 38:bounce_in, 39:bounce_out, 40:bounce_in_out, 41:bounce_out_in, 40:bounce_both, 42:curve_in, 43:curve_out, 44:curve_sine, 45:curve_cosine -
renderkitLightUpdatePos(renderkit, lightid, x, y, z)
-
renderkitLightUpdatePos this describes the eye position in world space. This is where the camera will start looking from.
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust lightid
int
Valid light ID's are 0, 1 or 2 (note : only some shaders use the lights) x
real
y
real
z
real
-
renderkitLightUpdatePosTween(renderkit, lightid, x, y, z, ms, type)
-
renderkitLightUpdatePosTween this animates the eye position in world space. This is where the camera will start looking from.
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust lightid
int
Valid light ID's are 0, 1 or 2 (note : only some shaders use the lights) x
real
y
real
z
real
ms
int
the number of milliseconds for the tween type
int
The allowable values of tween are 0:none, 1:linear, 2:ease_in, 3:ease_out, 4:ease_both, 5:ease_rev, 6:cubic_in, 7:cubic_out, 8:cubic_in_out, 9:cubic_out_in, 10:ease_in_strong, 11:ease_out_strong, 12:ease_both_strong, 13:ease_both_strong_rev ,14:quint_in, 15:quint_out, 16:quint_in_out, 17:quint_out_in, 18:sine_in, 19:sine_out, 20:sine_in_out, 21:sine_out_in, 22:expo_in, 23:expo_out, 24:expo_in_out, 25:expo_out_in, 26:circ_in, 27:circ_out, 28:circ_in_out, 29:circ_out_in, 30:elastic_in, 31:elastic_out, 32:elastic_in_out, 33:elastic_out_in, 32:elastic_both, 34:back_in, 35:back_out, 36:back_in_out, 37:back_out_in, 36:back_both, 38:bounce_in, 39:bounce_out, 40:bounce_in_out, 41:bounce_out_in, 40:bounce_both, 42:curve_in, 43:curve_out, 44:curve_sine, 45:curve_cosine -
renderkitMapGetTileCol(renderkit, map_idx, x)
-
renderkitMapGetTileCol returns the col of tiles the x value lines up with (allowing for the last renderkitMapRender).
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used map_idx
int
The map index from the pool of maps x
real
The x position in the current map to examine Returns:
col - returns the column of the map which the x falls intoExample
var row = renderkitMapGetTileRow(self, 0, y); var col = renderkitMapGetTileCol(self, 0, x); var tileid = renderkitMapGetTileID(self, 0, row, col));
-
renderkitMapGetTileID(renderkit, map_idx, row, col)
-
renderkitMapGetTileID returns the tile index for that item in the map for a given row and column
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used map_idx
int
The map index from the pool of maps row
int
the row of the tile to retrieve col
int
the column of the tile to retrieve Returns:
tile_idx - returns the tile index from the map given the row and column to examineExample
var row = renderkitMapGetTileRow(self, 0, y); var col = renderkitMapGetTileCol(self, 0, x); var tileid = renderkitMapGetTileID(self, 0, row, col));
-
renderkitMapGetTileRow(renderkit, map_idx, y)
-
renderkitMapGetTileRow returns the row of tiles the y value lines up with (allowing for the last renderkitMapRender).
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used map_idx
int
The map index from the pool of maps y
real
The y position in the current map to examine Returns:
row - returns the row of the map which the y falls intoExample
var row = renderkitMapGetTileRow(self, 0, y); var col = renderkitMapGetTileCol(self, 0, x); var tileid = renderkitMapGetTileID(self, 0, row, col));
-
renderkitMapLoad(renderkit, filename, gscale, width, height, row_height, col_width)
-
renderkitMapLoad adds a new map to the pool of hardware accelerated maps in the renderkit component. This map allocates it's own set of sprites from the pool of sprites in the renderkit.
You can load multiple maps to provide paralax layering.
Note : The map format is a simple binary format. See the demo applications for more information on making your own maps and spritesheets.Parameters:
Name Type Description renderkit
renderkit
The renderkit being used filename
string
The name of the map file in the images folder of your project gscale
real
The scale of the map as a ratio (1.0 is the default) width
int
The width of the map area in pixels height
int
The height of the map area in pixels row_height
int
The height of each row of sprites in pixels col_width
int
The width of each column of sprites in pixels Returns:
map_idx - the map index in the pool of mapsExample
var rk = createComponent(self, "renderkit", 0, 0, 100, 100) setProperty(rk,"spritesheet","sprites"); renderkitMapLoad(rk,'desert.map',1.0,width,height,128,128);
-
renderkitMapRender(renderkit, map_idx, x, y)
-
renderkitMapRender renders the map tiles/sprites at the specified x,y offset from it's origin
Parameters:
Name Type Description renderkit
renderkit
The renderkit to render from map_idx
int
The map index from the pool of maps x
real
The x offset from the origin (top left) of the map y
real
The y offset from the origin (top left) of the map Example
function gamemap_on_move(x, y, tid){ renderkitMapRender(self, map_idx, mx, my) }
-
renderkitModelAnimGetAnimations(renderkit, modelid)
-
renderkitModelAnimGetAnimations returns a pipe delimited list of animation names
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool - works with 3D and 2D animations Returns:
animList - the pipe | delimited list of animations- Type
-
string
-
renderkitModelAnimGetAttachmentsForSlots(renderkit, modelid, slot)
-
renderkitModelAnimGetAttachmentsForSlots returns a pipe delimited list of attachment names for a 2D animation slot, for example for slot head, attachments might be "hat|helmet|crown"
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool - works with 2D animations slot
string
the slot to examine Returns:
attachmentList - the pipe | delimited list of attachments- Type
-
string
-
renderkitModelAnimGetBonePosition(renderkit, modelid, bone)
-
renderkitModelAnimGetBonePosition returns the length of the current animation on a model
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool - works with 3D and 2D animations bone
string
The bone to examine Returns:
pos - a string with the "x,y" position of the bone -
renderkitModelAnimGetBones(renderkit, modelid)
-
renderkitModelAnimGetBones returns a pipe delimited list of bone names for 2D animations
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool - works with 2D animations Returns:
boneList - the pipe | delimited list of bones- Type
-
string
-
renderkitModelAnimGetLength(renderkit, modelid)
-
renderkitModelAnimGetLength returns the length of the current animation on a model
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool - works with 3D and 2D animations Returns:
length - the length of the animation in milliseconds -
renderkitModelAnimGetSkins(renderkit, modelid)
-
renderkitModelAnimGetSkins returns a pipe delimited list of skin names for 2D animations
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool - works with 2D animations Returns:
skinList - the pipe | delimited list of skins- Type
-
string
-
renderkitModelAnimGetSlots(renderkit, modelid)
-
renderkitModelAnimGetSlots returns a pipe delimited list of slot names for 2D animations, for example "head|hand"
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool - works with 2D animations Returns:
slotList - the pipe | delimited list of slots- Type
-
string
-
renderkitModelAnimMix(renderkit, modelid, animation_from, animation_to, blend_time)
-
renderkitModelAnimMix mix from one animation to another on a model (these are named animations created in the 2D animation package before they are exported to be used in Umajin)
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool - works with 2D animations animation_from
string
inital animation animation_to
string
final animation blend_time
int
the number of ms to blend between animations (mix is for 2D only, see renderkitModelAnimPlay for 3D) -
renderkitModelAnimPlay(renderkit, modelid, animation, blend_time, looping)
-
renderkitModelAnimPlay play an animation on a model (these are named animations created in the 3D/2D animation package before they are exported to be used in Umajin)
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool - works with 3D and 2D animations animation
string
name - the name of one of potentially multiple skeletal animations inside the model blend_time
int
the number of ms to blend between the previous playing animation to this new animation (the blend parameter is used in 3D but is ignored in 2D - see renderkitModelAnimMix for 2D blending) looping
int
0 for no loop, 1 to loop the animation continuously -
renderkitModelAnimSeek(renderkit, modelid, time)
-
renderkitModelAnimSeek seek to a specific time in an animation on a model
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool - works with 3D and 2D animations time
int
the time to seek into the animation in ms -
renderkitModelAnimSetAttachmentForSlot(renderkit, modelid, slot, attachment)
-
renderkitModelAnimSetAttachmentForSlot sets the attachment for a 2D model slot, examples might be a prop like a hat, or a weapon like a sword
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool - works with 2D animations slot
string
the slot to update (e.g. head) attachment
string
the attachment to apply (e.g. hat) -
renderkitModelAnimSetSkin(renderkit, modelid, skin)
-
renderkitModelAnimSetSkin sets the skin for a 2D model, the skeleton and animations stay the same, but the graphics will change
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool - works with 2D animations skin
string
the skin to set -
renderkitModelAnimTempo(renderkit, modelid, tempo_ratio)
-
renderkitModelAnimTempo adjust the speed of animation playback on a model when renderkitModelAnimPlay is called
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool - works with 3D and 2D animations tempo_ratio
int
the speed for playback (normally 1.0) -
renderkitModelClearQuads(renderkit, modelid)
-
renderkitModelClearQuads clears the quads.
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool -
renderkitModelClearTriangles(renderkit, modelid)
-
renderkitModelClearTriangles clears the triangles.
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool -
renderkitModelCount(renderkit)
-
renderkitModelCount returns the model count from the renderkit
Parameters:
Name Type Description renderkit
renderkit
The renderkit to examine Returns:
count - returns the model count -
renderkitModelCreate(renderkit, type, filename)
-
renderkitModelCreate adds a new model to the pool of hardware accelerated elements.
This can be a model, an image, a sphere or custom. Custom requires you to then create quads or triangles to make the model.Parameters:
Name Type Description renderkit
renderkit
The renderkit to add the model into type
string
The type of model (model, image, sphere, box, text) For sphere and box they are unit 1 in size and the filename has the diffuse image filename with options | delimited filenames for specular and bump maps. For text the filename is the characters to display at a unit size, optional pipe and stylename. filename
string
The model filename or texture to load. Note: these files must be placed in the model_3d resources folder Returns:
model_idx - the model index in the pool of modelsExample
var rk = createComponent(self, "renderkit", 0, 0, 100, 100); var id = renderkitModelCreate(rk, "sphere", "worldmap.jpg");
-
renderkitModelCreateQuad(renderkit, modelid, x1,y1,z1,u1,v1,c1, x2,y2,z2,u2,v2,c2, x3,y3,z3,u3,v3,c3, x4,y4,z4,u4,v4,c3)
-
renderkitModelCreateQuad create a basic quad with texture. This requires you to first use renderkitModelCreate with the type 'custom'. Normals are automatically created using the face normal.
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool x1,y1,z1,u1,v1,c1
real
first vertex position, texture coordinates and RGBA color as an integer x2,y2,z2,u2,v2,c2
real
second vertex position, texture coordinates and RGBA color as an integer x3,y3,z3,u3,v3,c3
real
third vertex position, texture coordinates and RGBA color as an integer x4,y4,z4,u4,v4,c3
real
fourth vertex position, texture coordinates and RGBA color as an integer -
renderkitModelCreateQuadArray(renderkit, buffer)
-
renderkitModelCreateQuadArray
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used buffer
buffer
JS ArrayBuffer, per face, [normal float XYZ], 4*[verts float XYZ], [color mode0 = none, mode1 = uint32, mode2 = uint16] -
renderkitModelCreateQuadFull(renderkit, modelid, x1,y1,z1,u1,v1,nx1,ny1,nz1,color, x2,y2,z2,u2,v2,nx2,ny2,nz2,color, x3,y3,z3,u3,v3,nx3,ny3,nz3,color, x4,y4,z4,u4,v4,nx4,ny4,nz4,color)
-
renderkitModelCreateQuadFull create a quad with texture, normals and color. This requires you to first use renderkitModelCreate with the type 'custom'.
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool x1,y1,z1,u1,v1,nx1,ny1,nz1,color
real
first vertex position, texture coordinates, normal and RBGA color as an integer x2,y2,z2,u2,v2,nx2,ny2,nz2,color
real
second vertex position, texture coordinates, normal and RBGA color as an integer x3,y3,z3,u3,v3,nx3,ny3,nz3,color
real
third vertex position, texture coordinates, normal and RBGA color as an integer x4,y4,z4,u4,v4,nx4,ny4,nz4,color
real
fourth vertex position, texture coordinates, normal and RBGA color as an integer -
renderkitModelCreateQuadFullArray(renderkit, buffer)
-
renderkitModelCreateQuadFullArray
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used buffer
buffer
JS ArrayBuffer, big endian, per face, 4*[normal float XYZ, verts float XYZ, texturecoord float UV, color Uint32] -
renderkitModelCreateTriangle(renderkit, modelid, x1,y1,z1,u1,v1,c1, x2,y2,z2,u2,v2,c2, x3,y3,z3,u3,v3,c3)
-
renderkitModelCreateTriangle create a basic triangle with texture. This requires you to first use renderkitModelCreate with the type 'custom'. Normals are automatically created using the face normal.
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool x1,y1,z1,u1,v1,c1
real
first vertex position, texture coordinates and RGBA color as an integer x2,y2,z2,u2,v2,c2
real
second vertex position, texture coordinates and RGBA color as an integer x3,y3,z3,u3,v3,c3
real
vertex position, texture coordinates and RGBA color as an integer -
renderkitModelCreateTriangleArray(renderkit, buffer)
-
renderkitModelCreateTriangleArray
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used buffer
buffer
JS ArrayBuffer, per face, [normal float XYZ], 3*[verts float XYZ], [color mode0 = none, mode1 = uint32, mode2 = uint16] -
renderkitModelCreateTriangleFull(renderkit, modelid, x1,y1,z1,u1,v1,nx1,ny1,nz1,color, x2,y2,z2,u2,v2,nx2,ny2,nz2,color, x3,y3,z3,u3,v3,nx3,ny3,nz3,color)
-
renderkitModelCreateTriangleFull create a triangle with texture, normals and color. This requires you to first use renderkitModelCreate with the type 'custom'.
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool x1,y1,z1,u1,v1,nx1,ny1,nz1,color
real
first vertex position, texture coordinates, normal and RBGA color as an integer x2,y2,z2,u2,v2,nx2,ny2,nz2,color
real
second vertex position, texture coordinates, normal and RBGA color as an integer x3,y3,z3,u3,v3,nx3,ny3,nz3,color
real
third vertex position, texture coordinates, normal and RBGA color as an integer -
renderkitModelGetModelspace(renderkit, modelid)
-
renderkitModelGetModelspace gets the modelspace axis aligned bounding box as a JSON formatted string
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust modelid
int
The index in the model pool Returns:
vectors - returns the JSON formatted string with min and max vectors- Type
-
string
-
renderkitModelGetScreenspace(renderkit, modelid)
-
renderkitModelGetScreenspace gets the screenspace bounding box as a JSON formatted string
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust modelid
int
The index in the model pool Returns:
vectors - returns the JSON formatted string with min and max vectors- Type
-
string
-
renderkitModelSetParent(renderkit, modelid, parent_modelid)
-
renderkitModelSetParent sets a parent for a model.
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing some models modelid
string
The modelid to re-parent parent_modelid
string
The modelid for the parent to set, or -1 for no parent -
renderkitModelSetProperty(renderkit, modelid, property, value)
-
renderkitModelSetProperty sets value to a specified property of a RenderKit Components model.
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust modelid
int
The index in the model pool property
string
The name of the property to set value
*
The value to assign -
renderkitModelSetPropertyBulk(renderkit, propertiesJson)
-
renderkitModelSetPropertyBulk sets property values and keys of a model in a RenderKit Component. The data parameter needs to be formated in stringified JSON.
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust propertiesJson
string
A string of stringified json data that contains the model ids, with properties and values to set. Example
// First create a couple of images in the RenderKit. var img1 = renderkitModelCreate(rk, 'image', 'image1.jpg'); var img2 = renderkitModelCreate(rk, 'image', 'image2.jpg'); // Setup an object that will be used to set properties on the images. var data = {}; data[img1] = { scale: imageScale }; data[img2] = { x: 2, color: 0xffff00ff }; // Update the RenderKit using the stringified data. renderkitModelSetPropertyBulk(rk, JSON.stringify(data));
-
renderkitModelUpdateAngle(renderkit, modelid, x, y, z)
-
renderkitModelUpdateAngle change the x,y,z angle of a model.
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool x
real
y
real
z
real
-
renderkitModelUpdateAngleArray(renderkit, buffer)
-
renderkitModelUpdateAngleArray updates models in a single batch.
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used buffer
buffer
JS ArrayBuffer with a 12 byte entry (real anglex, real angley, real anglez) Example
var buffer = new ArrayBuffer(model_count * 12); var dataview = new DataView(buffer); var ptr = 0 for(var index = 0; index < (model_count - 1); index++){ dataview.setFloat32(ptr, anglex); ptr+=4; dataview.setFloat32(ptr, angley); ptr+=4; dataview.setFloat32(ptr, anglez); ptr+=4; } renderkitModelUpdateAngleArray(renderkit_component,buffer);
-
renderkitModelUpdateAngleTween(renderkit, modelid, x, y, z, ms, type)
-
renderkitModelUpdateAngleTween change the x,y,z angle of a model over time
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool x
real
y
real
z
real
ms
int
the number of milliseconds for the tween type
int
The allowable values of tween are 0:none, 1:linear, 2:ease_in, 3:ease_out, 4:ease_both, 5:ease_rev, 6:cubic_in, 7:cubic_out, 8:cubic_in_out, 9:cubic_out_in, 10:ease_in_strong, 11:ease_out_strong, 12:ease_both_strong, 13:ease_both_strong_rev ,14:quint_in, 15:quint_out, 16:quint_in_out, 17:quint_out_in, 18:sine_in, 19:sine_out, 20:sine_in_out, 21:sine_out_in, 22:expo_in, 23:expo_out, 24:expo_in_out, 25:expo_out_in, 26:circ_in, 27:circ_out, 28:circ_in_out, 29:circ_out_in, 30:elastic_in, 31:elastic_out, 32:elastic_in_out, 33:elastic_out_in, 32:elastic_both, 34:back_in, 35:back_out, 36:back_in_out, 37:back_out_in, 36:back_both, 38:bounce_in, 39:bounce_out, 40:bounce_in_out, 41:bounce_out_in, 40:bounce_both, 42:curve_in, 43:curve_out, 44:curve_sine, 45:curve_cosine -
renderkitModelUpdateBlendMode(renderkit, modelid, blend_mode)
-
renderkitModelUpdateBlendMode update the model blendmode
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust modelid
int
The index in the model pool blend_mode
int
The blendmode. Use renderkitModelBlendMode enum. -
renderkitModelUpdateColor(renderkit, modelid, color)
-
renderkitModelUpdateColor update the model color
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust modelid
int
The index in the model pool color
int
The full 32 bit color representation including alpha (opaque white = 0xFFFFFFFF) -
renderkitModelUpdateColorTween(renderkit, modelid, color, ms, type)
-
renderkitModelUpdateColor update the model color over time
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust modelid
int
The index in the model pool color
int
The full 32 bit color representation including alpha (opaque white = 0xFFFFFFFF) ms
int
the number of milliseconds for the tween type
int
The allowable values of tween are 0:none, 1:linear, 2:ease_in, 3:ease_out, 4:ease_both, 5:ease_rev, 6:cubic_in, 7:cubic_out, 8:cubic_in_out, 9:cubic_out_in, 10:ease_in_strong, 11:ease_out_strong, 12:ease_both_strong, 13:ease_both_strong_rev ,14:quint_in, 15:quint_out, 16:quint_in_out, 17:quint_out_in, 18:sine_in, 19:sine_out, 20:sine_in_out, 21:sine_out_in, 22:expo_in, 23:expo_out, 24:expo_in_out, 25:expo_out_in, 26:circ_in, 27:circ_out, 28:circ_in_out, 29:circ_out_in, 30:elastic_in, 31:elastic_out, 32:elastic_in_out, 33:elastic_out_in, 32:elastic_both, 34:back_in, 35:back_out, 36:back_in_out, 37:back_out_in, 36:back_both, 38:bounce_in, 39:bounce_out, 40:bounce_in_out, 41:bounce_out_in, 40:bounce_both, 42:curve_in, 43:curve_out, 44:curve_sine, 45:curve_cosine -
renderkitModelUpdateDepthTesting(renderkit, modelid, depth_testing)
-
renderkitModelUpdateDepthTesting update the model depth testing
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust modelid
int
The index in the model pool depth_testing
int
0:off, 1:on -
renderkitModelUpdateDepthWriting(renderkit, modelid, depth_writing)
-
renderkitModelUpdateDepthWriting update the model depth writing
Parameters:
Name Type Description renderkit
renderkit
The renderkit object to adjust modelid
int
The index in the model pool depth_writing
int
0:off, 1:on -
renderkitModelUpdateEffect(renderkit, modelid, effect)
-
renderkitModelUpdateEffect change the GPU effect applied to the model
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool effect
string
The effect to apply (this is a GPU shader, several of which are supplied with Umajin) -
renderkitModelUpdateFilename(renderkit, modelid, filename)
-
renderkitModelUpdateFilename change the filename applied to the model
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool filename
string
The filename to apply (where appropriate) -
renderkitModelUpdateObjectUniform(renderkit, modelid, id, value)
-
renderkitModelUpdateObjectUniform set a per object shader uniform - this requires an effect to be assigned which can utilise this value
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool id
int
this is which uniform in the effect shader to access (0=shader_uniform2.x, 1=shader_uniform2.y, 2=shader_uniform2.z, 3=shader_uniform2.w) value
real
the value -
renderkitModelUpdateObjectUniformTween(renderkit, modelid, id, value, ms, type)
-
renderkitModelUpdateObjectUniformTween animate a per object shader uniform - this requires an effect to be assigned which can utilise this value
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool id
int
this is which uniform in the effect shader to access (0=shader_uniform2.x, 1=shader_uniform2.y, 2=shader_uniform2.z, 3=shader_uniform2.w) value
real
the value ms
int
the number of milliseconds for the tween type
int
The allowable values of tween are 0:none, 1:linear, 2:ease_in, 3:ease_out, 4:ease_both, 5:ease_rev, 6:cubic_in, 7:cubic_out, 8:cubic_in_out, 9:cubic_out_in, 10:ease_in_strong, 11:ease_out_strong, 12:ease_both_strong, 13:ease_both_strong_rev ,14:quint_in, 15:quint_out, 16:quint_in_out, 17:quint_out_in, 18:sine_in, 19:sine_out, 20:sine_in_out, 21:sine_out_in, 22:expo_in, 23:expo_out, 24:expo_in_out, 25:expo_out_in, 26:circ_in, 27:circ_out, 28:circ_in_out, 29:circ_out_in, 30:elastic_in, 31:elastic_out, 32:elastic_in_out, 33:elastic_out_in, 32:elastic_both, 34:back_in, 35:back_out, 36:back_in_out, 37:back_out_in, 36:back_both, 38:bounce_in, 39:bounce_out, 40:bounce_in_out, 41:bounce_out_in, 40:bounce_both, 42:curve_in, 43:curve_out, 44:curve_sine, 45:curve_cosine -
renderkitModelUpdateOrientation(renderkit, modelid, x,y,z,w)
-
renderkitModelUpdateOrientation set a model orientation using a quaternion (Hamiltonian 4th dimensional representation)
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool x,y,z,w
real
the two vectors used to describe orientation -
renderkitModelUpdateOrigin(renderkit, modelid, x, y, z)
-
renderkitModelUpdateOrigin change the x,y,z origin of a model.
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool x
real
y
real
z
real
-
renderkitModelUpdateOriginArray(renderkit, buffer)
-
renderkitModelUpdateOriginArray updates models in a single batch.
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used buffer
buffer
JS ArrayBuffer with a 12 byte entry (real originx, real originy, real originz) Example
var buffer = new ArrayBuffer(model_count * 12); var dataview = new DataView(buffer); var ptr = 0 for(var index = 0; index < (model_count - 1); index++){ dataview.setFloat32(ptr, originx); ptr+=4; dataview.setFloat32(ptr, originy); ptr+=4; dataview.setFloat32(ptr, originz); ptr+=4; } renderkitModelUpdateOriginArray(renderkit_component,buffer);
-
renderkitModelUpdateOriginTween(renderkit, modelid, x, y, z, ms, type)
-
renderkitModelUpdateOriginTween change the x,y,z origin of a model over time
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool x
real
y
real
z
real
ms
int
the number of milliseconds for the tween type
int
The allowable values of tween are 0:none, 1:linear, 2:ease_in, 3:ease_out, 4:ease_both, 5:ease_rev, 6:cubic_in, 7:cubic_out, 8:cubic_in_out, 9:cubic_out_in, 10:ease_in_strong, 11:ease_out_strong, 12:ease_both_strong, 13:ease_both_strong_rev ,14:quint_in, 15:quint_out, 16:quint_in_out, 17:quint_out_in, 18:sine_in, 19:sine_out, 20:sine_in_out, 21:sine_out_in, 22:expo_in, 23:expo_out, 24:expo_in_out, 25:expo_out_in, 26:circ_in, 27:circ_out, 28:circ_in_out, 29:circ_out_in, 30:elastic_in, 31:elastic_out, 32:elastic_in_out, 33:elastic_out_in, 32:elastic_both, 34:back_in, 35:back_out, 36:back_in_out, 37:back_out_in, 36:back_both, 38:bounce_in, 39:bounce_out, 40:bounce_in_out, 41:bounce_out_in, 40:bounce_both, 42:curve_in, 43:curve_out, 44:curve_sine, 45:curve_cosine -
renderkitModelUpdatePosition(renderkit, modelid, x, y, z)
-
renderkitModelUpdatePosition change the x,y,z position of a model.
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool x
real
y
real
z
real
-
renderkitModelUpdatePositionArray(renderkit, buffer)
-
renderkitModelUpdatePositionArray updates models in a single batch.
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used buffer
buffer
JS ArrayBuffer with a 12 byte entry (real x, real y, real z) Example
var buffer = new ArrayBuffer(model_count * 12); var dataview = new DataView(buffer); var ptr = 0 for(var index = 0; index < (model_count - 1); index++){ dataview.setFloat32(ptr, x); ptr+=4; dataview.setFloat32(ptr, y); ptr+=4; dataview.setFloat32(ptr, z); ptr+=4; } renderkitModelUpdatePositionArray(renderkit_component,buffer);
-
renderkitModelUpdatePositionTween(renderkit, modelid, x, y, z, ms, type)
-
renderkitModelUpdatePositionTween change the x,y,z position of a model over time
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool x
real
y
real
z
real
ms
int
the number of milliseconds for the tween type
int
The allowable values of tween are 0:none, 1:linear, 2:ease_in, 3:ease_out, 4:ease_both, 5:ease_rev, 6:cubic_in, 7:cubic_out, 8:cubic_in_out, 9:cubic_out_in, 10:ease_in_strong, 11:ease_out_strong, 12:ease_both_strong, 13:ease_both_strong_rev ,14:quint_in, 15:quint_out, 16:quint_in_out, 17:quint_out_in, 18:sine_in, 19:sine_out, 20:sine_in_out, 21:sine_out_in, 22:expo_in, 23:expo_out, 24:expo_in_out, 25:expo_out_in, 26:circ_in, 27:circ_out, 28:circ_in_out, 29:circ_out_in, 30:elastic_in, 31:elastic_out, 32:elastic_in_out, 33:elastic_out_in, 32:elastic_both, 34:back_in, 35:back_out, 36:back_in_out, 37:back_out_in, 36:back_both, 38:bounce_in, 39:bounce_out, 40:bounce_in_out, 41:bounce_out_in, 40:bounce_both, 42:curve_in, 43:curve_out, 44:curve_sine, 45:curve_cosine -
renderkitModelUpdateQuadFull(renderkit, modelid, quadid, x1,y1,z1,u1,v1,nx1,ny1,nz1,color, x2,y2,z2,u2,v2,nx2,ny2,nz2,color, x3,y3,z3,u3,v3,nx3,ny3,nz3,color, x4,y4,z4,u4,v4,nx4,ny4,nz4,color)
-
renderkitModelUpdateQuadFull updates a quad with texture, normals and color. This requires you to first use renderkitModelCreate with the type 'custom'.
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool quadid
int
The index in the quad pool x1,y1,z1,u1,v1,nx1,ny1,nz1,color
real
first vertex position, texture coordinates, normal and RBGA color as an integer x2,y2,z2,u2,v2,nx2,ny2,nz2,color
real
second vertex position, texture coordinates, normal and RBGA color as an integer x3,y3,z3,u3,v3,nx3,ny3,nz3,color
real
third vertex position, texture coordinates, normal and RBGA color as an integer x4,y4,z4,u4,v4,nx4,ny4,nz4,color
real
fourth vertex position, texture coordinates, normal and RBGA color as an integer -
renderkitModelUpdateScale(renderkit, modelid, x, y, z)
-
renderkitModelUpdateScale change the x,y,z scale of a model. (scale is a ratio so 1.0 is no change, 0.5 = half and 2.0 = double)
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool x
real
y
real
z
real
-
renderkitModelUpdateScaleArray(renderkit, buffer)
-
renderkitModelUpdateScaleArray updates models in a single batch.
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used buffer
buffer
JS ArrayBuffer with a 12 byte entry (real scalex, real scaley, real scalez) Example
var buffer = new ArrayBuffer(model_count * 12); var dataview = new DataView(buffer); var ptr = 0 for(var index = 0; index < (model_count - 1); index++){ dataview.setFloat32(ptr, scalex); ptr+=4; dataview.setFloat32(ptr, scaley); ptr+=4; dataview.setFloat32(ptr, scalez); ptr+=4; } renderkitModelUpdateScaleArray(renderkit_component,buffer);
-
renderkitModelUpdateScaleTween(renderkit, modelid, x, y, z, ms, type)
-
renderkitModelUpdateScaleTween change the x,y,z scale of a model over time
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool x
real
y
real
z
real
ms
int
the number of milliseconds for the tween type
int
The allowable values of tween are 0:none, 1:linear, 2:ease_in, 3:ease_out, 4:ease_both, 5:ease_rev, 6:cubic_in, 7:cubic_out, 8:cubic_in_out, 9:cubic_out_in, 10:ease_in_strong, 11:ease_out_strong, 12:ease_both_strong, 13:ease_both_strong_rev ,14:quint_in, 15:quint_out, 16:quint_in_out, 17:quint_out_in, 18:sine_in, 19:sine_out, 20:sine_in_out, 21:sine_out_in, 22:expo_in, 23:expo_out, 24:expo_in_out, 25:expo_out_in, 26:circ_in, 27:circ_out, 28:circ_in_out, 29:circ_out_in, 30:elastic_in, 31:elastic_out, 32:elastic_in_out, 33:elastic_out_in, 32:elastic_both, 34:back_in, 35:back_out, 36:back_in_out, 37:back_out_in, 36:back_both, 38:bounce_in, 39:bounce_out, 40:bounce_in_out, 41:bounce_out_in, 40:bounce_both, 42:curve_in, 43:curve_out, 44:curve_sine, 45:curve_cosine -
renderkitModelUpdateTriangleFull(renderkit, modelid, triangleid, x1,y1,z1,u1,v1,nx1,ny1,nz1,color, x2,y2,z2,u2,v2,nx2,ny2,nz2,color, x3,y3,z3,u3,v3,nx3,ny3,nz3,color)
-
renderkitModelUpdateTriangleFull updates a triangle with texture, normals and color. This requires you to first use renderkitModelCreate with the type 'custom'.
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool triangleid
int
The index in the triangle pool x1,y1,z1,u1,v1,nx1,ny1,nz1,color
real
first vertex position, texture coordinates, normal and RBGA color as an integer x2,y2,z2,u2,v2,nx2,ny2,nz2,color
real
second vertex position, texture coordinates, normal and RBGA color as an integer x3,y3,z3,u3,v3,nx3,ny3,nz3,color
real
third vertex position, texture coordinates, normal and RBGA color as an integer -
renderkitModelUpdateVisible(renderkit, modelid, visibility)
-
renderkitModelUpdateVisible sets a model visible or invisible
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool visibility
boolean
True by default -
renderkitModelUpdateVisibleTween(renderkit, modelid, visibility, time)
-
renderkitModelUpdateVisibleTween sets a model visible or invisible in a given time in ms
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model modelid
int
The index in the model pool visibility
boolean
True by default time
int
time in ms -
renderkitPickQuad(x,y, px1,py1,pz1,px2,py2,pz2,px3,py3,pz3, cull_backface)
-
renderkitPickQuad returns -1 for no intersection, or a JSON string containing the coordinates
Parameters:
Name Type Description x,y
real
the 2D position on the camera to look for a quad in the 3D scene px1,py1,pz1,px2,py2,pz2,px3,py3,pz3
real
position of the 1 top left, 2 top right and 3 bottom left corners of a quad in 3D cull_backface
boolean
off by default, determine if you can hit the quad from either side Returns:
-1 for no intersection, or the uv as a ratio and the xyz intesection position in world spaceExample
registerComponent("quad_hit_test", "", "quad_hit_test", "quad_hit_test", "quad_hit_test_init", "", "", "", "") function quad_hit_test_init(width, height){ var rk = createComponent(self, "renderkit", 0, 0, 100, 100); renderkitCameraUpdateFOV(rk, 60.0) //make a quad var i = renderkitModelCreate(rk,"box","") renderkitModelUpdateEffect(rk,i,"basic_lighting"); renderkitModelUpdateScale(rk,i,1,1,0.05) //make a sphere i = renderkitModelCreate(rk,"sphere","") renderkitModelUpdateScale(rk,i,0.1,0.1,0.1) renderkitModelUpdateEffect(rk,i,"basic_lighting") renderkitModelUpdateColor(rk,i, 0xFF0000FF) //bind for touch/mouse events bindEvent(rk,"on_move","quad_hit_test_on_move"); bindEvent(rk,"on_down","quad_hit_test_on_move"); bindEvent(rk,"on_up","quad_hit_test_on_up"); renderkitCameraUpdateEye(rk,0,0.5,2) renderkitCameraUpdateLookat(rk,0,0,-3) } function quad_hit_test_on_move(x, y, tid){ var hit = renderkitPickQuad(self, x,y, -0.5,0.5,0 ,0.5,0.5,0, -0.5,-0.5,0, 0) if (hit!="-1"){ var hitmap = JSON.parse(hit) renderkitModelUpdatePosition(self,1,Number(hitmap.u)-0.5,0.5-Number(hitmap.v),0.0) } } function quad_hit_test_on_up(x, y, tid){ //move the camera to show the picking working renderkitCameraUpdateLookatTween(self,Math.random()-0.5,Math.random()-0.5,-3 + Math.random(),1000,4) renderkitCameraUpdateEyeTween(self,Math.random()-0.5,Math.random(),1 + Math.random(),1000,4) }
-
renderkitPickSphere(x,y, spherePosx,spherePosy,spherePosz, sphereRadius)
-
renderkitPickSphere returns -1 for no intersection, or the distance to the first point
Parameters:
Name Type Description x,y
real
the 2D position on the camera to look for a sphere in the 3D scene spherePosx,spherePosy,spherePosz
real
position of the sphere sphereRadius
real
radius of the sphere Returns:
-1 or the intesection positionExample
registerComponent("sphere_hit_test", "", "sphere_hit_test", "sphere_hit_test", "sphere_hit_test_init", "", "", "", "") function sphere_hit_test_init(width, height){ var rk = createComponent(self, "renderkit", 0, 0, 100, 100); renderkitCameraUpdateFOV(rk, 60.0) //make some spheres for (i = 0; i < 10; i++) { renderkitModelCreate(rk,"sphere","") //generate and store the random sphere positions & scale positionScaleSphere(rk,i) renderkitModelUpdateEffect(rk,i,"basic_lighting"); } //bind for touch/mouse events bindEvent(rk,"on_down","sphere_hit_test_on_down"); renderkitCameraUpdateEye(rk,0,19,6) renderkitCameraUpdateLookat(rk,0,0,-3) } function positionScaleSphere(rk,i){ var sx = (Math.random()*20.0)-10 var sy = (Math.random()*20.0)-10 var sz = (Math.random()*-1.0)-2.0 var sscale = (Math.random()*5.0)+0.5 setData(rk,"sx" + i, sx) setData(rk,"sy" + i, sy) setData(rk,"sz" + i, sz) setData(rk,"sscale" + i, sscale) //set the properties for the spheres renderkitModelUpdateScaleTween(rk,i,sscale,sscale,sscale,200,1) renderkitModelUpdatePositionTween(rk,i,sx,sy,sz,200,1) } function sphere_hit_test_on_down(x, y, tid){ //Sphere pick for (i = 0; i < 10; i++) { var hit = renderkitPickSphere(self,x,y,getData(self,"sx" + i),getData(self,"sy" + i),getData(self,"sz" + i),getData(self,"sscale" + i) * 0.5) if (hit>-1){ //change the sphere color var r = Math.floor(Math.random()*200)+55 var g = Math.floor(Math.random()*200)+55 var b = Math.floor(Math.random()*200)+55 renderkitModelUpdateColor(self,i, r*256 + g*256*256 + b*256*256*256 + 255) positionScaleSphere(self,i) } } //move the camera to show the picking working renderkitCameraUpdateLookatTween(self,Math.random()-0.5,Math.random()-0.5,-3 + Math.random(),1000,4) renderkitCameraUpdateEyeTween(self,Math.random()-0.5,Math.random()*10+9,5 + Math.random(),1000,4) }
-
renderkitPostProcessUpdateEffect(renderkit, effect)
-
renderkitPostProcessUpdateEffect change the GPU effect applied to the scene as a post process
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the model effect
string
The effect to apply (this is a GPU shader, several of which are supplied with Umajin) -
renderkitShapeClear(renderkit, shape_idx)
-
renderkitShapeClear clears the surface of the shape but does not alter it's current position, angle or tint.
Once a shape has been cleared you can draw on it again using renderkitShapeDraw, renderkitShapeDoMove, renderkitShapeDoLine and renderkitShapeDoSpline.Parameters:
Name Type Description renderkit
renderkit
The renderkit being used shape_idx
int
The shape index from the pool of shapes in the renderkit Example
renderkitShapeClear(rk, shape_idx); renderkitShapeDoMove(rk, shape_idx, 0, 0); renderkitShapeDoLine(rk, shape_idx, 20, 20);
-
renderkitShapeCount(renderkit)
-
renderkitShapeCount returns the shape count from the renderkit
Parameters:
Name Type Description renderkit
renderkit
The renderkit to examine Returns:
count - returns the shape count -
renderkitShapeCreate(renderkit, command)
-
renderkitShapeCreate returns the shape index for the new shape from the pool of shapes in the renderkit
Parameters:
Name Type Description renderkit
renderkit
The renderkit to add the shape command
string
The optional SVG style shape command, see renderkitShapeDraw Returns:
shape_idx - returns the shape index from pool of shapes in the renderkitExample
var shape_idx = renderkitShapeCreate(rk, "M 45.673,0 L 67.781,0");
-
renderkitShapeDoClose(renderkit, shape_idx)
-
renderkitShapeDoClose closes up the current shape so it can be completed or filled.
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used shape_idx
int
The shape index from the pool of shapes in the renderkit Example
renderkitShapeClear(rk, shape_idx); renderkitShapeDoMove(rk, shape_idx, 0, 0); //draw a triangle renderkitShapeDoLine(rk, shape_idx, 20, 20); renderkitShapeDoLine(rk, shape_idx, 0, 20); renderkitShapeDoClose(rk, shape_idx);
-
renderkitShapeDoLine(renderkit, shape_idx, x, y)
-
renderkitShapeDoLine draws a line from the current pen position to the new absolute x,y on a shape.
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used shape_idx
int
The shape index from the pool of shapes in the renderkit x
real
The x position y
real
The y position Examples
renderkitShapeClear(rk, shape_idx); renderkitShapeDoMove(rk, shape_idx, 0, 0); renderkitShapeDoLine(rk, shape_idx, 20, 20);
function rk_shape_draw(rk){ // check size of renderkit in local units var width = getProperty(rk, "width"); var height2 = getProperty(rk, "height") / 2.0; // clear the shape renderkitShapeClear(rk,0) //setup the start of the curve var y = height2 + Math.sin((a / 3.0)) * height2 renderkitShapeDoMove(rk,0,y,50) // draw the lines of a sin curve for (var a = 0; a < 51; a++){ var y = height2 + Math.sin((a / 5.0)) * height2 renderkitShapeDoLine(rk,0,a * width / 50.0, y) } }
-
renderkitShapeDoMove(renderkit, shape_idx, x, y)
-
renderkitShapeDoMove moves the current pen on a shape to a new absolute x,y location ready for the next line or spline command.
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used shape_idx
int
The shape index from the pool of shapes in the renderkit x
real
The x position y
real
The y position Example
renderkitShapeClear(rk, shape_idx); renderkitShapeDoMove(rk, shape_idx, 0, 0); renderkitShapeDoLine(rk, shape_idx, 20, 20);
-
renderkitShapeDoSpline(renderkit, shape_idx, x, y, c1x, c1y, c2x, c2y)
-
renderkitShapeDoSpline draws a spline from the current pen position to the new absolute x,y on a shape using the 4 control points to define the shape of the curve.
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used shape_idx
int
The shape index from the pool of shapes in the renderkit x
real
The x position y
real
The y position c1x
real
The first control point x position c1y
real
The first control point y position c2x
real
The second control point x position c2y
real
The second control point y position Example
renderkitShapeClear(rk, shape_idx); renderkitShapeDoMove(rk, shape_idx, 0, 0); renderkitShapeDoSpline(rk, shape_idx, 20, 20, 10, 10, 30, 30);
-
renderkitShapeDoStrokeWidth(renderkit, shape_idx, width)
-
renderkitShapeDoStrokeWidth as you are drawing lines and splines this will adjust the line width as a multiple of renderkitShapeStrokeWidth
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used shape_idx
int
The shape index from the pool of shapes in the renderkit width
real
the new line width mutiplier -
renderkitShapeDoWedge(renderkit, shape_idx, x,y, inner_radius,outer_radius, startangle,endangle)
-
renderkitShapeDoWedge draws a wedge with an inner and outer radius at the nominated x,y position
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used shape_idx
int
The shape index from the pool of shapes in the renderkit x,y
int
The position for the center of the wedge inner_radius,outer_radius
real
The inner and outer radius. An inner_radius of 0 draws a full wedge startangle,endangle
real
The start and end angle in degrees for the wedge -
renderkitShapeDraw(renderkit, shape_idx, command)
-
renderkitShapeDraw creates shapes using an SVG style string format. Stroke caps are 0:butt, 1:round, 2:square. Join types are 0:bevel, 1:round, 2:mitre, 3:none.
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used shape_idx
int
The shape index from the pool of shapes in the renderkit command
string
The M (move absolute), m (move relative), L (doLine absolute), C x1,y1 x2,y2, x,y (doSpline absolute - note : this should be a cubic bezier in SVG) Umajin also supports R for Rect x1 y1 x2 y2, W for overall line width, w to multiply line with as we draw, n for line color, f for fill color, F [bool] to determine if the closure is filled, p for stroke cap, j for stroke join Examples
// basic black horizontal line renderkitShapeDraw(rk, id, "M 0,0 L 100,0");
// filled with dark red, a bright red 3 pixel width stroke forming a wide rectangle renderkitShapeDraw(rk, id, "F 1 f 0x0660000FF n 0xFF0000FF W 3 R 0 0 400 200");
// two part spline with an increasing diameter line renderkitShapeDraw(rk, id, "W 2 w 1 M 0,50 C 0,0 100,0 100,50 w 3 C 100,0 200,100 200,50");
-
renderkitShapeFillColor(renderkit, shape_idx, clr)
-
renderkitShapeFillColor sets the fill colour for shapes which have been renderkitShapeFilled
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used shape_idx
int
The shape index from the pool of shapes in the renderkit clr
real
the new fill color e.g. 0x002233FF -
renderkitShapeFilled(renderkit, shape_idx, flag)
-
renderkitShapeFilled sets if the shape should be filled or not, the color is determined by renderkitShapeFillColor
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used shape_idx
int
The shape index from the pool of shapes in the renderkit flag
boolean
if the shape is filled or not -
renderkitShapeStrokeColor(renderkit, shape_idx, clr)
-
renderkitShapeStrokeColor as you are drawing lines and splines this is the stroke color which will be used.
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used shape_idx
int
The shape index from the pool of shapes in the renderkit clr
real
the new fill color e.g. 0x002233FF -
renderkitShapeStrokeWidth(renderkit, shape_idx, width)
-
renderkitShapeStrokeWidth sets the basic width of the stroke for any lines or splines being drawn
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used shape_idx
int
The shape index from the pool of shapes in the renderkit width
real
the width of the stroke is in pixels (0 or 1 is hairline) -
renderkitShapeUpdate(renderkit, shape_idx, x, y, origin_x, origin_y, scale, angle, color)
-
renderkitShapeUpdate does not alter the shape commands, but allows the hardware accelerated shape to be moved, scaled and tinted inside the renderkit
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used shape_idx
int
The shape index from the pool of shapes in the renderkit x
real
The x position y
real
The y position origin_x
real
The x origin origin_y
real
The y origin scale
real
The scale of the shape as a ratio (1.0 is the default) angle
real
The angle of rotation in degrees (0 - 360) color
int
The full 32 bit color tint including alpha (opaque white = 0xFFFFFFFF) Example
renderkitShapeUpdate(rk, shape_idx, x, y, 0, 0, 1.0, 45, 0xFFFFFFFF);
-
renderkitShapeUpdateEffect(renderkit, shapeid, effect)
-
renderkitShapeUpdateEffect change the GPU effect applied to the shape
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the shape shapeid
int
The index in the shape pool effect
string
The effect to apply (this is a GPU shader, several of which are supplied with Umajin). Use "basic_lighting" to reset to default. -
renderkitShapeUpdateIn(renderkit, shape_idx, x, y, origin_x, origin_y, scale, angle, color, ms)
-
renderkitShapeUpdateIn does not alter the shape commands, but allows the hardware accelerated shape to be moved, scaled and tinted inside the renderkit after a time delay in milliseconds
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used shape_idx
int
The shape index from the pool of shapes in the renderkit x
real
The x position y
real
The y position origin_x
real
The x origin origin_y
real
The y origin scale
real
The scale of the shape as a ratio (1.0 is the default) angle
real
The angle of rotation in degrees (0 - 360) color
int
The full 32 bit color tint including alpha (opaque white = 0xFFFFFFFF) ms
int
The delay in milliseconds Example
renderkitShapeUpdateIn(rk, shape_idx, x, y, 0, 0, 1.0, 45, 0xFFFFFFFF, 100);
-
renderkitShapeUpdateInTween(renderkit, shape_idx, x, y, origin_x, origin_y, scale, angle, color, ms, tween)
-
renderkitShapeUpdateInTween does not alter the shape commands, but allows the hardware accelerated shape to be moved, scaled and tinted inside the renderkit and animated over a time in milliseconds
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used shape_idx
int
The shape index from the pool of shapes in the renderkit x
real
The x position y
real
The y position origin_x
real
The x origin origin_y
real
The y origin scale
real
The scale of the shape as a ratio (1.0 is the default) angle
real
The angle of rotation in degrees (0 - 360) color
int
The full 32 bit color tint including alpha (opaque white = 0xFFFFFFFF) ms
int
The delay in milliseconds tween
int
The allowable values of tween are 0:none, 1:linear, 2:ease_in, 3:ease_out, 4:ease_both, 5:ease_rev, 6:cubic_in, 7:cubic_out, 8:cubic_in_out, 9:cubic_out_in, 10:ease_in_strong, 11:ease_out_strong, 12:ease_both_strong, 13:ease_both_strong_rev ,14:quint_in, 15:quint_out, 16:quint_in_out, 17:quint_out_in, 18:sine_in, 19:sine_out, 20:sine_in_out, 21:sine_out_in, 22:expo_in, 23:expo_out, 24:expo_in_out, 25:expo_out_in, 26:circ_in, 27:circ_out, 28:circ_in_out, 29:circ_out_in, 30:elastic_in, 31:elastic_out, 32:elastic_in_out, 33:elastic_out_in, 32:elastic_both, 34:back_in, 35:back_out, 36:back_in_out, 37:back_out_in, 36:back_both, 38:bounce_in, 39:bounce_out, 40:bounce_in_out, 41:bounce_out_in, 40:bounce_both, 42:curve_in, 43:curve_out, 44:curve_sine, 45:curve_cosine Example
renderkitShapeUpdateInTween(rk, shape_idx, x, y, 0, 0, 1.0, 45, 0xFFFFFFFF, 100, 1);
-
renderkitShapeUpdateObjectUniform(renderkit, modelid, id, value)
-
renderkitShapeUpdateObjectUniform set a per object shader uniform - this requires an effect to be assigned which can utilise this value
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the shape modelid
int
The index in the shape pool id
int
this is which uniform in the effect shader to access (0=shader_uniform2.x, 1=shader_uniform2.y, 2=shader_uniform2.z, 3=shader_uniform2.w) value
real
the value -
renderkitShapeUpdateObjectUniformTween(renderkit, shapeid, id, value, ms, type)
-
renderkitShapeUpdateObjectUniformTween animate a per object shader uniform - this requires an effect to be assigned which can utilise this value
Parameters:
Name Type Description renderkit
renderkit
The renderkit containing the shape shapeid
int
The index in the shape pool id
int
this is which uniform in the effect shader to access (0=shader_uniform2.x, 1=shader_uniform2.y, 2=shader_uniform2.z, 3=shader_uniform2.w) value
real
the value ms
int
the number of milliseconds for the tween type
int
The allowable values of tween are 0:none, 1:linear, 2:ease_in, 3:ease_out, 4:ease_both, 5:ease_rev, 6:cubic_in, 7:cubic_out, 8:cubic_in_out, 9:cubic_out_in, 10:ease_in_strong, 11:ease_out_strong, 12:ease_both_strong, 13:ease_both_strong_rev ,14:quint_in, 15:quint_out, 16:quint_in_out, 17:quint_out_in, 18:sine_in, 19:sine_out, 20:sine_in_out, 21:sine_out_in, 22:expo_in, 23:expo_out, 24:expo_in_out, 25:expo_out_in, 26:circ_in, 27:circ_out, 28:circ_in_out, 29:circ_out_in, 30:elastic_in, 31:elastic_out, 32:elastic_in_out, 33:elastic_out_in, 32:elastic_both, 34:back_in, 35:back_out, 36:back_in_out, 37:back_out_in, 36:back_both, 38:bounce_in, 39:bounce_out, 40:bounce_in_out, 41:bounce_out_in, 40:bounce_both, 42:curve_in, 43:curve_out, 44:curve_sine, 45:curve_cosine -
renderkitShapeUpdateShaderTexture(renderkit, shapeid, texture)
-
renderkitShapeUpdateShaderTexture REMOVED use shaderUpdateUniformTexture.
Parameters:
Name Type Description renderkit
renderkit
Removed. shapeid
int
Removed. texture
string
Removed. -
renderkitSpriteCount(renderkit)
-
renderkitSpriteCount returns the sprite count from the renderkit
Parameters:
Name Type Description renderkit
renderkit
The renderkit to examine Returns:
count - returns the sprite count -
renderkitSpriteCreate(renderkit, cellid, imagename, x, y, scale, angle, alpha)
-
renderkitSpriteCreate adds a new sprite to the pool of hardware accelerated sprites in the renderkit component.
Note : The sprite sheet format is the same used by both Spine and libGDX. Please see the demo applications for more information on making your own spritesheets.Parameters:
Name Type Description renderkit
renderkit
The renderkit to add the sprite to cellid
int
The cell index in the spritesheet(-1 if you want to use the name) imagename
string
The sprite name in the spritesheet (only checked if the cellid is -1) x
real
The x position y
real
The y position scale
real
The scale of the sprite as a ratio (1.0 is the default) angle
real
The angle of rotation in degrees (0 - 360) alpha
int
The transparency of the sprite (0 = transparent, 255 = opaque) Returns:
sprite_idx - the sprite index in the pool of spritesExample
var rk = createComponent(self, "renderkit", 0, 0, 100, 100); setProperty(rk,"spritesheet","sprites"); var id = renderkitSpriteCreate(rk, 1, '', 50, 50, 1, 0, 255);
-
renderkitSpriteGetHeight(renderkit, cellid, imagename)
-
renderkitSpriteGetHeight returns the height of a sprite from the spritesheet in pixels
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used cellid
int
The cell index in the spritesheet(-1 if you want to use the name) imagename
string
The sprite name in the spritesheet (only checked if the cellid is -1) Returns:
sprite_height - the height of the spriteExample
var rk = createComponent(self, "renderkit", 0, 0, 100, 100); setProperty(rk,"spritesheet","sprites"); var cell1height = renderkitSpriteGetHeight(rk, 1, '');
-
renderkitSpriteGetWidth(renderkit, cellid, imagename)
-
renderkitSpriteGetWidth returns the width of a sprite from the spritesheet in pixels
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used cellid
int
The cell index in the spritesheet(-1 if you want to use the name) imagename
string
The sprite name in the spritesheet (only checked if the cellid is -1) Returns:
sprite_width - the width of the spriteExample
var rk = createComponent(self, "renderkit", 0, 0, 100, 100); setProperty(rk,"spritesheet","sprites"); var cell1width = renderkitSpriteGetWidth(rk, 1, '');
-
renderkitSpriteUpdate(renderkit, id, cellid, imagename, x, y, scale, angle, alpha)
-
renderkitSpriteUpdate updates a sprite which has been created using renderkitSpriteCreate in the renderkit component.
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used id
int
The sprite index from the pool of sprites in the renderkit cellid
int
The cell index in the spritesheet(-1 if you want to use the name) imagename
string
The sprite name in the spritesheet (only checked if the cellid is -1) x
real
The x position y
real
The y position scale
real
The scale of the sprite as a ratio (1.0 is the default) angle
real
The angle of rotation in degrees (0 - 360) alpha
int
The transparency of the sprite (0 = transparent, 255 = opaque) Example
var rk = createComponent(self, "renderkit", 0, 0, 100, 100); setProperty(rk,"spritesheet","sprites"); var id = renderkitSpriteCreate(rk, 1, '', 50, 50, 1, 0, 255); renderkitSpriteUpdate(rk, id, 1, '', 100, 100, 1, 90, 255);
-
renderkitSpriteUpdateArray(renderkit, buffer)
-
renderkitSpriteUpdateArray updates sprites in a single batch.
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used buffer
buffer
JS ArrayBuffer with a 24 byte entry (real x, real y, real scale, real angle, int sprite_index, int color) Example
var buffer = new ArrayBuffer(particle_count * 24); var dataview = new DataView(buffer); var ptr = 0 for(var index = 0; index < (particle_count - 1); index++){ dataview.setFloat32(ptr, x); ptr+=4; dataview.setFloat32(ptr, y); ptr+=4; dataview.setFloat32(ptr, scale); ptr+=4; dataview.setFloat32(ptr, angle); ptr+=4; dataview.setUint32(ptr, sprite_index); ptr+=4; dataview.setUint32(ptr, color); ptr+=4; } renderkitSpriteUpdateArray(renderkit_component,buffer);
-
renderkitSpriteUpdateFull(renderkit, id, cellid, imagename, x, y, x_scale, y_scale, angle, color)
-
renderkitSpriteUpdateFull updates a sprite which has been created using renderkitSpriteCreate in the renderkit component with fully detailed properties.
Parameters:
Name Type Description renderkit
renderkit
The renderkit being used id
int
The sprite index from the pool of sprites in the renderkit cellid
int
The cell index in the spritesheet(-1 if you want to use the name) imagename
string
The sprite name in the spritesheet (only checked if the cellid is -1) x
real
The x position y
real
The y position x_scale
real
The x scale of the sprite as a ratio (1.0 is the default) y_scale
real
The y scale of the sprite as a ratio (1.0 is the default) angle
real
The angle of rotation in degrees (0 - 360) color
int
The full 32 bit color representation including alpha (opaque white = 0xFFFFFFFF) Example
var rk = createComponent(self, "renderkit", 0, 0, 100, 100); setProperty(rk,"spritesheet","sprites"); var id = renderkitSpriteCreate(rk, 1, '', 50, 50, 1, 0, 255); renderkitSpriteUpdate(rk, id, 1, '', 100, 100, 1, 1.2, 90, 0x002233FF);
-
renderkitStereoDeformationCorrection(renderkit, Mode, Amount)
-
renderkitStereoDeformationCorrection sets the renderkit deformation mode and amount of correction to apply.
Parameters:
Name Type Description renderkit
renderkit
The renderkit to adjust Mode
int
The correction mode (0:none, 1:smoke, 2:fresnel) Amount
real
The amount of correction to apply (0.02 is the default) -
renderkitStereoEyeDistance(renderkit, StereoEyeDistance)
-
renderkitStereoEyeDistance sets the renderkit to Stereo mode with a non zero value for the distance between the two viewpoints. A zero distance turns stereo mode off.
Parameters:
Name Type Description renderkit
renderkit
The renderkit to adjust StereoEyeDistance
real
The distance between the stereo pairs horizontally (determined by your 3D world scale) -
renderkitTargetCount(renderkit)
-
renderkitTargetCount returns the target count from the renderkit
Parameters:
Name Type Description renderkit
renderkit
The renderkit to examine Returns:
count - returns the target count -
renderkitTargetCreate(renderkit, flags)
-
renderkitTargetCreate returns the target index for the new target from the pool of targets in the renderkit
Parameters:
Name Type Description renderkit
renderkit
The renderkit to add the shape flags
int
0: normal, 1: msaa //e.g. in the future may be different texture types, currently RGBA Returns:
targetID - returns the target index from pool of targets in the renderkit -
renderkitTargetRenderFrom(renderkit, targetid, comp, width)
-
renderkitTargetRenderFrom renders to a target from a component
Parameters:
Name Type Description renderkit
renderkit
The renderkit with the targets targetid
int
The targetID to render to comp
component
The component to render from width
int
The width to render -
shaderUpdateUniformFloat(shader_name, uniform_name, value)
-
shaderUpdateUniformFloat set shader uniform - this requires an effect to be assigned which can utilise this value
Parameters:
Name Type Description shader_name
string
The name of the shader uniform_name
string
The name of the shader uniform value
real
The single float value -
shaderUpdateUniformFloat2(shader_name, uniform_name, value, value)
-
shaderUpdateUniformFloat2 set shader uniform_float2 - this requires an effect to be assigned which can utilise this value
Parameters:
Name Type Description shader_name
string
The name of the shader uniform_name
string
The name of the shader uniform value
real
The first float value value
real
The second float value -
shaderUpdateUniformFloat3(shader_name, uniform_name, value, value, value)
-
shaderUpdateUniformFloat3 set shader uniform_float3 - this requires an effect to be assigned which can utilise this value
Parameters:
Name Type Description shader_name
string
The name of the shader uniform_name
string
The name of the shader uniform value
real
The first float value value
real
The second float value value
real
The third float value -
shaderUpdateUniformFloat4(shader_name, uniform_name, value, value, value, value)
-
shaderUpdateUniformFloat4 set shader uniform_float4 - this requires an effect to be assigned which can utilise this value
Parameters:
Name Type Description shader_name
string
The name of the shader uniform_name
string
The name of the shader uniform value
real
The first float value value
real
The second float value value
real
The third float value value
real
The forth float value -
shaderUpdateUniformTexture(shader_name, uniform_name, filename)
-
shaderUpdateUniformTexture set uniform texture - this requires an effect to be assigned which can utilise this value
Parameters:
Name Type Description shader_name
string
The name of the shader uniform_name
string
The name of the shader uniform filename
string
The filename of the texture to load -
shaderUpdateUniformTextureTarget(shader_name, uniform_name, renderkit, targetID)
-
shaderUpdateUniformTextureTarget set uniform texture - this requires an effect to be assigned which can utilise this value
Parameters:
Name Type Description shader_name
string
The name of the shader uniform_name
string
The name of the shader uniform renderkit
renderkit
The renderkit with the texture_target targetID
int
The texture_target ID