/home/lindsay/xeolabs/xeogl-next/xeogl/examples/js/helpers/aabbHelper.js
API Docs for:

File: /home/lindsay/xeolabs/xeogl-next/xeogl/examples/js/helpers/aabbHelper.js

  1. /**
  2.  
  3. Helper that visualizes the boundary of a target {{#crossLink "Component"}}{{/crossLink}} subtype with a World-space axis-aligned boundary (AABB).
  4.  
  5. @class AABBHelper
  6. @constructor
  7. @param cfg {*} Configuration
  8. @param [cfg.target] {Number|String|Component} ID or instance of a {{#crossLink "Component"}}{{/crossLink}} subtype with a World-space axis-aligned boundary (AABB).
  9. @param [cfg.color=[0.4,0.4,0.4]] {Float32Array} Emmissive color
  10. @param [cfg.visible=true] {Boolean} Indicates whether or not this helper is visible.
  11.  
  12. */
  13. xeogl.AABBHelper = class xeoglAABBHelper extends xeogl.Component{
  14.  
  15. init(cfg) {
  16.  
  17. super.init(cfg);
  18.  
  19. this._box = new xeogl.Mesh(this, {
  20. geometry: new xeogl.AABBGeometry(this),
  21. material: new xeogl.PhongMaterial(this, {
  22. emissive: [1, 0, 0],
  23. diffuse: [0, 0, 0],
  24. lineWidth: 4
  25. }),
  26. pickable: false,
  27. collidable: false,
  28. clippable: false
  29. });
  30.  
  31. this.target = cfg.target;
  32. this.color = cfg.color;
  33. this.visible = cfg.visible;
  34. }
  35.  
  36. /**
  37. * The target {{#crossLink "Component"}}{{/crossLink}} subtype.
  38. *
  39. * Must be within the same {{#crossLink "Scene"}}{{/crossLink}} as this CameraFollowAnimation. Defaults to the parent
  40. * {{#crossLink "Scene"}}Scene{{/crossLink}} when set to a null or undefined value.
  41. *
  42. * @property target
  43. * @type Component
  44. */
  45. set target(target) {
  46. this._box.geometry.target = target;
  47. }
  48.  
  49. get target() {
  50. return this._box.geometry.target;
  51. }
  52.  
  53. /**
  54. * Emissive color of this AABBHelper.
  55. *
  56. * @property color
  57. * @default [0,1,0]
  58. * @type {Float32Array}
  59. */
  60. set color(value) {
  61. this._box.material.emissive = value || [0, 1, 0];
  62. }
  63.  
  64. get color() {
  65. return this._box.emissive;
  66. }
  67.  
  68. /**
  69. Indicates whether this AABBHelper is visible or not.
  70.  
  71. Fires a {{#crossLink "AABBHelper/visible:event"}}{{/crossLink}} event on change.
  72.  
  73. @property visible
  74. @default true
  75. @type Boolean
  76. */
  77. set visible(value) {
  78. value = value !== false;
  79. this._box.visible = value;
  80. }
  81.  
  82. get visible() {
  83. return this._box.visible;
  84. }
  85. };
  86.