Last active
January 14, 2021 21:24
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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