Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Drop in Chrome console to log info on each (pickable) Entity you click on -- #xeogl #debugging
(function () {
var scenes = xeogl.scenes;
for (var sceneId in scenes) {
if (scenes.hasOwnProperty(sceneId)) {
scenes[sceneId].input.on("mouseclicked", function (coords) {
var hit = this.scene.pick({ // "this" points to the xeogl.Input component
canvasPos: coords,
pickSurface: true
});
console.log("");
if (hit) {
var entity = hit.entity;
console.log("Picked:");
console.log("hit.entity == xeogl.scenes[" + entity.scene.id + "].entities[" + entity.id + "]");
console.log("hit.entity.meta == " + JSON.stringify(entity.meta, null, '\t'));
console.log("hit.worldPos == [" + hit.worldPos[0] + "," + hit.worldPos[1] + "," + hit.worldPos[2] + "]");
console.log("hit.bary == [" + hit.bary[0] + "," + hit.bary[1] + "," + hit.bary[2] + "]");
console.log("hit.primIndex == " + hit.primIndex);
} else {
console.log("Nothing picked.");
}
console.log("");
});
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment