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
  • Select an option

  • Save molotovbliss/d661b62e30ed0998c54f85ebbe397f78 to your computer and use it in GitHub Desktop.

Select an option

Save molotovbliss/d661b62e30ed0998c54f85ebbe397f78 to your computer and use it in GitHub Desktop.

Revisions

  1. molotovbliss revised this gist Feb 18, 2021. 1 changed file with 7 additions and 6 deletions.
    13 changes: 7 additions & 6 deletions xeogl-debug-logPick.js
    Original file line number Diff line number Diff line change
    @@ -7,15 +7,16 @@
    canvasPos: coords,
    pickSurface: true
    });
    console.log("");
    console.log("=================== DEBUG PICKED =======================");
    if (hit) {
    var entity = hit.entity;
    var mesh = hit.mesh;
    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.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);
    console.log("hit.bary == [" + hit.bary[0] + "," + hit.bary[1] + "," + hit.bary[2] + "]");
    console.log("hit.primIndex == " + hit.primIndex);
    } else {
    console.log("Nothing picked.");
    }
  2. molotovbliss revised this gist Feb 18, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion xeogl-debug-logPick.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    (function () {
    var scenes = xeogl.scenes;
    var scenes = window.xeogl.scenes;
    for (var sceneId in scenes) {
    if (scenes.hasOwnProperty(sceneId)) {
    scenes[sceneId].input.on("mouseclicked", function (coords) {
  3. molotovbliss revised this gist Jan 14, 2021. No changes.
  4. @xeolabs xeolabs revised this gist Oct 25, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions xeogl-debug-logPick.js
    Original file line number Diff line number Diff line change
    @@ -14,6 +14,8 @@
    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.");
    }
  5. @xeolabs xeolabs revised this gist Nov 25, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion xeogl-debug-logPick.js
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@
    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 == 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] + "]");
    } else {
  6. @xeolabs xeolabs revised this gist Nov 24, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion xeogl-debug-logPick.js
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@
    if (hit) {
    var entity = hit.entity;
    console.log("Picked:");
    console.log("hit.entity == xeogl.scenes[" + entity.scene.id + "].entities[" + entity.id + "].meta = " + JSON.stringify(entity.meta, null, '\t'));
    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] + "]");
    } else {
  7. @xeolabs xeolabs revised this gist Nov 24, 2016. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions xeogl-debug-logPick.js
    Original file line number Diff line number Diff line change
    @@ -11,8 +11,9 @@
    if (hit) {
    var entity = hit.entity;
    console.log("Picked:");
    console.log("hit.entity = xeogl.scenes[" + entity.scene.id + "].entities[" + entity.id + "].meta = " + JSON.stringify(entity.meta, null, '\t'));
    console.log("hit.worldPos = [" + hit.worldPos[0] + "," + hit.worldPos[1] + "," + hit.worldPos[2] + "]");
    console.log("hit.entity == xeogl.scenes[" + entity.scene.id + "].entities[" + entity.id + "].meta = " + JSON.stringify(entity.meta, null, '\t'));
    console.log("hit.entity.meta == " + JSON.stringify(entity.meta, null, '\t'));
    console.log("hit.worldPos == [" + hit.worldPos[0] + "," + hit.worldPos[1] + "," + hit.worldPos[2] + "]");
    } else {
    console.log("Nothing picked.");
    }
  8. @xeolabs xeolabs revised this gist Nov 24, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions xeogl-debug-logPick.js
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@
    canvasPos: coords,
    pickSurface: true
    });
    console.log("----------------------------------------------------------------------------------------------------");
    console.log("");
    if (hit) {
    var entity = hit.entity;
    console.log("Picked:");
    @@ -16,7 +16,7 @@
    } else {
    console.log("Nothing picked.");
    }
    console.log("----------------------------------------------------------------------------------------------------");
    console.log("");
    });
    }
    }
  9. @xeolabs xeolabs revised this gist Nov 24, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion xeogl-debug-logPick.js
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@
    var entity = hit.entity;
    console.log("Picked:");
    console.log("hit.entity = xeogl.scenes[" + entity.scene.id + "].entities[" + entity.id + "].meta = " + JSON.stringify(entity.meta, null, '\t'));
    console.log("hit.worldPos = [" + hit.worldPos[0], hit.worldPos[1], hit.worldPos[2] + "]");
    console.log("hit.worldPos = [" + hit.worldPos[0] + "," + hit.worldPos[1] + "," + hit.worldPos[2] + "]");
    } else {
    console.log("Nothing picked.");
    }
  10. @xeolabs xeolabs revised this gist Nov 24, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion xeogl-debug-logPick.js
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@
    var entity = hit.entity;
    console.log("Picked:");
    console.log("hit.entity = xeogl.scenes[" + entity.scene.id + "].entities[" + entity.id + "].meta = " + JSON.stringify(entity.meta, null, '\t'));
    console.log("hit.worldPos = " + JSON.stringify(hit.worldPos, null, '\t'));
    console.log("hit.worldPos = [" + hit.worldPos[0], hit.worldPos[1], hit.worldPos[2] + "]");
    } else {
    console.log("Nothing picked.");
    }
  11. @xeolabs xeolabs revised this gist Nov 24, 2016. 1 changed file with 3 additions and 4 deletions.
    7 changes: 3 additions & 4 deletions xeogl-debug-logPick.js
    Original file line number Diff line number Diff line change
    @@ -4,16 +4,15 @@
    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
    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 + "].meta = " + JSON.stringify(entity.meta, null, '\t'));
    if (hit.worldPos) {
    console.log("hit.worldPos = " + JSON.stringify(hit.worldPos, null, '\t'));
    }
    console.log("hit.worldPos = " + JSON.stringify(hit.worldPos, null, '\t'));
    } else {
    console.log("Nothing picked.");
    }
  12. @xeolabs xeolabs renamed this gist Nov 24, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  13. @xeolabs xeolabs revised this gist Nov 24, 2016. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion xeogl-debug-logEntityOnClick.js
    Original file line number Diff line number Diff line change
    @@ -6,12 +6,18 @@
    var hit = this.scene.pick({ // "this" points to the xeogl.Input component
    canvasPos: coords
    });
    console.log("----------------------------------------------------------------------------------------------------");
    if (hit) {
    var entity = hit.entity;
    console.log("Picked xeogl.scenes[" + entity.scene.id + "].entities[" + entity.id + "].meta = " + JSON.stringify(entity.meta, null, '\t'));
    console.log("Picked:");
    console.log("hit.entity = xeogl.scenes[" + entity.scene.id + "].entities[" + entity.id + "].meta = " + JSON.stringify(entity.meta, null, '\t'));
    if (hit.worldPos) {
    console.log("hit.worldPos = " + JSON.stringify(hit.worldPos, null, '\t'));
    }
    } else {
    console.log("Nothing picked.");
    }
    console.log("----------------------------------------------------------------------------------------------------");
    });
    }
    }
  14. @xeolabs xeolabs revised this gist Nov 24, 2016. 1 changed file with 15 additions and 12 deletions.
    27 changes: 15 additions & 12 deletions xeogl-debug-logEntityOnClick.js
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,18 @@
    (function () {
    var mySceneID = 0; // <---- Change to your Scene ID, or leave untouched if using xeogl's default Scene
    xeogl.scenes[mySceneID].input.on("mouseclicked", function (coords) {
    var hit = this.scene.pick({
    canvasPos: coords
    });
    if (hit) {
    var entity = hit.entity;
    this.log("Picked Entity '" + entity.id + "'");
    this.log("Entity metadata:\n" + JSON.stringify(entity.meta, null, '\t'));
    } else {
    this.log("Nothing picked.");
    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
    });
    if (hit) {
    var entity = hit.entity;
    console.log("Picked xeogl.scenes[" + entity.scene.id + "].entities[" + entity.id + "].meta = " + JSON.stringify(entity.meta, null, '\t'));
    } else {
    console.log("Nothing picked.");
    }
    });
    }
    });
    }
    })();
  15. @xeolabs xeolabs revised this gist Nov 24, 2016. No changes.
  16. @xeolabs xeolabs revised this gist Nov 24, 2016. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions xeogl-debug-logEntityOnClick.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,5 @@
    (function () {

    var mySceneID = 0; // <---- Change to your Scene ID, or leave untouched if using xeogl's default Scene

    var mySceneID = 0; // <---- Change to your Scene ID, or leave untouched if using xeogl's default Scene
    xeogl.scenes[mySceneID].input.on("mouseclicked", function (coords) {
    var hit = this.scene.pick({
    canvasPos: coords
  17. @xeolabs xeolabs renamed this gist Nov 24, 2016. 1 changed file with 0 additions and 0 deletions.
  18. @xeolabs xeolabs revised this gist Nov 24, 2016. 1 changed file with 15 additions and 14 deletions.
    29 changes: 15 additions & 14 deletions xeogl-debug-getEntityInfoOnClick.js
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,17 @@
    // Console snippet to let you click on an Entity to get info on it.
    // Set mySceneID to your Scene's ID, or leave as is to work with xeogl's default Scene.
    (function () {

    var mySceneID = 0;
    xeogl.scenes[mySceneID].input.on("mouseclicked", function (coords) {
    var hit = this.scene.pick({
    canvasPos: coords
    var mySceneID = 0; // <---- Change to your Scene ID, or leave untouched if using xeogl's default Scene

    xeogl.scenes[mySceneID].input.on("mouseclicked", function (coords) {
    var hit = this.scene.pick({
    canvasPos: coords
    });
    if (hit) {
    var entity = hit.entity;
    this.log("Picked Entity '" + entity.id + "'");
    this.log("Entity metadata:\n" + JSON.stringify(entity.meta, null, '\t'));
    } else {
    this.log("Nothing picked.");
    }
    });
    if (hit) {
    var entity = hit.entity;
    this.log("Picked Entity '" + entity.id + "'");
    this.log("Metadata:\n" + JSON.stringify(entity.meta, null, '\t'));
    } else {
    this.log("Nothing picked.");
    }
    });
    })();
  19. @xeolabs xeolabs revised this gist Nov 24, 2016. No changes.
  20. @xeolabs xeolabs revised this gist Nov 24, 2016. No changes.
  21. @xeolabs xeolabs revised this gist Nov 24, 2016. No changes.
  22. @xeolabs xeolabs renamed this gist Nov 24, 2016. 1 changed file with 5 additions and 3 deletions.
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,15 @@
    // Console snippet to let you click on an Entity to get it's ID
    // Console snippet to let you click on an Entity to get info on it.
    // Set mySceneID to your Scene's ID, or leave as is to work with xeogl's default Scene.

    var mySceneID = 0;
    xeogl.scenes[mySceneID].input.on("mouseclicked", function (coords) {
    var hit = this.scene.pick({
    canvasPos: coords
    });
    if (hit) {
    this.log("Picked Entity '" + hit.entity.id + "'");
    if (hit) {
    var entity = hit.entity;
    this.log("Picked Entity '" + entity.id + "'");
    this.log("Metadata:\n" + JSON.stringify(entity.meta, null, '\t'));
    } else {
    this.log("Nothing picked.");
    }
  23. @xeolabs xeolabs revised this gist Nov 24, 2016. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions xeogl-debug-getEntityIDOnClick.js
    Original file line number Diff line number Diff line change
    @@ -2,10 +2,8 @@
    // Set mySceneID to your Scene's ID, or leave as is to work with xeogl's default Scene.

    var mySceneID = 0;

    xeogl.scenes[mySceneID].input.on("mouseclicked", function (coords) {

    var hit = scene.pick({
    var hit = this.scene.pick({
    canvasPos: coords
    });
    if (hit) {
  24. @xeolabs xeolabs created this gist Nov 24, 2016.
    16 changes: 16 additions & 0 deletions xeogl-debug-getEntityIDOnClick.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    // Console snippet to let you click on an Entity to get it's ID
    // Set mySceneID to your Scene's ID, or leave as is to work with xeogl's default Scene.

    var mySceneID = 0;

    xeogl.scenes[mySceneID].input.on("mouseclicked", function (coords) {

    var hit = scene.pick({
    canvasPos: coords
    });
    if (hit) {
    this.log("Picked Entity '" + hit.entity.id + "'");
    } else {
    this.log("Nothing picked.");
    }
    });