-
-
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
This file contains hidden or 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 = 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