@aibee/owlly 1.0.25

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 (500) hide show
  1. package/README.external.md +75 -0
  2. package/README.md +28 -0
  3. package/lib/src/external/lines/line-geometry.d.ts +9 -0
  4. package/lib/src/external/lines/line-geometry.js +52 -0
  5. package/lib/src/external/lines/line-geometry.js.map +1 -0
  6. package/lib/src/external/lines/line-material.d.ts +10 -0
  7. package/lib/src/external/lines/line-material.js +377 -0
  8. package/lib/src/external/lines/line-material.js.map +1 -0
  9. package/lib/src/external/lines/line-segments-2.d.ts +7 -0
  10. package/lib/src/external/lines/line-segments-2.js +144 -0
  11. package/lib/src/external/lines/line-segments-2.js.map +1 -0
  12. package/lib/src/external/lines/line-segments-geometry.d.ts +15 -0
  13. package/lib/src/external/lines/line-segments-geometry.js +141 -0
  14. package/lib/src/external/lines/line-segments-geometry.js.map +1 -0
  15. package/lib/src/external/loaders/gltf-loader.d.ts +77 -0
  16. package/lib/src/external/loaders/gltf-loader.js +2319 -0
  17. package/lib/src/external/loaders/gltf-loader.js.map +1 -0
  18. package/lib/src/external/orbit-controls.d.ts +44 -0
  19. package/lib/src/external/orbit-controls.js +746 -0
  20. package/lib/src/external/orbit-controls.js.map +1 -0
  21. package/lib/src/external/renderers/css-2d-renderer.d.ts +16 -0
  22. package/lib/src/external/renderers/css-2d-renderer.js +122 -0
  23. package/lib/src/external/renderers/css-2d-renderer.js.map +1 -0
  24. package/lib/src/external/renderers/css-3d-renderer.d.ts +18 -0
  25. package/lib/src/external/renderers/css-3d-renderer.js +139 -0
  26. package/lib/src/external/renderers/css-3d-renderer.js.map +1 -0
  27. package/lib/src/external/transform-controls.d.ts +106 -0
  28. package/lib/src/external/transform-controls.js +1113 -0
  29. package/lib/src/external/transform-controls.js.map +1 -0
  30. package/lib/src/external/util/buffer-geometry-utils.d.ts +45 -0
  31. package/lib/src/external/util/buffer-geometry-utils.js +569 -0
  32. package/lib/src/external/util/buffer-geometry-utils.js.map +1 -0
  33. package/lib/src/owlly/controller/aerial-element-controller.d.ts +65 -0
  34. package/lib/src/owlly/controller/aerial-element-controller.js +236 -0
  35. package/lib/src/owlly/controller/aerial-element-controller.js.map +1 -0
  36. package/lib/src/owlly/controller/basic-controller.d.ts +324 -0
  37. package/lib/src/owlly/controller/basic-controller.js +1239 -0
  38. package/lib/src/owlly/controller/basic-controller.js.map +1 -0
  39. package/lib/src/owlly/controller/camera-controller.d.ts +37 -0
  40. package/lib/src/owlly/controller/camera-controller.js +138 -0
  41. package/lib/src/owlly/controller/camera-controller.js.map +1 -0
  42. package/lib/src/owlly/controller/controller.d.ts +61 -0
  43. package/lib/src/owlly/controller/controller.js +24 -0
  44. package/lib/src/owlly/controller/controller.js.map +1 -0
  45. package/lib/src/owlly/controller/index.d.ts +2 -0
  46. package/lib/src/owlly/controller/index.js +14 -0
  47. package/lib/src/owlly/controller/index.js.map +1 -0
  48. package/lib/src/owlly/controller/mouse-indicator-controller.d.ts +34 -0
  49. package/lib/src/owlly/controller/mouse-indicator-controller.js +119 -0
  50. package/lib/src/owlly/controller/mouse-indicator-controller.js.map +1 -0
  51. package/lib/src/owlly/controller/orbit-control.d.ts +147 -0
  52. package/lib/src/owlly/controller/orbit-control.js +265 -0
  53. package/lib/src/owlly/controller/orbit-control.js.map +1 -0
  54. package/lib/src/owlly/controller/panorama-adjust-controller.d.ts +45 -0
  55. package/lib/src/owlly/controller/panorama-adjust-controller.js +158 -0
  56. package/lib/src/owlly/controller/panorama-adjust-controller.js.map +1 -0
  57. package/lib/src/owlly/controller/panorama-controller.d.ts +441 -0
  58. package/lib/src/owlly/controller/panorama-controller.js +1944 -0
  59. package/lib/src/owlly/controller/panorama-controller.js.map +1 -0
  60. package/lib/src/owlly/controller/panorama-transform-controller.d.ts +66 -0
  61. package/lib/src/owlly/controller/panorama-transform-controller.js +137 -0
  62. package/lib/src/owlly/controller/panorama-transform-controller.js.map +1 -0
  63. package/lib/src/owlly/controller/plane-controller.d.ts +43 -0
  64. package/lib/src/owlly/controller/plane-controller.js +174 -0
  65. package/lib/src/owlly/controller/plane-controller.js.map +1 -0
  66. package/lib/src/owlly/controller/texture-controller.d.ts +181 -0
  67. package/lib/src/owlly/controller/texture-controller.js +876 -0
  68. package/lib/src/owlly/controller/texture-controller.js.map +1 -0
  69. package/lib/src/owlly/controller/tile-panorama-controller.d.ts +308 -0
  70. package/lib/src/owlly/controller/tile-panorama-controller.js +1354 -0
  71. package/lib/src/owlly/controller/tile-panorama-controller.js.map +1 -0
  72. package/lib/src/owlly/controller/transform-controller.d.ts +106 -0
  73. package/lib/src/owlly/controller/transform-controller.js +546 -0
  74. package/lib/src/owlly/controller/transform-controller.js.map +1 -0
  75. package/lib/src/owlly/element/bottom-nav-element.d.ts +65 -0
  76. package/lib/src/owlly/element/bottom-nav-element.js +258 -0
  77. package/lib/src/owlly/element/bottom-nav-element.js.map +1 -0
  78. package/lib/src/owlly/element/camera.d.ts +82 -0
  79. package/lib/src/owlly/element/camera.js +284 -0
  80. package/lib/src/owlly/element/camera.js.map +1 -0
  81. package/lib/src/owlly/element/dom-2d-element.d.ts +35 -0
  82. package/lib/src/owlly/element/dom-2d-element.js +49 -0
  83. package/lib/src/owlly/element/dom-2d-element.js.map +1 -0
  84. package/lib/src/owlly/element/dom-3d-element.d.ts +27 -0
  85. package/lib/src/owlly/element/dom-3d-element.js +34 -0
  86. package/lib/src/owlly/element/dom-3d-element.js.map +1 -0
  87. package/lib/src/owlly/element/dom-label-2d.d.ts +116 -0
  88. package/lib/src/owlly/element/dom-label-2d.js +383 -0
  89. package/lib/src/owlly/element/dom-label-2d.js.map +1 -0
  90. package/lib/src/owlly/element/element.d.ts +53 -0
  91. package/lib/src/owlly/element/element.js +76 -0
  92. package/lib/src/owlly/element/element.js.map +1 -0
  93. package/lib/src/owlly/element/floor-model.d.ts +83 -0
  94. package/lib/src/owlly/element/floor-model.js +228 -0
  95. package/lib/src/owlly/element/floor-model.js.map +1 -0
  96. package/lib/src/owlly/element/gif-kit/Gif.d.ts +96 -0
  97. package/lib/src/owlly/element/gif-kit/Gif.js +433 -0
  98. package/lib/src/owlly/element/gif-kit/Gif.js.map +1 -0
  99. package/lib/src/owlly/element/gif-kit/GifColor.d.ts +21 -0
  100. package/lib/src/owlly/element/gif-kit/GifColor.js +38 -0
  101. package/lib/src/owlly/element/gif-kit/GifColor.js.map +1 -0
  102. package/lib/src/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.d.ts +20 -0
  103. package/lib/src/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.js +51 -0
  104. package/lib/src/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.js.map +1 -0
  105. package/lib/src/owlly/element/gif-kit/GifFrame.d.ts +31 -0
  106. package/lib/src/owlly/element/gif-kit/GifFrame.js +97 -0
  107. package/lib/src/owlly/element/gif-kit/GifFrame.js.map +1 -0
  108. package/lib/src/owlly/element/gif-kit/GifImage.d.ts +23 -0
  109. package/lib/src/owlly/element/gif-kit/GifImage.js +8 -0
  110. package/lib/src/owlly/element/gif-kit/GifImage.js.map +1 -0
  111. package/lib/src/owlly/element/gif-kit/GifParser.d.ts +17 -0
  112. package/lib/src/owlly/element/gif-kit/GifParser.js +197 -0
  113. package/lib/src/owlly/element/gif-kit/GifParser.js.map +1 -0
  114. package/lib/src/owlly/element/gif-kit/GifPresenter.d.ts +20 -0
  115. package/lib/src/owlly/element/gif-kit/GifPresenter.js +44 -0
  116. package/lib/src/owlly/element/gif-kit/GifPresenter.js.map +1 -0
  117. package/lib/src/owlly/element/gif-kit/GifVersion.d.ts +10 -0
  118. package/lib/src/owlly/element/gif-kit/GifVersion.js +13 -0
  119. package/lib/src/owlly/element/gif-kit/GifVersion.js.map +1 -0
  120. package/lib/src/owlly/element/gltf-mesh-element.d.ts +31 -0
  121. package/lib/src/owlly/element/gltf-mesh-element.js +137 -0
  122. package/lib/src/owlly/element/gltf-mesh-element.js.map +1 -0
  123. package/lib/src/owlly/element/index.d.ts +20 -0
  124. package/lib/src/owlly/element/index.js +25 -0
  125. package/lib/src/owlly/element/index.js.map +1 -0
  126. package/lib/src/owlly/element/map-kit/area.d.ts +24 -0
  127. package/lib/src/owlly/element/map-kit/area.js +218 -0
  128. package/lib/src/owlly/element/map-kit/area.js.map +1 -0
  129. package/lib/src/owlly/element/map-kit/block-set.d.ts +39 -0
  130. package/lib/src/owlly/element/map-kit/block-set.js +91 -0
  131. package/lib/src/owlly/element/map-kit/block-set.js.map +1 -0
  132. package/lib/src/owlly/element/map-kit/block.d.ts +77 -0
  133. package/lib/src/owlly/element/map-kit/block.js +339 -0
  134. package/lib/src/owlly/element/map-kit/block.js.map +1 -0
  135. package/lib/src/owlly/element/map-kit/index.d.ts +4 -0
  136. package/lib/src/owlly/element/map-kit/index.js +7 -0
  137. package/lib/src/owlly/element/map-kit/index.js.map +1 -0
  138. package/lib/src/owlly/element/map-kit/shape.d.ts +131 -0
  139. package/lib/src/owlly/element/map-kit/shape.js +190 -0
  140. package/lib/src/owlly/element/map-kit/shape.js.map +1 -0
  141. package/lib/src/owlly/element/mesh-element.d.ts +22 -0
  142. package/lib/src/owlly/element/mesh-element.js +64 -0
  143. package/lib/src/owlly/element/mesh-element.js.map +1 -0
  144. package/lib/src/owlly/element/mesh-line-2d.d.ts +82 -0
  145. package/lib/src/owlly/element/mesh-line-2d.js +888 -0
  146. package/lib/src/owlly/element/mesh-line-2d.js.map +1 -0
  147. package/lib/src/owlly/element/meshline-o.d.ts +64 -0
  148. package/lib/src/owlly/element/meshline-o.js +679 -0
  149. package/lib/src/owlly/element/meshline-o.js.map +1 -0
  150. package/lib/src/owlly/element/panorama-group.d.ts +241 -0
  151. package/lib/src/owlly/element/panorama-group.js +967 -0
  152. package/lib/src/owlly/element/panorama-group.js.map +1 -0
  153. package/lib/src/owlly/element/panorama.d.ts +132 -0
  154. package/lib/src/owlly/element/panorama.js +813 -0
  155. package/lib/src/owlly/element/panorama.js.map +1 -0
  156. package/lib/src/owlly/element/path-group.d.ts +69 -0
  157. package/lib/src/owlly/element/path-group.js +172 -0
  158. package/lib/src/owlly/element/path-group.js.map +1 -0
  159. package/lib/src/owlly/element/path.d.ts +99 -0
  160. package/lib/src/owlly/element/path.js +532 -0
  161. package/lib/src/owlly/element/path.js.map +1 -0
  162. package/lib/src/owlly/element/placeable-2d.d.ts +158 -0
  163. package/lib/src/owlly/element/placeable-2d.js +471 -0
  164. package/lib/src/owlly/element/placeable-2d.js.map +1 -0
  165. package/lib/src/owlly/element/polygon-mesh.d.ts +107 -0
  166. package/lib/src/owlly/element/polygon-mesh.js +308 -0
  167. package/lib/src/owlly/element/polygon-mesh.js.map +1 -0
  168. package/lib/src/owlly/element/ring-element.d.ts +79 -0
  169. package/lib/src/owlly/element/ring-element.js +384 -0
  170. package/lib/src/owlly/element/ring-element.js.map +1 -0
  171. package/lib/src/owlly/element/sphere-mesh.d.ts +28 -0
  172. package/lib/src/owlly/element/sphere-mesh.js +70 -0
  173. package/lib/src/owlly/element/sphere-mesh.js.map +1 -0
  174. package/lib/src/owlly/element/svg-floor-model.d.ts +22 -0
  175. package/lib/src/owlly/element/svg-floor-model.js +185 -0
  176. package/lib/src/owlly/element/svg-floor-model.js.map +1 -0
  177. package/lib/src/owlly/element/svg-floors.d.ts +27 -0
  178. package/lib/src/owlly/element/svg-floors.js +110 -0
  179. package/lib/src/owlly/element/svg-floors.js.map +1 -0
  180. package/lib/src/owlly/element/tile-panorama-group.d.ts +335 -0
  181. package/lib/src/owlly/element/tile-panorama-group.js +1007 -0
  182. package/lib/src/owlly/element/tile-panorama-group.js.map +1 -0
  183. package/lib/src/owlly/element/tile-panorama.d.ts +161 -0
  184. package/lib/src/owlly/element/tile-panorama.js +511 -0
  185. package/lib/src/owlly/element/tile-panorama.js.map +1 -0
  186. package/lib/src/owlly/element/tile-plane.d.ts +105 -0
  187. package/lib/src/owlly/element/tile-plane.js +361 -0
  188. package/lib/src/owlly/element/tile-plane.js.map +1 -0
  189. package/lib/src/owlly/element/video-element.d.ts +33 -0
  190. package/lib/src/owlly/element/video-element.js +160 -0
  191. package/lib/src/owlly/element/video-element.js.map +1 -0
  192. package/lib/src/owlly/geometries/ExtrudeGeometry2.d.ts +15 -0
  193. package/lib/src/owlly/geometries/ExtrudeGeometry2.js +211 -0
  194. package/lib/src/owlly/geometries/ExtrudeGeometry2.js.map +1 -0
  195. package/lib/src/owlly/index.d.ts +13 -0
  196. package/lib/src/owlly/index.js +17 -0
  197. package/lib/src/owlly/index.js.map +1 -0
  198. package/lib/src/owlly/overlay/canvas-overlay.d.ts +96 -0
  199. package/lib/src/owlly/overlay/canvas-overlay.js +511 -0
  200. package/lib/src/owlly/overlay/canvas-overlay.js.map +1 -0
  201. package/lib/src/owlly/overlay/css-2d-overlay.d.ts +14 -0
  202. package/lib/src/owlly/overlay/css-2d-overlay.js +36 -0
  203. package/lib/src/owlly/overlay/css-2d-overlay.js.map +1 -0
  204. package/lib/src/owlly/overlay/css-3d-overlay.d.ts +16 -0
  205. package/lib/src/owlly/overlay/css-3d-overlay.js +37 -0
  206. package/lib/src/owlly/overlay/css-3d-overlay.js.map +1 -0
  207. package/lib/src/owlly/overlay/index.d.ts +6 -0
  208. package/lib/src/owlly/overlay/index.js +12 -0
  209. package/lib/src/owlly/overlay/index.js.map +1 -0
  210. package/lib/src/owlly/overlay/label-overlay.d.ts +62 -0
  211. package/lib/src/owlly/overlay/label-overlay.js +329 -0
  212. package/lib/src/owlly/overlay/label-overlay.js.map +1 -0
  213. package/lib/src/owlly/overlay/overlay.d.ts +14 -0
  214. package/lib/src/owlly/overlay/overlay.js +5 -0
  215. package/lib/src/owlly/overlay/overlay.js.map +1 -0
  216. package/lib/src/owlly/overlay/path-overlay.d.ts +39 -0
  217. package/lib/src/owlly/overlay/path-overlay.js +125 -0
  218. package/lib/src/owlly/overlay/path-overlay.js.map +1 -0
  219. package/lib/src/owlly/overlay/path-overlay2.d.ts +35 -0
  220. package/lib/src/owlly/overlay/path-overlay2.js +119 -0
  221. package/lib/src/owlly/overlay/path-overlay2.js.map +1 -0
  222. package/lib/src/owlly/overlay/poi-overlay-3d.d.ts +278 -0
  223. package/lib/src/owlly/overlay/poi-overlay-3d.js +1433 -0
  224. package/lib/src/owlly/overlay/poi-overlay-3d.js.map +1 -0
  225. package/lib/src/owlly/overlay/poi-overlay.d.ts +277 -0
  226. package/lib/src/owlly/overlay/poi-overlay.js +1412 -0
  227. package/lib/src/owlly/overlay/poi-overlay.js.map +1 -0
  228. package/lib/src/owlly/owlly-2d/index.d.ts +28 -0
  229. package/lib/src/owlly/owlly-2d/index.js +93 -0
  230. package/lib/src/owlly/owlly-2d/index.js.map +1 -0
  231. package/lib/src/owlly/screen/index.d.ts +1 -0
  232. package/lib/src/owlly/screen/index.js +2 -0
  233. package/lib/src/owlly/screen/index.js.map +1 -0
  234. package/lib/src/owlly/screen/screen.d.ts +73 -0
  235. package/lib/src/owlly/screen/screen.js +237 -0
  236. package/lib/src/owlly/screen/screen.js.map +1 -0
  237. package/lib/src/owlly/stage/__test__/stage.spec.d.ts +1 -0
  238. package/lib/src/owlly/stage/__test__/stage.spec.js +15 -0
  239. package/lib/src/owlly/stage/__test__/stage.spec.js.map +1 -0
  240. package/lib/src/owlly/stage/externals.d.ts +19 -0
  241. package/lib/src/owlly/stage/externals.js +25 -0
  242. package/lib/src/owlly/stage/externals.js.map +1 -0
  243. package/lib/src/owlly/stage/index.d.ts +4 -0
  244. package/lib/src/owlly/stage/index.js +7 -0
  245. package/lib/src/owlly/stage/index.js.map +1 -0
  246. package/lib/src/owlly/stage/owlly.d.ts +38 -0
  247. package/lib/src/owlly/stage/owlly.js +168 -0
  248. package/lib/src/owlly/stage/owlly.js.map +1 -0
  249. package/lib/src/owlly/stage/stage.d.ts +108 -0
  250. package/lib/src/owlly/stage/stage.js +235 -0
  251. package/lib/src/owlly/stage/stage.js.map +1 -0
  252. package/lib/src/owlly/utils/alignment-utils.d.ts +20 -0
  253. package/lib/src/owlly/utils/alignment-utils.js +64 -0
  254. package/lib/src/owlly/utils/alignment-utils.js.map +1 -0
  255. package/lib/src/owlly/utils/basic-calc.d.ts +18 -0
  256. package/lib/src/owlly/utils/basic-calc.js +130 -0
  257. package/lib/src/owlly/utils/basic-calc.js.map +1 -0
  258. package/lib/src/owlly/utils/basic-tools.d.ts +71 -0
  259. package/lib/src/owlly/utils/basic-tools.js +236 -0
  260. package/lib/src/owlly/utils/basic-tools.js.map +1 -0
  261. package/lib/src/owlly/utils/bvh-tree.d.ts +105 -0
  262. package/lib/src/owlly/utils/bvh-tree.js +540 -0
  263. package/lib/src/owlly/utils/bvh-tree.js.map +1 -0
  264. package/lib/src/owlly/utils/camera.d.ts +37 -0
  265. package/lib/src/owlly/utils/camera.js +51 -0
  266. package/lib/src/owlly/utils/camera.js.map +1 -0
  267. package/lib/src/owlly/utils/cube-texture-cache.d.ts +25 -0
  268. package/lib/src/owlly/utils/cube-texture-cache.js +144 -0
  269. package/lib/src/owlly/utils/cube-texture-cache.js.map +1 -0
  270. package/lib/src/owlly/utils/device-utils.d.ts +18 -0
  271. package/lib/src/owlly/utils/device-utils.js +42 -0
  272. package/lib/src/owlly/utils/device-utils.js.map +1 -0
  273. package/lib/src/owlly/utils/environment-utils.d.ts +37 -0
  274. package/lib/src/owlly/utils/environment-utils.js +74 -0
  275. package/lib/src/owlly/utils/environment-utils.js.map +1 -0
  276. package/lib/src/owlly/utils/event-hub.d.ts +50 -0
  277. package/lib/src/owlly/utils/event-hub.js +107 -0
  278. package/lib/src/owlly/utils/event-hub.js.map +1 -0
  279. package/lib/src/owlly/utils/events.d.ts +219 -0
  280. package/lib/src/owlly/utils/events.js +220 -0
  281. package/lib/src/owlly/utils/events.js.map +1 -0
  282. package/lib/src/owlly/utils/geometry-utils.d.ts +119 -0
  283. package/lib/src/owlly/utils/geometry-utils.js +623 -0
  284. package/lib/src/owlly/utils/geometry-utils.js.map +1 -0
  285. package/lib/src/owlly/utils/helper.d.ts +6 -0
  286. package/lib/src/owlly/utils/helper.js +25 -0
  287. package/lib/src/owlly/utils/helper.js.map +1 -0
  288. package/lib/src/owlly/utils/index.d.ts +14 -0
  289. package/lib/src/owlly/utils/index.js +18 -0
  290. package/lib/src/owlly/utils/index.js.map +1 -0
  291. package/lib/src/owlly/utils/lru-cache.d.ts +26 -0
  292. package/lib/src/owlly/utils/lru-cache.js +110 -0
  293. package/lib/src/owlly/utils/lru-cache.js.map +1 -0
  294. package/lib/src/owlly/utils/map-utils.d.ts +7 -0
  295. package/lib/src/owlly/utils/map-utils.js +53 -0
  296. package/lib/src/owlly/utils/map-utils.js.map +1 -0
  297. package/lib/src/owlly/utils/number-utils.d.ts +8 -0
  298. package/lib/src/owlly/utils/number-utils.js +73 -0
  299. package/lib/src/owlly/utils/number-utils.js.map +1 -0
  300. package/lib/src/owlly/utils/panorama-model-util.d.ts +46 -0
  301. package/lib/src/owlly/utils/panorama-model-util.js +246 -0
  302. package/lib/src/owlly/utils/panorama-model-util.js.map +1 -0
  303. package/lib/src/owlly/utils/path-utils.d.ts +80 -0
  304. package/lib/src/owlly/utils/path-utils.js +729 -0
  305. package/lib/src/owlly/utils/path-utils.js.map +1 -0
  306. package/lib/src/owlly/utils/svgutils.d.ts +138 -0
  307. package/lib/src/owlly/utils/svgutils.js +562 -0
  308. package/lib/src/owlly/utils/svgutils.js.map +1 -0
  309. package/lib/src/owlly/utils/texture-cache.d.ts +29 -0
  310. package/lib/src/owlly/utils/texture-cache.js +116 -0
  311. package/lib/src/owlly/utils/texture-cache.js.map +1 -0
  312. package/lib/src/owlly/utils/tile-util.d.ts +187 -0
  313. package/lib/src/owlly/utils/tile-util.js +457 -0
  314. package/lib/src/owlly/utils/tile-util.js.map +1 -0
  315. package/lib/src/owlly/utils/time-profiler.d.ts +21 -0
  316. package/lib/src/owlly/utils/time-profiler.js +49 -0
  317. package/lib/src/owlly/utils/time-profiler.js.map +1 -0
  318. package/lib/src/owlly/view/__test__/perspective-view.spec.d.ts +0 -0
  319. package/lib/src/owlly/view/__test__/perspective-view.spec.js +22 -0
  320. package/lib/src/owlly/view/__test__/perspective-view.spec.js.map +1 -0
  321. package/lib/src/owlly/view/camera-view.d.ts +35 -0
  322. package/lib/src/owlly/view/camera-view.js +102 -0
  323. package/lib/src/owlly/view/camera-view.js.map +1 -0
  324. package/lib/src/owlly/view/index.d.ts +3 -0
  325. package/lib/src/owlly/view/index.js +6 -0
  326. package/lib/src/owlly/view/index.js.map +1 -0
  327. package/lib/src/owlly/view/orthographic-view.d.ts +40 -0
  328. package/lib/src/owlly/view/orthographic-view.js +95 -0
  329. package/lib/src/owlly/view/orthographic-view.js.map +1 -0
  330. package/lib/src/owlly/view/perspective-view.d.ts +40 -0
  331. package/lib/src/owlly/view/perspective-view.js +96 -0
  332. package/lib/src/owlly/view/perspective-view.js.map +1 -0
  333. package/lib/src/owlly/view/svg-map-view.d.ts +46 -0
  334. package/lib/src/owlly/view/svg-map-view.js +145 -0
  335. package/lib/src/owlly/view/svg-map-view.js.map +1 -0
  336. package/lib/src/owlly/view/view.d.ts +146 -0
  337. package/lib/src/owlly/view/view.js +318 -0
  338. package/lib/src/owlly/view/view.js.map +1 -0
  339. package/lib/src/web/main.centroid.d.ts +0 -0
  340. package/lib/src/web/main.centroid.js +74 -0
  341. package/lib/src/web/main.centroid.js.map +1 -0
  342. package/lib/src/web/main.hyma.meshline2d.d.ts +1 -0
  343. package/lib/src/web/main.hyma.meshline2d.js +76 -0
  344. package/lib/src/web/main.hyma.meshline2d.js.map +1 -0
  345. package/lib/src/web/main.jyfang.sample.d.ts +0 -0
  346. package/lib/src/web/main.jyfang.sample.js +122 -0
  347. package/lib/src/web/main.jyfang.sample.js.map +1 -0
  348. package/lib/src/web/main.rpeng.extrude.d.ts +1 -0
  349. package/lib/src/web/main.rpeng.extrude.js +180 -0
  350. package/lib/src/web/main.rpeng.extrude.js.map +1 -0
  351. package/lib/src/web/main.rpeng.mes.plane.d.ts +1 -0
  352. package/lib/src/web/main.rpeng.mes.plane.js +135 -0
  353. package/lib/src/web/main.rpeng.mes.plane.js.map +1 -0
  354. package/lib/src/web/main.rpeng.sample.d.ts +0 -0
  355. package/lib/src/web/main.rpeng.sample.js +318 -0
  356. package/lib/src/web/main.rpeng.sample.js.map +1 -0
  357. package/lib/src/web/main.rpeng.vr.d.ts +1 -0
  358. package/lib/src/web/main.rpeng.vr.js +141 -0
  359. package/lib/src/web/main.rpeng.vr.js.map +1 -0
  360. package/lib/src/web/main.sample.d.ts +1 -0
  361. package/lib/src/web/main.sample.js +52 -0
  362. package/lib/src/web/main.sample.js.map +1 -0
  363. package/lib/src/web/quattree.hyma.d.ts +0 -0
  364. package/lib/src/web/quattree.hyma.js +150 -0
  365. package/lib/src/web/quattree.hyma.js.map +1 -0
  366. package/lib/src/web/sensor-vr-plugin.d.ts +0 -0
  367. package/lib/src/web/sensor-vr-plugin.js +166 -0
  368. package/lib/src/web/sensor-vr-plugin.js.map +1 -0
  369. package/package.json +142 -0
  370. package/src/@types/SceneUtils.d.ts +9 -0
  371. package/src/@types/chaikin-smooth.d.ts +5 -0
  372. package/src/@types/global.d.ts +3 -0
  373. package/src/@types/snapsvg.d.ts +11 -0
  374. package/src/@types/svgson.d.ts +30 -0
  375. package/src/assets/favicon.ico +0 -0
  376. package/src/external/lines/line-geometry.ts +70 -0
  377. package/src/external/lines/line-material.ts +453 -0
  378. package/src/external/lines/line-segments-2.ts +194 -0
  379. package/src/external/lines/line-segments-geometry.ts +197 -0
  380. package/src/external/loaders/gltf-loader.ts +3004 -0
  381. package/src/external/orbit-controls.ts +1070 -0
  382. package/src/external/renderers/css-2d-renderer.ts +185 -0
  383. package/src/external/renderers/css-3d-renderer.ts +245 -0
  384. package/src/external/transform-controls.ts +1532 -0
  385. package/src/external/util/buffer-geometry-utils.ts +783 -0
  386. package/src/owlly/controller/aerial-element-controller.ts +277 -0
  387. package/src/owlly/controller/basic-controller.ts +1509 -0
  388. package/src/owlly/controller/camera-controller.ts +155 -0
  389. package/src/owlly/controller/controller.ts +76 -0
  390. package/src/owlly/controller/index.ts +15 -0
  391. package/src/owlly/controller/mouse-indicator-controller.ts +157 -0
  392. package/src/owlly/controller/orbit-control.ts +310 -0
  393. package/src/owlly/controller/panorama-adjust-controller.ts +183 -0
  394. package/src/owlly/controller/panorama-controller.ts +2234 -0
  395. package/src/owlly/controller/panorama-transform-controller.ts +151 -0
  396. package/src/owlly/controller/plane-controller.ts +222 -0
  397. package/src/owlly/controller/texture-controller.ts +949 -0
  398. package/src/owlly/controller/tile-panorama-controller.ts +1633 -0
  399. package/src/owlly/controller/transform-controller.ts +684 -0
  400. package/src/owlly/element/bottom-nav-element.ts +352 -0
  401. package/src/owlly/element/camera.ts +389 -0
  402. package/src/owlly/element/dom-2d-element.ts +88 -0
  403. package/src/owlly/element/dom-3d-element.ts +87 -0
  404. package/src/owlly/element/dom-label-2d.ts +497 -0
  405. package/src/owlly/element/element.ts +117 -0
  406. package/src/owlly/element/floor-model.ts +290 -0
  407. package/src/owlly/element/gif-kit/Gif.ts +509 -0
  408. package/src/owlly/element/gif-kit/GifColor.ts +44 -0
  409. package/src/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.ts +56 -0
  410. package/src/owlly/element/gif-kit/GifFrame.ts +207 -0
  411. package/src/owlly/element/gif-kit/GifImage.ts +26 -0
  412. package/src/owlly/element/gif-kit/GifParser.ts +254 -0
  413. package/src/owlly/element/gif-kit/GifPresenter.ts +46 -0
  414. package/src/owlly/element/gif-kit/GifVersion.ts +12 -0
  415. package/src/owlly/element/gltf-mesh-element.ts +184 -0
  416. package/src/owlly/element/index.ts +25 -0
  417. package/src/owlly/element/map-kit/area.ts +232 -0
  418. package/src/owlly/element/map-kit/block-set.ts +102 -0
  419. package/src/owlly/element/map-kit/block.ts +417 -0
  420. package/src/owlly/element/map-kit/index.ts +6 -0
  421. package/src/owlly/element/map-kit/shape.ts +285 -0
  422. package/src/owlly/element/mesh-element.ts +94 -0
  423. package/src/owlly/element/mesh-line-2d.ts +1032 -0
  424. package/src/owlly/element/meshline-o.ts +802 -0
  425. package/src/owlly/element/panorama-group.ts +1250 -0
  426. package/src/owlly/element/panorama.ts +1044 -0
  427. package/src/owlly/element/path-group.ts +212 -0
  428. package/src/owlly/element/path.ts +727 -0
  429. package/src/owlly/element/placeable-2d.ts +627 -0
  430. package/src/owlly/element/polygon-mesh.ts +344 -0
  431. package/src/owlly/element/ring-element.ts +517 -0
  432. package/src/owlly/element/sphere-mesh.ts +96 -0
  433. package/src/owlly/element/svg-floor-model.ts +200 -0
  434. package/src/owlly/element/svg-floors.ts +121 -0
  435. package/src/owlly/element/tile-panorama-group.ts +1314 -0
  436. package/src/owlly/element/tile-panorama.ts +636 -0
  437. package/src/owlly/element/tile-plane.ts +430 -0
  438. package/src/owlly/element/video-element.ts +190 -0
  439. package/src/owlly/geometries/ExtrudeGeometry2.ts +255 -0
  440. package/src/owlly/index.ts +19 -0
  441. package/src/owlly/overlay/canvas-overlay.ts +642 -0
  442. package/src/owlly/overlay/css-2d-overlay.ts +48 -0
  443. package/src/owlly/overlay/css-3d-overlay.ts +50 -0
  444. package/src/owlly/overlay/index.ts +11 -0
  445. package/src/owlly/overlay/label-overlay.ts +419 -0
  446. package/src/owlly/overlay/overlay.ts +17 -0
  447. package/src/owlly/overlay/path-overlay.ts +170 -0
  448. package/src/owlly/overlay/path-overlay2.ts +149 -0
  449. package/src/owlly/overlay/poi-overlay-3d.ts +1759 -0
  450. package/src/owlly/overlay/poi-overlay.ts +1739 -0
  451. package/src/owlly/owlly-2d/index.ts +108 -0
  452. package/src/owlly/screen/index.ts +1 -0
  453. package/src/owlly/screen/screen.ts +323 -0
  454. package/src/owlly/stage/__test__/stage.spec.ts +15 -0
  455. package/src/owlly/stage/externals.ts +45 -0
  456. package/src/owlly/stage/index.ts +12 -0
  457. package/src/owlly/stage/owlly.ts +223 -0
  458. package/src/owlly/stage/stage.ts +274 -0
  459. package/src/owlly/utils/alignment-utils.ts +84 -0
  460. package/src/owlly/utils/basic-calc.ts +141 -0
  461. package/src/owlly/utils/basic-tools.ts +286 -0
  462. package/src/owlly/utils/bvh-tree.ts +695 -0
  463. package/src/owlly/utils/camera.ts +72 -0
  464. package/src/owlly/utils/cube-texture-cache.ts +155 -0
  465. package/src/owlly/utils/device-utils.ts +53 -0
  466. package/src/owlly/utils/environment-utils.ts +81 -0
  467. package/src/owlly/utils/event-hub.ts +120 -0
  468. package/src/owlly/utils/events.ts +266 -0
  469. package/src/owlly/utils/geometry-utils.ts +749 -0
  470. package/src/owlly/utils/helper.ts +33 -0
  471. package/src/owlly/utils/index.ts +17 -0
  472. package/src/owlly/utils/lru-cache.ts +126 -0
  473. package/src/owlly/utils/map-utils.ts +55 -0
  474. package/src/owlly/utils/number-utils.ts +75 -0
  475. package/src/owlly/utils/panorama-model-util.ts +255 -0
  476. package/src/owlly/utils/path-utils.ts +837 -0
  477. package/src/owlly/utils/svgutils.ts +732 -0
  478. package/src/owlly/utils/texture-cache.ts +132 -0
  479. package/src/owlly/utils/tile-util.ts +563 -0
  480. package/src/owlly/utils/time-profiler.ts +57 -0
  481. package/src/owlly/view/__test__/perspective-view.spec.ts +23 -0
  482. package/src/owlly/view/camera-view.ts +114 -0
  483. package/src/owlly/view/index.ts +5 -0
  484. package/src/owlly/view/orthographic-view.ts +124 -0
  485. package/src/owlly/view/perspective-view.ts +125 -0
  486. package/src/owlly/view/svg-map-view.ts +187 -0
  487. package/src/owlly/view/view.ts +409 -0
  488. package/src/public/js/jsmpeg.min.js +3129 -0
  489. package/src/web/index.html +52 -0
  490. package/src/web/main.centroid.ts +85 -0
  491. package/src/web/main.hyma.meshline2d.ts +84 -0
  492. package/src/web/main.jyfang.sample.ts +139 -0
  493. package/src/web/main.rpeng.extrude.ts +194 -0
  494. package/src/web/main.rpeng.mes.plane.ts +161 -0
  495. package/src/web/main.rpeng.sample.ts +345 -0
  496. package/src/web/main.rpeng.vr.ts +159 -0
  497. package/src/web/main.sample.ts +59 -0
  498. package/src/web/quattree.hyma.ts +163 -0
  499. package/src/web/sensor-vr-plugin.ts +201 -0
  500. package/src/web/testPixel.png +0 -0
@@ -0,0 +1,1239 @@
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 };
1239
+ //# sourceMappingURL=basic-controller.js.map