Nunu Class

Module: Runtime

nunuStudio core main file.

Store nunuStudio development version and timestamp and contains global method to check browser feature support.

Methods

copyNamespace

() static

Import stuff from a namespace to another target namespace.

If not target is specified window is used.

createWorker

(
  • code
  • onMessage
)
Worker

Create a web worker from code written in a string.

Uses a blob to inject the code and loads it from and URL object.

Parameters:

  • code String

    Javascript code for this worker.

  • onMessage Function

    On message worker callback.

Returns:

Worker:

Returns a worker instance (for comunication).

developmentMode

() Boolean

Check if nunu if running in development mode.

Returns:

Boolean:

True if running as development mode.

enterVR

(
  • renderer
  • onSuccess
)

Enter virtual reality mode using WebXR or WebVR depending on the API available.

If booth API are available the WebXR API is used.

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

Parameters:

  • renderer WebGLRenderer

    Renderer used to draw the scene.

  • onSuccess Function

    Method called if the application entered VR successfully.

exitVR

(
  • renderer
)

Enter virtual reality mode, if the application is not running on VR mode does not do anything.

Parameters:

  • renderer WebGLRenderer

    Renderer used to draw the scene.

getPlatform

() Number

Check in wich platform the enviroment is running.

Possible return values are:

  • Nunu.NWJS
  • Nunu.BROWSER
  • Nunu.CORDOVA

Returns:

Number:

Indicates the platform type.

getQueryParameters

() Object

Get the query parameter from the browser URL.

Returns:

Object:

Object with parameters read from the URL.

getVRDisplays

(
  • onDisplay
)

Used to get the first VR display available, the display is returned as argument of the onDisplay function.

Parameters:

  • onDisplay Function

    Function used to get the display, receives the display as argument.

getXRSession

(
  • onSession
)

Get WebXR session.

Parameters:

  • onSession Function

    Function used to get the XR session, receives the session as argument.

isFullscreen

() Boolean

Check if there is some element on fullscreen mode.

Returns true even the fullscreen element is not related with the app.

Returns:

Boolean:

True if there is some element in fullscreen mode.

openWebpage

()

Open a webpage on a new window.

On desktop and mobile it will open the default browser.

On the web it will open as a popup.

runningOnDesktop

() Boolean

Check if nunu is running inside NWJS.

Returns:

Boolean:

True if running inside NWJS

setFullscreen

(
  • fullscreen
  • element
)

Set an element into fullscreen mode or exit out of fullscreen mode.

Uses isFullscreen to check if the application is running in fullscreen mode already.

Parameters:

  • fullscreen Boolean

    If true the application will enter fullscreen mode, if false it will exit, if undefine it will toggle the value.

  • element Component

    DOM element to put into fullscreen.

vrAvailable

() Boolean

Check if there is any VR API available, on the device.

Checks if there is support for WebVR or WebXR.

Returns:

Boolean:

True if the browser supports vr.

webAudioAvailable

() Boolean

Check if host supports WebAudio.

Returns:

Boolean:

True if WebAudio is available.

webglAvailable

() Boolean

Check if host supports WebGL, only checks for WebGL 1.0 support.

Returns:

Boolean:

True if WebGL is available.

webVRAvailable

() Boolean

Check if host supports WebVR.

Returns:

Boolean:

True is WebVR is available.

webXRAvailable

() Boolean

Check if host supports WebXR.

Returns:

Boolean:

True is WebVR is available.

Attributes

BROWSER

Number static

Running inside of a regular web browser.

CORDOVA

Number static

Cordova platform, used for mobile versions.

NAME

String

nunuStudio

Default: "nunuStudio"

NWJS

Number static

NWJS platform, used for desktop version.

REPOSITORY_BRANCH

String static

Repository branch, used to track the version after publishing.

REPOSITORY_COMMIT

String static

Repository commit uuid, used to track the version after publishing.

TIMESTAMP

String

Stores the nunu runtime dev timestamp.

VERSION

String

Stores the nunu runtime version.

webVRDisplay

VRDisplay

Web VR display obtained.

webVRHasDisplay

Boolean

Flag indicating if there are any VR displays available.

Checked on the library bootup if WebVR is available, while the check does not finish it is set to null.

webXRSession

XRSession

WebXR session created.

webXRSupported

Boolean

Flag checking if there is support for XR immersive VR mode.

Checked on the library startup if XR is supported, while the check does not finish it is set to null.