Skip to content

Instantly share code, notes, and snippets.

@molotovbliss
Forked from xeolabs/xeogl-debug-logPick.js
Last active February 18, 2021 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save molotovbliss/d661b62e30ed0998c54f85ebbe397f78 to your computer and use it in GitHub Desktop.
Save molotovbliss/d661b62e30ed0998c54f85ebbe397f78 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 = window.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("=================== DEBUG PICKED =======================");
if (hit) {
var mesh = hit.mesh;
console.log("Picked:");
console.log("hit.mesh.parent == " + JSON.stringify(mesh.parent.id));
console.log("hit.mesh._material._state == " + JSON.stringify(mesh._material._state));
console.log("hit.mesh == xeogl.scenes[" + mesh.scene.id + "].entities[" + mesh.id + "]");
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