DragControls.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <meta charset="utf-8" />
  5. <base href="../../../" />
  6. <script src="page.js"></script>
  7. <link type="text/css" rel="stylesheet" href="page.css" />
  8. </head>
  9. <body>
  10. [page:EventDispatcher] &rarr;
  11. <h1>拖放控制器([name])</h1>
  12. <p class="desc">
  13. 该类被用于提供一个拖放交互。
  14. </p>
  15. <h2>进口</h2>
  16. <p>
  17. [name] 是一个附加组件,必须显式导入。
  18. See [link:#manual/introduction/Installation Installation / Addons].
  19. </p>
  20. <code>
  21. import { DragControls } from 'three/addons/controls/DragControls.js';
  22. </code>
  23. <h2>代码示例</h2>
  24. <code>
  25. const controls = new DragControls( objects, camera, renderer.domElement );
  26. // add event listener to highlight dragged objects
  27. controls.addEventListener( 'dragstart', function ( event ) {
  28. event.object.material.emissive.set( 0xaaaaaa );
  29. } );
  30. controls.addEventListener( 'dragend', function ( event ) {
  31. event.object.material.emissive.set( 0x000000 );
  32. } );
  33. </code>
  34. <h2>例子</h2>
  35. <p>[example:misc_controls_drag misc / controls / drag ]</p>
  36. <h2>Constructor</h2>
  37. <h3>[name]( [param:Array objects], [param:Camera camera], [param:HTMLDOMElement domElement] )</h3>
  38. <p>
  39. <p>
  40. [page:Array objects]: 一组可被拖拽的3D Objects。
  41. </p>
  42. <p>
  43. [page:Camera camera]: 渲染场景的摄像机。
  44. </p>
  45. <p>
  46. [page:HTMLDOMElement domElement]: 用于事件监听的HTML元素。
  47. </p>
  48. <p>
  49. 创建一个新的 [name] 实例。
  50. </p>
  51. </p>
  52. <h2>事件</h2>
  53. <h3>dragstart</h3>
  54. <p>
  55. 当用户开始拖拽3D Objects时触发。
  56. </p>
  57. <h3>drag</h3>
  58. <p>
  59. 当用户拖拽3D Objects时触发。
  60. </p>
  61. <h3>dragend</h3>
  62. <p>
  63. 当用户开始完成3D Objects时触发。
  64. </p>
  65. <h3>hoveron</h3>
  66. <p>
  67. 当指针移动到一个3D Object或者其某个子级上时触发。
  68. </p>
  69. <h3>hoveroff</h3>
  70. <p>
  71. 当指针移出一个3D Object时触发。
  72. </p>
  73. <h2>属性</h2>
  74. <h3>[property:Boolean enabled]</h3>
  75. <p>
  76. 是否启用控制器。
  77. </p>
  78. <h3>[property:Boolean transformGroup]</h3>
  79. <p>
  80. This option only works if the [page:DragControls.objects] array contains a single draggable group object.
  81. If set to *true*, [name] does not transform individual objects but the entire group. Default is *false*.
  82. </p>
  83. <h2>Methods</h2>
  84. <p>共有方法请参见其基类[page:EventDispatcher]。</p>
  85. <h3>[method:undefined activate] ()</h3>
  86. <p>
  87. 添加控制器的事件监听。
  88. </p>
  89. <h3>[method:undefined deactivate] ()</h3>
  90. <p>
  91. 移除控制器的事件监听。
  92. </p>
  93. <h3>[method:undefined dispose] ()</h3>
  94. <p>
  95. 若不再需要该控制器,则应当调用此函数。
  96. </p>
  97. <h3>[method:Array getObjects] ()</h3>
  98. <p>
  99. Returns the array of draggable objects.
  100. </p>
  101. <h3>[method:Raycaster getRaycaster] ()</h3>
  102. <p>
  103. Returns the internal [page:Raycaster] instance that is used for intersection tests.
  104. </p>
  105. <h2>Source</h2>
  106. <p>
  107. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/DragControls.js examples/jsm/controls/DragControls.js]
  108. </p>
  109. </body>
  110. </html>