@aibee/owlly 1.0.26 → 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,1943 @@
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 } from '../stage/externals';
12
+ import { OrbitControls } from '../../external/orbit-controls';
13
+ import { Controller } from './controller';
14
+ import { PanoramaGroup } from '../element/panorama-group';
15
+ import { Events } from '../utils/events';
16
+ import { FloorModel } from '../element/floor-model';
17
+ import { CubeTextureCache } from '../utils/cube-texture-cache';
18
+ import { TextureCache } from '../utils/texture-cache';
19
+ // import { OwllyEvents } from '../utils/events';
20
+ const ROTATION_LOCK_BOUNDARY = 3 / 180 * Math.PI;
21
+ /**
22
+ * 在升级至瓦片后, 停止使用该控制器
23
+ */
24
+ class PanoramaController extends Controller {
25
+ /**
26
+ *
27
+ * @param view 绑定的View
28
+ * @param panoramaGroups 全景图组数组,至少需要有一个元素
29
+ * @param showModel 可选,是否一开始就显示模型
30
+ * @example
31
+ * ``` typescript
32
+ * panoCtl = new PanoramaController(view, panoMgr);
33
+ * panoCtl.setMouseClickEnabled(true);
34
+ * stage.bindController(panoCtl);
35
+ * panoCtl.lookFromPanorama(0, new Vector3(-1, 0, 0));
36
+ */
37
+ constructor(view, panoramaGroups, showModel) {
38
+ super();
39
+ const { THREE } = Externals.getInstance();
40
+ this.hidePanoramas = false;
41
+ this.showModel = showModel === undefined || showModel;
42
+ this.panoramaGroupChanged = true;
43
+ this.touches = {
44
+ s: [new THREE.Vector2(), new THREE.Vector2()],
45
+ c: [new THREE.Vector2(), new THREE.Vector2()],
46
+ state: 'idle',
47
+ dist: 0,
48
+ fov: 60,
49
+ };
50
+ this.touchStartHandler = (event) => {
51
+ // event.preventDefault();
52
+ const l = event.touches.length;
53
+ const tl = event.targetTouches.length;
54
+ for (let i = 0; i < Math.min(l, 2); i++) {
55
+ const t = event.touches[i];
56
+ this.touches.s[i] = new THREE.Vector2(t.clientX, t.clientY);
57
+ }
58
+ this.touches.state = 'down';
59
+ if (tl > 1 && this.view.camera instanceof THREE.PerspectiveCamera) {
60
+ this.touches.state = 'zoom';
61
+ this.touches.dist = this.touches.s[0].distanceTo(this.touches.s[1]);
62
+ this.touches.fov = this.view.camera.fov;
63
+ }
64
+ };
65
+ this.touchMoveHandler = (event) => {
66
+ if (!this.view.camera || !(this.view.camera instanceof THREE.PerspectiveCamera))
67
+ return;
68
+ if (this.touches.state === 'idle')
69
+ return;
70
+ event.preventDefault();
71
+ event.stopPropagation();
72
+ const l = event.touches.length;
73
+ for (let i = 0; i < Math.min(l, 2); i++) {
74
+ const t = event.touches[i];
75
+ this.touches.c[i] = new THREE.Vector2(t.clientX, t.clientY);
76
+ }
77
+ if (this.touches.state === 'down' && this.touches.c[0].distanceToSquared(this.touches.s[0]) > 100) {
78
+ this.touches.state = 'move';
79
+ }
80
+ else if (this.touches.state === 'zoom') {
81
+ const distDiff = this.touches.c[0].distanceTo(this.touches.c[1]) - this.touches.dist;
82
+ const { innerWidth, innerHeight } = window;
83
+ const diagnalDist = Math.sqrt((Math.pow(innerWidth, 2)) + (Math.pow(innerHeight, 2)));
84
+ const distRatio = distDiff / diagnalDist;
85
+ this.view.camera.fov = Math.min(Math.max(this.touches.fov - distRatio * 90, this.fovRange.min), this.fovRange.max);
86
+ this.view.camera.updateProjectionMatrix();
87
+ this.orbitControl.rotateSpeed = -this.view.camera.fov / 360 * this.rotateSpeed;
88
+ this.renderThisFrame();
89
+ }
90
+ };
91
+ this.touchEndHandler = (event) => __awaiter(this, void 0, void 0, function* () {
92
+ if (this.touches.state === 'idle')
93
+ return;
94
+ if (this.touches.state === 'down' && this.view.renderer) {
95
+ const touchPoint = new THREE.Vector2(this.touches.s[0].x, this.touches.s[0].y);
96
+ const { clientWidth, clientHeight } = this.view.container;
97
+ const { left: rectX, top: rectY } = this.view.container.getBoundingClientRect();
98
+ const x = touchPoint.x - rectX;
99
+ const y = touchPoint.y - rectY;
100
+ this.raycaster.setFromCamera({ x, y }, this.view.camera);
101
+ if (this.currentPanoramaGroup) {
102
+ let toPID;
103
+ if (this.onScreenDetectRadius > 0 && this.view.camera) {
104
+ toPID = this.currentPanoramaGroup.intersectIndicatorsOnScreen(new THREE.Vector2(x, y), this.onScreenDetectRadius, { screenWidth: clientWidth, screenHeight: clientHeight }, this.view.camera);
105
+ }
106
+ else {
107
+ toPID = this.currentPanoramaGroup.intersectIndicators(this.raycaster.ray.origin, this.raycaster.ray.direction);
108
+ }
109
+ if (toPID !== -1) {
110
+ this.emit(Events.CLICK_PANORAMA, toPID, event);
111
+ // this.moveToPanorama(toPID, { interval: 2000, toDirection: new Vector3(-0.8, 0.6, 0.0) });
112
+ if (this.moveOnClick && this.currentPanoramaGroup.currentPanoramaID !== toPID) {
113
+ yield this.moveToPanorama(toPID, { interval: 1000, showModel: true, fadeInOut: false });
114
+ }
115
+ }
116
+ }
117
+ }
118
+ this.touches.state = 'idle';
119
+ });
120
+ this.mouseDownHandler = (event) => {
121
+ if (event.pointerType !== 'mouse')
122
+ return;
123
+ // this.mouseMovement = new Vector2(event.movementX, event.movementY).length();
124
+ this.touches.s[0] = new THREE.Vector2(event.clientX, event.clientY);
125
+ this.touches.state = 'down';
126
+ };
127
+ this.mouseMoveHandler = (event) => {
128
+ if (event.pointerType !== 'mouse')
129
+ return;
130
+ // this.mouseMovement += new Vector2(event.movementX, event.movementY).length();
131
+ this.touches.c[0] = new THREE.Vector2(event.clientX, event.clientY);
132
+ if (this.touches.state === 'down' && this.touches.c[0].distanceToSquared(this.touches.s[0]) > 100) {
133
+ this.touches.state = 'move';
134
+ }
135
+ if (this.raycaster && this.captureMove) {
136
+ const { clientWidth, clientHeight } = this.view.container;
137
+ const { left: rectX, top: rectY } = this.view.container.getBoundingClientRect();
138
+ const x = event.clientX - rectX;
139
+ const y = event.clientY - rectY;
140
+ this.raycaster.setFromCamera({ x, y }, this.view.camera);
141
+ if (this.currentPanoramaGroup) {
142
+ let toPID;
143
+ if (this.onScreenDetectRadius > 0 && this.view.camera) {
144
+ toPID = this.currentPanoramaGroup.intersectIndicatorsOnScreen(new THREE.Vector2(x, y), this.onScreenDetectRadius, { screenWidth: clientWidth, screenHeight: clientHeight }, this.view.camera);
145
+ }
146
+ else {
147
+ toPID = this.currentPanoramaGroup.intersectIndicators(this.raycaster.ray.origin, this.raycaster.ray.direction);
148
+ }
149
+ if (toPID > -1) {
150
+ this.emit(Events.PANORAMA_HOVER, toPID, this.currentPanoramaGroup.getIndicatorPosition(toPID));
151
+ }
152
+ }
153
+ }
154
+ };
155
+ this.mouseUpHandler = (event) => __awaiter(this, void 0, void 0, function* () {
156
+ // console.info('## mouseup : ', event);
157
+ // if (this.touches.state === 'idle') return;
158
+ if (event.pointerType !== 'mouse')
159
+ return;
160
+ if (this.touches.state === 'down') {
161
+ const { clientWidth, clientHeight } = this.view.container;
162
+ const { left: rectX, top: rectY } = this.view.container.getBoundingClientRect();
163
+ const x = event.clientX - rectX;
164
+ const y = event.clientY - rectY;
165
+ if (this.raycaster) {
166
+ this.raycaster.setFromCamera({ x, y }, this.view.camera);
167
+ if (this.onScreenDetectRadius && this.currentPanoramaGroup) {
168
+ let toPID;
169
+ if (this.view.camera) {
170
+ toPID = this.currentPanoramaGroup.intersectIndicatorsOnScreen(new THREE.Vector2(x, y), this.onScreenDetectRadius, { screenWidth: clientWidth, screenHeight: clientHeight }, this.view.camera);
171
+ }
172
+ else {
173
+ toPID = this.currentPanoramaGroup.intersectIndicators(this.raycaster.ray.origin, this.raycaster.ray.direction);
174
+ }
175
+ if (toPID !== -1) {
176
+ this.emit(Events.CLICK_PANORAMA, toPID, event);
177
+ // this.moveToPanorama(toPID, { interval: 2000, toDirection: new Vector3(-0.8, 0.6, 0.0) });
178
+ if (event.button === 0 && this.moveOnClick && this.currentPanoramaGroup.currentPanoramaID !== toPID) {
179
+ yield this.moveToPanorama(toPID, { interval: 1000, showModel: true, fadeInOut: false });
180
+ }
181
+ }
182
+ }
183
+ }
184
+ }
185
+ this.touches.state = 'idle';
186
+ });
187
+ this.mouseWheelHandler = (event) => {
188
+ event.preventDefault();
189
+ if (!(this.view.camera instanceof THREE.PerspectiveCamera))
190
+ return;
191
+ this.view.camera.fov = Math.min(Math.max(this.view.camera.fov - Math.sign(event.deltaY) * 1.5, this.fovRange.min), this.fovRange.max);
192
+ this.view.camera.updateProjectionMatrix();
193
+ this.orbitControl.rotateSpeed = -this.view.camera.fov / 360 * this.rotateSpeed;
194
+ this.renderThisFrame();
195
+ };
196
+ this.moveOnClick = true;
197
+ this.onScreenDetectRadius = 1000;
198
+ this.rotateSpeed = 1;
199
+ if (view) {
200
+ this.bindView(view);
201
+ this.renderThisFrame();
202
+ }
203
+ if (panoramaGroups) {
204
+ if (panoramaGroups instanceof PanoramaGroup) {
205
+ this.panoramaGroups = [panoramaGroups];
206
+ }
207
+ else {
208
+ this.panoramaGroups = panoramaGroups;
209
+ }
210
+ }
211
+ else {
212
+ this.panoramaGroups = [];
213
+ }
214
+ if (this.panoramaGroups.length > 0) {
215
+ [this.currentPanoramaGroup] = this.panoramaGroups;
216
+ }
217
+ this.pid2GroupMap = new Map();
218
+ const modelVisible = (undefined === showModel || showModel === true || this.showModel);
219
+ this.panoramaGroups.forEach((panoGroup) => {
220
+ const modelMesh = PanoramaController.getModelMesh(panoGroup);
221
+ this.setModelAppearance(panoGroup.modelElement, modelVisible, undefined, modelMesh);
222
+ });
223
+ // this.mouseMovement = 0;
224
+ this.isAnimating = false;
225
+ this.rotationLocks = {
226
+ lockAzimuth: false,
227
+ lockPolar: false,
228
+ centralAzimuth: 0,
229
+ centralPolar: Math.PI / 2,
230
+ azimuthRange: Math.PI,
231
+ polarRange: Math.PI / 2,
232
+ };
233
+ this.fovRange = { min: 60, max: 90 };
234
+ this.raycaster = new THREE.Raycaster();
235
+ }
236
+ /**
237
+ * 获得模型顶点着色器
238
+ * @ignore
239
+ * @returns {string} 顶点着色器代码
240
+ */
241
+ static getModelVS() {
242
+ const vertexShader = `
243
+ uniform vec3 pano0Position;
244
+ uniform mat4 pano0Matrix;
245
+ uniform vec3 pano1Position;
246
+ uniform mat4 pano1Matrix;
247
+
248
+ varying vec3 vWorldPosition0;
249
+ varying vec3 vWorldPosition1;
250
+
251
+ void main() {
252
+
253
+ vec4 worldPosition = modelMatrix * vec4(position, 1.0);
254
+
255
+ vec3 positionLocalToPanoCenter0 = worldPosition.xyz - pano0Position;
256
+ vWorldPosition0 = (vec4(positionLocalToPanoCenter0, 1.0) * pano0Matrix).xyz;
257
+ vWorldPosition0.y *= -1.0;
258
+
259
+ vec3 positionLocalToPanoCenter1 = worldPosition.xyz - pano1Position;
260
+ vWorldPosition1 = (vec4(positionLocalToPanoCenter1, 1.0) * pano1Matrix).xyz;
261
+ vWorldPosition1.y *= -1.0;
262
+
263
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
264
+ }`;
265
+ return vertexShader;
266
+ }
267
+ static getInstantTranslationVS() {
268
+ // L == lookAt = Inv(R) * Inv(T)
269
+ // L1 * p1 = L0 * p0 => p0 = Inv(L0) * L1 * p1
270
+ // Let T = Inv(L0) * L1
271
+ const vertexShader = `
272
+ uniform mat4 matrixT;
273
+
274
+ uniform vec3 pano0Position;
275
+ uniform mat4 pano0Matrix;
276
+ uniform vec3 pano1Position;
277
+ uniform mat4 pano1Matrix;
278
+
279
+ varying vec3 vWorldPosition0;
280
+ varying vec3 vWorldPosition1;
281
+
282
+ void main() {
283
+
284
+ vec4 worldPosition = modelMatrix * vec4(position, 1.0);
285
+ vec4 worldPosition0 = matrixT * worldPosition;
286
+
287
+ vec3 positionLocalToPanoCenter1 = worldPosition.xyz - pano1Position;
288
+ vWorldPosition1 = (vec4(positionLocalToPanoCenter1, 1.0) * pano1Matrix).xyz;
289
+ vWorldPosition1.y *= -1.0;
290
+
291
+ vec3 positionLocalToPanoCenter0 = worldPosition0.xyz - pano0Position;
292
+ vWorldPosition0 = (vec4(positionLocalToPanoCenter0, 1.0) * pano0Matrix).xyz;
293
+ vWorldPosition0.y *= -1.0;
294
+
295
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
296
+ }`;
297
+ return vertexShader;
298
+ }
299
+ /**
300
+ * 获得模型片源着色器
301
+ * @ignore
302
+ * @returns {string} 片源着色器代码
303
+ */
304
+ static getModelFS() {
305
+ const fragmentShader = `
306
+ uniform float weight0;
307
+ uniform float weight1;
308
+
309
+ uniform samplerCube pano0Map;
310
+
311
+ uniform samplerCube pano1Map;
312
+
313
+ varying vec3 vWorldPosition0;
314
+ varying vec3 vWorldPosition1;
315
+
316
+ void main() {
317
+ vec3 cp0 = vWorldPosition0.xyz;
318
+ vec3 cp1 = vWorldPosition1.xyz;
319
+ vec4 colorFromPano0 = textureCube( pano0Map, cp0);
320
+ vec4 colorFromPano1 = textureCube( pano1Map, cp1);
321
+
322
+ vec4 colorFromPanos;
323
+ // 'colorFromPanos = mix(colorFromPano0, colorFromPano1, progress);
324
+ colorFromPanos = colorFromPano0 * weight0 + colorFromPano1 * weight1;
325
+ gl_FragColor = vec4(colorFromPanos.rgb, 1.0);
326
+ }`;
327
+ return fragmentShader;
328
+ }
329
+ static debugModelVS() {
330
+ const vertexShader = `
331
+ uniform vec2 xRange;
332
+ uniform vec2 yRange;
333
+ uniform vec2 zRange;
334
+ varying vec4 vColor;
335
+
336
+ void main() {
337
+ vColor = vec4((position.x - xRange.x) / xRange.y, (position.y - yRange.x) / yRange.y, (position.z - zRange.x) / zRange.y, 1.0);
338
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
339
+ }`;
340
+ return vertexShader;
341
+ }
342
+ static debugModelFS() {
343
+ const fragmentShader = `
344
+ varying vec4 vColor;
345
+
346
+ void main() {
347
+ gl_FragColor = vColor;
348
+ }`;
349
+ return fragmentShader;
350
+ }
351
+ dispose() {
352
+ return __awaiter(this, void 0, void 0, function* () {
353
+ if (this.modelMaterial) {
354
+ this.modelMaterial.dispose();
355
+ }
356
+ if (this.instantTranslationMaterial) {
357
+ this.instantTranslationMaterial.dispose();
358
+ }
359
+ this.setTouchEnabled(false);
360
+ this.setMouseClickEnabled(false);
361
+ TextureCache.disposeAll();
362
+ CubeTextureCache.disposeAll();
363
+ if (this.translatePromise) {
364
+ yield this.translatePromise;
365
+ }
366
+ });
367
+ }
368
+ setViewConfiguration(hidePanoramas, showModel) {
369
+ return __awaiter(this, void 0, void 0, function* () {
370
+ this.hidePanoramas = hidePanoramas;
371
+ this.showModel = showModel;
372
+ if (this.currentPanoramaGroup) {
373
+ const pano = yield this.currentPanoramaGroup.getPanoramaByPID(this.currentPanoramaGroup.currentPanoramaID);
374
+ if (pano) {
375
+ pano.addViewConfiguration({
376
+ targetView: this.view,
377
+ showSkyBox: !hidePanoramas,
378
+ });
379
+ }
380
+ this.setModelAppearance(this.currentPanoramaGroup.modelElement, showModel);
381
+ }
382
+ });
383
+ }
384
+ bindElement(element) {
385
+ if (element instanceof Array) {
386
+ element.forEach((e) => { this.bindElement(e); });
387
+ }
388
+ else {
389
+ if (!this.elements) {
390
+ this.elements = new Set();
391
+ }
392
+ this.elements.add(element);
393
+ // if (element.intersectables && element.intersectables.length) {
394
+ // element.intersectables.forEach((object) => {
395
+ // this.intersectables.push({ object, parent: element });
396
+ // });
397
+ // } else {
398
+ // element.children.filter((c) => (c as Mesh).isMesh).forEach((object) => {
399
+ // this.intersectables.push({ object, parent: element });
400
+ // });
401
+ // }
402
+ }
403
+ }
404
+ unbindElement(element) {
405
+ if (element instanceof Array) {
406
+ element.forEach((e) => { this.unbindElement(e); });
407
+ }
408
+ else if (this.elements && this.elements.has(element)) {
409
+ this.elements.delete(element);
410
+ }
411
+ }
412
+ /**
413
+ * 添加全景图组
414
+ * @param panoramaGroups 新增加的全景图组(单个或数组)
415
+ * @parama showModel 可选,是否一开始就显示模型
416
+ */
417
+ addPanoramaGroups(panoramaGroups, showModel) {
418
+ let groupArray;
419
+ if (panoramaGroups instanceof PanoramaGroup) {
420
+ groupArray = [panoramaGroups];
421
+ }
422
+ else {
423
+ groupArray = panoramaGroups;
424
+ }
425
+ this.panoramaGroups.push(...groupArray);
426
+ const modelVisible = (undefined === showModel || showModel === true || this.showModel);
427
+ groupArray.forEach((panoGroup) => {
428
+ const modelMesh = PanoramaController.getModelMesh(panoGroup);
429
+ this.setModelAppearance(panoGroup.modelElement, modelVisible, undefined, modelMesh);
430
+ });
431
+ }
432
+ removePanoramaGroup(panoramaGroup) {
433
+ const index = this.panoramaGroups.indexOf(panoramaGroup);
434
+ if (index >= 0) {
435
+ this.panoramaGroups = this.panoramaGroups.slice(0, index).concat(this.panoramaGroups.slice(index + 1));
436
+ if (panoramaGroup === this.currentPanoramaGroup) {
437
+ this.currentPanoramaGroup = undefined;
438
+ }
439
+ return true;
440
+ }
441
+ return false;
442
+ }
443
+ renderThisFrame() {
444
+ if (!this.renderFrame) {
445
+ this.renderFrame = true;
446
+ }
447
+ }
448
+ static getModelMeshInElement(e) {
449
+ let ret;
450
+ const { THREE } = Externals.getInstance();
451
+ if (e instanceof THREE.Mesh)
452
+ return e;
453
+ if (e) {
454
+ e.traverse((obj) => {
455
+ if (obj instanceof THREE.Mesh) {
456
+ ret = obj;
457
+ }
458
+ });
459
+ }
460
+ return ret;
461
+ }
462
+ static getModelMesh(panoGroup) {
463
+ if (panoGroup && panoGroup.modelElement) { // TODO: Multiple children mesh?
464
+ return PanoramaController.getModelMeshInElement(panoGroup.modelElement);
465
+ }
466
+ return undefined;
467
+ }
468
+ bindView(view) {
469
+ if (!view.camera || !view.renderer) {
470
+ throw new Error('No Camera or Renderer found in view');
471
+ }
472
+ this.view = view;
473
+ const { THREE } = Externals.getInstance();
474
+ this.setTouchEnabled(true);
475
+ this.orbitControl = new OrbitControls(view.camera, view.container);
476
+ this.orbitControl.addEventListener('start', () => {
477
+ this.renderThisFrame();
478
+ });
479
+ this.orbitControl.addEventListener('end', () => {
480
+ this.renderThisFrame();
481
+ });
482
+ this.orbitControl.addEventListener('change', () => {
483
+ this.emit(Events.PANORAMA_CAMERA_CHANGED, view.camera.position, view.camera.quaternion, this);
484
+ const { lockAzimuth, lockPolar } = this.rotationLocks;
485
+ let vFov = 0;
486
+ let hFov = 0;
487
+ if (this.orbitControl.object instanceof THREE.PerspectiveCamera) {
488
+ const { clientWidth, clientHeight } = this.view.container;
489
+ vFov = this.orbitControl.object.fov / 180 * Math.PI;
490
+ hFov = vFov * clientWidth / clientHeight;
491
+ }
492
+ if (lockAzimuth) {
493
+ const { centralAzimuth, azimuthRange } = this.rotationLocks;
494
+ const azimuth = this.orbitControl.getAzimuthalAngle();
495
+ let minAzimuth = centralAzimuth - azimuthRange / 2 + hFov / 2;
496
+ let maxAzimuth = centralAzimuth + azimuthRange / 2 - hFov / 2;
497
+ if (minAzimuth > Math.PI)
498
+ minAzimuth -= 2 * Math.PI;
499
+ if (maxAzimuth < -Math.PI)
500
+ maxAzimuth += 2 * Math.PI;
501
+ if (minAzimuth > maxAzimuth) {
502
+ this.orbitControl.minAzimuthAngle = centralAzimuth;
503
+ this.orbitControl.maxAzimuthAngle = centralAzimuth;
504
+ }
505
+ else {
506
+ if (minAzimuth < -Math.PI)
507
+ minAzimuth += 2 * Math.PI;
508
+ if (maxAzimuth > Math.PI)
509
+ maxAzimuth -= 2 * Math.PI;
510
+ if (minAzimuth > maxAzimuth) {
511
+ if (Math.abs(azimuth) > Math.PI - ROTATION_LOCK_BOUNDARY) {
512
+ this.orbitControl.minAzimuthAngle = -Infinity;
513
+ this.orbitControl.maxAzimuthAngle = Infinity;
514
+ }
515
+ else if (azimuth > 0) {
516
+ this.orbitControl.minAzimuthAngle = minAzimuth;
517
+ this.orbitControl.maxAzimuthAngle = Infinity;
518
+ }
519
+ else if (azimuth < 0) {
520
+ this.orbitControl.minAzimuthAngle = -Infinity;
521
+ this.orbitControl.maxAzimuthAngle = maxAzimuth;
522
+ }
523
+ }
524
+ else {
525
+ this.orbitControl.minAzimuthAngle = minAzimuth;
526
+ this.orbitControl.maxAzimuthAngle = maxAzimuth;
527
+ }
528
+ }
529
+ }
530
+ if (lockPolar) {
531
+ const { centralPolar, polarRange } = this.rotationLocks;
532
+ const polar = this.orbitControl.getPolarAngle();
533
+ let minPolar = centralPolar - polarRange / 2 + vFov / 2;
534
+ let maxPolar = centralPolar + polarRange / 2 - vFov / 2;
535
+ if (minPolar > Math.PI)
536
+ minPolar -= Math.PI;
537
+ if (maxPolar < 0)
538
+ maxPolar += Math.PI;
539
+ if (minPolar > maxPolar) {
540
+ this.orbitControl.minPolarAngle = centralPolar;
541
+ this.orbitControl.maxPolarAngle = centralPolar;
542
+ }
543
+ else {
544
+ if (minPolar < 0)
545
+ minPolar += Math.PI;
546
+ if (maxPolar > Math.PI)
547
+ maxPolar -= Math.PI;
548
+ if (minPolar > maxPolar) {
549
+ if (Math.abs(polar - Math.PI / 2) > Math.PI / 2 - ROTATION_LOCK_BOUNDARY) {
550
+ this.orbitControl.minPolarAngle = -Infinity;
551
+ this.orbitControl.maxPolarAngle = Infinity;
552
+ }
553
+ else if (polar > 0) {
554
+ this.orbitControl.minPolarAngle = minPolar;
555
+ this.orbitControl.maxPolarAngle = Infinity;
556
+ }
557
+ else if (polar < 0) {
558
+ this.orbitControl.minPolarAngle = -Infinity;
559
+ this.orbitControl.maxPolarAngle = maxPolar;
560
+ }
561
+ }
562
+ else {
563
+ this.orbitControl.minPolarAngle = minPolar;
564
+ this.orbitControl.maxPolarAngle = maxPolar;
565
+ }
566
+ }
567
+ }
568
+ this.renderThisFrame();
569
+ });
570
+ this.orbitControl.rotateSpeed = PanoramaController.RotateSpeed;
571
+ if (view.camera && view.camera instanceof THREE.PerspectiveCamera) {
572
+ const { fov } = view.camera;
573
+ this.orbitControl.rotateSpeed = -fov / 360 * this.rotateSpeed;
574
+ }
575
+ this.setMouseControls({ LEFT: THREE.MOUSE.ROTATE, MIDDLE: THREE.MOUSE.DOLLY, RIGHT: THREE.MOUSE.PAN });
576
+ this.setTouchControls({ ONE: THREE.TOUCH.ROTATE, TWO: THREE.TOUCH.PAN });
577
+ this.setDampingEnabled(true);
578
+ this.setDampingFactor(0.25);
579
+ this.setKeysEnabled(false);
580
+ this.setRotateEnabled(true);
581
+ this.setPanEnabled(false);
582
+ this.setZoomEnabled(false);
583
+ this.orbitControl.update();
584
+ this.setEnabled(true);
585
+ this.renderThisFrame();
586
+ }
587
+ unbind() {
588
+ const _super = Object.create(null, {
589
+ unbind: { get: () => super.unbind }
590
+ });
591
+ return __awaiter(this, void 0, void 0, function* () {
592
+ _super.unbind.call(this);
593
+ if (this.orbitControl)
594
+ this.orbitControl.dispose();
595
+ yield this.dispose();
596
+ });
597
+ }
598
+ /**
599
+ * @ignore
600
+ */
601
+ update() {
602
+ if (this.orbitControl && this.orbitControl.enabled)
603
+ this.orbitControl.update();
604
+ let result = true;
605
+ if (!this.renderFrame)
606
+ result = false;
607
+ this.renderFrame = false;
608
+ return result;
609
+ }
610
+ /**
611
+ * 设置是否启用该控制器
612
+ * @param value 开关值
613
+ */
614
+ setEnabled(value) {
615
+ if (this.orbitControl)
616
+ this.orbitControl.enabled = value;
617
+ }
618
+ /**
619
+ * 设置键盘控制启用
620
+ * @param value 是否启用键盘控制
621
+ */
622
+ setKeysEnabled(value) {
623
+ if (!this.orbitControl)
624
+ return;
625
+ this.orbitControl.enableKeys = value;
626
+ }
627
+ /**
628
+ * 使能/禁用 鼠标点击
629
+ * @param value 使能还是禁用
630
+ */
631
+ setMouseClickEnabled(enable) {
632
+ if (!this.view.renderer)
633
+ return false;
634
+ const { THREE } = Externals.getInstance();
635
+ if (this.view.camera && this.view.camera instanceof THREE.Camera) {
636
+ if (enable) {
637
+ this.view.container.addEventListener('pointerup', this.mouseUpHandler, false);
638
+ this.view.container.addEventListener('pointermove', this.mouseMoveHandler, false);
639
+ this.view.container.addEventListener('pointerdown', this.mouseDownHandler, false);
640
+ this.view.container.addEventListener('wheel', this.mouseWheelHandler, false);
641
+ }
642
+ else {
643
+ this.view.container.removeEventListener('pointerup', this.mouseUpHandler, false);
644
+ this.view.container.removeEventListener('pointermove', this.mouseMoveHandler, false);
645
+ this.view.container.removeEventListener('pointerdown', this.mouseDownHandler, false);
646
+ this.view.container.removeEventListener('wheel', this.mouseWheelHandler, false);
647
+ }
648
+ }
649
+ return true;
650
+ }
651
+ setTouchEnabled(enable) {
652
+ if (!this.view.renderer)
653
+ return false;
654
+ const { THREE } = Externals.getInstance();
655
+ if (this.view.camera && this.view.camera instanceof THREE.Camera) {
656
+ if (enable) {
657
+ this.view.container.addEventListener('touchstart', this.touchStartHandler, false);
658
+ this.view.container.addEventListener('touchmove', this.touchMoveHandler, false);
659
+ this.view.container.addEventListener('touchend', this.touchEndHandler, false);
660
+ this.view.container.addEventListener('touchcancel', this.touchEndHandler, false);
661
+ }
662
+ else {
663
+ this.view.container.removeEventListener('touchstart', this.touchStartHandler);
664
+ this.view.container.removeEventListener('touchmove', this.touchMoveHandler);
665
+ this.view.container.removeEventListener('touchend', this.touchEndHandler);
666
+ this.view.container.removeEventListener('touchcancel', this.touchEndHandler);
667
+ }
668
+ }
669
+ return true;
670
+ }
671
+ /**
672
+ * 设置是否启用惯性
673
+ * @param value 开关值
674
+ */
675
+ setDampingEnabled(value) {
676
+ if (!this.orbitControl)
677
+ return;
678
+ this.orbitControl.enableDamping = value;
679
+ }
680
+ /**
681
+ * 设置是否启用旋转功能
682
+ * @param value 开关值
683
+ */
684
+ setRotateEnabled(value) {
685
+ if (!this.orbitControl)
686
+ return;
687
+ this.orbitControl.enableRotate = value;
688
+ }
689
+ /**
690
+ * 设置是否启用平移功能
691
+ * @param value 开关值
692
+ */
693
+ setPanEnabled(value) {
694
+ if (!this.orbitControl)
695
+ return;
696
+ this.orbitControl.enablePan = value;
697
+ }
698
+ /**
699
+ * 设置是否启用缩放功能
700
+ * @param value 开关值
701
+ */
702
+ setZoomEnabled(value) {
703
+ if (!this.orbitControl)
704
+ return;
705
+ this.orbitControl.enableZoom = value;
706
+ }
707
+ /**
708
+ * 设置缩放
709
+ * @param zoom 缩放比例值
710
+ */
711
+ setZoom(zoom) {
712
+ if (!this.orbitControl)
713
+ return;
714
+ const { THREE } = Externals.getInstance();
715
+ if (!(this.view.camera instanceof THREE.PerspectiveCamera)
716
+ && !(this.view.camera instanceof THREE.OrthographicCamera))
717
+ throw new Error('Cannot set zoom for camera');
718
+ this.view.camera.zoom = zoom;
719
+ this.view.camera.updateProjectionMatrix();
720
+ this.renderFrame = true;
721
+ }
722
+ /**
723
+ * 设置FOV, 不可以超过setFOVRange所设置的范围.
724
+ * @param fov 垂直方向视场角
725
+ */
726
+ setFOV(fov) {
727
+ const { THREE } = Externals.getInstance();
728
+ if (!this.orbitControl || !(this.view.camera instanceof THREE.PerspectiveCamera))
729
+ return;
730
+ const targetFov = Math.min(Math.max(fov, this.fovRange.min), this.fovRange.max);
731
+ this.view.camera.fov = targetFov;
732
+ this.view.camera.updateProjectionMatrix();
733
+ this.orbitControl.rotateSpeed = -targetFov / 360 * this.rotateSpeed;
734
+ this.renderFrame = true;
735
+ }
736
+ /**
737
+ * 设置FOV范围, 默认为[60, 90]
738
+ * @param min 垂直方向视场角最小值
739
+ * @param max 垂直方向视场角最大值
740
+ */
741
+ setFOVRange(min, max) {
742
+ this.fovRange.min = min;
743
+ this.fovRange.max = max;
744
+ const { THREE } = Externals.getInstance();
745
+ if (!this.orbitControl || !(this.view.camera instanceof THREE.PerspectiveCamera))
746
+ return;
747
+ this.setFOV(this.view.camera.fov);
748
+ }
749
+ /**
750
+ * 设置惯性阻尼
751
+ * @param value 衰减值
752
+ */
753
+ setDampingFactor(value) {
754
+ if (!this.orbitControl)
755
+ return;
756
+ this.orbitControl.dampingFactor = value;
757
+ }
758
+ /**
759
+ * 设置位移速度
760
+ * @param value 位移速度
761
+ */
762
+ setPanSpeed(value) {
763
+ if (!this.orbitControl)
764
+ return;
765
+ this.orbitControl.panSpeed = value;
766
+ }
767
+ /**
768
+ * 设置旋转速度
769
+ * @param value 旋转速度
770
+ */
771
+ // public setRotateSpeed(value: number): void {
772
+ // if (!this.orbitControl) return;
773
+ // this.orbitControl.rotateSpeed = value;
774
+ // }
775
+ /**
776
+ * 设置触摸操作模式
777
+ * @param touches 触摸配置
778
+ */
779
+ setTouchControls(touches) {
780
+ if (!this.orbitControl)
781
+ return;
782
+ this.orbitControl.touches = touches;
783
+ }
784
+ /**
785
+ * 设置鼠标操作模式
786
+ * @param mouseButtons 鼠标按键配置
787
+ */
788
+ setMouseControls(mouseButtons) {
789
+ if (!this.orbitControl)
790
+ return;
791
+ this.orbitControl.mouseButtons = mouseButtons;
792
+ }
793
+ /**
794
+ * 设置控制中心点
795
+ * @param x 世界坐标X
796
+ * @param y 世界坐标Y
797
+ * @param z 世界坐标Z
798
+ */
799
+ setTarget(x, y, z) {
800
+ if (!this.orbitControl)
801
+ return;
802
+ this.orbitControl.target.set(x, y, z);
803
+ this.orbitControl.update();
804
+ }
805
+ /**
806
+ * 设置摄像机观察方向和位置
807
+ * @param position 摄像机所在位置
808
+ * @param lookAt 观察目标点,同时也是[[OrbitControls]]的旋转中心
809
+ */
810
+ setCameraPose(position, lookAt, useLookAt = true) {
811
+ if (this.view.camera) {
812
+ this.view.camera.position.set(...position);
813
+ // this.view.camera.lookAt(...lookAt);
814
+ }
815
+ if (useLookAt)
816
+ this.setTarget(...lookAt);
817
+ // console.log(lookAt);
818
+ this.renderThisFrame();
819
+ }
820
+ getPanoramaOfPID(pid) {
821
+ return __awaiter(this, void 0, void 0, function* () {
822
+ const panoGroup = this.pid2GroupMap.get(pid);
823
+ if (panoGroup) {
824
+ const pano = yield panoGroup.getPanoramaByPID(pid);
825
+ return { pano, panoramaGroup: panoGroup };
826
+ }
827
+ for (let i = 0; i < this.panoramaGroups.length; i += 1) {
828
+ const panoramaGroup = this.panoramaGroups[i];
829
+ // eslint-disable-next-line no-await-in-loop
830
+ const pano = yield panoramaGroup.getPanoramaByPID(pid);
831
+ if (pano) {
832
+ this.pid2GroupMap.set(pid, panoramaGroup);
833
+ return { pano, panoramaGroup };
834
+ }
835
+ }
836
+ return {};
837
+ });
838
+ }
839
+ preloadCubeTexturesOfPIDs(pids, waitForReadyCount, recycleIntermediateTextures) {
840
+ return __awaiter(this, void 0, void 0, function* () {
841
+ const panos = yield Promise.all(pids.map((pid) => this.getPanoramaOfPID(pid)));
842
+ const textureURLsArray = panos.map(({ pano }) => {
843
+ if (pano) {
844
+ return pano.textureURLs;
845
+ }
846
+ return undefined;
847
+ });
848
+ return CubeTextureCache.sharedInstance.preloadCubeTextures(textureURLsArray, waitForReadyCount, recycleIntermediateTextures);
849
+ });
850
+ }
851
+ /**
852
+ * 设置摄像机按指定视线方向看向目标位置
853
+ * @param target 目标位置
854
+ * @param sightDirection 可选,视线方向,不设置则默认以摄像机当前方向
855
+ */
856
+ setCameraLookAt(target, sightDirection) {
857
+ const { x, y, z } = target;
858
+ const { THREE } = Externals.getInstance();
859
+ let direction;
860
+ if (sightDirection) {
861
+ direction = sightDirection.clone().normalize();
862
+ }
863
+ else if (this.view.camera) {
864
+ direction = this.view.camera.getWorldDirection(new THREE.Vector3(0, 0, -1));
865
+ }
866
+ else {
867
+ direction = new THREE.Vector3(1, 0, 0);
868
+ }
869
+ const p0 = direction
870
+ .multiplyScalar(PanoramaController.DirectionVectorScalar)
871
+ .add(target);
872
+ this.setCameraPose([p0.x, p0.y, p0.z], [x, y, z]);
873
+ }
874
+ /**
875
+ * 仅显示指定全景图,但不操作摄像机
876
+ * @param pid 全景点PID
877
+ * @parama showModel 可选,是否一开始就显示模型
878
+ * @param preInitPanoramasStrategy 可选,预创建全景对象的顺序策略,详见[PanoramaGroup]的【initializePanoramasIfNecessary]方法说明
879
+ */
880
+ showPanorama(pid, options) {
881
+ return __awaiter(this, void 0, void 0, function* () {
882
+ const { lookDirection, target, showModel, preInitPanoramasStrategy, } = options || {};
883
+ const { pano, panoramaGroup } = yield this.getPanoramaOfPID(pid);
884
+ if (panoramaGroup) {
885
+ if (this.currentPanoramaGroup !== panoramaGroup)
886
+ this.panoramaGroupChanged = true;
887
+ this.currentPanoramaGroup = panoramaGroup;
888
+ if (panoramaGroup.modelElement) {
889
+ this.setModelAppearance(panoramaGroup.modelElement, false, undefined);
890
+ }
891
+ if (preInitPanoramasStrategy) {
892
+ panoramaGroup.initializePanoramasIfNecessary(preInitPanoramasStrategy);
893
+ }
894
+ panoramaGroup.panoramaIDsAround(pid);
895
+ // const allPanos = await panoramaGroup.allPanoramas();
896
+ // // console.info(`#Async# showPanorama : allPanos(${allPanos!.length})=`, allPanos);
897
+ // allPanos.forEach((panorama: Panorama) => {
898
+ // panorama.addViewConfiguration({
899
+ // targetView: this.view,
900
+ // showBorder: false,
901
+ // showSkyBox: false,
902
+ // });
903
+ // });
904
+ // if (aroundPIDs) {
905
+ // const panoramas = await Promise.all(aroundPIDs.map((panoID: number) => panoramaGroup.getPanoramaByPID(panoID)));
906
+ // console.info('#Async# showPanorama : panoramas=', panoramas);
907
+ // panoramas.forEach((panorama: Panorama) => {
908
+ // panorama.addViewConfiguration({
909
+ // targetView: this.view,
910
+ // showBorder: false,
911
+ // showSkyBox: false,
912
+ // });
913
+ // });
914
+ // }
915
+ panoramaGroup.presentPanoramaIndicatorsAround(pid, this.view);
916
+ if (pano) {
917
+ if (lookDirection) {
918
+ this.setCameraLookAt(pano.position, lookDirection);
919
+ }
920
+ else if (target) {
921
+ this.setCameraLookAt(pano.position, target.clone().sub(pano.position));
922
+ }
923
+ if (!pano.legacyMode) {
924
+ const tiles = pano.getIntersectedTiles(this.view.camera);
925
+ yield panoramaGroup.presentPanoramaAround(pid, tiles.hdTiles, tiles.ldTiles, this.view);
926
+ }
927
+ else {
928
+ yield panoramaGroup.presentPanoramaAround(pid, [], [], this.view);
929
+ }
930
+ pano.addViewConfiguration({
931
+ targetView: this.view,
932
+ showBorder: false,
933
+ showSkyBox: !this.hidePanoramas,
934
+ });
935
+ if (undefined === showModel || showModel === true) {
936
+ const material = this.getModelMaterial();
937
+ const uniforms = material.uniforms;
938
+ uniforms.pano0Matrix.value = pano.matrix;
939
+ uniforms.pano0Position.value = pano.position;
940
+ uniforms.pano1Matrix.value = pano.matrix;
941
+ uniforms.pano1Position.value = pano.position;
942
+ uniforms.weight0.value = 1.0;
943
+ uniforms.weight1.value = 0.0;
944
+ const textures = yield CubeTextureCache.sharedInstance.preloadCubeTextures([pano.textureURLs], 1);
945
+ [uniforms.pano0Map.value, uniforms.pano1Map.value] = [textures[0], textures[0]];
946
+ this.setModelAppearance(panoramaGroup.modelElement, true, material);
947
+ }
948
+ }
949
+ return pano;
950
+ }
951
+ return undefined;
952
+ });
953
+ }
954
+ /**
955
+ * 从指定全景图中心以指定视线方向观看
956
+ * @param pid 全景图PID
957
+ * @param lookDirection 视线方向
958
+ * @parama showModel 可选,是否一开始就显示模型
959
+ * @param preInitPanoramasStrategy 可选,预创建全景对象的顺序策略,详见[PanoramaGroup]的【initializePanoramasIfNecessary]方法说明
960
+ */
961
+ lookFromPanorama(pid, lookDirection, showModel, preInitPanoramasStrategy) {
962
+ return __awaiter(this, void 0, void 0, function* () {
963
+ const pano = yield this.showPanorama(pid, { lookDirection, showModel, preInitPanoramasStrategy });
964
+ this.emit(Events.MOVE_TO_PANORAMA, pid, pano ? pano.position : null, this.panoramaGroupChanged);
965
+ this.panoramaGroupChanged = false;
966
+ });
967
+ }
968
+ /**
969
+ * 从指定全景图中心看向指定位置
970
+ * @param pid 全景图PID
971
+ * @param target 目标位置
972
+ * @parama showModel 可选,是否一开始就显示模型
973
+ * @param preInitPanoramasStrategy 可选,预创建全景对象的顺序策略,详见[PanoramaGroup]的【initializePanoramasIfNecessary]方法说明
974
+ */
975
+ lookFromPanoramaTo(pid, target, showModel, preInitPanoramasStrategy) {
976
+ return __awaiter(this, void 0, void 0, function* () {
977
+ const pano = yield this.showPanorama(pid, { target, showModel, preInitPanoramasStrategy });
978
+ this.emit(Events.MOVE_TO_PANORAMA, pid, pano ? pano.position : null, this.panoramaGroupChanged);
979
+ this.panoramaGroupChanged = false;
980
+ });
981
+ }
982
+ static createModelUniforms() {
983
+ const { THREE } = Externals.getInstance();
984
+ const modelUniforms = {
985
+ weight0: {
986
+ type: 'f',
987
+ value: 0,
988
+ },
989
+ weight1: {
990
+ type: 'f',
991
+ value: 0,
992
+ },
993
+ // 源全景图立方体贴图
994
+ pano0Map: {
995
+ type: 't',
996
+ value: null,
997
+ },
998
+ // 源全景图位置
999
+ pano0Position: {
1000
+ type: 'v3',
1001
+ value: new THREE.Vector3(),
1002
+ },
1003
+ // 源全景图世界变换矩阵
1004
+ pano0Matrix: {
1005
+ type: 'm4',
1006
+ value: new THREE.Matrix4(),
1007
+ },
1008
+ // 目标全景图立方体贴图
1009
+ pano1Map: {
1010
+ type: 't',
1011
+ value: null,
1012
+ },
1013
+ // 目标全景图位置
1014
+ pano1Position: {
1015
+ type: 'v3',
1016
+ value: new THREE.Vector3(),
1017
+ },
1018
+ // 目标全景图世界变换矩阵
1019
+ pano1Matrix: {
1020
+ type: 'm4',
1021
+ value: new THREE.Matrix4(),
1022
+ },
1023
+ };
1024
+ return modelUniforms;
1025
+ }
1026
+ static createInstantTranslationUniforms() {
1027
+ const { THREE } = Externals.getInstance();
1028
+ const modelUniforms = {
1029
+ weight0: {
1030
+ type: 'f',
1031
+ value: 0,
1032
+ },
1033
+ weight1: {
1034
+ type: 'f',
1035
+ value: 0,
1036
+ },
1037
+ // 源全景图立方体贴图
1038
+ pano0Map: {
1039
+ type: 't',
1040
+ value: null,
1041
+ },
1042
+ pano0Position: {
1043
+ type: 'v3',
1044
+ value: new THREE.Vector3(),
1045
+ },
1046
+ // 源全景图世界变换矩阵
1047
+ pano0Matrix: {
1048
+ type: 'm4',
1049
+ value: new THREE.Matrix4(),
1050
+ },
1051
+ // 目标全景图立方体贴图
1052
+ pano1Map: {
1053
+ type: 't',
1054
+ value: null,
1055
+ },
1056
+ // 目标全景图位置
1057
+ pano1Position: {
1058
+ type: 'v3',
1059
+ value: new THREE.Vector3(),
1060
+ },
1061
+ // 目标全景图世界变换矩阵
1062
+ pano1Matrix: {
1063
+ type: 'm4',
1064
+ value: new THREE.Matrix4(),
1065
+ },
1066
+ matrixT: {
1067
+ type: 'm4',
1068
+ value: new THREE.Matrix4(),
1069
+ },
1070
+ };
1071
+ return modelUniforms;
1072
+ }
1073
+ getModelMaterial() {
1074
+ if (this.modelMaterial) {
1075
+ return this.modelMaterial;
1076
+ }
1077
+ const { THREE } = Externals.getInstance();
1078
+ const uniforms = PanoramaController.createModelUniforms();
1079
+ this.modelMaterial = new THREE.ShaderMaterial({
1080
+ side: THREE.DoubleSide,
1081
+ vertexShader: PanoramaController.getModelVS(),
1082
+ fragmentShader: PanoramaController.getModelFS(),
1083
+ uniforms,
1084
+ name: 'modelMaterial',
1085
+ });
1086
+ return this.modelMaterial;
1087
+ }
1088
+ getInstantTranslationMaterial() {
1089
+ if (this.instantTranslationMaterial) {
1090
+ return this.instantTranslationMaterial;
1091
+ }
1092
+ const { THREE } = Externals.getInstance();
1093
+ const uniforms = PanoramaController.createInstantTranslationUniforms();
1094
+ this.instantTranslationMaterial = new THREE.ShaderMaterial({
1095
+ side: THREE.DoubleSide,
1096
+ vertexShader: PanoramaController.getInstantTranslationVS(),
1097
+ fragmentShader: PanoramaController.getModelFS(),
1098
+ uniforms,
1099
+ name: 'instantTranslationMaterial',
1100
+ });
1101
+ return this.instantTranslationMaterial;
1102
+ }
1103
+ /**
1104
+ * @ignore
1105
+ * @param visible
1106
+ */
1107
+ setModelAppearance(modelElement, visible, meshMaterial, modelMesh) {
1108
+ if (modelElement) {
1109
+ if (modelElement instanceof FloorModel) {
1110
+ modelElement.addViewConfiguration({
1111
+ targetView: this.view,
1112
+ visible,
1113
+ meshMaterial,
1114
+ });
1115
+ }
1116
+ else {
1117
+ modelElement.visible = visible;
1118
+ let mesh = modelMesh;
1119
+ if (!mesh) {
1120
+ mesh = PanoramaController.getModelMeshInElement(modelElement);
1121
+ }
1122
+ if (mesh && meshMaterial) {
1123
+ mesh.material = meshMaterial;
1124
+ }
1125
+ }
1126
+ }
1127
+ }
1128
+ /**
1129
+ * 配置controller是否开启点击移动
1130
+ * @param value 是否开启点击移动
1131
+ */
1132
+ setMoveOnClickEnabled(value) {
1133
+ this.moveOnClick = value;
1134
+ }
1135
+ /**
1136
+ * 移动到指定的全景点处
1137
+ * @param toPID 目标全景点ID
1138
+ * @param interval 可选,过渡所用时长
1139
+ * @param easing 可选,插值函数
1140
+ * @param fadeInOut 可选,是否使用淡出淡入变换
1141
+ * @param toDirection 可选,到达目的点时要转到的视线方向,
1142
+ * 若不设置则默认以从起始点到目的点的连线为最终视线方向
1143
+ * @param lookAtTarget 可选,到达目的点时视线看向的位置,优先于toDirection
1144
+ * @param fov 可选,视场角度数
1145
+ * @param rotateDelays 可选,旋转时的延迟时间
1146
+ */
1147
+ moveToPanorama(toPID, params) {
1148
+ return __awaiter(this, void 0, void 0, function* () {
1149
+ const p = params || {};
1150
+ return this.moveInPath([toPID], {
1151
+ queueIfBusy: false,
1152
+ lookAtTargets: p.lookAtTarget,
1153
+ toDirections: p.toDirection,
1154
+ intervals: p.interval,
1155
+ fovs: p.fov,
1156
+ fadeInOuts: p.fadeInOut,
1157
+ easings: p.easing,
1158
+ freeRotation: !p.lookAtTarget,
1159
+ showModel: p.showModel,
1160
+ rotateDelays: p.rotateDelays,
1161
+ });
1162
+ });
1163
+ }
1164
+ /**
1165
+ * 移动到指定的全景点处
1166
+ * 此方法与[[moveToPanorama]]的不同点在于通过Promise机制实现同步阻塞,
1167
+ * 在前一个Translation未完成时发起的Translation会自动被阻塞到前一个完成时再执行
1168
+ * @param toPID 目标全景点ID
1169
+ * @param interval 可选,过渡所用时长
1170
+ * @param easing 可选,插值函数
1171
+ * @param fadeInOut 可选,是否使用淡出淡入变换
1172
+ * @param toDirection 可选,到达目的点时要转到的视线方向,
1173
+ * 若不设置则默认以从起始点到目的点的连线为最终视线方向
1174
+ * @param lookAtTarget 可选,到达目的点时视线看向的位置,优先于toDirection
1175
+ * @param fov 可选,视场角度数
1176
+ * @param rotateDelays 可选,旋转时的延迟时间
1177
+ */
1178
+ moveToPanoramaSync(toPID, params) {
1179
+ return __awaiter(this, void 0, void 0, function* () {
1180
+ const p = params || {};
1181
+ return this.moveInPath([toPID], {
1182
+ queueIfBusy: true,
1183
+ lookAtTargets: p.lookAtTarget,
1184
+ toDirections: p.toDirection,
1185
+ intervals: p.interval,
1186
+ fovs: p.fov,
1187
+ fadeInOuts: p.fadeInOut,
1188
+ easings: p.easing,
1189
+ freeRotation: !p.lookAtTarget,
1190
+ showModel: p.showModel,
1191
+ rotateDelays: p.rotateDelays,
1192
+ });
1193
+ });
1194
+ }
1195
+ /**
1196
+ * 摄像机按指定路径运动,并在全景点之间产生渐入渐出效果
1197
+ * @param pathPIDs 目标全景点序列
1198
+ * @param queueIfBusy 可选,指示当当前有动画在进行中时,是把此次动作排队还是直接放弃
1199
+ * @param showModel 可选 是否在移动完成后也保持模型显示(用于遮挡路径)
1200
+ * @param intervals 可选,若为数组则依次是每一段路径所花费的时间间隔,若是一个数则全都用该时间间隔
1201
+ * @param fovs 可选,若为数组则依次是每一段路径结束时的视场角,若是一个数则全都用该视场角
1202
+ * @param toDirections 可选,若为数组则依次是每一段路径结束点的视线方向,若是单一Vector3对象则全用此视线方向
1203
+ * @param lookAtTargets 可选,若为数组则依次是每一段路径所看向的位置,若是单一Vector3对象则始终看向此位置
1204
+ * toDirections与lookAtTargets最多只能有一个,如果同时传入了则只以lookAtTargets为准
1205
+ * @param rotateDelays 可选,旋转时的延迟时间
1206
+ * @param easings 可选,若为数组则依次是每一段路径的动画插值函数,
1207
+ * 若是单一{(k: number): number}对象则全用此插值函数
1208
+ * @example
1209
+ * ``` typescript
1210
+ * panoCtl = new PanoramaController(view, panoMgr, floorModel);
1211
+ * panoCtl.setMouseClickEnabled(true);
1212
+ * stage.bindController(panoCtl);
1213
+ * panoCtl.lookFromPanorama(0, new Vector3(-1, 0, 0));
1214
+ * panoCtl.moveInPath([0, 68, 69, 68, 0], {
1215
+ * queueIfBusy: true,
1216
+ * intervals: [200, 1000, 2000, 1000, 3000],
1217
+ * toDirections: [
1218
+ * new Vector3(-1, 0, 0),
1219
+ * new Vector3(-0.8, 0.6, 0),
1220
+ * new Vector3(-0.6, 0.8, 0),
1221
+ * new Vector3(0, 0.8, 0),
1222
+ * new Vector3(0.6, 0, 0),
1223
+ * ],
1224
+ * });
1225
+ */
1226
+ moveInPath(path, params) {
1227
+ return __awaiter(this, void 0, void 0, function* () {
1228
+ if (path.length === 0)
1229
+ return;
1230
+ // const path: number[] = pathPIDs;
1231
+ const pathPositions = [];
1232
+ const inPathPanos = yield Promise.all(path.map((pid) => this.getPanoramaOfPID(pid)));
1233
+ inPathPanos.forEach((item) => {
1234
+ if (item.pano) {
1235
+ pathPositions.push(item.pano.position.clone());
1236
+ }
1237
+ });
1238
+ const { toDirections, lookAtTargets, intervals, fovs, easings, fadeInOuts, queueIfBusy, showModel, freeRotation, rotateDelays, } = params || {};
1239
+ const modelVisible = (undefined === showModel || showModel === true || this.showModel);
1240
+ let material;
1241
+ let uniforms;
1242
+ let previousMaterial;
1243
+ let fromPID = -1;
1244
+ let toPID;
1245
+ let fadeInOut = false;
1246
+ const preloadTextureCount = CubeTextureCache.sharedInstance.getCapacity();
1247
+ let from;
1248
+ let to;
1249
+ let modelElement;
1250
+ const trivialProgressTransform = (progress) => progress;
1251
+ const fadeInOutProgressTransform = (progress) => {
1252
+ if (progress < 0.25)
1253
+ return 0;
1254
+ if (progress > 0.75)
1255
+ return 1;
1256
+ return 2 * (progress - 0.25);
1257
+ };
1258
+ let progressTransforms;
1259
+ if (Array.isArray(fadeInOuts)) {
1260
+ progressTransforms = fadeInOuts.map((b) => (b ? fadeInOutProgressTransform : trivialProgressTransform));
1261
+ }
1262
+ else if (fadeInOuts === true) {
1263
+ progressTransforms = fadeInOutProgressTransform;
1264
+ }
1265
+ yield this.moveCameraInPath(pathPositions, {
1266
+ queueIfBusy,
1267
+ toDirections,
1268
+ lookAtTargets,
1269
+ intervals,
1270
+ fovs,
1271
+ easings,
1272
+ progressTransforms,
1273
+ freeRotation,
1274
+ rotateDelays,
1275
+ beforeAllMoves: () => __awaiter(this, void 0, void 0, function* () {
1276
+ // console.log('#PanoCtrl# beforeAllMoves');
1277
+ fromPID = this.currentPanoramaGroup ? this.currentPanoramaGroup.currentPanoramaID : -1;
1278
+ material = this.getModelMaterial();
1279
+ uniforms = material.uniforms;
1280
+ // this.getModelMesh();
1281
+ // if (this.modelMesh) {
1282
+ // previousMaterial = this.modelMesh.material;
1283
+ // this.setModelAppearance(true, material);
1284
+ // }
1285
+ // this.panoramaGroup.setBoundBoxAppearance(material);
1286
+ // this.panoramaGroup.addGroupViewConfiguration({
1287
+ // targetView: this.view,
1288
+ // showBoundBox: true,
1289
+ // });// /!!! master
1290
+ if (path.length > 1)
1291
+ this.emit(Events.PATH_MOVEMENT_START, path);
1292
+ }),
1293
+ onOneMoveStart: (index, target0, eye0, target1, eye1) => __awaiter(this, void 0, void 0, function* () {
1294
+ // console.log(`#PanoCtrl# onOneMoveStart(${index}`);
1295
+ // console.log(`#PanoCtrl# Will moveToPanorama from #${fromPID} to #${toPID}`);
1296
+ toPID = path[index];
1297
+ from = yield this.getPanoramaOfPID(fromPID);
1298
+ to = yield this.getPanoramaOfPID(toPID);
1299
+ const { THREE } = Externals.getInstance();
1300
+ // console.log(`#PanoCtrl# onOneMoveStart : from(${fromPID})=${from}, to(${toPID})=${to}`);
1301
+ if (!from.pano || !to.pano || !from.panoramaGroup || !to.panoramaGroup)
1302
+ return false;
1303
+ from.modelMesh = PanoramaController.getModelMesh(from.panoramaGroup);
1304
+ to.modelMesh = PanoramaController.getModelMesh(to.panoramaGroup);
1305
+ const preloadPIDs = [fromPID];
1306
+ const preloadPIDsSet = new Set();
1307
+ preloadPIDsSet.add(fromPID);
1308
+ for (let i = index; preloadPIDs.length < preloadTextureCount && i < path.length; i += 1) {
1309
+ if (!preloadPIDsSet.has(path[i])) {
1310
+ preloadPIDsSet.add(path[i]);
1311
+ preloadPIDs.push(path[i]);
1312
+ }
1313
+ }
1314
+ yield this.preloadCubeTexturesOfPIDs(preloadPIDs, preloadPIDs.length, preloadPIDs.map((pid) => (pid === fromPID))); // #TiledCube# Keep LD cubeTexture
1315
+ this.emit(Events.WILL_MOVE_TO_PANORAMA, toPID, to.pano ? to.pano.position : null);
1316
+ if (fromPID === toPID)
1317
+ return false;
1318
+ if (Array.isArray(fadeInOuts)) {
1319
+ if (fadeInOuts.length > index) {
1320
+ fadeInOut = fadeInOuts[index];
1321
+ }
1322
+ else if (fadeInOuts.length > 0) {
1323
+ fadeInOut = fadeInOuts[fadeInOuts.length - 1];
1324
+ }
1325
+ }
1326
+ else if (fadeInOuts) {
1327
+ fadeInOut = fadeInOuts;
1328
+ }
1329
+ const translateBetweenGroups = (from.panoramaGroup !== to.panoramaGroup);
1330
+ if (translateBetweenGroups) {
1331
+ material = this.getInstantTranslationMaterial();
1332
+ uniforms = material.uniforms;
1333
+ // /!!!from.panoramaGroup.dispose(from.pano.pid);
1334
+ // TODO: Dispose useless PanoramaGroup(s) after all moves,
1335
+ // and initialize necessary PanoramaGroup(s) before all moves
1336
+ }
1337
+ else {
1338
+ material = this.getModelMaterial();
1339
+ uniforms = material.uniforms;
1340
+ }
1341
+ if (!translateBetweenGroups && !modelVisible) {
1342
+ const distance = to.pano.position.distanceTo(from.pano.position);
1343
+ const boxGeometry = new THREE.BoxGeometry(5, (from.pano.position.z + 0.93) * 2, distance * 4);
1344
+ modelElement = new THREE.Mesh(boxGeometry, material);
1345
+ modelElement.position.copy(from.pano.position);
1346
+ modelElement.up.set(0, 0, 1);
1347
+ modelElement.lookAt(to.pano.position);
1348
+ to.panoramaGroup.add(modelElement);
1349
+ }
1350
+ if (!translateBetweenGroups && !modelVisible) {
1351
+ const distance = to.pano.position.distanceTo(from.pano.position);
1352
+ const boxGeometry = new THREE.BoxGeometry(5, (from.pano.position.z + 0.93) * 2, distance * 4);
1353
+ modelElement = new THREE.Mesh(boxGeometry, material);
1354
+ modelElement.position.copy(from.pano.position);
1355
+ modelElement.up.set(0, 0, 1);
1356
+ modelElement.lookAt(to.pano.position);
1357
+ to.panoramaGroup.add(modelElement);
1358
+ }
1359
+ if (!translateBetweenGroups && !modelVisible) {
1360
+ const distance = to.pano.position.distanceTo(from.pano.position);
1361
+ const boxGeometry = new THREE.BoxGeometry(5, (from.pano.position.z + 0.93) * 2, distance * 4);
1362
+ modelElement = new THREE.Mesh(boxGeometry, material);
1363
+ modelElement.position.copy(from.pano.position);
1364
+ modelElement.up.set(0, 0, 1);
1365
+ modelElement.lookAt(to.pano.position);
1366
+ to.panoramaGroup.add(modelElement);
1367
+ }
1368
+ [to].forEach(({ panoramaGroup, modelMesh }) => {
1369
+ if (modelMesh && panoramaGroup) {
1370
+ previousMaterial = modelMesh.material;
1371
+ if (from.panoramaGroup === to.panoramaGroup) {
1372
+ this.setModelAppearance(panoramaGroup.modelElement, modelVisible, material, modelMesh);
1373
+ }
1374
+ else {
1375
+ this.setModelAppearance(panoramaGroup.modelElement, false, material, modelMesh);
1376
+ }
1377
+ panoramaGroup.setBoundBoxAppearance(material);
1378
+ panoramaGroup.addGroupViewConfiguration({
1379
+ targetView: this.view,
1380
+ showBoundBox: true,
1381
+ });
1382
+ }
1383
+ });
1384
+ // console.log(`#Async# moveInPath$onOneMoveStart : Hide 'from' pano#${from.pano.pid}`);
1385
+ from.pano.addViewConfiguration({
1386
+ targetView: this.view,
1387
+ showBorder: false,
1388
+ showSkyBox: false,
1389
+ });
1390
+ if (translateBetweenGroups) {
1391
+ // Inv(L0) * L1
1392
+ let up = new THREE.Vector3(0, 1, 0);
1393
+ if (this.view.camera) {
1394
+ up = this.view.camera.up;
1395
+ }
1396
+ const invLookAt0 = new THREE.Matrix4().lookAt(eye0, target0, up);
1397
+ const invLookAt1 = new THREE.Matrix4().lookAt(eye1, target1, up);
1398
+ uniforms.matrixT.value = invLookAt0.multiply(invLookAt1.clone().invert());
1399
+ }
1400
+ uniforms.pano0Matrix.value = from.pano.matrix;
1401
+ uniforms.pano0Position.value = from.pano.position;
1402
+ uniforms.pano1Matrix.value = to.pano.matrix;
1403
+ uniforms.pano1Position.value = to.pano.position;
1404
+ uniforms.weight0.value = 1.0;
1405
+ uniforms.weight1.value = 0.0;
1406
+ const textures = yield CubeTextureCache.sharedInstance.preloadCubeTextures([from.pano.textureURLs, to.pano.textureURLs], 2, [true, false]);
1407
+ [uniforms.pano0Map.value, uniforms.pano1Map.value] = textures; // #TiledCube# Keep LD cubeTexture
1408
+ // console.log(`#PanoCtrl# moveToPanorama#onStart from #${fromPID} to #${toPID}`);
1409
+ // if (index === path.length - 1) {
1410
+ // const nextCamera = new PerspectiveCamera();
1411
+ // nextCamera.position.copy(eye1);
1412
+ // nextCamera.lookAt(target1);
1413
+ // const tiles = to.pano!.getIntersectedTiles(nextCamera);
1414
+ // // console.info('#TiledCube# getIntersectedTiles:', tiles.hdTiles, tiles.ldTiles);
1415
+ // to.panoramaGroup.presentPanoramaAround(toPID, tiles.hdTiles, tiles.ldTiles, this.view);
1416
+ // to.panoramaGroup.presentPanoramaIndicatorsAround(toPID, this.view);
1417
+ // }
1418
+ // console.log(`#PanoCtrl# Translate onStart:toPID=${toPID}`);
1419
+ return translateBetweenGroups;
1420
+ }),
1421
+ onOneMoveUpdate: (index, progress) => {
1422
+ if (fromPID === toPID)
1423
+ return;
1424
+ const translateBetweenGroups = (from.panoramaGroup !== to.panoramaGroup);
1425
+ if (translateBetweenGroups) {
1426
+ if (progress < 0.5) {
1427
+ uniforms.weight0.value = 1.0 - progress * 2;
1428
+ uniforms.weight1.value = 0.0;
1429
+ }
1430
+ else {
1431
+ uniforms.weight1.value = progress * 2 - 1.0;
1432
+ uniforms.weight0.value = 0.0;
1433
+ }
1434
+ }
1435
+ else if (fadeInOut) {
1436
+ if (progress < 0.25) {
1437
+ uniforms.weight0.value = 1.0 - progress * 4;
1438
+ uniforms.weight1.value = 0.0;
1439
+ }
1440
+ else if (progress > 0.75) {
1441
+ uniforms.weight1.value = progress * 4 - 3.0;
1442
+ uniforms.weight0.value = 0.0;
1443
+ }
1444
+ else {
1445
+ uniforms.weight1.value = 0.0;
1446
+ uniforms.weight0.value = 0.0;
1447
+ }
1448
+ }
1449
+ else {
1450
+ uniforms.weight0.value = 1.0 - progress;
1451
+ uniforms.weight1.value = progress;
1452
+ }
1453
+ },
1454
+ onOneMoveComplete: (index) => __awaiter(this, void 0, void 0, function* () {
1455
+ // console.log(`#PanoCtrl# onOneMoveComplete : from=${from}, to=${to}`);
1456
+ // if (index === path.length - 1) {
1457
+ // const tiles = to.pano!.getIntersectedTiles(this.view.camera);
1458
+ // // console.info('#TiledCube# getIntersectedTiles:', tiles.hdTiles, tiles.ldTiles);
1459
+ // await to.panoramaGroup!.presentPanoramaAround(toPID, tiles.hdTiles, tiles.ldTiles, this.view);
1460
+ // to.panoramaGroup!.presentPanoramaIndicatorsAround(toPID, this.view);
1461
+ // to.pano!.addViewConfiguration({
1462
+ // targetView: this.view,
1463
+ // showBorder: false,
1464
+ // showSkyBox: true,
1465
+ // });
1466
+ // // const allPanos = await to.panoramaGroup!.allPanoramas();
1467
+ // // console.info('#Async# onOneMoveComplete : Set all panos invisible:', allPanos);
1468
+ // // allPanos.forEach((panorama: Panorama) => {
1469
+ // // panorama.addViewConfiguration({
1470
+ // // targetView: this.view,
1471
+ // // showBorder: false,
1472
+ // // showSkyBox: false,
1473
+ // // });
1474
+ // // });
1475
+ // }
1476
+ if (from.modelMesh && from.panoramaGroup && from.panoramaGroup !== to.panoramaGroup) {
1477
+ if (!modelVisible) {
1478
+ this.setModelAppearance(from.panoramaGroup.modelElement, false, previousMaterial, from.modelMesh);
1479
+ }
1480
+ from.panoramaGroup.addGroupViewConfiguration({
1481
+ targetView: this.view,
1482
+ showBoundBox: false,
1483
+ });
1484
+ }
1485
+ to.panoramaGroup.remove(modelElement);
1486
+ this.emit(Events.MOVE_TO_PANORAMA, toPID, to.pano ? to.pano.position : null, from.panoramaGroup !== to.panoramaGroup);
1487
+ this.panoramaGroupChanged = false;
1488
+ if (index < path.length - 1) {
1489
+ fromPID = path[index];
1490
+ }
1491
+ }),
1492
+ afterAllMoves: () => __awaiter(this, void 0, void 0, function* () {
1493
+ const tiles = to.pano.getIntersectedTiles(this.view.camera);
1494
+ // console.info('#TiledCube# getIntersectedTiles:', tiles.hdTiles, tiles.ldTiles);
1495
+ yield to.panoramaGroup.presentPanoramaAround(toPID, tiles.hdTiles, tiles.ldTiles, this.view);
1496
+ // console.log(`#Async# moveInPath$afterAllMoves : Show 'to' pano#${to.pano!.pid}`);
1497
+ to.pano.addViewConfiguration({
1498
+ targetView: this.view,
1499
+ showBorder: false,
1500
+ showSkyBox: !this.hidePanoramas,
1501
+ });
1502
+ to.panoramaGroup.presentPanoramaIndicatorsAround(toPID, this.view);
1503
+ if (fromPID !== toPID && to && from) {
1504
+ if (to.modelMesh && to.panoramaGroup) {
1505
+ if (!modelVisible) {
1506
+ this.setModelAppearance(to.panoramaGroup.modelElement, false, previousMaterial, to.modelMesh);
1507
+ }
1508
+ to.panoramaGroup.addGroupViewConfiguration({
1509
+ targetView: this.view,
1510
+ showBoundBox: false,
1511
+ });
1512
+ }
1513
+ if (to.panoramaGroup) {
1514
+ this.currentPanoramaGroup = to.panoramaGroup;
1515
+ }
1516
+ }
1517
+ if (path.length > 1)
1518
+ this.emit(Events.PATH_MOVEMENT_COMPLETED, path);
1519
+ }),
1520
+ });
1521
+ });
1522
+ }
1523
+ /**
1524
+ * 摄像机按指定路径运动
1525
+ * @param pathPoints 摄像机运动的路径上每一段目的点的Vector3坐标数组
1526
+ * @param queueIfBusy 可选,指示当当前有动画在进行中时,是把此次动作排队还是直接放弃
1527
+ * @param intervals 可选,若为数组则依次是每一段路径所花费的时间间隔,若是一个数则全都用该时间间隔
1528
+ * @param fovs 可选,若为数组则依次是每一段路径结束时的视场角,若是一个数则全都用该视场角
1529
+ * @param toDirections 可选,若为数组则依次是每一段路径结束点的视线方向,若是单一Vector3对象则全用此视线方向
1530
+ * @param lookAtTargets 可选,若为数组则依次是每一段路径所看向的位置,若是单一Vector3对象则始终看向此位置
1531
+ * toDirections与lookAtTargets最多只能有一个,如果同时传入了则只以lookAtTargets为准
1532
+ * @param easings 可选,若为数组则依次是每一段路径的动画插值函数,
1533
+ * 若是单一{(k: number): number}对象则全用此插值函数
1534
+ * @param rotateDelays 可选,旋转时的延迟时间
1535
+ * @param progressTransforms 可选,转换progress的映射函数,从0~1之间的小数映射到另一个0~1之间的小数
1536
+ * @param beforeAllMoves 整个路径移动即将开始前的回调
1537
+ * @param onOneMoveStart 每段路径移动开始时的回调
1538
+ * @param onOneMoveUpdate 每段路径移动进行中的进度回调
1539
+ * @param onOneMoveComplete 每段路径移动结束时的回调
1540
+ * @param afterAllMoves 整个路径移动结束时的回调
1541
+ * @example
1542
+ * ``` typescript
1543
+ * panoCtl.moveCameraInPath(points, {
1544
+ * queueIfBusy: false,
1545
+ * intervals: [200, 1000, 2000, 1000, 3000],
1546
+ * toDirections: [
1547
+ * new Vector3(-1, 0, 0),
1548
+ * new Vector3(-0.8, 0.6, 0),
1549
+ * new Vector3(-0.6, 0.8, 0),
1550
+ * new Vector3(0, 0.8, 0),
1551
+ * new Vector3(0.6, 0, 0),
1552
+ * ],
1553
+ * });
1554
+ */
1555
+ moveCameraInPath(pathPoints, params) {
1556
+ return __awaiter(this, void 0, void 0, function* () {
1557
+ if (!pathPoints || pathPoints.length === 0)
1558
+ return;
1559
+ const { THREE } = Externals.getInstance();
1560
+ const { queueIfBusy = false } = params || {};
1561
+ if (!queueIfBusy) {
1562
+ if (this.isAnimating)
1563
+ return;
1564
+ this.isAnimating = true;
1565
+ }
1566
+ while (this.translatePromise) {
1567
+ // eslint-disable-next-line no-await-in-loop
1568
+ yield this.translatePromise;
1569
+ }
1570
+ // eslint-disable-next-line no-async-promise-executor
1571
+ const translatePromise = new Promise((resolve0) => __awaiter(this, void 0, void 0, function* () {
1572
+ const { beforeAllMoves, onOneMoveStart, onOneMoveUpdate, onOneMoveComplete, afterAllMoves, } = params || {};
1573
+ let iPath = 0;
1574
+ // eslint-disable-next-line no-async-promise-executor
1575
+ const createTask = () => new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
1576
+ if (!this.view.camera || this.cancelAnimation) {
1577
+ reject();
1578
+ this.cancelAnimation = false;
1579
+ return;
1580
+ }
1581
+ const { toDirections, lookAtTargets, intervals, fovs, easings, progressTransforms, freeRotation, rotateDelays, } = params || {};
1582
+ const fromPosition = this.orbitControl.target.clone();
1583
+ const toPosition = pathPoints[iPath];
1584
+ const diff = toPosition.clone().sub(fromPosition);
1585
+ let toDirection = toPosition.clone();
1586
+ // let directionFrom = toPosition;
1587
+ if (Array.isArray(lookAtTargets)) {
1588
+ if (lookAtTargets.length > iPath) {
1589
+ toDirection = lookAtTargets[iPath].clone();
1590
+ }
1591
+ else if (lookAtTargets.length > 0) {
1592
+ toDirection = lookAtTargets[lookAtTargets.length - 1].clone();
1593
+ }
1594
+ }
1595
+ else if (lookAtTargets instanceof THREE.Vector3) {
1596
+ toDirection = lookAtTargets.clone();
1597
+ } // else {
1598
+ // directionFrom = fromPosition;
1599
+ // }
1600
+ let rotateDelay = 0;
1601
+ if (rotateDelays) {
1602
+ if (Array.isArray(rotateDelays)) {
1603
+ if (rotateDelays.length > iPath) {
1604
+ rotateDelay = rotateDelays[iPath];
1605
+ }
1606
+ else if (rotateDelays.length > 0) {
1607
+ rotateDelay = rotateDelays[rotateDelays.length - 1];
1608
+ }
1609
+ }
1610
+ else {
1611
+ rotateDelay = rotateDelays || 0;
1612
+ }
1613
+ }
1614
+ if (lookAtTargets || !toDirections) {
1615
+ if (toDirection.distanceToSquared(toPosition) < 0.000001) {
1616
+ toDirection = this.orbitControl.target.clone().sub(this.view.camera.position);
1617
+ }
1618
+ else {
1619
+ toDirection.sub(toPosition);
1620
+ }
1621
+ }
1622
+ else if (Array.isArray(toDirections)) {
1623
+ if (toDirections.length > iPath) {
1624
+ toDirection = toDirections[iPath];
1625
+ }
1626
+ else if (toDirections.length > 0) {
1627
+ toDirection = toDirections[toDirections.length - 1];
1628
+ }
1629
+ }
1630
+ else if (toDirections instanceof THREE.Vector3) {
1631
+ toDirection = toDirections;
1632
+ }
1633
+ toDirection.normalize();
1634
+ // toDirection = this.view.camera.up.clone().cross(toDirection.cross(this.view.camera.up));
1635
+ // toDirection.normalize();
1636
+ const fromDirection = this.orbitControl.target.clone().sub(this.view.camera.position).normalize();
1637
+ // const diffQuaternion = new Quaternion().setFromUnitVectors(fromDirection, toDirection);
1638
+ const quat = new THREE.Quaternion().setFromUnitVectors(this.view.camera.up, new THREE.Vector3(0, 1, 0));
1639
+ const quatInverse = quat.clone().invert();
1640
+ fromDirection.applyQuaternion(quat);
1641
+ toDirection.applyQuaternion(quat);
1642
+ const fromSpherical = new THREE.Spherical().setFromVector3(fromDirection);
1643
+ const toSpherical = new THREE.Spherical().setFromVector3(toDirection);
1644
+ const thetaDiff = fromSpherical.theta - toSpherical.theta;
1645
+ fromDirection.applyQuaternion(quatInverse);
1646
+ toDirection.applyQuaternion(quatInverse);
1647
+ let toFOV = 60;
1648
+ let fromFOV = 60;
1649
+ if (this.view.camera instanceof THREE.PerspectiveCamera) {
1650
+ const camera = this.view.camera;
1651
+ fromFOV = camera.fov;
1652
+ toFOV = camera.fov;
1653
+ if (Array.isArray(fovs)) {
1654
+ if (fovs.length > iPath) {
1655
+ toFOV = fovs[iPath];
1656
+ }
1657
+ else if (fovs.length > 0) {
1658
+ toFOV = fovs[fovs.length - 1];
1659
+ }
1660
+ }
1661
+ else if (fovs) {
1662
+ toFOV = fovs;
1663
+ }
1664
+ }
1665
+ let interval = 1000;
1666
+ if (Array.isArray(intervals)) {
1667
+ if (intervals.length > iPath) {
1668
+ interval = intervals[iPath];
1669
+ }
1670
+ else if (intervals.length > 0) {
1671
+ interval = intervals[intervals.length - 1];
1672
+ }
1673
+ }
1674
+ else if (intervals) {
1675
+ interval = intervals;
1676
+ }
1677
+ let easing = TWEEN.Easing.Linear.None;
1678
+ if (Array.isArray(easings)) {
1679
+ if (easings.length > iPath) {
1680
+ easing = easings[iPath];
1681
+ }
1682
+ else if (easings.length > 0) {
1683
+ easing = easings[easings.length - 1];
1684
+ }
1685
+ }
1686
+ else if (typeof easings === 'function') {
1687
+ easing = easings;
1688
+ }
1689
+ else if (iPath === 0) {
1690
+ easing = TWEEN.Easing.Quadratic.Out;
1691
+ if ((iPath === pathPoints.length - 1))
1692
+ easing = TWEEN.Easing.Quadratic.InOut;
1693
+ }
1694
+ else if (iPath === pathPoints.length - 1) {
1695
+ easing = TWEEN.Easing.Quadratic.In;
1696
+ }
1697
+ let progressTransform;
1698
+ if (Array.isArray(progressTransforms)) {
1699
+ if (progressTransforms.length > iPath) {
1700
+ progressTransform = progressTransforms[iPath];
1701
+ }
1702
+ else if (progressTransforms.length > 0) {
1703
+ progressTransform = progressTransforms[progressTransforms.length - 1];
1704
+ }
1705
+ }
1706
+ else if (progressTransforms) {
1707
+ progressTransform = progressTransforms;
1708
+ }
1709
+ const target1 = toPosition;
1710
+ const eye1 = toDirection.clone()
1711
+ .multiplyScalar(PanoramaController.DirectionVectorScalar)
1712
+ .add(target1);
1713
+ const target0 = fromPosition;
1714
+ const eye0 = fromDirection.clone()
1715
+ .multiplyScalar(PanoramaController.DirectionVectorScalar)
1716
+ .add(target0);
1717
+ let skipPositionTranslate = false;
1718
+ if (onOneMoveStart) {
1719
+ skipPositionTranslate = yield onOneMoveStart(iPath, target0, eye0, target1, eye1);
1720
+ }
1721
+ const fromTheta = fromSpherical.theta;
1722
+ const toTheta = Math.abs(thetaDiff) > Math.PI
1723
+ ? toSpherical.theta + Math.sign(thetaDiff) * Math.PI * 2 : toSpherical.theta;
1724
+ const fromPhi = fromSpherical.phi;
1725
+ const toPhi = toSpherical.phi;
1726
+ new TWEEN.Tween({ timer: 0 })
1727
+ .to({
1728
+ timer: interval,
1729
+ }, interval)
1730
+ .easing(easing)
1731
+ .onStart(() => {
1732
+ let eye = skipPositionTranslate ? eye1 : eye0;
1733
+ const target = skipPositionTranslate ? target1 : target0;
1734
+ if (freeRotation) {
1735
+ this.orbitControl.update();
1736
+ const orbitControlTarget = this.orbitControl.target.clone();
1737
+ const cameraPosition = this.orbitControl.object.position.clone();
1738
+ const originDiff = orbitControlTarget.sub(cameraPosition).normalize();
1739
+ eye = originDiff.multiplyScalar(PanoramaController.DirectionVectorScalar).add(target);
1740
+ }
1741
+ this.setCameraPose([eye.x, eye.y, eye.z], [target.x, target.y, target.z]);
1742
+ this.renderThisFrame();
1743
+ })
1744
+ .onUpdate(({ timer }) => {
1745
+ const progress = timer / interval;
1746
+ let rotateProgress = (timer - rotateDelay) / (interval - rotateDelay);
1747
+ rotateProgress = easing(Math.max(Math.min(rotateProgress, 1), 0));
1748
+ const theta = fromTheta + (toTheta - fromTheta) * rotateProgress;
1749
+ const phi = fromPhi + (toPhi - fromPhi) * rotateProgress;
1750
+ const transformedProgress = progressTransform ? progressTransform(progress) : progress;
1751
+ // const progress = progress0;
1752
+ if (!skipPositionTranslate) {
1753
+ // if (freeRotation) lookAt = this.orbitControl.target.clone();
1754
+ const spherical = new THREE.Spherical(1, phi, Math.abs(theta) > Math.PI ? theta - Math.sign(theta) * Math.PI * 2 : theta);
1755
+ spherical.makeSafe();
1756
+ const direction = new THREE.Vector3().setFromSpherical(spherical).applyQuaternion(quatInverse);
1757
+ // console.log(`#PanoCtrl# onUpdate: direction=(${direction.x}, ${direction.y}, ${direction.z})`);
1758
+ const lookAt = fromPosition.clone().addScaledVector(diff, transformedProgress);
1759
+ this.orbitControl.update();
1760
+ const orbitControlTarget = this.orbitControl.target.clone();
1761
+ const cameraPosition = this.orbitControl.object.position.clone();
1762
+ const originDiff = orbitControlTarget.sub(cameraPosition).normalize();
1763
+ const fromNormalized = fromDirection.clone().normalize();
1764
+ const dist = originDiff.distanceToSquared(fromNormalized);
1765
+ const cameraPos = (freeRotation && dist > 0.0001 ? originDiff : direction)
1766
+ .multiplyScalar(PanoramaController.DirectionVectorScalar)
1767
+ .add(lookAt);
1768
+ this.setCameraPose([cameraPos.x, cameraPos.y, cameraPos.z], [lookAt.x, lookAt.y, lookAt.z]);
1769
+ }
1770
+ const currentFOV = fromFOV + transformedProgress * (toFOV - fromFOV);
1771
+ this.setFOV(currentFOV);
1772
+ if (onOneMoveUpdate) {
1773
+ onOneMoveUpdate(iPath, progress, transformedProgress);
1774
+ }
1775
+ this.renderThisFrame();
1776
+ })
1777
+ .onComplete(() => __awaiter(this, void 0, void 0, function* () {
1778
+ if (!skipPositionTranslate) {
1779
+ const toLookAt = toPosition;
1780
+ this.orbitControl.update();
1781
+ const orbitControlTarget = this.orbitControl.target.clone();
1782
+ const cameraPosition = this.orbitControl.object.position.clone();
1783
+ const originDiff = orbitControlTarget.sub(cameraPosition).normalize();
1784
+ // const toLookAt = freeRotation ? this.orbitControl.target.clone() : toPosition;
1785
+ // console.log(`#PanoCtrl# onComplete: direction=(${toDirection.x}, ${toDirection.y}, ${toDirection.z})`);
1786
+ const cameraPos = (freeRotation ? originDiff : toDirection).clone()
1787
+ .multiplyScalar(PanoramaController.DirectionVectorScalar)
1788
+ .add(toLookAt);
1789
+ this.setCameraPose([cameraPos.x, cameraPos.y, cameraPos.z], [toLookAt.x, toLookAt.y, toLookAt.z]);
1790
+ }
1791
+ this.renderThisFrame();
1792
+ if (onOneMoveComplete) {
1793
+ yield onOneMoveComplete(iPath);
1794
+ }
1795
+ resolve();
1796
+ }))
1797
+ .start();
1798
+ }));
1799
+ if (beforeAllMoves) {
1800
+ yield beforeAllMoves();
1801
+ }
1802
+ while (iPath < pathPoints.length) {
1803
+ if (this.cancelAnimation)
1804
+ break;
1805
+ const task = createTask();
1806
+ // eslint-disable-next-line no-await-in-loop
1807
+ yield task;
1808
+ iPath += 1;
1809
+ }
1810
+ if (!this.cancelAnimation) {
1811
+ if (afterAllMoves) {
1812
+ yield afterAllMoves();
1813
+ }
1814
+ }
1815
+ this.cancelAnimation = false;
1816
+ this.translatePromise = undefined;
1817
+ if (!queueIfBusy) {
1818
+ this.isAnimating = false;
1819
+ }
1820
+ resolve0();
1821
+ }));
1822
+ this.translatePromise = translatePromise;
1823
+ // eslint-disable-next-line consistent-return
1824
+ yield translatePromise;
1825
+ });
1826
+ }
1827
+ unlockRotation() {
1828
+ this.rotationLocks = {
1829
+ lockAzimuth: false,
1830
+ lockPolar: false,
1831
+ centralAzimuth: 0,
1832
+ centralPolar: Math.PI / 2,
1833
+ azimuthRange: Math.PI,
1834
+ polarRange: Math.PI / 2,
1835
+ };
1836
+ this.orbitControl.maxAzimuthAngle = Infinity;
1837
+ this.orbitControl.minAzimuthAngle = -Infinity;
1838
+ this.orbitControl.maxPolarAngle = Infinity;
1839
+ this.orbitControl.minPolarAngle = -Infinity;
1840
+ }
1841
+ unlockPolarAngle() {
1842
+ Object.assign(this.rotationLocks, {
1843
+ lockPolar: false,
1844
+ centralPolar: Math.PI / 2,
1845
+ polarRange: Math.PI / 2,
1846
+ });
1847
+ this.orbitControl.maxPolarAngle = Infinity;
1848
+ this.orbitControl.minPolarAngle = -Infinity;
1849
+ }
1850
+ lockPolarAngle(range) {
1851
+ if (range < ROTATION_LOCK_BOUNDARY)
1852
+ throw new Error(`Cannot set polar range smaller than ${ROTATION_LOCK_BOUNDARY}`);
1853
+ Object.assign(this.rotationLocks, {
1854
+ lockPolar: true,
1855
+ polarRange: range,
1856
+ centralPolar: this.orbitControl.getPolarAngle(),
1857
+ });
1858
+ }
1859
+ unlockAzimuthalAngle() {
1860
+ Object.assign(this.rotationLocks, {
1861
+ lockAzimuth: false,
1862
+ centralAzimuth: 0,
1863
+ azimuthRange: Math.PI,
1864
+ });
1865
+ this.orbitControl.maxAzimuthAngle = Infinity;
1866
+ this.orbitControl.minAzimuthAngle = -Infinity;
1867
+ }
1868
+ lockAzimuthalAngle(range) {
1869
+ if (range < ROTATION_LOCK_BOUNDARY)
1870
+ throw new Error(`Cannot set azimuth range smaller than ${ROTATION_LOCK_BOUNDARY}`);
1871
+ Object.assign(this.rotationLocks, {
1872
+ lockAzimuth: true,
1873
+ azimuthRange: range,
1874
+ centralAzimuth: this.orbitControl.getAzimuthalAngle(),
1875
+ });
1876
+ }
1877
+ /**
1878
+ * 获取当前纵向转动角度
1879
+ */
1880
+ getPolarAngle() {
1881
+ return this.orbitControl.getPolarAngle();
1882
+ }
1883
+ /**
1884
+ * 获取当前横向转动角度
1885
+ */
1886
+ getAzimuthalAngle() {
1887
+ return this.orbitControl.getAzimuthalAngle();
1888
+ }
1889
+ setCaptureMove(capture) {
1890
+ this.captureMove = capture;
1891
+ }
1892
+ setOnScreenDetectRadius(radius) {
1893
+ this.onScreenDetectRadius = radius;
1894
+ }
1895
+ /**
1896
+ * 设置纵向转动范围, 最低为0, 最高为Math.PI
1897
+ * @param min 纵向转动范围最小值
1898
+ * @param max 纵向转动范围最大值
1899
+ */
1900
+ setPolarAngleRange(min, max) {
1901
+ this.orbitControl.minPolarAngle = min;
1902
+ this.orbitControl.maxPolarAngle = max;
1903
+ }
1904
+ /**
1905
+ * 设置横向转动范围, 最低为-Math.PI, 最高为Math.PI
1906
+ * @param min 横向转动范围最小值
1907
+ * @param max 横向转动范围最大值
1908
+ */
1909
+ setAzimuthAngleRange(min, max) {
1910
+ this.orbitControl.minAzimuthAngle = min;
1911
+ this.orbitControl.maxAzimuthAngle = max;
1912
+ }
1913
+ /**
1914
+ * 设置相机的横向旋转
1915
+ * @param radius 目标弧度
1916
+ */
1917
+ setAzimuthAngle(radius) {
1918
+ const { minAzimuthAngle, maxAzimuthAngle } = this.orbitControl;
1919
+ this.setAzimuthAngleRange(radius, radius + 0.000001);
1920
+ this.orbitControl.update();
1921
+ this.setAzimuthAngleRange(minAzimuthAngle, maxAzimuthAngle);
1922
+ this.orbitControl.update();
1923
+ this.renderThisFrame();
1924
+ }
1925
+ /**
1926
+ * 设置相机的纵向旋转
1927
+ * @param radius 目标弧度
1928
+ */
1929
+ setPolarAngle(radius) {
1930
+ const { minPolarAngle, maxPolarAngle } = this.orbitControl;
1931
+ this.setPolarAngleRange(radius, radius + 0.000001);
1932
+ this.orbitControl.update();
1933
+ this.setPolarAngleRange(minPolarAngle, maxPolarAngle);
1934
+ this.orbitControl.update();
1935
+ this.renderThisFrame();
1936
+ }
1937
+ stopMoving() {
1938
+ this.cancelAnimation = false;
1939
+ }
1940
+ }
1941
+ PanoramaController.RotateSpeed = -1;
1942
+ PanoramaController.DirectionVectorScalar = -0.0001;
1943
+ export { PanoramaController };