@aibee/owlly 1.0.25 → 1.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (359) hide show
  1. package/lib/external/lines/line-geometry.d.ts +9 -0
  2. package/lib/external/lines/line-geometry.js +51 -0
  3. package/lib/external/lines/line-material.d.ts +10 -0
  4. package/lib/external/lines/line-material.js +376 -0
  5. package/lib/external/lines/line-segments-2.d.ts +7 -0
  6. package/lib/external/lines/line-segments-2.js +143 -0
  7. package/lib/external/lines/line-segments-geometry.d.ts +15 -0
  8. package/lib/external/lines/line-segments-geometry.js +140 -0
  9. package/lib/external/loaders/gltf-loader.d.ts +77 -0
  10. package/lib/external/loaders/gltf-loader.js +2318 -0
  11. package/lib/external/orbit-controls.d.ts +44 -0
  12. package/lib/external/orbit-controls.js +745 -0
  13. package/lib/external/renderers/css-2d-renderer.d.ts +16 -0
  14. package/lib/external/renderers/css-2d-renderer.js +121 -0
  15. package/lib/external/renderers/css-3d-renderer.d.ts +18 -0
  16. package/lib/external/renderers/css-3d-renderer.js +138 -0
  17. package/lib/external/transform-controls.d.ts +106 -0
  18. package/lib/external/transform-controls.js +1112 -0
  19. package/lib/owlly/controller/aerial-element-controller.d.ts +65 -0
  20. package/lib/owlly/controller/aerial-element-controller.js +235 -0
  21. package/lib/owlly/controller/basic-controller.d.ts +324 -0
  22. package/lib/owlly/controller/basic-controller.js +1238 -0
  23. package/lib/owlly/controller/camera-controller.d.ts +37 -0
  24. package/lib/owlly/controller/camera-controller.js +137 -0
  25. package/lib/owlly/controller/controller.d.ts +61 -0
  26. package/lib/owlly/controller/controller.js +23 -0
  27. package/lib/owlly/controller/index.d.ts +2 -0
  28. package/lib/owlly/controller/index.js +13 -0
  29. package/lib/owlly/controller/mouse-indicator-controller.d.ts +34 -0
  30. package/lib/owlly/controller/mouse-indicator-controller.js +118 -0
  31. package/lib/owlly/controller/orbit-control.d.ts +147 -0
  32. package/lib/owlly/controller/orbit-control.js +264 -0
  33. package/lib/owlly/controller/panorama-adjust-controller.d.ts +45 -0
  34. package/lib/owlly/controller/panorama-adjust-controller.js +157 -0
  35. package/lib/owlly/controller/panorama-controller.d.ts +441 -0
  36. package/lib/owlly/controller/panorama-controller.js +1943 -0
  37. package/lib/owlly/controller/panorama-transform-controller.d.ts +66 -0
  38. package/lib/owlly/controller/panorama-transform-controller.js +136 -0
  39. package/lib/owlly/controller/plane-controller.d.ts +43 -0
  40. package/lib/owlly/controller/plane-controller.js +173 -0
  41. package/lib/owlly/controller/texture-controller.d.ts +181 -0
  42. package/lib/owlly/controller/texture-controller.js +875 -0
  43. package/lib/owlly/controller/tile-panorama-controller.d.ts +308 -0
  44. package/lib/owlly/controller/tile-panorama-controller.js +1353 -0
  45. package/lib/owlly/controller/transform-controller.d.ts +106 -0
  46. package/lib/owlly/controller/transform-controller.js +545 -0
  47. package/lib/owlly/element/bottom-nav-element.d.ts +65 -0
  48. package/lib/owlly/element/bottom-nav-element.js +257 -0
  49. package/lib/owlly/element/camera.d.ts +82 -0
  50. package/lib/owlly/element/camera.js +283 -0
  51. package/lib/owlly/element/dom-2d-element.d.ts +35 -0
  52. package/lib/owlly/element/dom-2d-element.js +48 -0
  53. package/lib/owlly/element/dom-3d-element.d.ts +27 -0
  54. package/lib/owlly/element/dom-3d-element.js +33 -0
  55. package/lib/owlly/element/dom-label-2d.d.ts +116 -0
  56. package/lib/owlly/element/dom-label-2d.js +382 -0
  57. package/lib/owlly/element/element.d.ts +53 -0
  58. package/lib/owlly/element/element.js +75 -0
  59. package/lib/owlly/element/floor-model.d.ts +83 -0
  60. package/lib/owlly/element/floor-model.js +227 -0
  61. package/lib/owlly/element/gif-kit/Gif.d.ts +96 -0
  62. package/lib/owlly/element/gif-kit/Gif.js +432 -0
  63. package/lib/owlly/element/gif-kit/GifColor.d.ts +21 -0
  64. package/lib/owlly/element/gif-kit/GifColor.js +37 -0
  65. package/lib/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.d.ts +20 -0
  66. package/lib/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.js +50 -0
  67. package/lib/owlly/element/gif-kit/GifFrame.d.ts +31 -0
  68. package/lib/owlly/element/gif-kit/GifFrame.js +96 -0
  69. package/lib/owlly/element/gif-kit/GifImage.d.ts +23 -0
  70. package/lib/owlly/element/gif-kit/GifImage.js +7 -0
  71. package/lib/owlly/element/gif-kit/GifParser.d.ts +17 -0
  72. package/lib/owlly/element/gif-kit/GifParser.js +196 -0
  73. package/lib/owlly/element/gif-kit/GifPresenter.d.ts +20 -0
  74. package/lib/owlly/element/gif-kit/GifPresenter.js +43 -0
  75. package/lib/owlly/element/gif-kit/GifVersion.d.ts +10 -0
  76. package/lib/owlly/element/gif-kit/GifVersion.js +12 -0
  77. package/lib/owlly/element/gltf-mesh-element.d.ts +31 -0
  78. package/lib/owlly/element/gltf-mesh-element.js +136 -0
  79. package/lib/owlly/element/index.d.ts +20 -0
  80. package/lib/owlly/element/index.js +24 -0
  81. package/lib/owlly/element/map-kit/shape.d.ts +131 -0
  82. package/lib/owlly/element/map-kit/shape.js +189 -0
  83. package/lib/owlly/element/mesh-element.d.ts +22 -0
  84. package/lib/owlly/element/mesh-element.js +63 -0
  85. package/lib/owlly/element/mesh-line-2d.d.ts +82 -0
  86. package/lib/owlly/element/mesh-line-2d.js +887 -0
  87. package/lib/owlly/element/meshline-o.d.ts +64 -0
  88. package/lib/owlly/element/meshline-o.js +678 -0
  89. package/lib/owlly/element/panorama-group.d.ts +241 -0
  90. package/lib/owlly/element/panorama-group.js +966 -0
  91. package/lib/owlly/element/panorama.d.ts +132 -0
  92. package/lib/owlly/element/panorama.js +812 -0
  93. package/lib/owlly/element/path-group.d.ts +69 -0
  94. package/lib/owlly/element/path-group.js +171 -0
  95. package/lib/owlly/element/path.d.ts +99 -0
  96. package/lib/owlly/element/path.js +531 -0
  97. package/lib/owlly/element/placeable-2d.d.ts +158 -0
  98. package/lib/owlly/element/placeable-2d.js +470 -0
  99. package/lib/owlly/element/polygon-mesh.d.ts +107 -0
  100. package/lib/owlly/element/polygon-mesh.js +307 -0
  101. package/lib/owlly/element/ring-element.d.ts +79 -0
  102. package/lib/owlly/element/ring-element.js +383 -0
  103. package/lib/owlly/element/sphere-mesh.d.ts +28 -0
  104. package/lib/owlly/element/sphere-mesh.js +69 -0
  105. package/lib/owlly/element/svg-floor-model.d.ts +22 -0
  106. package/lib/owlly/element/svg-floor-model.js +184 -0
  107. package/lib/owlly/element/svg-floors.d.ts +27 -0
  108. package/lib/owlly/element/svg-floors.js +109 -0
  109. package/lib/owlly/element/tile-panorama-group.d.ts +335 -0
  110. package/lib/owlly/element/tile-panorama-group.js +1006 -0
  111. package/lib/owlly/element/tile-panorama.d.ts +161 -0
  112. package/lib/owlly/element/tile-panorama.js +509 -0
  113. package/lib/owlly/element/tile-plane.d.ts +105 -0
  114. package/lib/owlly/element/tile-plane.js +360 -0
  115. package/lib/owlly/element/video-element.d.ts +33 -0
  116. package/lib/owlly/element/video-element.js +159 -0
  117. package/lib/owlly/geometries/ExtrudeGeometry2.d.ts +15 -0
  118. package/lib/owlly/geometries/ExtrudeGeometry2.js +210 -0
  119. package/lib/owlly/index.d.ts +13 -0
  120. package/lib/owlly/index.js +16 -0
  121. package/lib/owlly/overlay/canvas-overlay.d.ts +96 -0
  122. package/lib/owlly/overlay/canvas-overlay.js +510 -0
  123. package/lib/owlly/overlay/css-2d-overlay.d.ts +14 -0
  124. package/lib/owlly/overlay/css-2d-overlay.js +35 -0
  125. package/lib/owlly/overlay/css-3d-overlay.d.ts +16 -0
  126. package/lib/owlly/overlay/css-3d-overlay.js +36 -0
  127. package/lib/owlly/overlay/index.d.ts +6 -0
  128. package/lib/owlly/overlay/index.js +11 -0
  129. package/lib/owlly/overlay/label-overlay.d.ts +62 -0
  130. package/lib/owlly/overlay/label-overlay.js +328 -0
  131. package/lib/owlly/overlay/overlay.d.ts +14 -0
  132. package/lib/owlly/overlay/overlay.js +4 -0
  133. package/lib/owlly/overlay/path-overlay.d.ts +39 -0
  134. package/lib/owlly/overlay/path-overlay.js +124 -0
  135. package/lib/owlly/overlay/path-overlay2.d.ts +35 -0
  136. package/lib/owlly/overlay/path-overlay2.js +118 -0
  137. package/lib/owlly/overlay/poi-overlay-3d.d.ts +278 -0
  138. package/lib/owlly/overlay/poi-overlay-3d.js +1432 -0
  139. package/lib/owlly/overlay/poi-overlay.d.ts +277 -0
  140. package/lib/owlly/overlay/poi-overlay.js +1411 -0
  141. package/lib/owlly/owlly-2d/index.d.ts +28 -0
  142. package/lib/owlly/owlly-2d/index.js +92 -0
  143. package/lib/owlly/screen/index.d.ts +1 -0
  144. package/lib/owlly/screen/index.js +1 -0
  145. package/lib/owlly/screen/screen.d.ts +73 -0
  146. package/lib/owlly/screen/screen.js +236 -0
  147. package/lib/owlly/stage/externals.d.ts +19 -0
  148. package/lib/owlly/stage/externals.js +24 -0
  149. package/lib/owlly/stage/index.d.ts +4 -0
  150. package/lib/owlly/stage/index.js +6 -0
  151. package/lib/owlly/stage/owlly.d.ts +38 -0
  152. package/lib/owlly/stage/owlly.js +168 -0
  153. package/lib/owlly/stage/stage.d.ts +108 -0
  154. package/lib/owlly/stage/stage.js +234 -0
  155. package/lib/owlly/utils/alignment-utils.d.ts +20 -0
  156. package/lib/owlly/utils/alignment-utils.js +63 -0
  157. package/lib/owlly/utils/basic-calc.d.ts +18 -0
  158. package/lib/owlly/utils/basic-calc.js +129 -0
  159. package/lib/owlly/utils/basic-tools.d.ts +71 -0
  160. package/lib/owlly/utils/basic-tools.js +235 -0
  161. package/lib/owlly/utils/bvh-tree.d.ts +105 -0
  162. package/lib/owlly/utils/bvh-tree.js +539 -0
  163. package/lib/owlly/utils/camera.d.ts +37 -0
  164. package/lib/owlly/utils/camera.js +50 -0
  165. package/lib/owlly/utils/cube-texture-cache.d.ts +25 -0
  166. package/lib/owlly/utils/cube-texture-cache.js +143 -0
  167. package/lib/owlly/utils/device-utils.d.ts +18 -0
  168. package/lib/owlly/utils/device-utils.js +41 -0
  169. package/lib/owlly/utils/environment-utils.d.ts +37 -0
  170. package/lib/owlly/utils/environment-utils.js +73 -0
  171. package/lib/owlly/utils/event-hub.d.ts +50 -0
  172. package/lib/owlly/utils/event-hub.js +106 -0
  173. package/lib/owlly/utils/events.d.ts +219 -0
  174. package/lib/owlly/utils/events.js +219 -0
  175. package/lib/owlly/utils/geometry-utils.d.ts +119 -0
  176. package/lib/owlly/utils/geometry-utils.js +622 -0
  177. package/lib/owlly/utils/helper.d.ts +6 -0
  178. package/lib/owlly/utils/helper.js +24 -0
  179. package/lib/owlly/utils/index.d.ts +14 -0
  180. package/lib/owlly/utils/index.js +17 -0
  181. package/lib/owlly/utils/lru-cache.d.ts +26 -0
  182. package/lib/owlly/utils/lru-cache.js +109 -0
  183. package/lib/owlly/utils/map-utils.d.ts +7 -0
  184. package/lib/owlly/utils/map-utils.js +52 -0
  185. package/lib/owlly/utils/number-utils.d.ts +8 -0
  186. package/lib/owlly/utils/number-utils.js +72 -0
  187. package/lib/owlly/utils/panorama-model-util.d.ts +46 -0
  188. package/lib/owlly/utils/panorama-model-util.js +245 -0
  189. package/lib/owlly/utils/path-utils.d.ts +80 -0
  190. package/lib/owlly/utils/path-utils.js +728 -0
  191. package/lib/owlly/utils/svgutils.d.ts +138 -0
  192. package/lib/owlly/utils/svgutils.js +561 -0
  193. package/lib/owlly/utils/texture-cache.d.ts +29 -0
  194. package/lib/owlly/utils/texture-cache.js +115 -0
  195. package/lib/owlly/utils/tile-util.d.ts +187 -0
  196. package/lib/owlly/utils/tile-util.js +456 -0
  197. package/lib/owlly/utils/time-profiler.d.ts +21 -0
  198. package/lib/owlly/utils/time-profiler.js +48 -0
  199. package/lib/owlly/view/camera-view.d.ts +35 -0
  200. package/lib/owlly/view/camera-view.js +101 -0
  201. package/lib/owlly/view/index.d.ts +3 -0
  202. package/lib/owlly/view/index.js +5 -0
  203. package/lib/owlly/view/orthographic-view.d.ts +40 -0
  204. package/lib/owlly/view/orthographic-view.js +94 -0
  205. package/lib/owlly/view/perspective-view.d.ts +40 -0
  206. package/lib/owlly/view/perspective-view.js +95 -0
  207. package/lib/owlly/view/svg-map-view.d.ts +46 -0
  208. package/lib/owlly/view/svg-map-view.js +144 -0
  209. package/lib/owlly/view/view.d.ts +146 -0
  210. package/lib/owlly/view/view.js +317 -0
  211. package/lib/prod/owlly.esm.js +93462 -0
  212. package/lib/prod/owlly.esm.js.map +1 -0
  213. package/lib/prod/owlly.esm.min.js +54 -0
  214. package/lib/prod/owlly.iife.js +93560 -0
  215. package/lib/prod/owlly.iife.js.map +1 -0
  216. package/lib/prod/owlly.iife.min.js +69 -0
  217. package/lib/prod/owlly.miniapp.js +73845 -0
  218. package/lib/prod/owlly.miniapp.js.map +1 -0
  219. package/lib/prod/owlly.miniapp.min.js +63 -0
  220. package/lib/prod/src/external/lines/line-geometry.d.ts +9 -0
  221. package/lib/prod/src/external/lines/line-material.d.ts +10 -0
  222. package/lib/prod/src/external/lines/line-segments-2.d.ts +7 -0
  223. package/lib/prod/src/external/lines/line-segments-geometry.d.ts +15 -0
  224. package/lib/prod/src/external/loaders/gltf-loader.d.ts +77 -0
  225. package/lib/prod/src/external/orbit-controls.d.ts +44 -0
  226. package/lib/prod/src/external/renderers/css-2d-renderer.d.ts +16 -0
  227. package/lib/prod/src/external/renderers/css-3d-renderer.d.ts +18 -0
  228. package/lib/prod/src/external/transform-controls.d.ts +106 -0
  229. package/lib/prod/src/external/util/buffer-geometry-utils.d.ts +45 -0
  230. package/lib/prod/src/owlly/controller/aerial-element-controller.d.ts +65 -0
  231. package/lib/prod/src/owlly/controller/basic-controller.d.ts +324 -0
  232. package/lib/prod/src/owlly/controller/camera-controller.d.ts +37 -0
  233. package/lib/prod/src/owlly/controller/controller.d.ts +61 -0
  234. package/lib/prod/src/owlly/controller/index.d.ts +2 -0
  235. package/lib/prod/src/owlly/controller/mouse-indicator-controller.d.ts +34 -0
  236. package/lib/prod/src/owlly/controller/orbit-control.d.ts +147 -0
  237. package/lib/prod/src/owlly/controller/panorama-adjust-controller.d.ts +45 -0
  238. package/lib/prod/src/owlly/controller/panorama-controller.d.ts +441 -0
  239. package/lib/prod/src/owlly/controller/panorama-transform-controller.d.ts +66 -0
  240. package/lib/prod/src/owlly/controller/plane-controller.d.ts +43 -0
  241. package/lib/prod/src/owlly/controller/texture-controller.d.ts +183 -0
  242. package/lib/prod/src/owlly/controller/tile-panorama-controller.d.ts +308 -0
  243. package/lib/prod/src/owlly/controller/transform-controller.d.ts +106 -0
  244. package/lib/prod/src/owlly/element/bottom-nav-element.d.ts +65 -0
  245. package/lib/prod/src/owlly/element/camera.d.ts +82 -0
  246. package/lib/prod/src/owlly/element/dom-2d-element.d.ts +35 -0
  247. package/lib/prod/src/owlly/element/dom-3d-element.d.ts +27 -0
  248. package/lib/prod/src/owlly/element/dom-label-2d.d.ts +116 -0
  249. package/lib/prod/src/owlly/element/element.d.ts +53 -0
  250. package/lib/prod/src/owlly/element/floor-model.d.ts +83 -0
  251. package/lib/prod/src/owlly/element/gif-kit/Gif.d.ts +96 -0
  252. package/lib/prod/src/owlly/element/gif-kit/GifColor.d.ts +21 -0
  253. package/lib/prod/src/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.d.ts +20 -0
  254. package/lib/prod/src/owlly/element/gif-kit/GifFrame.d.ts +31 -0
  255. package/lib/prod/src/owlly/element/gif-kit/GifImage.d.ts +23 -0
  256. package/lib/prod/src/owlly/element/gif-kit/GifParser.d.ts +17 -0
  257. package/lib/prod/src/owlly/element/gif-kit/GifPresenter.d.ts +20 -0
  258. package/lib/prod/src/owlly/element/gif-kit/GifVersion.d.ts +10 -0
  259. package/lib/prod/src/owlly/element/gltf-mesh-element.d.ts +31 -0
  260. package/lib/prod/src/owlly/element/index.d.ts +6 -0
  261. package/lib/prod/src/owlly/element/map-kit/area.d.ts +24 -0
  262. package/lib/prod/src/owlly/element/map-kit/block-set.d.ts +39 -0
  263. package/lib/prod/src/owlly/element/map-kit/block.d.ts +77 -0
  264. package/lib/prod/src/owlly/element/map-kit/index.d.ts +3 -0
  265. package/lib/prod/src/owlly/element/map-kit/shape.d.ts +131 -0
  266. package/lib/prod/src/owlly/element/mesh-element.d.ts +22 -0
  267. package/lib/prod/src/owlly/element/mesh-line-2d.d.ts +82 -0
  268. package/lib/prod/src/owlly/element/meshline-o.d.ts +64 -0
  269. package/lib/prod/src/owlly/element/panorama-group.d.ts +241 -0
  270. package/lib/prod/src/owlly/element/panorama.d.ts +132 -0
  271. package/lib/prod/src/owlly/element/path-group.d.ts +69 -0
  272. package/lib/prod/src/owlly/element/path.d.ts +99 -0
  273. package/lib/prod/src/owlly/element/placeable-2d.d.ts +158 -0
  274. package/lib/prod/src/owlly/element/polygon-mesh.d.ts +107 -0
  275. package/lib/prod/src/owlly/element/ring-element.d.ts +79 -0
  276. package/lib/prod/src/owlly/element/sphere-mesh.d.ts +28 -0
  277. package/lib/prod/src/owlly/element/svg-floor-model.d.ts +22 -0
  278. package/lib/prod/src/owlly/element/svg-floors.d.ts +27 -0
  279. package/lib/prod/src/owlly/element/tile-panorama-group.d.ts +335 -0
  280. package/lib/prod/src/owlly/element/tile-panorama.d.ts +162 -0
  281. package/lib/prod/src/owlly/element/tile-plane.d.ts +114 -0
  282. package/lib/prod/src/owlly/element/video-element.d.ts +33 -0
  283. package/lib/prod/src/owlly/geometries/ExtrudeGeometry2.d.ts +15 -0
  284. package/lib/prod/src/owlly/index.d.ts +13 -0
  285. package/lib/prod/src/owlly/overlay/canvas-overlay.d.ts +96 -0
  286. package/lib/prod/src/owlly/overlay/css-2d-overlay.d.ts +14 -0
  287. package/lib/prod/src/owlly/overlay/css-3d-overlay.d.ts +16 -0
  288. package/lib/prod/src/owlly/overlay/index.d.ts +5 -0
  289. package/lib/prod/src/owlly/overlay/label-overlay.d.ts +62 -0
  290. package/lib/prod/src/owlly/overlay/overlay.d.ts +14 -0
  291. package/lib/prod/src/owlly/overlay/path-overlay.d.ts +39 -0
  292. package/lib/prod/src/owlly/overlay/path-overlay2.d.ts +35 -0
  293. package/lib/prod/src/owlly/overlay/poi-overlay-3d.d.ts +278 -0
  294. package/lib/prod/src/owlly/overlay/poi-overlay.d.ts +277 -0
  295. package/lib/prod/src/owlly/owlly-2d/index.d.ts +28 -0
  296. package/lib/prod/src/owlly/screen/index.d.ts +1 -0
  297. package/lib/prod/src/owlly/screen/screen.d.ts +73 -0
  298. package/lib/prod/src/owlly/stage/__test__/stage.spec.d.ts +1 -0
  299. package/lib/prod/src/owlly/stage/externals.d.ts +19 -0
  300. package/lib/prod/src/owlly/stage/index.d.ts +3 -0
  301. package/lib/prod/src/owlly/stage/owlly.d.ts +38 -0
  302. package/lib/prod/src/owlly/stage/stage.d.ts +108 -0
  303. package/lib/prod/src/owlly/utils/alignment-utils.d.ts +20 -0
  304. package/lib/prod/src/owlly/utils/basic-calc.d.ts +18 -0
  305. package/lib/prod/src/owlly/utils/basic-tools.d.ts +71 -0
  306. package/lib/prod/src/owlly/utils/bvh-tree.d.ts +105 -0
  307. package/lib/prod/src/owlly/utils/camera.d.ts +37 -0
  308. package/lib/prod/src/owlly/utils/cube-texture-cache.d.ts +25 -0
  309. package/lib/prod/src/owlly/utils/device-utils.d.ts +18 -0
  310. package/lib/prod/src/owlly/utils/environment-utils.d.ts +37 -0
  311. package/lib/prod/src/owlly/utils/event-hub.d.ts +50 -0
  312. package/lib/prod/src/owlly/utils/events.d.ts +219 -0
  313. package/lib/prod/src/owlly/utils/geometry-utils.d.ts +119 -0
  314. package/lib/prod/src/owlly/utils/helper.d.ts +6 -0
  315. package/lib/prod/src/owlly/utils/index.d.ts +13 -0
  316. package/lib/prod/src/owlly/utils/lru-cache.d.ts +26 -0
  317. package/lib/prod/src/owlly/utils/map-utils.d.ts +7 -0
  318. package/lib/prod/src/owlly/utils/number-utils.d.ts +8 -0
  319. package/lib/prod/src/owlly/utils/panorama-model-util.d.ts +46 -0
  320. package/lib/prod/src/owlly/utils/path-utils.d.ts +80 -0
  321. package/lib/prod/src/owlly/utils/svgutils.d.ts +138 -0
  322. package/lib/prod/src/owlly/utils/texture-cache.d.ts +29 -0
  323. package/lib/prod/src/owlly/utils/tile-util.d.ts +187 -0
  324. package/lib/prod/src/owlly/utils/time-profiler.d.ts +21 -0
  325. package/lib/prod/src/owlly/view/__test__/perspective-view.spec.d.ts +0 -0
  326. package/lib/prod/src/owlly/view/camera-view.d.ts +35 -0
  327. package/lib/prod/src/owlly/view/index.d.ts +3 -0
  328. package/lib/prod/src/owlly/view/orthographic-view.d.ts +40 -0
  329. package/lib/prod/src/owlly/view/perspective-view.d.ts +40 -0
  330. package/lib/prod/src/owlly/view/svg-map-view.d.ts +46 -0
  331. package/lib/prod/src/owlly/view/view.d.ts +146 -0
  332. package/lib/src/owlly/controller/texture-controller.d.ts +3 -1
  333. package/lib/src/owlly/controller/texture-controller.js +16 -1
  334. package/lib/src/owlly/controller/texture-controller.js.map +1 -1
  335. package/lib/src/owlly/controller/tile-panorama-controller.js +4 -0
  336. package/lib/src/owlly/controller/tile-panorama-controller.js.map +1 -1
  337. package/lib/src/owlly/element/tile-panorama.d.ts +1 -0
  338. package/lib/src/owlly/element/tile-panorama.js +16 -3
  339. package/lib/src/owlly/element/tile-panorama.js.map +1 -1
  340. package/lib/src/owlly/element/tile-plane.d.ts +9 -0
  341. package/lib/src/owlly/element/tile-plane.js +27 -0
  342. package/lib/src/owlly/element/tile-plane.js.map +1 -1
  343. package/lib/src/owlly/overlay/poi-overlay-3d.js.map +1 -1
  344. package/lib/src/owlly/overlay/poi-overlay.js.map +1 -1
  345. package/lib/src/owlly/stage/owlly.js +7 -1
  346. package/lib/src/owlly/stage/owlly.js.map +1 -1
  347. package/lib/src/owlly/stage/stage.js +2 -0
  348. package/lib/src/owlly/stage/stage.js.map +1 -1
  349. package/lib/src/web/main.rpeng.mes.plane.js.map +1 -1
  350. package/package.json +16 -7
  351. package/src/owlly/controller/texture-controller.ts +18 -1
  352. package/src/owlly/controller/tile-panorama-controller.ts +3 -1
  353. package/src/owlly/element/tile-panorama.ts +14 -0
  354. package/src/owlly/element/tile-plane.ts +26 -0
  355. package/src/owlly/overlay/poi-overlay-3d.ts +0 -4
  356. package/src/owlly/overlay/poi-overlay.ts +0 -4
  357. package/src/owlly/stage/owlly.ts +6 -1
  358. package/src/owlly/stage/stage.ts +2 -0
  359. package/src/web/main.rpeng.mes.plane.ts +0 -6
@@ -0,0 +1,1238 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import TWEEN from '@tweenjs/tween.js';
11
+ import { Externals, NS_THREE } from '../stage/externals';
12
+ import { Controller } from './controller';
13
+ import { Events, OwllyEvents } from '../utils/events';
14
+ import { Env, EnvironmentUtils } from '../utils/environment-utils';
15
+ import { BasicTools } from '../utils';
16
+ var STATE;
17
+ (function (STATE) {
18
+ STATE[STATE["IDLE"] = 0] = "IDLE";
19
+ STATE[STATE["ROTATE"] = 1] = "ROTATE";
20
+ STATE[STATE["ORBIT"] = 2] = "ORBIT";
21
+ STATE[STATE["PAN"] = 3] = "PAN";
22
+ STATE[STATE["DOLLY"] = 4] = "DOLLY";
23
+ STATE[STATE["TOUCH_ROTATE"] = 5] = "TOUCH_ROTATE";
24
+ STATE[STATE["TOUCH_ORBIT"] = 6] = "TOUCH_ORBIT";
25
+ STATE[STATE["TOUCH_PAN"] = 7] = "TOUCH_PAN";
26
+ STATE[STATE["TOUCH_DOLLY_ROTATE"] = 8] = "TOUCH_DOLLY_ROTATE";
27
+ STATE[STATE["TOUCH_DOLLY_PAN"] = 9] = "TOUCH_DOLLY_PAN";
28
+ STATE[STATE["TOUCH_MAP"] = 10] = "TOUCH_MAP";
29
+ })(STATE || (STATE = {}));
30
+ const EPS = 0.000001;
31
+ class BasicController extends Controller {
32
+ constructor(view) {
33
+ super();
34
+ const { THREE } = Externals.getInstance();
35
+ this.eventListeners = {
36
+ onMouseDown: (e) => { this.onMouseDown(e); },
37
+ onMouseMove: (e) => { this.onMouseMove(e); },
38
+ onMouseUp: (e) => { this.onMouseUp(e); },
39
+ onMouseWheel: (e) => { this.onMouseWheel(e); },
40
+ onTouchStart: (e) => { this.onTouchStart(e); },
41
+ onTouchMove: (e) => { this.onTouchMove(e); },
42
+ onTouchEnd: (e) => { this.onTouchEnd(e); },
43
+ onContextMenu: (e) => { this.onContextMenu(e); },
44
+ };
45
+ this.state = STATE.IDLE;
46
+ this.enabled = true;
47
+ this.target = new THREE.Vector3();
48
+ this.lastTick = Date.now();
49
+ this.enableDamping = false;
50
+ this.dampingFactor = 0;
51
+ this.mouseButtons = {
52
+ LEFT: THREE.MOUSE.ROTATE,
53
+ MIDDLE: THREE.MOUSE.DOLLY,
54
+ RIGHT: THREE.MOUSE.PAN,
55
+ };
56
+ this.touches = { ONE: THREE.TOUCH.ROTATE, TWO: THREE.TOUCH.DOLLY_PAN };
57
+ this.boundaryEnabled = false;
58
+ this.boundary = new THREE.Box3(new THREE.Vector3(-Infinity, -Infinity, -Infinity), new THREE.Vector3(Infinity, Infinity, Infinity));
59
+ this.touchCenter = new THREE.Vector2();
60
+ this.inertiaFactor = 1;
61
+ this.enableRotate = true;
62
+ this.rotateMode = 'self';
63
+ this.rotateSpeed = 1;
64
+ this.rotateStart = new THREE.Vector2();
65
+ this.rotateEnd = new THREE.Vector2();
66
+ this.rotateDelta = new THREE.Vector2();
67
+ this.rotateLineStart = new THREE.Vector2();
68
+ this.rotateLineEnd = new THREE.Vector2();
69
+ this.rotateInertiaDirection = new THREE.Vector2();
70
+ this.rotateInertiaEnabled = true;
71
+ this.rotateInertiaBase = 0;
72
+ this.rotateInertia = 0;
73
+ this.rotateInertiaType = 'normal';
74
+ this.spherical = new THREE.Spherical();
75
+ this.sphericalDelta = new THREE.Spherical();
76
+ this.maxSpherical = new THREE.Spherical(1, Infinity, Infinity);
77
+ this.minSpherical = new THREE.Spherical(1, -Infinity, -Infinity);
78
+ this.lastQuaternion = new THREE.Quaternion();
79
+ this.enableZoom = true;
80
+ this.dollyStart = new THREE.Vector2();
81
+ this.dollyEnd = new THREE.Vector2();
82
+ this.zoomMode = 'zoom';
83
+ this.zoomDelta = 0;
84
+ this.zoomRange = { min: 1, max: 10 };
85
+ this.fovRange = { min: 60, max: 90 };
86
+ this.zoomInertiaEnabled = true;
87
+ this.zoomInertiaBase = 0;
88
+ this.zoomInertia = 0;
89
+ this.zoomScale = 1;
90
+ this.enablePan = true;
91
+ this.panStart = new THREE.Vector2();
92
+ this.panDelta = new THREE.Vector2();
93
+ this.panEnd = new THREE.Vector2();
94
+ this.panOffset = new THREE.Vector3();
95
+ this.panSpeed = 1;
96
+ this.screenSpacePanning = true;
97
+ this.lastPosition = new THREE.Vector3();
98
+ this.panInertiaDirection = new THREE.Vector2();
99
+ this.panInertiaEnabled = true;
100
+ this.panInertiaBase = 0;
101
+ this.panInertia = 0;
102
+ this.mouseXY = new THREE.Vector2();
103
+ this.bindView(view);
104
+ }
105
+ registerEvents() {
106
+ if (!this.bindingView)
107
+ return;
108
+ this.bindingView.on(OwllyEvents.MOUSE_DOWN, this.eventListeners.onMouseDown);
109
+ this.bindingView.on(OwllyEvents.MOUSE_MOVE, this.eventListeners.onMouseMove);
110
+ this.bindingView.on(OwllyEvents.MOUSE_UP, this.eventListeners.onMouseUp);
111
+ this.bindingView.on(OwllyEvents.MOUSE_WHEEL, this.eventListeners.onMouseWheel);
112
+ this.bindingView.on(OwllyEvents.TOUCH_START, this.eventListeners.onTouchStart);
113
+ this.bindingView.on(OwllyEvents.TOUCH_MOVE, this.eventListeners.onTouchMove);
114
+ this.bindingView.on(OwllyEvents.TOUCH_END, this.eventListeners.onTouchEnd);
115
+ this.bindingView.on(OwllyEvents.CONTEXT_MENU, this.eventListeners.onContextMenu);
116
+ }
117
+ unregisterEvents() {
118
+ if (!this.bindingView)
119
+ return;
120
+ this.bindingView.off(OwllyEvents.MOUSE_DOWN, this.eventListeners.onMouseDown);
121
+ this.bindingView.off(OwllyEvents.MOUSE_MOVE, this.eventListeners.onMouseMove);
122
+ this.bindingView.off(OwllyEvents.MOUSE_UP, this.eventListeners.onMouseUp);
123
+ this.bindingView.off(OwllyEvents.MOUSE_WHEEL, this.eventListeners.onMouseWheel);
124
+ this.bindingView.off(OwllyEvents.TOUCH_START, this.eventListeners.onTouchStart);
125
+ this.bindingView.off(OwllyEvents.TOUCH_MOVE, this.eventListeners.onTouchMove);
126
+ this.bindingView.off(OwllyEvents.TOUCH_END, this.eventListeners.onTouchEnd);
127
+ this.bindingView.off(OwllyEvents.CONTEXT_MENU, this.eventListeners.onContextMenu);
128
+ }
129
+ /* Event Callbacks */
130
+ onMouseDown(e) {
131
+ e.preventDefault();
132
+ let mouseAction;
133
+ switch (e.button) {
134
+ case 0:
135
+ mouseAction = this.mouseButtons.LEFT;
136
+ break;
137
+ case 1:
138
+ mouseAction = this.mouseButtons.MIDDLE;
139
+ break;
140
+ case 2:
141
+ mouseAction = this.mouseButtons.RIGHT;
142
+ break;
143
+ default: break;
144
+ }
145
+ switch (mouseAction) {
146
+ case NS_THREE.MOUSE.ROTATE:
147
+ if (this.enableRotate)
148
+ this.state = STATE.ROTATE;
149
+ break;
150
+ case NS_THREE.MOUSE.PAN:
151
+ if (this.enablePan)
152
+ this.state = STATE.PAN;
153
+ break;
154
+ case NS_THREE.MOUSE.DOLLY:
155
+ if (this.enableZoom)
156
+ this.state = STATE.DOLLY;
157
+ break;
158
+ default:
159
+ this.state = STATE.IDLE;
160
+ break;
161
+ }
162
+ switch (this.state) {
163
+ case STATE.ROTATE:
164
+ this.handleMouseDownRotate(e);
165
+ break;
166
+ case STATE.PAN:
167
+ this.handleMouseDownPan(e);
168
+ break;
169
+ case STATE.DOLLY:
170
+ this.handleMouseDownDolly(e);
171
+ break;
172
+ default: break;
173
+ }
174
+ if (this.state !== STATE.IDLE) {
175
+ if (this.bindingView) {
176
+ this.bindingView.on(OwllyEvents.MOUSE_MOVE, this.eventListeners.onMouseMove);
177
+ this.bindingView.on(OwllyEvents.MOUSE_UP, this.eventListeners.onMouseUp);
178
+ }
179
+ this.panInertiaBase = 0;
180
+ this.rotateInertiaBase = 0;
181
+ this.zoomInertiaBase = 0;
182
+ }
183
+ }
184
+ onMouseMove(e) {
185
+ e.preventDefault();
186
+ switch (this.state) {
187
+ case STATE.ROTATE:
188
+ this.handleMouseMoveSelfRotate(e);
189
+ break;
190
+ case STATE.PAN:
191
+ this.handleMouseMovePan(e);
192
+ break;
193
+ case STATE.DOLLY:
194
+ this.handleMouseMoveDolly(e);
195
+ break;
196
+ default: break;
197
+ }
198
+ }
199
+ onMouseUp(e) {
200
+ e.preventDefault();
201
+ if (this.bindingView) {
202
+ this.bindingView.off(OwllyEvents.MOUSE_MOVE, this.eventListeners.onMouseMove);
203
+ this.bindingView.off(OwllyEvents.MOUSE_UP, this.eventListeners.onMouseUp);
204
+ }
205
+ switch (this.state) {
206
+ case STATE.ROTATE:
207
+ this.handleUpRotate();
208
+ break;
209
+ case STATE.PAN:
210
+ this.handleUpPan();
211
+ break;
212
+ default: break;
213
+ }
214
+ this.state = STATE.IDLE;
215
+ }
216
+ onMouseWheel(e) {
217
+ if (!this.enableZoom || (this.state !== STATE.IDLE && this.state !== STATE.ROTATE))
218
+ return;
219
+ e.preventDefault();
220
+ e.stopPropagation();
221
+ this.handleMouseWheel(e);
222
+ }
223
+ onContextMenu(e) {
224
+ e.preventDefault();
225
+ }
226
+ onTouchStart(e) {
227
+ if (EnvironmentUtils.GetEnv() !== Env.Miniapp) {
228
+ e.preventDefault();
229
+ }
230
+ this.timeStart = e.timeStamp;
231
+ switch (e.touches.length) {
232
+ case 1:
233
+ switch (this.touches.ONE) {
234
+ case NS_THREE.TOUCH.PAN:
235
+ if (this.enablePan)
236
+ this.state = STATE.TOUCH_PAN;
237
+ break;
238
+ case NS_THREE.TOUCH.ROTATE:
239
+ if (this.enableRotate)
240
+ this.state = STATE.TOUCH_ROTATE;
241
+ break;
242
+ default:
243
+ this.state = STATE.IDLE;
244
+ break;
245
+ }
246
+ break;
247
+ case 2:
248
+ this.touchCenter.set((e.touches[0].clientX + e.touches[1].clientX) / 2, (e.touches[0].clientY + e.touches[1].clientY) / 2);
249
+ switch (this.touches.TWO) {
250
+ case NS_THREE.TOUCH.DOLLY_PAN:
251
+ this.state = STATE.TOUCH_DOLLY_PAN;
252
+ break;
253
+ case NS_THREE.TOUCH.DOLLY_ROTATE:
254
+ this.state = STATE.TOUCH_DOLLY_ROTATE;
255
+ break;
256
+ case 'map':
257
+ this.state = STATE.TOUCH_MAP;
258
+ break;
259
+ default:
260
+ this.state = STATE.IDLE;
261
+ break;
262
+ }
263
+ break;
264
+ default:
265
+ this.state = STATE.IDLE;
266
+ break;
267
+ }
268
+ switch (this.state) {
269
+ case STATE.TOUCH_PAN:
270
+ this.handleTouchStartPan(e);
271
+ break;
272
+ case STATE.TOUCH_ROTATE:
273
+ this.handleTouchStartRotate(e);
274
+ break;
275
+ case STATE.TOUCH_DOLLY_ROTATE:
276
+ this.handleTouchStartDollyRotate(e);
277
+ break;
278
+ case STATE.TOUCH_DOLLY_PAN:
279
+ this.handleTouchStartDollyPan(e);
280
+ break;
281
+ case STATE.TOUCH_MAP:
282
+ this.handleTouchStartMap(e);
283
+ break;
284
+ default: break;
285
+ }
286
+ if (this.state !== STATE.IDLE) {
287
+ if (this.bindingView) {
288
+ this.bindingView.on(OwllyEvents.MOUSE_MOVE, this.eventListeners.onMouseMove);
289
+ this.bindingView.on(OwllyEvents.MOUSE_UP, this.eventListeners.onMouseUp);
290
+ }
291
+ this.panInertiaBase = 0;
292
+ this.rotateInertiaBase = 0;
293
+ this.zoomInertiaBase = 0;
294
+ }
295
+ }
296
+ onTouchMove(e) {
297
+ if (EnvironmentUtils.GetEnv() !== Env.Miniapp) {
298
+ e.preventDefault();
299
+ }
300
+ if (e.touches.length === 2) {
301
+ this.touchCenter.set((e.touches[0].clientX + e.touches[1].clientX) / 2, (e.touches[0].clientY + e.touches[1].clientY) / 2);
302
+ }
303
+ switch (this.state) {
304
+ case STATE.TOUCH_PAN:
305
+ this.handleTouchMovePan(e);
306
+ break;
307
+ case STATE.TOUCH_ROTATE:
308
+ this.handleTouchMoveSelfRotate(e);
309
+ break;
310
+ case STATE.TOUCH_DOLLY_ROTATE:
311
+ this.handleTouchMoveDollyRotate(e);
312
+ break;
313
+ case STATE.TOUCH_DOLLY_PAN:
314
+ this.handleTouchMoveDollyPan(e);
315
+ break;
316
+ case STATE.TOUCH_MAP:
317
+ this.handleTouchMoveAll(e);
318
+ break;
319
+ default: break;
320
+ }
321
+ this.timeEnd = this.timeStart;
322
+ this.timeStart = e.timeStamp;
323
+ }
324
+ onTouchEnd(e) {
325
+ if (EnvironmentUtils.GetEnv() !== Env.Miniapp) {
326
+ e.preventDefault();
327
+ }
328
+ switch (this.state) {
329
+ case STATE.TOUCH_ROTATE:
330
+ case STATE.TOUCH_DOLLY_ROTATE:
331
+ this.handleUpRotate();
332
+ break;
333
+ case STATE.TOUCH_PAN:
334
+ case STATE.TOUCH_DOLLY_PAN:
335
+ this.handleUpPan();
336
+ break;
337
+ case STATE.TOUCH_MAP:
338
+ this.handleUpAll();
339
+ break;
340
+ default: break;
341
+ }
342
+ this.state = STATE.IDLE;
343
+ }
344
+ /* Action Handlers */
345
+ handleMouseDownRotate(e) {
346
+ this.handleDownRotate(e.offsetX, e.offsetY);
347
+ }
348
+ handleMouseMoveSelfRotate(e) {
349
+ this.handleMoveRotate(e.offsetX, e.offsetY);
350
+ }
351
+ handleTouchStartRotate(e) {
352
+ if (e.touches.length === 1) {
353
+ this.handleDownRotate(e.touches[0].clientX, e.touches[0].clientY);
354
+ }
355
+ else if (this.state === STATE.TOUCH_MAP) {
356
+ const slope = (e.touches[1].clientY - e.touches[0].clientY) / (e.touches[1].clientX - e.touches[0].clientX);
357
+ const intercept = e.touches[0].clientY - slope * e.touches[0].clientX;
358
+ this.rotateLineStart.set(slope, intercept);
359
+ }
360
+ else {
361
+ const x = 0.5 * (e.touches[0].clientX + e.touches[1].clientX);
362
+ const y = 0.5 * (e.touches[0].clientY + e.touches[1].clientY);
363
+ this.handleDownRotate(x, y);
364
+ }
365
+ }
366
+ handleTouchMoveSelfRotate(e) {
367
+ if (!this.bindingView)
368
+ return;
369
+ if (e.touches.length === 1) {
370
+ this.handleMoveRotate(e.touches[0].clientX, e.touches[0].clientY);
371
+ }
372
+ else if (this.state === STATE.TOUCH_MAP) {
373
+ const slope = (e.touches[1].clientY - e.touches[0].clientY) / (e.touches[1].clientX - e.touches[0].clientX);
374
+ const intercept = e.touches[0].clientY - slope * e.touches[0].clientX;
375
+ this.rotateLineEnd.set(slope, intercept);
376
+ if (Number.isFinite(this.rotateLineEnd.x) && Number.isFinite(this.rotateLineStart.x)) {
377
+ const interceptionX = (this.rotateLineStart.y - this.rotateLineEnd.y)
378
+ / (this.rotateLineEnd.x - this.rotateLineStart.x);
379
+ const interceptionY = slope * interceptionX + intercept;
380
+ if (Number.isFinite(interceptionX) && Number.isFinite(interceptionY)) {
381
+ let angleDelta = Math.atan(this.rotateLineEnd.x) - Math.atan(this.rotateLineStart.x);
382
+ if (Math.PI - Math.abs(angleDelta) < 0.5) {
383
+ angleDelta = -Math.sign(angleDelta) * (Math.PI - Math.abs(angleDelta));
384
+ }
385
+ if (Math.abs(angleDelta) > 0.01) {
386
+ const cameraCenter = this.rotateLineStart.clone().set(
387
+ // TODO: 这里需要处理为View的尺寸
388
+ this.bindingView.getViewWidth() / 2, this.bindingView.getViewHeight() / 2);
389
+ const rotateCenter = this.rotateLineStart.clone().set(interceptionX, interceptionY);
390
+ const cameraDelta = cameraCenter.clone().rotateAround(rotateCenter, angleDelta).sub(cameraCenter);
391
+ this.handlePanDelta(cameraDelta.x, cameraDelta.y);
392
+ this.rotateDelta.set(angleDelta, 0);
393
+ this.handleRotateSphericalDelta(this.rotateDelta.x, this.rotateDelta.y);
394
+ }
395
+ }
396
+ }
397
+ this.rotateLineStart.copy(this.rotateLineEnd);
398
+ }
399
+ else {
400
+ const x = 0.5 * (e.touches[0].clientX + e.touches[1].clientX);
401
+ const y = 0.5 * (e.touches[0].clientY + e.touches[1].clientY);
402
+ this.handleMoveRotate(x, y);
403
+ }
404
+ }
405
+ handleDownRotate(x, y) {
406
+ this.rotateStart.set(x, y);
407
+ }
408
+ handleMoveRotate(x, y) {
409
+ this.rotateEnd.set(x, y);
410
+ this.rotateDelta.subVectors(this.rotateEnd, this.rotateStart).multiplyScalar(this.rotateSpeed);
411
+ this.handleRotateDelta(this.rotateDelta.x, this.rotateDelta.y);
412
+ this.rotateStart.copy(this.rotateEnd);
413
+ }
414
+ handleRotateDelta(deltaX, deltaY) {
415
+ if (!this.bindingView)
416
+ return;
417
+ // TODO: 这里需要处理为View的尺寸
418
+ const clientHeight = this.bindingView.getViewHeight();
419
+ const xCorrection = this.rotateMode === 'self' ? -1 : 1;
420
+ let factor = 1;
421
+ if (this.camera.isPerspectiveCamera) {
422
+ const camera = this.camera;
423
+ factor *= camera.fov / camera.zoom / 360;
424
+ }
425
+ this.handleRotateSphericalDelta(-xCorrection * 2 * Math.PI * deltaX / clientHeight * factor, -2 * Math.PI * deltaY / clientHeight * factor);
426
+ }
427
+ handleRotateSphericalDelta(deltaTheta, deltaPhi) {
428
+ this.sphericalDelta.theta += deltaTheta;
429
+ this.sphericalDelta.phi += deltaPhi;
430
+ }
431
+ handleUpRotate() {
432
+ if (!this.rotateInertiaEnabled || !this.bindingView)
433
+ return;
434
+ const timeElapsed = this.timeStart - this.timeEnd;
435
+ if (this.state === STATE.TOUCH_MAP) {
436
+ // do nothing now
437
+ this.rotateInertiaType = 'map';
438
+ const speed = this.rotateDelta.x / timeElapsed;
439
+ if (Number.isFinite(speed) && speed > 0.001) {
440
+ this.rotateInertiaBase = this.rotateDelta.x / 10;
441
+ this.rotateInertiaDuration = 0;
442
+ this.rotateInertia = this.rotateInertiaBase;
443
+ }
444
+ }
445
+ else {
446
+ this.rotateInertiaType = 'normal';
447
+ const speed = this.rotateDelta.length() * this.rotateSpeed / timeElapsed;
448
+ // TODO: 这里需要处理为View的尺寸
449
+ const clientWidth = this.bindingView.getViewWidth();
450
+ const factor = speed * 1000 / clientWidth * 0.6;
451
+ if (timeElapsed === 0 || !Number.isFinite(speed))
452
+ return;
453
+ if (Number.isFinite(speed) && speed > 0.3) {
454
+ this.rotateInertiaBase = speed * factor * this.inertiaFactor;
455
+ this.rotateInertiaDuration = 0;
456
+ this.rotateInertiaDirection = this.rotateDelta.clone().normalize();
457
+ this.rotateInertia = this.rotateInertiaBase;
458
+ }
459
+ }
460
+ }
461
+ handleMouseDownPan(e) {
462
+ this.handleDownPan(e.offsetX, e.offsetY);
463
+ }
464
+ handleMouseMovePan(e) {
465
+ this.handleMovePan(e.offsetX, e.offsetY);
466
+ }
467
+ handleTouchStartPan(e) {
468
+ if (e.touches.length === 1) {
469
+ this.handleDownPan(e.touches[0].clientX, e.touches[0].clientY);
470
+ }
471
+ else {
472
+ const x = 0.5 * (e.touches[0].clientX + e.touches[1].clientX);
473
+ const y = 0.5 * (e.touches[0].clientY + e.touches[1].clientY);
474
+ this.handleDownPan(x, y);
475
+ }
476
+ }
477
+ handleTouchMovePan(e) {
478
+ if (e.touches.length === 1) {
479
+ this.handleMovePan(e.touches[0].clientX, e.touches[0].clientY);
480
+ }
481
+ else {
482
+ const x = 0.5 * (e.touches[0].clientX + e.touches[1].clientX);
483
+ const y = 0.5 * (e.touches[0].clientY + e.touches[1].clientY);
484
+ this.handleMovePan(x, y);
485
+ }
486
+ }
487
+ handleDownPan(x, y) {
488
+ this.panStart.set(x, y);
489
+ }
490
+ handleMovePan(x, y) {
491
+ this.panEnd.set(x, y);
492
+ this.panDelta.subVectors(this.panEnd, this.panStart).multiplyScalar(this.panSpeed);
493
+ this.handlePanDelta(this.panDelta.x, this.panDelta.y);
494
+ this.panStart.copy(this.panEnd);
495
+ }
496
+ handlePanDelta(deltaX, deltaY) {
497
+ if (!this.bindingView)
498
+ return;
499
+ const { THREE } = Externals.getInstance();
500
+ const v = new THREE.Vector3();
501
+ // TODO: 这里需要处理为View的尺寸
502
+ const clientWidth = this.bindingView.getViewWidth();
503
+ const clientHeight = this.bindingView.getViewHeight();
504
+ let offsetX = 0;
505
+ let offsetY = 0;
506
+ if (this.camera.isPerspectiveCamera) {
507
+ const camera = this.camera;
508
+ v.subVectors(this.target, this.camera.position);
509
+ let targetDistance = v.length();
510
+ targetDistance *= Math.tan((camera.fov / 2) * Math.PI / 180.0);
511
+ offsetX = 2 * deltaX * targetDistance / clientHeight;
512
+ offsetY = 2 * deltaY * targetDistance / clientHeight;
513
+ }
514
+ else {
515
+ const camera = this.camera;
516
+ offsetX = deltaX * (camera.right - camera.left) / camera.zoom / clientWidth;
517
+ offsetY = deltaY * (camera.top - camera.bottom) / camera.zoom / clientHeight;
518
+ }
519
+ v.setFromMatrixColumn(this.camera.matrix, 0);
520
+ v.multiplyScalar(-offsetX);
521
+ this.panOffset.add(v);
522
+ if (this.screenSpacePanning) {
523
+ v.setFromMatrixColumn(this.camera.matrix, 1);
524
+ }
525
+ else {
526
+ v.setFromMatrixColumn(this.camera.matrix, 0);
527
+ v.crossVectors(this.camera.up, v);
528
+ }
529
+ v.multiplyScalar(offsetY);
530
+ this.panOffset.add(v);
531
+ }
532
+ handleUpPan() {
533
+ if (!this.panInertiaEnabled)
534
+ return;
535
+ const timeElapsed = this.timeStart - this.timeEnd;
536
+ const speed = this.panDelta.length() * 10 * this.panSpeed / timeElapsed;
537
+ if (timeElapsed === 0 || !Number.isFinite(speed))
538
+ return;
539
+ if (Number.isFinite(speed) && speed > 1) {
540
+ this.panInertiaBase = speed * this.inertiaFactor;
541
+ this.panInertiaDuration = 0;
542
+ this.panInertiaDirection = this.panDelta.clone().normalize();
543
+ this.panInertia = this.panInertiaBase;
544
+ }
545
+ }
546
+ handleMouseWheel(e) {
547
+ this.zoomDelta = e.deltaY / 67;
548
+ this.mouseXY.set(e.offsetX, e.offsetY);
549
+ // console.log(e);
550
+ }
551
+ handleZoom(delta) {
552
+ if (Math.abs(delta) < 0.0001)
553
+ return;
554
+ let zoomChange = 0;
555
+ let lastPos = null;
556
+ if (this.followMouse) {
557
+ lastPos = BasicTools.getHorizontalPlaneCoordinate3({ x: this.mouseXY.x, y: this.mouseXY.y }, this.bindingView, this.camera);
558
+ }
559
+ // eslint-disable-next-line no-param-reassign
560
+ delta *= this.zoomScale;
561
+ if (this.zoomMode === 'zoom') {
562
+ const tZoom = Math.min(Math.max(this.camera.zoom * (1 + delta), this.zoomRange.min), this.zoomRange.max);
563
+ zoomChange = tZoom - this.camera.zoom;
564
+ this.camera.zoom = tZoom;
565
+ }
566
+ else if (this.camera.isPerspectiveCamera) {
567
+ const camera = this.camera;
568
+ camera.fov = Math.min(Math.max(camera.fov + delta * 66.67, this.fovRange.min), this.fovRange.max);
569
+ }
570
+ this.camera.updateProjectionMatrix();
571
+ this.needUpdate = true;
572
+ this.emit(Events.CAMERA_ZOOM, this.zoomMode, this.zoomMode === 'zoom' ? this.camera.zoom : this.camera.fov, this);
573
+ if (this.followMouse && zoomChange && this.bindingView) {
574
+ const nowPos = BasicTools.getHorizontalPlaneCoordinate3({ x: this.mouseXY.x, y: this.mouseXY.y }, this.bindingView, this.camera);
575
+ if (lastPos && nowPos) {
576
+ const vector = nowPos.clone().sub(lastPos);
577
+ this.setCameraPosition(this.camera.position.clone().sub(vector), true);
578
+ }
579
+ }
580
+ }
581
+ handleUpZoom() {
582
+ if (!this.zoomInertiaEnabled)
583
+ return;
584
+ const timeElapsed = this.timeStart - this.timeEnd;
585
+ const speed = this.zoomDelta / timeElapsed;
586
+ if (timeElapsed === 0 || !Number.isFinite(speed))
587
+ return;
588
+ if (Math.abs(speed) > 0.001) {
589
+ this.zoomInertiaBase = speed * this.inertiaFactor * 2;
590
+ this.zoomInertiaDuration = 0;
591
+ this.zoomInertia = this.zoomInertiaBase;
592
+ }
593
+ }
594
+ handleMouseDownDolly(e) {
595
+ this.dollyStart.set(e.offsetX, e.offsetY);
596
+ }
597
+ handleMouseMoveDolly(e) {
598
+ this.dollyEnd.set(e.offsetX, e.offsetY);
599
+ const sign = -Math.sign(this.dollyEnd.y - this.dollyStart.y);
600
+ const distance = this.dollyStart.distanceTo(this.dollyEnd);
601
+ // const { innerWidth, innerHeight } = window;
602
+ // const diagonalDist = Math.sqrt((innerWidth ** 2) + (innerHeight ** 2));
603
+ const clientWidth = this.bindingView.getViewWidth();
604
+ const clientHeight = this.bindingView.getViewHeight();
605
+ const diagonalDist = Math.sqrt((Math.pow(clientWidth, 2)) + (Math.pow(clientHeight, 2)));
606
+ const distRatio = distance / diagonalDist;
607
+ this.zoomDelta = sign * Math.floor(distRatio * diagonalDist) * EnvironmentUtils.GetGlobalDPR();
608
+ this.dollyStart.copy(this.dollyEnd);
609
+ }
610
+ handleTouchStartDolly(e) {
611
+ const dx = e.touches[0].clientX - e.touches[1].clientX;
612
+ const dy = e.touches[0].clientY - e.touches[1].clientY;
613
+ const distance = Math.sqrt(dx * dx + dy * dy);
614
+ this.dollyStart.set(0, distance);
615
+ }
616
+ handleTouchMoveDolly(e) {
617
+ if (!this.bindingView)
618
+ return;
619
+ const dx = e.touches[0].clientX - e.touches[1].clientX;
620
+ const dy = e.touches[0].clientY - e.touches[1].clientY;
621
+ const distance = Math.sqrt(dx * dx + dy * dy);
622
+ this.dollyEnd.set(0, distance);
623
+ // let innerWidth = 0;
624
+ // let innerHeight = 0;
625
+ // if (EnvironmentUtils.GetEnv() !== Env.Miniapp) {
626
+ // innerWidth = window.innerWidth;
627
+ // innerHeight = window.innerWidth;
628
+ // } else {
629
+ // innerWidth = this.bindingView.canvas.clientWidth;
630
+ // innerHeight = this.bindingView.canvas.clientHeight;
631
+ // }
632
+ const innerWidth = this.bindingView.canvas.clientWidth;
633
+ const innerHeight = this.bindingView.canvas.clientHeight;
634
+ const diagonalDist = Math.sqrt((Math.pow(innerWidth, 2)) + (Math.pow(innerHeight, 2)));
635
+ const distRatio = (distance - this.dollyStart.y) / diagonalDist;
636
+ this.zoomDelta = -distRatio;
637
+ let d = 1 + Math.abs(this.zoomDelta);
638
+ if (this.zoomDelta > 0)
639
+ d = 1 / d;
640
+ this.zoomDelta = d - 1;
641
+ this.zoomDelta *= 2;
642
+ const cameraCenter = this.touchCenter.clone().set(
643
+ // TODO: 这里需要处理为View的尺寸
644
+ this.bindingView.getViewWidth() / 2, this.bindingView.getViewHeight() / 2);
645
+ const zoomPanDelta = this.touchCenter.clone().sub(cameraCenter).multiplyScalar(-this.zoomDelta);
646
+ this.mouseXY.set(this.touchCenter.x, this.touchCenter.y);
647
+ this.zoomDelta *= EnvironmentUtils.GetGlobalDPR();
648
+ this.handlePanDelta(zoomPanDelta.x, zoomPanDelta.y);
649
+ this.dollyStart.copy(this.dollyEnd);
650
+ }
651
+ handleTouchStartDollyRotate(e) {
652
+ if (this.enableZoom)
653
+ this.handleTouchStartDolly(e);
654
+ if (this.enableRotate)
655
+ this.handleTouchStartRotate(e);
656
+ }
657
+ handleTouchMoveDollyRotate(e) {
658
+ if (this.enableZoom)
659
+ this.handleTouchMoveDolly(e);
660
+ if (this.enableRotate)
661
+ this.handleTouchMoveSelfRotate(e);
662
+ }
663
+ handleTouchStartDollyPan(e) {
664
+ if (this.enableZoom)
665
+ this.handleTouchStartDolly(e);
666
+ if (this.enablePan)
667
+ this.handleTouchStartPan(e);
668
+ }
669
+ handleTouchMoveDollyPan(e) {
670
+ if (this.enableZoom)
671
+ this.handleTouchMoveDolly(e);
672
+ if (this.enablePan)
673
+ this.handleTouchMovePan(e);
674
+ }
675
+ handleTouchStartMap(e) {
676
+ if (this.enableZoom)
677
+ this.handleTouchStartDolly(e);
678
+ if (this.enablePan)
679
+ this.handleTouchStartPan(e);
680
+ if (this.enableRotate)
681
+ this.handleTouchStartRotate(e);
682
+ }
683
+ handleTouchMoveAll(e) {
684
+ if (this.enableZoom)
685
+ this.handleTouchMoveDolly(e);
686
+ if (this.enablePan)
687
+ this.handleTouchMovePan(e);
688
+ if (this.enableRotate)
689
+ this.handleTouchMoveSelfRotate(e);
690
+ }
691
+ handleUpAll() {
692
+ this.handleUpZoom();
693
+ this.handleUpPan();
694
+ this.handleUpRotate();
695
+ }
696
+ resetVectors() {
697
+ this.panInertiaBase = 0;
698
+ this.panInertia = 0;
699
+ this.panDelta.set(0, 0);
700
+ this.rotateInertiaBase = 0;
701
+ this.rotateInertia = 0;
702
+ this.rotateDelta.set(0, 0);
703
+ }
704
+ /* Camera Movement */
705
+ /** @ignore 暂缓开放 */
706
+ moveCameraTo(position, duration = 1000, callbacks) {
707
+ return __awaiter(this, void 0, void 0, function* () {
708
+ return new Promise((resolve) => {
709
+ const { THREE } = Externals.getInstance();
710
+ const from = this.camera.position.clone();
711
+ const positionVector = new THREE.Vector3();
712
+ const cb = callbacks || {};
713
+ new TWEEN.Tween({ progress: 0 })
714
+ .to({ progress: 1 }, duration)
715
+ .easing(TWEEN.Easing.Quadratic.InOut)
716
+ .onUpdate(({ progress }) => {
717
+ positionVector.lerpVectors(from, position, progress);
718
+ this.camera.position.copy(positionVector);
719
+ if (cb.onUpdate)
720
+ cb.onUpdate(progress);
721
+ this.needUpdate = true;
722
+ })
723
+ .onComplete(() => {
724
+ resolve();
725
+ })
726
+ .start();
727
+ });
728
+ });
729
+ }
730
+ /* Getter & Setters */
731
+ /**
732
+ * 设置相机位置坐标
733
+ * @param position 位置坐标
734
+ * @param updateTarget 是否更新目标点坐标, 默认为true
735
+ */
736
+ setCameraPosition(position, updateTarget = true) {
737
+ const { THREE } = Externals.getInstance();
738
+ const lookAtVector = new THREE.Vector3().subVectors(this.target, this.camera.position);
739
+ this.camera.position.copy(position);
740
+ if (updateTarget)
741
+ this.target.copy(position.clone().add(lookAtVector));
742
+ this.needUpdate = true;
743
+ }
744
+ /**
745
+ * 获取相机位置坐标
746
+ */
747
+ getCameraPosition() {
748
+ return this.camera.position.clone();
749
+ }
750
+ /**
751
+ * 设置当前相机看向目标位置
752
+ * @param target 目标点坐标
753
+ * @param updateCameraPosition 是否同步更新相机位置, 默认值为false
754
+ */
755
+ setCameraLookAt(target, updateCameraPosition = false) {
756
+ const { THREE } = Externals.getInstance();
757
+ const lookAtVector = new THREE.Vector3().subVectors(this.camera.position, this.target);
758
+ this.target.copy(target);
759
+ if (updateCameraPosition)
760
+ this.camera.position.copy(target.clone().add(lookAtVector));
761
+ this.camera.lookAt(target);
762
+ this.needUpdate = true;
763
+ }
764
+ /**
765
+ * 获取相机看向目标位置
766
+ * @returns vec3
767
+ */
768
+ getCameraTarget() {
769
+ return this.target.clone();
770
+ }
771
+ /**
772
+ * 设置当前相机视线方向
773
+ * @param direction 方向向量
774
+ * @param distance 目标距离, 默认值为1
775
+ */
776
+ setCameraLookAtVector(direction, distance = 1) {
777
+ this.setCameraLookAt(this.camera.position.clone().add(direction.normalize().multiplyScalar(distance)));
778
+ }
779
+ /**
780
+ * 设置是否开启阻尼
781
+ * @param enable 布尔值
782
+ */
783
+ setDampingEnabled(enable) {
784
+ this.enableDamping = enable;
785
+ }
786
+ /**
787
+ * 设置阻尼系数, 默认值为0
788
+ * @param factor 阻尼系数
789
+ */
790
+ setDampingFactor(factor) {
791
+ this.dampingFactor = factor;
792
+ }
793
+ /**
794
+ * 获取阻尼系数
795
+ */
796
+ getDampingFactor() {
797
+ return this.dampingFactor;
798
+ }
799
+ /**
800
+ * 设置是否激活缩放
801
+ * @param enable 布尔值
802
+ */
803
+ setZoomEnabled(enable) {
804
+ this.enableZoom = enable;
805
+ }
806
+ /**
807
+ * 设置放大模式, 可选值: 'zoom': 使用变焦放大, 'fov': 使用fov放大
808
+ * @param mode 放大模式
809
+ */
810
+ setZoomMode(mode) {
811
+ if (this.camera.isOrthographicCamera && mode === 'fov') {
812
+ throw new Error('[BasicController] Cannot use fov zoom mode for OrthographicCamera');
813
+ }
814
+ this.zoomMode = mode;
815
+ }
816
+ /**
817
+ * 设置相机fov范围, 默认值为[60, 90]
818
+ * @param min 最小值
819
+ * @param max 最大值
820
+ */
821
+ setFovRange(min, max) {
822
+ this.fovRange.min = min;
823
+ this.fovRange.max = max;
824
+ if (!this.camera.isPerspectiveCamera)
825
+ return;
826
+ const camera = this.camera;
827
+ camera.fov = Math.min(Math.max(camera.fov, this.fovRange.min), this.fovRange.max);
828
+ camera.updateProjectionMatrix();
829
+ this.needUpdate = true;
830
+ }
831
+ /**
832
+ * 设置当前相机fov, 仅限透视投影相机使用
833
+ * @param fov FOV值
834
+ */
835
+ setFov(fov) {
836
+ if (!this.camera.isPerspectiveCamera)
837
+ return;
838
+ const camera = this.camera;
839
+ camera.fov = Math.min(Math.max(fov, this.fovRange.min), this.fovRange.max);
840
+ camera.updateProjectionMatrix();
841
+ this.needUpdate = true;
842
+ }
843
+ /**
844
+ * 获取当前相机fov, 仅限透视投影相机使用
845
+ */
846
+ getFov() {
847
+ if (!this.camera.isPerspectiveCamera)
848
+ return null;
849
+ return this.camera.fov;
850
+ }
851
+ /**
852
+ * 设置变焦倍数范围, 默认值为[0, 10]
853
+ * @param min 最小值
854
+ * @param max 最大值
855
+ */
856
+ setZoomRange(min, max) {
857
+ this.zoomRange.min = min;
858
+ this.zoomRange.max = max;
859
+ this.camera.zoom = Math.min(Math.max(this.camera.zoom, this.zoomRange.min), this.zoomRange.max);
860
+ this.camera.updateProjectionMatrix();
861
+ this.needUpdate = true;
862
+ }
863
+ /**
864
+ * 设置当前变焦倍数, 倍数受倍数范围影响
865
+ * @param zoom 变焦倍数
866
+ */
867
+ setZoom(zoom) {
868
+ this.camera.zoom = Math.min(Math.max(zoom, this.zoomRange.min), this.zoomRange.max);
869
+ this.camera.updateProjectionMatrix();
870
+ this.needUpdate = true;
871
+ }
872
+ /**
873
+ * 获取当前变焦倍数
874
+ */
875
+ getZoom() {
876
+ return this.camera.zoom;
877
+ }
878
+ /**
879
+ * 设置是否激活变焦的惯性
880
+ * @param enabled 布尔值
881
+ */
882
+ setZoomInertiaEnabled(enabled) {
883
+ this.zoomInertiaEnabled = enabled;
884
+ }
885
+ /**
886
+ * 设置是否激活旋转
887
+ * @param enable 布尔值
888
+ */
889
+ setRotateEnabled(enable) {
890
+ this.enableRotate = enable;
891
+ }
892
+ /**
893
+ * 设置旋转模式, 可选值 'self':自转, 'orbit': 公转
894
+ * @param mode 旋转模式
895
+ */
896
+ setRotateMode(mode) {
897
+ this.rotateMode = mode;
898
+ }
899
+ /**
900
+ * 设置旋转速度
901
+ * @param speed 旋转速度倍数
902
+ */
903
+ setRotateSpeed(speed) {
904
+ this.rotateSpeed = speed;
905
+ }
906
+ /**
907
+ * 获取旋转速度
908
+ */
909
+ getRotateSpeed() {
910
+ return this.rotateSpeed;
911
+ }
912
+ /**
913
+ * 设置是否激活旋转运动的惯性
914
+ * @param enabled 布尔值
915
+ */
916
+ setRotateInertiaEnabled(enabled) {
917
+ this.rotateInertiaEnabled = enabled;
918
+ }
919
+ /**
920
+ * 设置横向转动角度
921
+ * @param azimuth 弧度
922
+ */
923
+ setAzimuthAngle(azimuth) {
924
+ const { THREE } = Externals.getInstance();
925
+ const quat = new THREE.Quaternion().setFromUnitVectors(this.camera.up, new THREE.Vector3(0, 1, 0));
926
+ const quatInverse = quat.clone().invert();
927
+ const lookAtVector = new THREE.Vector3().subVectors(this.target, this.camera.position);
928
+ if (this.rotateMode === 'orbit')
929
+ lookAtVector.multiplyScalar(-1);
930
+ lookAtVector.applyQuaternion(quat);
931
+ this.spherical.setFromVector3(lookAtVector);
932
+ this.spherical.theta = azimuth;
933
+ this.spherical.makeSafe();
934
+ lookAtVector.setFromSpherical(this.spherical);
935
+ lookAtVector.applyQuaternion(quatInverse);
936
+ if (this.rotateMode === 'self') {
937
+ this.target.copy(this.camera.position.clone().add(lookAtVector));
938
+ }
939
+ else {
940
+ this.camera.position.copy(this.target.clone().add(lookAtVector));
941
+ }
942
+ this.camera.lookAt(this.target);
943
+ this.needUpdate = true;
944
+ }
945
+ /**
946
+ * 获取当前横向转动值, 范围区间为[-2 * PI, 2 * PI]
947
+ */
948
+ getAzimuthAngle() {
949
+ return this.spherical.theta;
950
+ }
951
+ /**
952
+ * 设置纵向旋转角度
953
+ * @param polar 弧度
954
+ */
955
+ setPolarAngle(polar) {
956
+ const { THREE } = Externals.getInstance();
957
+ const quat = new THREE.Quaternion().setFromUnitVectors(this.camera.up, new THREE.Vector3(0, 1, 0));
958
+ const quatInverse = quat.clone().invert();
959
+ const lookAtVector = new THREE.Vector3().subVectors(this.target, this.camera.position);
960
+ if (this.rotateMode === 'orbit')
961
+ lookAtVector.multiplyScalar(-1);
962
+ lookAtVector.applyQuaternion(quat);
963
+ this.spherical.setFromVector3(lookAtVector);
964
+ this.spherical.phi = polar;
965
+ this.spherical.makeSafe();
966
+ lookAtVector.setFromSpherical(this.spherical);
967
+ lookAtVector.applyQuaternion(quatInverse);
968
+ if (this.rotateMode === 'self') {
969
+ this.target.copy(this.camera.position.clone().add(lookAtVector));
970
+ }
971
+ else {
972
+ this.camera.position.copy(this.target.clone().add(lookAtVector));
973
+ }
974
+ this.camera.lookAt(this.target);
975
+ this.needUpdate = true;
976
+ }
977
+ /**
978
+ * 获取当前纵向转动值
979
+ */
980
+ getPolarAngle() {
981
+ return this.spherical.phi;
982
+ }
983
+ /**
984
+ * 设置横向转动范围, 范围区间为[-2 * PI, 2 * PI]
985
+ * @param min 最小值
986
+ * @param max 最大值
987
+ */
988
+ setAzimuthRange(min, max) {
989
+ this.minSpherical.theta = min;
990
+ this.maxSpherical.theta = max;
991
+ }
992
+ /**
993
+ * 设置纵向旋转范围, 范围区间为[0, PI]
994
+ * @param min 最小值
995
+ * @param max 最大值
996
+ */
997
+ setPolarRange(min, max) {
998
+ this.minSpherical.phi = min;
999
+ this.maxSpherical.phi = max;
1000
+ }
1001
+ /**
1002
+ * 设置是否激活摇镜运动的惯性
1003
+ * @param enabled 布尔值
1004
+ */
1005
+ setPanInertiaEnabled(enabled) {
1006
+ this.panInertiaEnabled = enabled;
1007
+ }
1008
+ /**
1009
+ * 设置惯性系数
1010
+ * @param factor 惯性系数
1011
+ */
1012
+ setInertiaFactor(factor) {
1013
+ this.inertiaFactor = factor;
1014
+ }
1015
+ /**
1016
+ * 设置是否激活摇镜(移动)
1017
+ * @param enable 布尔值
1018
+ */
1019
+ setPanEnabled(enable) {
1020
+ this.enablePan = enable;
1021
+ }
1022
+ /**
1023
+ * 设置摇镜操作是否跟随屏幕空间朝向
1024
+ * @param enabled 布尔值
1025
+ */
1026
+ setScreenSpacePanning(enabled) {
1027
+ this.screenSpacePanning = enabled;
1028
+ }
1029
+ /**
1030
+ * 设置鼠标操作关联
1031
+ * @param mouseButtons 鼠标操作关联
1032
+ */
1033
+ setMouseButtons(mouseButtons) {
1034
+ this.mouseButtons = mouseButtons;
1035
+ }
1036
+ /**
1037
+ * 设置触摸操作关联
1038
+ * @param touches 触摸操作关联
1039
+ */
1040
+ setTouches(touches) {
1041
+ this.touches = touches;
1042
+ }
1043
+ /**
1044
+ * 设置是否限制相机运动范围
1045
+ * @param enable 是否限制
1046
+ */
1047
+ setBoundaryEnabled(enable) {
1048
+ this.boundaryEnabled = enable;
1049
+ }
1050
+ /**
1051
+ * 设置相机运动范围, 范围是一个包围盒, 使用最小值点与最大值点描述
1052
+ * @param min 包围盒最小值点坐标, 默认值为无限小
1053
+ * @param max 包围盒最大值点坐标, 默认值为无限大
1054
+ */
1055
+ setBoundary(min, max) {
1056
+ this.boundary.set(min, max);
1057
+ }
1058
+ /**
1059
+ * 设置BasicController是否激活可用
1060
+ * @param enabled 是否激活
1061
+ */
1062
+ setEnabled(enabled) {
1063
+ if (enabled === this.enabled)
1064
+ return;
1065
+ this.enabled = enabled;
1066
+ if (enabled) {
1067
+ this.registerEvents();
1068
+ }
1069
+ else {
1070
+ this.unregisterEvents();
1071
+ this.resetVectors();
1072
+ }
1073
+ }
1074
+ /**
1075
+ * 获取当前激活状态
1076
+ */
1077
+ getEnabled() {
1078
+ return this.enabled;
1079
+ }
1080
+ /** @ignore */
1081
+ bindView(view) {
1082
+ this.unbindView();
1083
+ if (!view.container && !view.canvas) {
1084
+ throw new Error('View needed initialized with an HTML container or Canvas');
1085
+ }
1086
+ if (!view.camera)
1087
+ throw new Error('[BasicController] View for basic controller should have a camera.');
1088
+ if (!view.camera.isPerspectiveCamera
1089
+ && !view.camera.isOrthographicCamera) {
1090
+ throw new Error('[BasicController] Only supports PerspectiveCamera or OrthographicCamera.');
1091
+ }
1092
+ const { THREE } = Externals.getInstance();
1093
+ this.camera = view.camera;
1094
+ this.bindingView = view;
1095
+ this.target = new THREE.Vector3(0, 0, -1).applyQuaternion(this.camera.quaternion);
1096
+ this.registerEvents();
1097
+ }
1098
+ /** @ignore */
1099
+ update() {
1100
+ const now = Date.now();
1101
+ const timeElapsed = now - this.lastTick;
1102
+ this.lastTick = now;
1103
+ const { THREE } = Externals.getInstance();
1104
+ const quat = new THREE.Quaternion().setFromUnitVectors(this.camera.up, new THREE.Vector3(0, 1, 0));
1105
+ const quatInverse = quat.clone().invert();
1106
+ const lookAtVector = new THREE.Vector3().subVectors(this.target, this.camera.position);
1107
+ if (this.rotateMode === 'orbit')
1108
+ lookAtVector.multiplyScalar(-1);
1109
+ if (Math.abs(this.zoomInertiaBase) > 0 && this.zoomInertiaDuration < 600) {
1110
+ this.handleZoom(this.zoomInertia);
1111
+ const q = this.zoomInertiaDuration / 600;
1112
+ this.zoomInertia = this.zoomInertiaBase * (Math.pow((1 - q), 2));
1113
+ this.zoomInertia = Math.max(0, Math.abs(this.zoomInertia)) * Math.sign(this.zoomInertia);
1114
+ this.zoomInertiaDuration += timeElapsed;
1115
+ }
1116
+ if (this.panInertiaBase > 0 && this.panInertiaDuration < 600) {
1117
+ const { x, y } = this.panInertiaDirection;
1118
+ this.handlePanDelta(x * this.panInertia, y * this.panInertia);
1119
+ const q = this.panInertiaDuration / 600;
1120
+ this.panInertia = this.panInertiaBase * (Math.pow((1 - q), 2));
1121
+ this.panInertia = Math.max(0, this.panInertia);
1122
+ this.panInertiaDuration += timeElapsed;
1123
+ }
1124
+ if (this.rotateInertiaBase > 0 && this.rotateInertiaDuration < 600) {
1125
+ if (this.rotateInertiaType === 'normal') {
1126
+ const { x, y } = this.rotateInertiaDirection;
1127
+ this.handleRotateDelta(x * this.rotateInertia, y * this.rotateInertia);
1128
+ }
1129
+ else {
1130
+ this.handleRotateSphericalDelta(this.rotateInertia, 0);
1131
+ }
1132
+ const q = this.rotateInertiaDuration / 600;
1133
+ this.rotateInertia = this.rotateInertiaBase * (Math.pow((1 - q), 2));
1134
+ this.rotateInertia = Math.max(0, this.rotateInertia);
1135
+ this.rotateInertiaDuration += timeElapsed;
1136
+ }
1137
+ lookAtVector.applyQuaternion(quat);
1138
+ this.spherical.setFromVector3(lookAtVector);
1139
+ const sphericalDelta = this.sphericalDelta.clone();
1140
+ let { zoomDelta } = this;
1141
+ if (this.enableDamping) {
1142
+ sphericalDelta.theta *= this.dampingFactor;
1143
+ sphericalDelta.phi *= this.dampingFactor;
1144
+ zoomDelta *= this.dampingFactor;
1145
+ }
1146
+ this.spherical.theta += sphericalDelta.theta;
1147
+ this.spherical.phi += sphericalDelta.phi;
1148
+ let { theta: minAzimuth } = this.minSpherical;
1149
+ let { theta: maxAzimuth } = this.maxSpherical;
1150
+ const twoPI = Math.PI * 2;
1151
+ if (Number.isFinite(minAzimuth) && Number.isFinite(maxAzimuth)) {
1152
+ if (minAzimuth < -Math.PI)
1153
+ minAzimuth += twoPI;
1154
+ else if (minAzimuth > Math.PI)
1155
+ minAzimuth -= twoPI;
1156
+ if (maxAzimuth < -Math.PI)
1157
+ maxAzimuth += twoPI;
1158
+ else if (maxAzimuth > Math.PI)
1159
+ maxAzimuth -= twoPI;
1160
+ if (minAzimuth < maxAzimuth) {
1161
+ this.spherical.theta = Math.max(minAzimuth, Math.min(maxAzimuth, this.spherical.theta));
1162
+ }
1163
+ else {
1164
+ this.spherical.theta = (this.spherical.theta > (minAzimuth + maxAzimuth) / 2)
1165
+ ? Math.max(minAzimuth, this.spherical.theta)
1166
+ : Math.min(maxAzimuth, this.spherical.theta);
1167
+ }
1168
+ }
1169
+ this.spherical.phi = Math.max(this.minSpherical.phi, Math.min(this.maxSpherical.phi, this.spherical.phi));
1170
+ this.spherical.makeSafe();
1171
+ lookAtVector.setFromSpherical(this.spherical);
1172
+ lookAtVector.applyQuaternion(quatInverse);
1173
+ this.handleZoom(zoomDelta);
1174
+ if (this.enableDamping) {
1175
+ if (this.rotateMode === 'self')
1176
+ this.camera.position.addScaledVector(this.panOffset, this.dampingFactor);
1177
+ else
1178
+ this.target.addScaledVector(this.panOffset, this.dampingFactor);
1179
+ }
1180
+ else {
1181
+ // eslint-disable-next-line no-lonely-if
1182
+ if (this.rotateMode === 'self')
1183
+ this.camera.position.add(this.panOffset);
1184
+ else
1185
+ this.target.add(this.panOffset);
1186
+ }
1187
+ if (this.boundaryEnabled) {
1188
+ if (this.rotateMode === 'self') {
1189
+ this.camera.position.x = Math.min(this.boundary.max.x, Math.max(this.boundary.min.x, this.camera.position.x));
1190
+ this.camera.position.y = Math.min(this.boundary.max.y, Math.max(this.boundary.min.y, this.camera.position.y));
1191
+ this.camera.position.z = Math.min(this.boundary.max.z, Math.max(this.boundary.min.z, this.camera.position.z));
1192
+ }
1193
+ else {
1194
+ this.target.x = Math.min(this.boundary.max.x, Math.max(this.boundary.min.x, this.target.x));
1195
+ this.target.y = Math.min(this.boundary.max.y, Math.max(this.boundary.min.y, this.target.y));
1196
+ this.target.z = Math.min(this.boundary.max.z, Math.max(this.boundary.min.z, this.target.z));
1197
+ }
1198
+ }
1199
+ if (this.rotateMode === 'self') {
1200
+ this.target.copy(this.camera.position.clone().add(lookAtVector));
1201
+ }
1202
+ else {
1203
+ this.camera.position.copy(this.target.clone().add(lookAtVector));
1204
+ }
1205
+ this.camera.lookAt(this.target);
1206
+ if (this.enableDamping) {
1207
+ this.sphericalDelta.theta *= (1 - this.dampingFactor);
1208
+ this.sphericalDelta.phi *= (1 - this.dampingFactor);
1209
+ this.panOffset.multiplyScalar(1 - this.dampingFactor);
1210
+ this.zoomDelta *= (1 - this.dampingFactor);
1211
+ }
1212
+ else {
1213
+ this.sphericalDelta.set(0, 0, 0);
1214
+ this.panOffset.set(0, 0, 0);
1215
+ this.zoomDelta = 0;
1216
+ }
1217
+ if (this.needUpdate
1218
+ || this.lastPosition.distanceToSquared(this.camera.position) > EPS
1219
+ || 8 * (1 - this.lastQuaternion.dot(this.camera.quaternion)) > EPS) {
1220
+ this.lastPosition.copy(this.camera.position);
1221
+ this.lastQuaternion.copy(this.camera.quaternion);
1222
+ this.needUpdate = false;
1223
+ this.emit(Events.CAMERA_CHANGED, this.camera.position.clone(), this.camera.quaternion.clone(), this);
1224
+ return true;
1225
+ }
1226
+ return false;
1227
+ }
1228
+ /** @ignore */
1229
+ unbind() {
1230
+ this.dispose();
1231
+ this.unbindView();
1232
+ }
1233
+ unbindView() {
1234
+ this.unregisterEvents();
1235
+ this.bindingView = null;
1236
+ }
1237
+ }
1238
+ export { BasicController };