Skip to content

Instantly share code, notes, and snippets.

@xeolabs
Last active January 14, 2021 21:24
Show Gist options
  • Save xeolabs/1e348a408cd25e35e1960d5d6cac26c8 to your computer and use it in GitHub Desktop.
Save xeolabs/1e348a408cd25e35e1960d5d6cac26c8 to your computer and use it in GitHub Desktop.
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