OrbitControls.html 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. <h1>[name]</h1>
  11. <p class="desc">
  12. 궤도 컨트롤을 사용하면 카메라가 대상 주위를 공전 할 수 있습니다.<br>
  13. 이것을 사용하려면, / examples 디렉토리의 모든 파일들이 HTML에 별도의 파일을 포함해야합니다.
  14. </p>
  15. <h2>코드 예시</h2>
  16. <code>
  17. const renderer = new THREE.WebGLRenderer();
  18. renderer.setSize( window.innerWidth, window.innerHeight );
  19. document.body.appendChild( renderer.domElement );
  20. const scene = new THREE.Scene();
  21. const camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
  22. const controls = new OrbitControls( camera, renderer.domElement );
  23. //controls.update()는 카메라 변환설정을 수동으로 변경한 후에 호출해야 합니다.
  24. camera.position.set( 0, 20, 100 );
  25. controls.update();
  26. function animate() {
  27. requestAnimationFrame( animate );
  28. // 만약 controls.enableDamping, controls.autoRotate 둘 중 하나라도 true로 설정될 경우 필수로 호출되어야 합니다.
  29. controls.update();
  30. renderer.render( scene, camera );
  31. }
  32. </code>
  33. <h2>예시</h2>
  34. <p>[example:misc_controls_orbit misc / controls / orbit ]</p>
  35. <h2>생성자</h2>
  36. <h3>[name]( [param:Camera object], [param:HTMLDOMElement domElement] )</h3>
  37. <p>
  38. [page:Camera object]: (필수) 제어할 카메라 객체 입니다. 해당 객체가 장면에 포함되지 않을 경우 다른 객체의 자식이 아니여야 합니다..<br><br>
  39. [page:HTMLDOMElement domElement]: 이벤트 리스너에 사용되는 HTML 엘리먼트입니다.
  40. </p>
  41. <h2>이벤트</h2>
  42. <h3>변경</h3>
  43. <p>
  44. 컨트롤에 의해 카메라가 변환되면 호출됩니다.
  45. </p>
  46. <h3>start</h3>
  47. <p>
  48. 상호 작용이 시작되면 호출됩니다.
  49. </p>
  50. <h3>end</h3>
  51. <p>
  52. 상호 작용이 끝나면 호출됩니다.
  53. </p>
  54. <h2>특성</h2>
  55. <h3>[property:Boolean autoRotate]</h3>
  56. <p>
  57. 대상 주위를 자동으로 회전하려면 true로 설정합니다.<br> autoRotate를 활성할 경우, 애니메이션 루프에서 [page:.update()]를 호출해야 합니다.
  58. </p>
  59. <h3>[property:Float autoRotateSpeed]</h3>
  60. <p>
  61. [page:.autoRotate]가 true일 경우, 타겟을 기준으로 주위의 회전 속도를 설정합니다. 기본값은 2.0 이고, 60fps에서 회전 당 30초에 해당합니다.
  62. <br>만약 [page:.autoRotate]를 활성할 경우, 에니메이션 루프에서 [page:.update]를 호출해야 합니다.
  63. </p>
  64. <h3>
  65. [property:Float dampingFactor]</h3>
  66. <p> [page:.enableDamping]이 true일 경우 에니메이션 루프에서 [page:.update]()를 호출해야만 감쇠 관성를 사용할 수 있습니다.
  67. </p>
  68. <h3>[property:HTMLDOMElement domElement]</h3>
  69. <p>
  70. 마우스 / 터치 이벤트를 수신하는 데 사용되는 HTMLDOMElement입니다. 이것은 생성자에 의해 설정되어야 합니다; 생성자를 통해 설정되지 않을 경우 새 이벤트 리스너에 설정되지 않습니다.
  71. </p>
  72. <h3>[property:Boolean enabled]</h3>
  73. <p>
  74. *false*로 설정할 경우, 컨트롤은 사용자 입력에 응답하지 못합니다. 기본값은 *true* 입니다.
  75. </p>
  76. <h3>[property:Boolean enableDamping]</h3>
  77. <p>
  78. 컨트롤의 가중치를 부여하는 데 사용할 수있는 댐핑 (관성)을 활성화하려면 true로 설정합니다.<br>
  79. 만약 enableDamping을 활성화 할 경우, 애니메이션 루프에서 [page:.update]를 호출해야 합니다.
  80. </p>
  81. <h3>[property:Boolean enableKeys]</h3>
  82. <p>
  83. Enable or disable the use of keyboard controls.
  84. </p>
  85. <h3>[property:Boolean enablePan]</h3>
  86. <p>
  87. Enable or disable camera panning. Default is true.
  88. </p>
  89. <h3>[property:Boolean enableRotate]</h3>
  90. <p>
  91. Enable or disable horizontal and vertical rotation of the camera. Default is true.<br>
  92. Note that it is possible to disable a single axis by setting the min and max of the
  93. [page:.minPolarAngle polar angle] or [page:.minAzimuthAngle azimuth angle] to the same value,
  94. which will cause the vertical or horizontal rotation to be fixed at that value.
  95. </p>
  96. <h3>[property:Boolean enableZoom]</h3>
  97. <p>
  98. Enable or disable zooming (dollying) of the camera.
  99. </p>
  100. <h3>[property:Float keyPanSpeed]</h3>
  101. <p>
  102. How fast to pan the camera when the keyboard is used. Default is 7.0 pixels per keypress.
  103. </p>
  104. <h3>[property:Object keys]</h3>
  105. <p>
  106. This object contains references to the keycodes for controlling camera panning. Default is the 4 arrow keys.
  107. <code>
  108. controls.keys = {
  109. LEFT: 37, //left arrow
  110. UP: 38, // up arrow
  111. RIGHT: 39, // right arrow
  112. BOTTOM: 40 // down arrow
  113. }
  114. </code> See [link:https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode this page] for a full
  115. list of keycodes.
  116. </p>
  117. <h3>[property:Float maxAzimuthAngle]</h3>
  118. <p>
  119. How far you can orbit horizontally, upper limit. If set, the interval [ min, max ] must be a sub-interval of [ - 2 PI, 2 PI ], with ( max - min < 2 PI ). Default is Infinity.
  120. </p>
  121. <h3>[property:Float maxDistance]</h3>
  122. <p>
  123. How far you can dolly out ( [page:PerspectiveCamera] only ). Default is Infinity.
  124. </p>
  125. <h3>[property:Float maxPolarAngle]</h3>
  126. <p>
  127. How far you can orbit vertically, upper limit. Range is 0 to Math.PI radians, and default is Math.PI.
  128. </p>
  129. <h3>[property:Float maxZoom]</h3>
  130. <p>
  131. How far you can zoom out ( [page:OrthographicCamera] only ). Default is Infinity.
  132. </p>
  133. <h3>[property:Float minAzimuthAngle]</h3>
  134. <p>
  135. How far you can orbit horizontally, lower limit. If set, the interval [ min, max ] must be a sub-interval of [ - 2 PI, 2 PI ], with ( max - min < 2 PI ). Default is Infinity.
  136. </p>
  137. <h3>[property:Float minDistance]</h3>
  138. <p>
  139. How far you can dolly in ( [page:PerspectiveCamera] only ). Default is 0.
  140. </p>
  141. <h3>[property:Float minPolarAngle]</h3>
  142. <p>
  143. How far you can orbit vertically, lower limit. Range is 0 to Math.PI radians, and default is 0.
  144. </p>
  145. <h3>[property:Float minZoom]</h3>
  146. <p>
  147. How far you can zoom in ( [page:OrthographicCamera] only ). Default is 0.
  148. </p>
  149. <h3>
  150. [property:Object mouseButtons]</h3>
  151. <p>
  152. This object contains references to the mouse actions used by the controls.
  153. <code>
  154. controls.mouseButtons = {
  155. LEFT: THREE.MOUSE.ROTATE,
  156. MIDDLE: THREE.MOUSE.DOLLY,
  157. RIGHT: THREE.MOUSE.PAN
  158. }
  159. </code>
  160. </p>
  161. <h3>[property:Camera object]</h3>
  162. <p>
  163. The camera being controlled.
  164. </p>
  165. <h3>[property:Float panSpeed]</h3>
  166. <p>
  167. Speed of panning. Default is 1.
  168. </p>
  169. <h3>[property:Vector3 position0]</h3>
  170. <p>
  171. Used internally by the [method:saveState] and [method:reset] methods.
  172. </p>
  173. <h3>[property:Float rotateSpeed]</h3>
  174. <p>
  175. Speed of rotation. Default is 1.
  176. </p>
  177. <h3>[property:Boolean screenSpacePanning]</h3>
  178. <p>
  179. Defines how the camera's position is translated when panning. If true, the camera pans in screen space.
  180. Otherwise, the camera pans in the plane orthogonal to the camera's up direction.
  181. Default is true for OrbitControls; false for MapControls.
  182. </p>
  183. <h3>[property:Vector3 target0]</h3>
  184. <p>
  185. Used internally by the [method:saveState] and [method:reset] methods.
  186. </p>
  187. <h3>[property:Vector3 target]</h3>
  188. <p>
  189. The focus point of the controls, the [page:.object] orbits around this. It can be updated manually at any point to change
  190. the focus of the controls.
  191. </p>
  192. <h3>[property:Object touches]</h3>
  193. <p>
  194. This object contains references to the touch actions used by the controls.
  195. <code>
  196. controls.touches = {
  197. ONE: THREE.TOUCH.ROTATE,
  198. TWO: THREE.TOUCH.DOLLY_PAN
  199. }
  200. </code>
  201. </p>
  202. <h3>[property:Float zoom0]</h3>
  203. <p>
  204. Used internally by the [method:saveState] and [method:reset] methods.
  205. </p>
  206. <h3>[property:Float zoomSpeed]</h3>
  207. <p>
  208. Speed of zooming / dollying. Default is 1.
  209. </p>
  210. <h2>Methods</h2>
  211. <h3>[method:null dispose] ()</h3>
  212. <p>
  213. Remove all the event listeners.
  214. </p>
  215. <h3>[method:radians getAzimuthalAngle] ()</h3>
  216. <p>
  217. Get the current horizontal rotation, in radians.
  218. </p>
  219. <h3>[method:radians getPolarAngle] ()</h3>
  220. <p>
  221. Get the current vertical rotation, in radians.
  222. </p>
  223. <h3>[method:null reset] ()</h3>
  224. <p>
  225. Reset the controls to their state from either the last time the [page:.saveState] was called, or the initial state.
  226. </p>
  227. <h3>[method:null saveState] ()</h3>
  228. <p>
  229. Save the current state of the controls. This can later be recovered with [page:.reset].
  230. </p>
  231. <h3>[method:Boolean update] ()</h3>
  232. <p>
  233. Update the controls. Must be called after any manual changes to the camera's transform,
  234. or in the update loop if [page:.autoRotate] or [page:.enableDamping] are set.
  235. </p>
  236. <h2>Source</h2>
  237. <p>
  238. [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/controls/OrbitControls.js examples/jsm/controls/OrbitControls.js]
  239. </p>
  240. </body>
  241. </html>