Program Class

Extends ResourceManager
Module: Core

Program class contains all the data of a nunuStudio program.

Program is also used to store and manage all available resources.

Constructor

Program

(
  • name
)

Parameters:

  • name String

    Program name

Methods

add

(
  • scene
)

Add new scene to this program.

On the program class only scenes can be added as children.

Parameters:

addDefaultScene

(
  • material
)

Create a scene using a default template.

This is the scene used when creating a new program or scene inside the editor.

Parameters:

  • material Material

    Default material used by objects, if empty a new material is created

clone

() Program

Clone program, keeping uuids and every identification attribute.

Clone method uses the ObjectLoad to serialize and create a new program instance with the same data.

Returns:

Program:

Cloned program

displayVR

()

Enter virtual reality mode.

To enter virtual reality mode a WebVR enabled browser is required.

When displaying VR content the display.requestAnimationFrame should be used to call the render method.

dispose

()

Dispose program data to avoid memory leaks.

Called when exiting the program.

exitVR

()

Exit virtual relity mode.

initialize

()

Select initial scene and initialize that scene.

Automatically called by the runtime.

receiveDataApp

(
  • data
)

Receive external data and pass it to all script instances.

Parameters:

  • data Object

remove

(
  • scene
)

Remove Scene from program.

Parameters:

render

(
  • renderer
)

Render current scene to canvas.

When rendering in VR mode all effects and camera parameters are ignored.

Renderer should be initialized and passed as argument.

Parameters:

  • renderer Renderer

resize

(
  • x
  • y
)

Resize the current scene elements.

Parameters:

  • x Number

    Width.

  • y Number

    Height.

sendDataApp

(
  • data
)

Send data to external app instance.

Parameters:

  • data Object

setInitialScene

(
  • uuid
)

Set a scene as initial scene using its uuid.

This method is used by the editor.

Parameters:

  • uuid String

    Scene uuid

setMouseKeyboard

(
  • mouse
  • keyboard
)

Set program mouse and keyboard.

Parameters:

setRenderer

(
  • renderer
  • configure
)

Set program renderer to be used by this program.

Parameters:

  • renderer WebGLRenderer

    Three.js renderer to be used by this program

  • configure Bool

    If true also updates renderer configuration to match rendering quality specified in the program.

setScene

(
  • scene
)

Change scene during runtime, this method can receive booth a scene name or a scene object.

This method should be used inside of script objects during runtime.

Parameters:

toJSON

(
  • meta
  • exportResources
)
Object

Serialize object to JSON.

Parameters:

  • meta Object
  • exportResources Boolean

    If true all resouces in the program are exported, else only resources attached to objects are exported

Returns:

Object:

json

update

()

Update program state, this updated all current scene children elements.

updateRenderer

()

This method updated the webgl renderer configuration.

Should be called after changing any rendering related parameter.

Properties

antialiasing

Boolean

Antialiasing flag

Default: false

app

Unknown

NunuRuntime instance used to communication between nunu app and the host webpage

Default: null

author

String

Program author

canvas

DOM

Canvas being used to draw content.

Default: null

description

String

Program description

division

DOM

DOM Division element that can be used to add html content to the app.

Default: null

handlePixelRatio

Boolean

Flag to indicate if the runtime should handle device pixel ratio

Default: false

keyboard

Keyboard

Keyboard input object

lockPointer

Boolean

Flag to control pointer locking

Default: false

mouse

Mouse

Mouse input object

renderer

WebGLRenderer

Threejs WebGLRenderer being used

Default: null

shadows

Boolean

If true the program is rendered with shadows

Default: true

shadowsType

Number

Shadow type

Default: PCFSoftShadowMap

toneMapping

Number

Tonemapping mode

Default: NoToneMapping

version

String

Program version

Default: "0"

vr

Boolean

Enable virtual reality flag

Default: false

vrScale

Number

Virtual reality movement scale

Default: 1.0