Source: extern/anchors.js

  1. import register from "../util/register.js";
  2. import m_anchors_fact from "../intern/anchors.js";
  3. /**
  4. * Anchors are Empty objects assigned in Blender.
  5. * They are used to project 3D points or HTML elements to the 2D screen.
  6. * <p>For more info about anchor configuration check out the {@link https://www.blend4web.com/doc/en/objects.html#anchor-settings|user manual}.
  7. * @module anchors
  8. * @local AnchorMoveCallback
  9. */
  10. function Anchors(ns, exports) {
  11. var m_anchors = m_anchors_fact(ns);
  12. /**
  13. * The callback for the movement of the anchor.
  14. * @callback AnchorMoveCallback
  15. * @param {number} x X (left) canvas coordinate.
  16. * @param {number} y Y (top) canvas coordinate.
  17. * @param {string} appearance Anchor appearance, one of "visible", "out",
  18. * "covered"
  19. * @param {Object3D} obj Anchor object.
  20. * @param {?HTMLElement} anchor Anchor HTML element
  21. */
  22. /**
  23. * Attach the movement callback to the anchor object.
  24. * @method module:anchors.attach_move_cb
  25. * @param {Object3D} obj Anchor object.
  26. * @param {AnchorMoveCallback} anchor_move_cb Anchor movement callback
  27. */
  28. exports.attach_move_cb = m_anchors.attach_move_cb;
  29. /**
  30. * Detach the movement callback from the anchor object.
  31. * @method module:anchors.detach_move_cb
  32. * @param {Object3D} obj Anchor object.
  33. */
  34. exports.detach_move_cb = m_anchors.detach_move_cb;
  35. /**
  36. * Check if the given object is an anchor.
  37. * @method module:anchors.is_anchor
  38. * @param {Object3D} obj Anchor object.
  39. * @returns {boolean} Check result.
  40. */
  41. exports.is_anchor = m_anchors.is_anchor;
  42. /**
  43. * Get anchor element ID.
  44. * @method module:anchors.get_element_id
  45. * @param {Object3D} obj Anchor object.
  46. * @returns {string|boolean} Element ID or FALSE if the given object is not a
  47. * valid anchor.
  48. */
  49. exports.get_element_id = m_anchors.get_element_id;
  50. /**
  51. * Force update positions of anchors.
  52. * @method module:anchors.update
  53. */
  54. exports.update = function() {
  55. m_anchors.update(true);
  56. }
  57. }
  58. var anchors_factory = register("anchors", Anchors);
  59. export default anchors_factory;