Messages
scene.capture
Captures the current scene state
Usage
human.send(
'scene.capture'
, callback)
Parameters:
Name |
callback
|
---|---|
Type | scene.SceneCaptureCallback |
Example
Scene capture and restore
var sceneState;
// Initialize API
var human = new HumanAPI("embeddedHuman");
human.on("human.ready", function() {
console.log("Highlighting objects");
human.send("scene.selectObjects", {
"maleAdult_standard-Right_Craniofacial_Bones_ID": true
});
console.log("Setting camera");
human.send("camera.set", {
position: {
x: 20,
y: 40,
z: 0
}
}, function() {
console.log("Capturing scene state");
// Capturing the scene state provides a JavaScript object
// containing the data necessary to recreate the scene.
// This object can be passed to "scene.restore" to re-create
// the scene.
human.send("scene.capture",
function (scene) {
sceneState = scene;
});
console.log("Resetting scene in 2s")
setTimeout(function() {
human.send("scene.reset");
console.log("Restoring scene state in 2s");
setTimeout(function() {
// Here, we pass the scene state object that
// was captured by "scene.capture" to "scene.restore"
// so it can restore the scene to the captured state.
human.send("scene.restore", sceneState);
}, 2000);
}, 2000);
});
});
// Fired whenever scene is restored to a captured state
human.on("scene.restored", function() {
console.log("Scene restored!");
});
scene.colorObject
Modify object colors
Usage
human.send(
'scene.colorObject'
, params)
Parameters:
Name |
params
|
||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type | object | ||||||||||||||||||||||||||||
Properties |
|
Example
Color Object
// Initialize API
var human = new HumanAPI("embeddedHuman");
human.send("scene.colorObject", {
objectId: "maleAdult_standard-Frontal_bone_52734_ID",
tintColor: [1, 0, 0],
brightness: 0.1,
saturation: -0.5,
contrast: 0.5,
opacity: 1.0
});
scene.colorObjects
Modify colors on multiple objects
Usage
human.send(
'scene.colorObjects'
, params)
Parameters:
Name | params |
||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type | object | ||||||||||||||||||||||||||||||||||
Description | Map of object IDs to paint recipes | ||||||||||||||||||||||||||||||||||
Properties |
|
Example
Color Objects
// Initialize API
var human = new HumanAPI("embeddedHuman");
human.send("scene.colorObjects", {
"maleAdult_standard-Frontal_bone_52734_ID": {
tintColor: [1, 0, 0],
saturation: -0.5,
},
"bd_brain-right_superior_frontal_gyrus_ID": {
tintColor: [0, 1, 0],
brightness: 0.1,
}
});
scene.disableHighlight
Disables highlight mode
Usage
human.send(
'scene.disableHighlight'
, callbackopt)
Parameters:
Name |
callback
(optional)
|
---|---|
Type | function |
scene.disableXray
Disable xray mode (see scene.enableXray)
Usage
human.send(
'scene.disableXray'
, callbackopt)
Parameters:
Name |
callback
(optional)
|
---|---|
Type | function |
Fires:
scene.enableHighlight
Enables highlight mode
Usage
human.send(
'scene.enableHighlight'
, callbackopt)
Parameters:
Name |
callback
(optional)
|
---|---|
Type | function |
scene.enableXray
Enable xray mode (make all unselected objects transparent)
Usage
human.send(
'scene.enableXray'
, callbackopt)
Parameters:
Name |
callback
(optional)
|
---|---|
Type | function |
Fires:
scene.getColor
Gets the object's color properties
Usage
human.send(
'scene.getColor'
, callback)
Parameters:
Name |
callback
|
---|---|
Type | scene.ColorInfoCallback |
Example
Get object color
// Initialize API
var human = new HumanAPI("embeddedHuman");
human.send("scene.getColor", function (data) {
console.log(JSON.stringify(data));
});
scene.getHighlightColor
Gets the current highlight color for selected objects.
Usage
human.send(
'scene.getHighlightColor'
, callback)
Parameters:
Name |
callback
|
---|---|
Type | scene.HighlightColorInfoCallback |
Example
Get highlight color
// Initialize API
var human = new HumanAPI("embeddedHuman");
human.send("scene.getHighlightColor", function (data) {
console.log(JSON.stringify(data));
});
scene.getLayers
Gather the current anatomy slider layers
Usage
human.send(
'scene.getLayers'
, callback)
Parameters:
Name |
callback
|
---|---|
Type | scene.SceneSliderLayersCallback |
Example
Get Anatomy Slider Layers
// Initialize API
var human = new HumanAPI("embeddedHuman");
human.send("scene.getLayers", function (layers) {
console.log(layers);
});
scene.info
Gather information about the objects in the scene
Usage
human.send(
'scene.info'
, callback)
Parameters:
Name |
objectId
(optional)
|
---|---|
Type | string |
Description | The (optional) object id of a single object to retrieve additional metadata (i.e., description). |
Name |
callback
|
Type | scene.SceneInfoCallback |
Example
Scene info
// Initialize API
var human = new HumanAPI("embeddedHuman");
human.send("scene.info", function (data) {
console.log(JSON.stringify(data));
});
scene.load
Load new content into the scene. This can be either a module (core content created by BioDigital), or bookmark
Usage
HumanAPI.call(
'scene.load'
, idopt, callback)
Parameters:
Name |
id
(optional)
|
---|---|
Type | string |
Description | ID of the module or bookmark to load |
Name |
callback
|
Type | scene.PickInfoCallback |
Fires:
Example
Load a scene programmatically
var sceneState;
// Initialize API
var human = new HumanAPI("embeddedHuman");
var sceneIds = ["production/maleAdult/heart.json", "production/maleAdult/artery.json", "1FAM", "1FAQ"];
var i = 0;
console.log("Loading scenes programmatically");
(function loadScene() {
console.log("Loading scene ID: " + sceneIds[i]);
human.send("scene.load", sceneIds[i], function() {
i = (i + 1) % sceneIds.length;
setTimeout(loadScene, 5000);
});
})();
scene.metadata
Gather information about the current scene and chapters, including titles, descriptions and animation details.
Usage
human.send(
'scene.metadata'
, callback)
Parameters:
Name |
callback
|
---|---|
Type | scene.SceneMetadataCallback |
Example
Scene metadata
// Initialize API
var human = new HumanAPI("embeddedHuman");
human.send("scene.metadata", function (data) {
console.log("scene metadata", data);
});
scene.pick
Get info about the 3D scene at a given canvas location. Optionally, trigger actions associated with the current pick mode
Usage
human.send(
'scene.pick'
, params, callback)
Parameters:
Name |
params
|
||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type | object | ||||||||||||||||||||
Properties |
|
||||||||||||||||||||
Name |
callback
|
||||||||||||||||||||
Type | scene.PickInfoCallback |
Fires:
Example
Programmatic picking
// Initialize API
var human = new HumanAPI("embeddedHuman");
var iframe = document.getElementById("embeddedHuman");
var w = iframe.clientWidth;
var h = iframe.clientHeight;
setInterval(function () {
var canvasX = Math.round(Math.random() * 300 - 150 + w / 2);
var canvasY = Math.round(Math.random() * 300 - 150 + h / 2);
console.log("Try pick at " + canvasX + ", " + canvasY);
human.send("scene.pick", { x: canvasX, y: canvasY },
function (hit) {
if (hit) {
console.log("Hit: " + JSON.stringify(hit));
} else {
console.log("Miss");
}
});
}, 2000);
scene.reset
Reset the scene to its original state
Usage
human.send(
'scene.reset'
, callbackopt)
Parameters:
Name |
callback
(optional)
|
---|---|
Type | function |
Example
Scene reset
// Initialize API
var human = new HumanAPI("embeddedHuman");
console.log("Setting camera")
human.send("camera.set", {
position: {
x: 20,
y: 40,
z: 0
}
}, function() {
console.log("Scene reset in 2s");
setTimeout(function() {
human.send("scene.reset");
}, 2000);
});
scene.restore
Restores scene state from description captured by scene.capture
Usage
human.send(
'scene.restore'
, sceneState, callbackopt)
Parameters:
Name |
sceneState
|
---|---|
Type | object |
Description | Scene state captured from scene.capture |
Name |
callback
(optional)
|
Type | function |
Fires:
scene.selectObjects
Select or deselect objects in the scene
Usage
human.send(
'scene.selectObjects'
, selectionMap)
Parameters:
Name |
selectionMap
|
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Type | object | ||||||||||
Description | Map of object IDs or FMA IDs to true to select, false to deselect | ||||||||||
Properties |
|
Fires:
Example
Select object
// Initialize API
var human = new HumanAPI("embeddedHuman");
var select = true;
console.log("Intermittent switching of selected objects");
(function toggleSelect() {
human.send("scene.selectObjects", {
"maleAdult_standard-Left_Craniofacial_Bones_ID": select,
"maleAdult_standard-Right_Craniofacial_Bones_ID": !select
});
select = !select;
setTimeout(toggleSelect, 3000);
})();
human.on("scene.objectsSelected", function(event) {
var selected = [];
var deselected = [];
// Event contains a map of objects that were selected
// or deselected by this update.
Object.keys(event).forEach(function(objectId) {
if (event[objectId]) {
selected.push(objectId);
} else {
deselected.push(objectId);
}
});
console.log("Selected objects: " + selected.join(", "));
console.log("Deslected objects: " + deselected.join(", "));
});
scene.setHighlightColor
Set the highlight color for selected objects.
Usage
human.send(
'scene.setHighlightColor'
, params)
Parameters:
Name |
params
|
||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type | object | ||||||||||||||||||||
Properties |
|
Example
Set Highlight Color
// Initialize API
var human = new HumanAPI("embeddedHuman");
human.send("scene.setHighlightColor", {
tintColor: [1, 0, 0],
brightness: 0.1,
saturation: -0.5,
contrast: 0.5,
});
scene.setLayersSliderPosition
Set the position of the anatomy layers slider.
Usage
human.send(
'scene.setLayersSliderPosition'
, params)
Parameters:
Name |
params
|
|||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type | object | |||||||||||||||
Properties |
|
Example
Show objects
// Initialize API
var human = new HumanAPI("embeddedHuman");
console.log("Intermittent setting of slider position");
(function setPosition() {
human.send("scene.setLayersSliderPosition", {
position: Math.random(),
record: true
});
setTimeout(setPosition, 3000);
})();
scene.showObjects
Show or hide objects in the scene
Usage
human.send(
'scene.showObjects'
, selectionMap)
Parameters:
Name |
selectionMap
|
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Type | object | ||||||||||
Description | Map of object IDs or FMA IDs to true to show, false to hide | ||||||||||
Properties |
|
Fires:
Example
Show objects
// Initialize API
var human = new HumanAPI("embeddedHuman");
var show = true;
console.log("Intermittent showing and hiding of scene objects");
(function toggleShow() {
human.send("scene.showObjects", {
"maleAdult_standard-Left_Craniofacial_Bones_ID": show,
"maleAdult_standard-Right_Craniofacial_Bones_ID": !show
});
show = !show;
setTimeout(toggleShow, 3000);
})();
human.on("scene.objectsShown", function(event) {
var shown = [];
var hidden = [];
// Event contains a map of objects that were shown
// or hidden by this update.
Object.keys(event).forEach(function(objectId) {
if (event[objectId]) {
shown.push(objectId);
} else {
hidden.push(objectId);
}
});
console.log("Shown objects: " + shown.join(", "));
console.log("Hidden objects: " + hidden.join(", "));
});
scene.transformObject
Transform object to new position or orientation
Usage
human.send(
'scene.transformObject'
, params)
Parameters:
Name |
params
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type | object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Properties |
|
Example
Transform objects
// Initialize API
var human = new HumanAPI("embeddedHuman");
var t = 0;
var inc = 0.01;
console.log("Animating object position");
(function animate() {
t += inc;
if (t > 1) {
t = 1;
inc *= -1;
}
if (t < 0) {
t = 0;
inc *= -1;
}
human.send("scene.transformObject", {
objectId: "maleAdult_standard-Frontal_bone_52734_ID",
translate: {x: -8 * t, y: 2 * t, z: -8 * t},
rotate: { y: t * 90 }
});
requestAnimationFrame(animate);
})();
scene.uncolorObject
Clear object colors
Usage
human.send(
'scene.uncolorObject'
, params)
Parameters:
Name |
params
|
||||||||
---|---|---|---|---|---|---|---|---|---|
Type | object | ||||||||
Properties |
|
Example
Undo object coloring
// Initialize API
var human = new HumanAPI("embeddedHuman");
human.send("scene.uncolorObject", {
objectId: "maleAdult_standard-Frontal_bone_52734_ID"
});
Type Definitions
scene.ColorInfoCallback
Usage
ColorInfoCallback(tintColor, saturation, brightness, contrast, opacity)
Parameters:
Name |
tintColor
|
---|---|
Type | array |
Description | RGB triplet to tint the object with. RGB values can be between 0 and 1 |
Name |
saturation
|
Type | number |
Description | Saturation of object colors. Values between -1 and 1. |
Name |
brightness
|
Type | number |
Description | Brightness of object colors. Values between -1 and 1. |
Name |
contrast
|
Type | number |
Description | Contrast of object colors. Values between -1 and 1. |
Name |
opacity
|
Type | number |
Description | Opacity of object colors. Values between 0 and 1. |
scene.HighlightColorInfoCallback
Usage
HighlightColorInfoCallback(tintColor, saturation, brightness, contrast)
Parameters:
Name |
tintColor
|
---|---|
Type | array |
Description | RGB triplet to tint the object with. RGB values can be between 0 and 1 |
Name |
saturation
|
Type | number |
Description | Saturation of object colors. Values between -1 and 1. |
Name |
brightness
|
Type | number |
Description | Brightness of object colors. Values between -1 and 1. |
Name |
contrast
|
Type | number |
Description | Contrast of object colors. Values between -1 and 1. |
scene.PickInfoCallback
Usage
PickInfoCallback()
Properties:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pick |
object |
Properties
|
scene.SceneCaptureCallback
Usage
SceneCaptureCallback(sceneState)
Parameters:
Name |
sceneState
|
---|---|
Type | object |
Description | Captured scene state. Can be passed to scene.restore |
scene.SceneInfoCallback
Usage
SceneInfoCallback(name, objectMap)
Parameters:
Name |
name
|
||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type | string | ||||||||||||||||||||||||||||||||
Description | Name of the currently loaded scene | ||||||||||||||||||||||||||||||||
Name |
objectMap
|
||||||||||||||||||||||||||||||||
Type | object | ||||||||||||||||||||||||||||||||
Description | A map of object IDs to object info | ||||||||||||||||||||||||||||||||
Properties |
|
scene.SceneMetadataCallback
Usage
SceneMetadataCallback(name, objectMap)
Parameters:
Name |
metadata
|
||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type | object | ||||||||||||||||
Properties |
|
scene.SceneChapterMetadataCallback
Usage
SceneChapterMetadataCallback(name, objectMap)
Parameters:
Name |
metadata
|
|||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Type | object | |||||||||||||||||||||||||||||||||||||
Properties |
|
scene.SceneSliderLayersCallback
Usage
Array<Array<SliderLayer>>
Parameters:
Type | Array<SliderLayer> | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description | An array of anatomy slider layers | ||||||||||||
SliderLayer |
|
Events
scene.objectsSelected
Usage
human.on(
'scene.objectsSelected'
, callback)
Properties:
Name | Type | Description |
---|---|---|
event |
object | Map listing object IDs and whether they were selected or deselected |
scene.objectsShown
Usage
human.on(
'scene.objectsShown'
, callback)
Properties:
Name | Type | Description |
---|---|---|
event |
object | Map listing object IDs and whether they were shown or hidden |
scene.picked
Usage
human.on(
'scene.picked'
, callback)
Properties:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
event |
object |
Properties
|
Example
Pick event
// Initialize API
var human = new HumanAPI("embeddedHuman");
console.log("Pick or hover over something!");
human.on("scene.picked",
function (pickEvent) {
console.log("'scene.picked' event: " + JSON.stringify(pickEvent));
});
scene.restored
Usage
human.on(
'scene.restored'
, callback)
Properties:
Name | Type | Description |
---|---|---|
event |
object | Scene state captured by scene.capture |
scene.xrayDisabled
Usage
human.on(
'scene.xrayDisabled'
, callback)
Example
Enable xray
// Initialize API
var human = new HumanAPI("embeddedHuman");
var enable = true;
human.on("scene.xrayEnabled", function() {
console.log("Xray mode enabled");
});
human.on("scene.xrayDisabled", function() {
console.log("Xray mode disabled");
});
human.on("human.ready", toggleXray);
function toggleXray() {
human.send(enable ? "scene.enableXray" : "scene.disableXray");
enable = !enable;
setTimeout(toggleXray, 3000);
}
scene.xrayEnabled
Usage
human.on(
'scene.xrayEnabled'
, callback)
Example
Enable xray
// Initialize API
var human = new HumanAPI("embeddedHuman");
var enable = true;
human.on("scene.xrayEnabled", function() {
console.log("Xray mode enabled");
});
human.on("scene.xrayDisabled", function() {
console.log("Xray mode disabled");
});
human.on("human.ready", toggleXray);
function toggleXray() {
human.send(enable ? "scene.enableXray" : "scene.disableXray");
enable = !enable;
setTimeout(toggleXray, 3000);
}