Open Hybrid

Reference

Java Script

 

Include the open hybrid functionality by instancing as following in your Java Script code:

 

var obj = new HybridObject();

 

 

Interface with IO-Points

 

.addReadListener([IO Point], callback)

Every communication with the object is happening passively. This means that the object is not pushing data. If a user interface wants to read data from a Hybrid Object it first needs to send a read request.

 

Example:

 obj.addReadListener("led", function(e){

        input = e*255;

    });

 

 

.write([IO Point], [Value 0 ~ 1])

You can write to the Hybrid Object with write(). The scale of your values should be between 0.0 and 1.0.

 

Example:

 obj.write("led", output);

 

 

Interface with Reality Editor

 

.sendGlobalMessage([message])

Send broadcast messages to all other objects currently visible in the Reality Editor.

 

Example:

 obj.sendGlobalMessage("Hello World");

 

 

.addGlobalMessageListener(callback[message])

Allows you to listen to messages send to all other objects currently visible in the Reality Editor.

 

Example:

 obj.addGlobalMessageListener(function(e){

        console.log(e);

    });

 

.subscribeToMatrix()

Forces the Reality Editor to send the 3D transformation Matrices.

 

Example:

 obj.sendGlobalMessage();

 

 

.addMatrixListener(callback[modelViewMatrix][porjectionMatrix])

Allows you to listen to updates 3D-transformations. It only works once subscribeToMatrix() has been called.

This listener is synchronized with the video update rate.

 

Example:

 obj.addMatrixListener(function(e,f){

        modelview = e;

        projection = f;

    });

 

 

.setFullScreenOn()

Forces the Reality Editor to show your content full screen without 3d transformation. This comes in handy for when you want to use the transformation matrices directly.

 

Example:

 obj.setFullScreenOn();

 

 

.setFullScreenOff()

Does the oposit from setFullScreenOn. :-)

 

Example:

 obj.setFullScreenOff();

 

 

.addVisibilityListener(callback[e])

Allows you read if the interface is visible or not. The interface stays active for 3 seconds after it becomes invisible.

 

Example:

  obj.addMatrixListener(function(e){

        visible = e;

    });

 

 

.getPossitionX(), .getPossitionY(), .getPossitionZ()

Returns a number for translation distance and position between the iOS device and the marker.

 

Example:

 x =  obj.getPossitionX();

 y =  obj.getPossitionY();

 z =  obj.getPossitionZ();