2
0

DragControls.html 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. [page:EventDispatcher] &rarr;
  12. <h1>[name]</h1>
  13. <p class="desc">
  14. This class can be used to provide a drag'n'drop interaction.
  15. </p>
  16. <h2>Code Example</h2>
  17. <code>
  18. var controls = new DragControls( objects, camera, renderer.domElement );
  19. // add event listener to highlight dragged objects
  20. controls.addEventListener( 'dragstart', function ( event ) {
  21. event.object.material.emissive.set( 0xaaaaaa );
  22. } );
  23. controls.addEventListener( 'dragend', function ( event ) {
  24. event.object.material.emissive.set( 0x000000 );
  25. } );
  26. </code>
  27. <h2>Examples</h2>
  28. <p>[example:misc_controls_drag misc / controls / drag ]</p>
  29. <h2>Constructor</h2>
  30. <h3>[name]( [param:Array objects], [param:Camera camera], [param:HTMLDOMElement domElement] )</h3>
  31. <p>
  32. <p>
  33. [page:Array objects]: An array of draggable 3D objects.
  34. </p>
  35. <p>
  36. [page:Camera camera]: The camera of the rendered scene.
  37. </p>
  38. <p>
  39. [page:HTMLDOMElement domElement]: The HTML element used for event listeners.
  40. </p>
  41. <p>
  42. Creates a new instance of [name].
  43. </p>
  44. </p>
  45. <h2>Events</h2>
  46. <h3>dragstart</h3>
  47. <p>
  48. Fires when the user starts to drag a 3D object.
  49. </p>
  50. <h3>drag</h3>
  51. <p>
  52. Fires when the user drags a 3D object.
  53. </p>
  54. <h3>dragend</h3>
  55. <p>
  56. Fires when the user has finished dragging a 3D object.
  57. </p>
  58. <h3>hoveron</h3>
  59. <p>
  60. Fires when the pointer is moved onto a 3D object, or onto one of its children.
  61. </p>
  62. <h3>hoveroff</h3>
  63. <p>
  64. Fires when the pointer is moved out of a 3D object.
  65. </p>
  66. <h2>Properties</h2>
  67. <h3>[property:Boolean enabled]</h3>
  68. <p>
  69. Whether or not the controls are enabled.
  70. </p>
  71. <h3>[property:Boolean transformGroup]</h3>
  72. <p>
  73. This option only works if the [page:DragControls.objects] array contains a single draggable group object.
  74. If set to *true*, [name] does not transform individual objects but the entire group. Default is *false*.
  75. </p>
  76. <h2>Methods</h2>
  77. <p>See the base [page:EventDispatcher] class for common methods.</p>
  78. <h3>[method:null activate] ()</h3>
  79. <p>
  80. Adds the event listeners of the controls.
  81. </p>
  82. <h3>[method:null deactivate] ()</h3>
  83. <p>
  84. Removes the event listeners of the controls.
  85. </p>
  86. <h3>[method:null dispose] ()</h3>
  87. <p>
  88. Should be called if the controls is no longer required.
  89. </p>
  90. <h3>[method:Array getObjects] ()</h3>
  91. <p>
  92. Returns the array of draggable objects.
  93. </p>
  94. <h2>Source</h2>
  95. <p>
  96. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/DragControls.js examples/jsm/controls/DragControls.js]
  97. </p>
  98. </body>
  99. </html>