TransformControls.html 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <!DOCTYPE html>
  2. <html lang="en">
  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:Controls] &rarr;
  11. <h1>[name]</h1>
  12. <p class="desc">
  13. This class can be used to transform objects in 3D space by adapting a similar interaction model of DCC tools like Blender.
  14. Unlike other controls, it is not intended to transform the scene's camera.<br /><br />
  15. [name] expects that its attached 3D object is part of the scene graph.
  16. </p>
  17. <h2>Import</h2>
  18. <p>
  19. [name] is an add-on, and must be imported explicitly.
  20. See [link:#manual/introduction/Installation Installation / Addons].
  21. </p>
  22. <code>
  23. import { TransformControls } from 'three/addons/controls/TransformControls.js';
  24. </code>
  25. <h2>Examples</h2>
  26. <p>[example:misc_controls_transform misc / controls / transform ]</p>
  27. <h2>Constructor</h2>
  28. <h3>[name]( [param:Camera camera], [param:HTMLDOMElement domElement] )</h3>
  29. <p>
  30. [page:Camera camera]: The camera of the rendered scene.
  31. </p>
  32. <p>
  33. [page:HTMLDOMElement domElement]: The HTML element used for event listeners. (optional)
  34. </p>
  35. <p>
  36. Creates a new instance of [name].
  37. </p>
  38. <h2>Events</h2>
  39. <h3>change</h3>
  40. <p>
  41. Fires if any type of change (object or property change) is performed. Property changes
  42. are separate events you can add event listeners to. The event type is "propertyname-changed".
  43. </p>
  44. <h3>mouseDown</h3>
  45. <p>
  46. Fires if a pointer (mouse/touch) becomes active.
  47. </p>
  48. <h3>mouseUp</h3>
  49. <p>
  50. Fires if a pointer (mouse/touch) is no longer active.
  51. </p>
  52. <h3>objectChange</h3>
  53. <p>
  54. Fires if the controlled 3D object is changed.
  55. </p>
  56. <h2>Properties</h2>
  57. <p>See the base [page:Controls] class for common properties.</p>
  58. <h3>[property:String axis]</h3>
  59. <p>
  60. The current transformation axis.
  61. </p>
  62. <h3>[property:Camera camera]</h3>
  63. <p>
  64. The camera of the rendered scene.
  65. </p>
  66. <h3>[property:Boolean dragging]</h3>
  67. <p>
  68. Whether or not dragging is currently performed. Read-only property.
  69. </p>
  70. <h3>[property:String mode]</h3>
  71. <p>
  72. The current transformation mode. Possible values are "translate", "rotate" and "scale". Default is `translate`.
  73. </p>
  74. <h3>[property:Number rotationSnap]</h3>
  75. <p>
  76. By default, 3D objects are continuously rotated. If you set this property to a numeric value (radians), you can define in which
  77. steps the 3D object should be rotated. Default is `null`.
  78. </p>
  79. <h3>[property:Boolean showX]</h3>
  80. <p>
  81. Whether or not the x-axis helper should be visible. Default is `true`.
  82. </p>
  83. <h3>[property:Boolean showY]</h3>
  84. <p>
  85. Whether or not the y-axis helper should be visible. Default is `true`.
  86. </p>
  87. <h3>[property:Boolean showZ]</h3>
  88. <p>
  89. Whether or not the z-axis helper should be visible. Default is `true`.
  90. </p>
  91. <h3>[property:Number size]</h3>
  92. <p>
  93. The size of the helper UI (axes/planes). Default is *1*.
  94. </p>
  95. <h3>[property:String space]</h3>
  96. <p>
  97. Defines in which coordinate space transformations should be performed. Possible values are "world" and "local". Default is `world`.
  98. </p>
  99. <h3>[property:Number translationSnap]</h3>
  100. <p>
  101. By default, 3D objects are continuously translated. If you set this property to a numeric value (world units), you can define in which
  102. steps the 3D object should be translated. Default is `null`.
  103. </p>
  104. <h3>[property:Number minX]</h3>
  105. <p>
  106. The minimum allowed X position during translation. Default is `-Infinity`.
  107. </p>
  108. <h3>[property:Number maxX]</h3>
  109. <p>
  110. The maximum allowed X position during translation. Default is `Infinity`.
  111. </p>
  112. <h3>[property:Number minY]</h3>
  113. <p>
  114. The minimum allowed Y position during translation. Default is `-Infinity`.
  115. </p>
  116. <h3>[property:Number maxY]</h3>
  117. <p>
  118. The maximum allowed Y position during translation. Default is `Infinity`.
  119. </p>
  120. <h3>[property:Number minZ]</h3>
  121. <p>
  122. The minimum allowed Z position during translation. Default is `-Infinity`.
  123. </p>
  124. <h3>[property:Number maxZ]</h3>
  125. <p>
  126. The maximum allowed Z position during translation. Default is `Infinity`.
  127. </p>
  128. <h2>Methods</h2>
  129. <p>See the base [page:Controls] class for common methods.</p>
  130. <h3>[method:TransformControls attach] ( [param:Object3D object] )</h3>
  131. <p>
  132. <p>
  133. [page:Object3D object]: The 3D object that should be transformed.
  134. </p>
  135. <p>
  136. Sets the 3D object that should be transformed and ensures the controls UI is visible.
  137. </p>
  138. </p>
  139. <h3>[method:TransformControls detach] ()</h3>
  140. <p>
  141. Removes the current 3D object from the controls and makes the helper UI invisible.
  142. </p>
  143. <h3>[method:Object3D getHelper] ()</h3>
  144. <p>
  145. Returns the visual representation of the controls. Add the helper to your scene to visually transform the attached
  146. 3D object.
  147. </p>
  148. <h3>[method:Raycaster getRaycaster] ()</h3>
  149. <p>
  150. Returns the [page:Raycaster] object that is used for user interaction. This object is shared between all instances of
  151. TransformControls. If you set the [page:Object3D.layers .layers] property of the [name], you will also want to
  152. set the [page:Raycaster.layers .layers] property on the [page:Raycaster] with a matching value, or else the [name]
  153. won't work as expected.
  154. </p>
  155. <h3>[method:String getMode] ()</h3>
  156. <p>
  157. Returns the transformation mode.
  158. </p>
  159. <h3>[method:undefined reset] ()</h3>
  160. <p>
  161. Resets the object's position, rotation and scale to when the current transform began.
  162. </p>
  163. <h3>[method:undefined setMode] ( [param:String mode] )</h3>
  164. <p>
  165. <p>
  166. [page:String mode]: The transformation mode.
  167. </p>
  168. <p>
  169. Sets the transformation mode.
  170. </p>
  171. </p>
  172. <h3>[method:undefined setRotationSnap] ( [param:Number rotationSnap] )</h3>
  173. <p>
  174. <p>
  175. [page:Number rotationSnap]: The rotation snap.
  176. </p>
  177. <p>
  178. Sets the rotation snap.
  179. </p>
  180. </p>
  181. <h3>[method:undefined setScaleSnap] ( [param:Number scaleSnap] )</h3>
  182. <p>
  183. <p>
  184. [page:Number scaleSnap]: The scale snap.
  185. </p>
  186. <p>
  187. Sets the scale snap.
  188. </p>
  189. </p>
  190. <h3>[method:undefined setSize] ( [param:Number size] )</h3>
  191. <p>
  192. <p>
  193. [page:Number size]: The size of the helper UI.
  194. </p>
  195. <p>
  196. Sets the size of the helper UI.
  197. </p>
  198. </p>
  199. <h3>[method:undefined setSpace] ( [param:String space] )</h3>
  200. <p>
  201. <p>
  202. [page:String space]: The coordinate space in which transformations are applied.
  203. </p>
  204. <p>
  205. Sets the coordinate space in which transformations are applied.
  206. </p>
  207. </p>
  208. <h3>[method:undefined setTranslationSnap] ( [param:Number translationSnap] )</h3>
  209. <p>
  210. <p>
  211. [page:Number translationSnap]: The translation snap.
  212. </p>
  213. <p>
  214. Sets the translation snap.
  215. </p>
  216. </p>
  217. <h2>Source</h2>
  218. <p>
  219. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/TransformControls.js examples/jsm/controls/TransformControls.js]
  220. </p>
  221. </body>
  222. </html>
粤ICP备19079148号