V8 Javascript API

Types

[Commands]

Description

V8 commands support most native JavaScript types as arguments and return values in addtion to some custom RealityServer types to allow binary data to be returned and manipulated. All supported types are automatically converted between C++ mi::IData types and JavaScript.

Simple Types

Type name

Iray type

Javsacript type

Boolean

mi::IBoolean

Boolean

Sint8

mi::ISint8

Number

Sint16

mi::ISint16

Number

Sint32

mi::ISint32

Number

Sint64

mi::ISint64

Number

Uint8

mi::IUint8

Number

Uint16

mi::IUint16

Number

Uint32

mi::IUint32

Number

Uint64

mi::IUint64

Number

Float32

mi::IFloat32

Number

Float64

mi::IFloat64

Number

String

mi::IString

String

Map

mi::IMap

Object

Array

mi::IArray

Array

Compound types

All compound types are supported and are converted to either RealityServer Math classes or generic JavaScript objects if no specific implementation exists. For example a Color argument will be provided converted to RS.Math.Color whereas an Sint32<2> will become an Object with x, and y properties of type Number.

Type name

Iray type

Javsacript type

Float32<2>

mi::IFloat32_2

RS.Math.Vector2

Float32<3>

mi::IFloat32_3

RS.Math.Vector3

Float32<4>

mi::IFloat32_4

RS.Math.Vector4

Float64<4,4>

mi::IFloat64_4_4

RS.Math.Matrix4x4

Color

mi::IColor

RS.Math.Color

Spectrum

mi::ISpectrum

RS.Math.Spectrum

User types

Similar to compound types all user types are supported as generic Objects.

Pixel Types

The following are acceptable pixel types to use when creating, converting or manipulating canvases. Pixel type gives the number of components per pixel and each components type. ArrayBufferView type indicates which type of ArrayBufferView should be used to access the canvas pixel data.

Type name

Pixel Type

ArrayBufferView type

Sint8

1 x mi::Sint8

Int8Array

Float32

1 x mi::IFloat32

Float32Array

Float32<2>

2 x mi::Float32

Float32Array

Float32<3>

3 x mi::Float32

Float32Array

Float32<4>

4 x mi::Float32

Float32Array

Rgb

3 x mi::Uint8

Uint8Array

Rgba

4 x mi::Uint8

Uint8Array

Rgbe

4 x mi::Uint8

Uint8Array

Rgbea

5 x mi::Uint8

Uint8Array

Rgb_16

3 x mi::Uint16

Uint16Array

Rgba_16

4 x mi::Uint16

Uint16Array

Rgb_fp

3 x mi::Float32

Float32Array

Color

4 x mi::Float32

Float32Array

Custom types

A number of custom types are also provided to provide functionality not available via standard JavaScript.

Type name

Iray type

Javsacript type

Binary

mi::nservices::IBinary

Binary

Canvas

mi::nservices::ICanvas

Canvas

The Binary type allows arbitrary binary data to be returned with an associated mime-type. Canvas represents images and allows for their manipulation, encoding and decoding.

Return types

The special type Void can be used when a command is not expected to return an explicit result. These can also be used with command arguments in which case they are converted to an empty object, however they are not particularly useful.

Type name

Iray type

Javsacript type

Void

mi::IVoid

Object

Classes

class 
The Binary class allows arbitrary binary data to be returned by a command. More...
class 
The Canvas class represents an image within RealityServer, either the result of a render or obtained from a texture. More...