Class HumanAPI.Human


Extends HumanAPI.Component.
API for a Human embedded in an IFRAME.

Getting a Human

A basic instantiation of the Human API requires only the ID of the iframe to which the API will be linked:

     var human = new HumanAPI.Human("myIframeId");
     

More advanced initialization can be done with an options object:

        var human = new HumanAPI.Human({
            iframeId: "embeddedHuman",
            showLog: true,
            humanLog: true
        });
      

Subscribing to Human readiness

Get a notification once the Human is ready:

     human.on("ready",function () {
        console.log("Human ready");
    });
     

We don't actually need to wait for the "ready" notification - the API will buffer everything we do with it until the Human is ready. If we make that subscription when the Human is already ready, then we'll get the notification immediately.

Subscribing to errors

Subscribe to errors signalled by the Human like this:

     human.on("error",function (err) {

        var errorName   = err.errorName;    // String, brief name of error
        var code        = err.code;         // String, Human-assigned code for error
        var msg         = err.msg;          // String, error description
        var fatal       = err.fatal         // Boolean, true when Human must reset to recover

        //...
    });
     

Subscribing to unsupported browser error

When the browser does not support Human, you'll get an 'unsupported' notification, which you can subscribe to as shown below. When you get one of these, you won't get a 'ready'.

    human.on("unsupported", function (data) {

    // Boolean flags indicating what failed

    var html5 = data.html5;     // False when HTML5 not supported
    var webgl = data.webgl;     // False when WebGL not supported
    var human = data.human;     // False when Human not supported, despite browser support for HTML5 and WebGL
    var error = data.error;     // Describes support failure

    //...
});
     

Getting Human modes and tools

The various sub-systems of the Human are organized into components on the API. For example, to set visibilities of objects within the 3D scene, you would get the scene and access the objects, like this:

    human.scene.showObjects({
        objectIds: {
            "maleAdult-Skeletal_System" : true,
            "maleAdult-Left_minor_alar_cartilage" : false
        },
        replace: true
    });
 

The API components are lazy-instantiated once they are used. API components synchronize their states with the Human via events, so this approach allows us to only incur the overhead of running an API component when we are actually using the associated Human sub-system.

Primary components include:

There are also a variety of interaction modes who's components are grouped together under in the human.modes namespace:

The simplest way to enable an interaction mode is to use the human.setMode() method, e.g.:

    human.enableMode("xray");    // Enable the interaction mode
    human.disableMode("xray");   // Disable the interaction mode
  

Media clips are stored under the human.media namespace:

A snapshot of the scene can be grabbed using the human.snapshot() method. The method will provide a data URL representing the scene:

    human.snapshot(function(url) {
        // Use data URL
    });
  

Resetting the Human

Reset Human to the state it was in immediately after it signalled "ready":

 human.reset();
 

This will reset everything (camera, object visibility and selection, view modes etc) to what they were when the Human was first ready.


Defined in: human.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
 
Destroys this API.
 
Disable an interaction mode of the scene (xray, highlight, isolate, dissect, labels).
 
enableMode(name)
Enable an interaction mode of the scene (xray, highlight, isolate, dissect, labels).
 
reset(ok)
Reset the human to its state immediately after it signalled "ready"
 
snapshot(params, ok)

Get snapshot at canvas dimensions

     human.snapshot(function(url) {

       // Set attribute of IMG element using jQuery

       $("#image1").attr({
           src: url
       });
   });
     

Get snapshot of desired dimensions:

     human.snapshot({ width: 600, height: 400 }, function(url) {

       // Set attribute of an IMG element using jQuery

       $("#image1").attr({
           src: url
       });
  });
     
Methods borrowed from class HumanAPI.Component:
log, off, on, once
Class Detail
HumanAPI.Human(cfg)
Parameters:
cfg
{Object} cfg.iframe
Configuration when connecting to a Human embedded in an IFRAME.
{Object} cfg.iframeId
ID of IFRAME containing target Human
{Object} cfg.showLog Optional
Set true to append Human's logging to the end of the document
Method Detail
destroy()
Destroys this API.

disableMode(name)
Disable an interaction mode of the scene (xray, highlight, isolate, dissect, labels).
Parameters:
{string} name Optional
The interaction mode name.

enableMode(name)
Enable an interaction mode of the scene (xray, highlight, isolate, dissect, labels).
Parameters:
{string} name Optional
The interaction mode name.

reset(ok)
Reset the human to its state immediately after it signalled "ready"
Parameters:
{Function()} ok Optional
Callback fired on result

snapshot(params, ok)

Get snapshot at canvas dimensions

     human.snapshot(function(url) {

       // Set attribute of IMG element using jQuery

       $("#image1").attr({
           src: url
       });
   });
     

Get snapshot of desired dimensions:

     human.snapshot({ width: 600, height: 400 }, function(url) {

       // Set attribute of an IMG element using jQuery

       $("#image1").attr({
           src: url
       });
  });
     
Parameters:
params
{Function} ok Optional

Documentation generated by JsDoc Toolkit 2.4.0 on Mon Aug 03 2015 18:07:11 GMT-0400 (Eastern Daylight Time)