@aibee/owlly 1.0.25 → 1.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (359) hide show
  1. package/lib/external/lines/line-geometry.d.ts +9 -0
  2. package/lib/external/lines/line-geometry.js +51 -0
  3. package/lib/external/lines/line-material.d.ts +10 -0
  4. package/lib/external/lines/line-material.js +376 -0
  5. package/lib/external/lines/line-segments-2.d.ts +7 -0
  6. package/lib/external/lines/line-segments-2.js +143 -0
  7. package/lib/external/lines/line-segments-geometry.d.ts +15 -0
  8. package/lib/external/lines/line-segments-geometry.js +140 -0
  9. package/lib/external/loaders/gltf-loader.d.ts +77 -0
  10. package/lib/external/loaders/gltf-loader.js +2318 -0
  11. package/lib/external/orbit-controls.d.ts +44 -0
  12. package/lib/external/orbit-controls.js +745 -0
  13. package/lib/external/renderers/css-2d-renderer.d.ts +16 -0
  14. package/lib/external/renderers/css-2d-renderer.js +121 -0
  15. package/lib/external/renderers/css-3d-renderer.d.ts +18 -0
  16. package/lib/external/renderers/css-3d-renderer.js +138 -0
  17. package/lib/external/transform-controls.d.ts +106 -0
  18. package/lib/external/transform-controls.js +1112 -0
  19. package/lib/owlly/controller/aerial-element-controller.d.ts +65 -0
  20. package/lib/owlly/controller/aerial-element-controller.js +235 -0
  21. package/lib/owlly/controller/basic-controller.d.ts +324 -0
  22. package/lib/owlly/controller/basic-controller.js +1238 -0
  23. package/lib/owlly/controller/camera-controller.d.ts +37 -0
  24. package/lib/owlly/controller/camera-controller.js +137 -0
  25. package/lib/owlly/controller/controller.d.ts +61 -0
  26. package/lib/owlly/controller/controller.js +23 -0
  27. package/lib/owlly/controller/index.d.ts +2 -0
  28. package/lib/owlly/controller/index.js +13 -0
  29. package/lib/owlly/controller/mouse-indicator-controller.d.ts +34 -0
  30. package/lib/owlly/controller/mouse-indicator-controller.js +118 -0
  31. package/lib/owlly/controller/orbit-control.d.ts +147 -0
  32. package/lib/owlly/controller/orbit-control.js +264 -0
  33. package/lib/owlly/controller/panorama-adjust-controller.d.ts +45 -0
  34. package/lib/owlly/controller/panorama-adjust-controller.js +157 -0
  35. package/lib/owlly/controller/panorama-controller.d.ts +441 -0
  36. package/lib/owlly/controller/panorama-controller.js +1943 -0
  37. package/lib/owlly/controller/panorama-transform-controller.d.ts +66 -0
  38. package/lib/owlly/controller/panorama-transform-controller.js +136 -0
  39. package/lib/owlly/controller/plane-controller.d.ts +43 -0
  40. package/lib/owlly/controller/plane-controller.js +173 -0
  41. package/lib/owlly/controller/texture-controller.d.ts +181 -0
  42. package/lib/owlly/controller/texture-controller.js +875 -0
  43. package/lib/owlly/controller/tile-panorama-controller.d.ts +308 -0
  44. package/lib/owlly/controller/tile-panorama-controller.js +1353 -0
  45. package/lib/owlly/controller/transform-controller.d.ts +106 -0
  46. package/lib/owlly/controller/transform-controller.js +545 -0
  47. package/lib/owlly/element/bottom-nav-element.d.ts +65 -0
  48. package/lib/owlly/element/bottom-nav-element.js +257 -0
  49. package/lib/owlly/element/camera.d.ts +82 -0
  50. package/lib/owlly/element/camera.js +283 -0
  51. package/lib/owlly/element/dom-2d-element.d.ts +35 -0
  52. package/lib/owlly/element/dom-2d-element.js +48 -0
  53. package/lib/owlly/element/dom-3d-element.d.ts +27 -0
  54. package/lib/owlly/element/dom-3d-element.js +33 -0
  55. package/lib/owlly/element/dom-label-2d.d.ts +116 -0
  56. package/lib/owlly/element/dom-label-2d.js +382 -0
  57. package/lib/owlly/element/element.d.ts +53 -0
  58. package/lib/owlly/element/element.js +75 -0
  59. package/lib/owlly/element/floor-model.d.ts +83 -0
  60. package/lib/owlly/element/floor-model.js +227 -0
  61. package/lib/owlly/element/gif-kit/Gif.d.ts +96 -0
  62. package/lib/owlly/element/gif-kit/Gif.js +432 -0
  63. package/lib/owlly/element/gif-kit/GifColor.d.ts +21 -0
  64. package/lib/owlly/element/gif-kit/GifColor.js +37 -0
  65. package/lib/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.d.ts +20 -0
  66. package/lib/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.js +50 -0
  67. package/lib/owlly/element/gif-kit/GifFrame.d.ts +31 -0
  68. package/lib/owlly/element/gif-kit/GifFrame.js +96 -0
  69. package/lib/owlly/element/gif-kit/GifImage.d.ts +23 -0
  70. package/lib/owlly/element/gif-kit/GifImage.js +7 -0
  71. package/lib/owlly/element/gif-kit/GifParser.d.ts +17 -0
  72. package/lib/owlly/element/gif-kit/GifParser.js +196 -0
  73. package/lib/owlly/element/gif-kit/GifPresenter.d.ts +20 -0
  74. package/lib/owlly/element/gif-kit/GifPresenter.js +43 -0
  75. package/lib/owlly/element/gif-kit/GifVersion.d.ts +10 -0
  76. package/lib/owlly/element/gif-kit/GifVersion.js +12 -0
  77. package/lib/owlly/element/gltf-mesh-element.d.ts +31 -0
  78. package/lib/owlly/element/gltf-mesh-element.js +136 -0
  79. package/lib/owlly/element/index.d.ts +20 -0
  80. package/lib/owlly/element/index.js +24 -0
  81. package/lib/owlly/element/map-kit/shape.d.ts +131 -0
  82. package/lib/owlly/element/map-kit/shape.js +189 -0
  83. package/lib/owlly/element/mesh-element.d.ts +22 -0
  84. package/lib/owlly/element/mesh-element.js +63 -0
  85. package/lib/owlly/element/mesh-line-2d.d.ts +82 -0
  86. package/lib/owlly/element/mesh-line-2d.js +887 -0
  87. package/lib/owlly/element/meshline-o.d.ts +64 -0
  88. package/lib/owlly/element/meshline-o.js +678 -0
  89. package/lib/owlly/element/panorama-group.d.ts +241 -0
  90. package/lib/owlly/element/panorama-group.js +966 -0
  91. package/lib/owlly/element/panorama.d.ts +132 -0
  92. package/lib/owlly/element/panorama.js +812 -0
  93. package/lib/owlly/element/path-group.d.ts +69 -0
  94. package/lib/owlly/element/path-group.js +171 -0
  95. package/lib/owlly/element/path.d.ts +99 -0
  96. package/lib/owlly/element/path.js +531 -0
  97. package/lib/owlly/element/placeable-2d.d.ts +158 -0
  98. package/lib/owlly/element/placeable-2d.js +470 -0
  99. package/lib/owlly/element/polygon-mesh.d.ts +107 -0
  100. package/lib/owlly/element/polygon-mesh.js +307 -0
  101. package/lib/owlly/element/ring-element.d.ts +79 -0
  102. package/lib/owlly/element/ring-element.js +383 -0
  103. package/lib/owlly/element/sphere-mesh.d.ts +28 -0
  104. package/lib/owlly/element/sphere-mesh.js +69 -0
  105. package/lib/owlly/element/svg-floor-model.d.ts +22 -0
  106. package/lib/owlly/element/svg-floor-model.js +184 -0
  107. package/lib/owlly/element/svg-floors.d.ts +27 -0
  108. package/lib/owlly/element/svg-floors.js +109 -0
  109. package/lib/owlly/element/tile-panorama-group.d.ts +335 -0
  110. package/lib/owlly/element/tile-panorama-group.js +1006 -0
  111. package/lib/owlly/element/tile-panorama.d.ts +161 -0
  112. package/lib/owlly/element/tile-panorama.js +509 -0
  113. package/lib/owlly/element/tile-plane.d.ts +105 -0
  114. package/lib/owlly/element/tile-plane.js +360 -0
  115. package/lib/owlly/element/video-element.d.ts +33 -0
  116. package/lib/owlly/element/video-element.js +159 -0
  117. package/lib/owlly/geometries/ExtrudeGeometry2.d.ts +15 -0
  118. package/lib/owlly/geometries/ExtrudeGeometry2.js +210 -0
  119. package/lib/owlly/index.d.ts +13 -0
  120. package/lib/owlly/index.js +16 -0
  121. package/lib/owlly/overlay/canvas-overlay.d.ts +96 -0
  122. package/lib/owlly/overlay/canvas-overlay.js +510 -0
  123. package/lib/owlly/overlay/css-2d-overlay.d.ts +14 -0
  124. package/lib/owlly/overlay/css-2d-overlay.js +35 -0
  125. package/lib/owlly/overlay/css-3d-overlay.d.ts +16 -0
  126. package/lib/owlly/overlay/css-3d-overlay.js +36 -0
  127. package/lib/owlly/overlay/index.d.ts +6 -0
  128. package/lib/owlly/overlay/index.js +11 -0
  129. package/lib/owlly/overlay/label-overlay.d.ts +62 -0
  130. package/lib/owlly/overlay/label-overlay.js +328 -0
  131. package/lib/owlly/overlay/overlay.d.ts +14 -0
  132. package/lib/owlly/overlay/overlay.js +4 -0
  133. package/lib/owlly/overlay/path-overlay.d.ts +39 -0
  134. package/lib/owlly/overlay/path-overlay.js +124 -0
  135. package/lib/owlly/overlay/path-overlay2.d.ts +35 -0
  136. package/lib/owlly/overlay/path-overlay2.js +118 -0
  137. package/lib/owlly/overlay/poi-overlay-3d.d.ts +278 -0
  138. package/lib/owlly/overlay/poi-overlay-3d.js +1432 -0
  139. package/lib/owlly/overlay/poi-overlay.d.ts +277 -0
  140. package/lib/owlly/overlay/poi-overlay.js +1411 -0
  141. package/lib/owlly/owlly-2d/index.d.ts +28 -0
  142. package/lib/owlly/owlly-2d/index.js +92 -0
  143. package/lib/owlly/screen/index.d.ts +1 -0
  144. package/lib/owlly/screen/index.js +1 -0
  145. package/lib/owlly/screen/screen.d.ts +73 -0
  146. package/lib/owlly/screen/screen.js +236 -0
  147. package/lib/owlly/stage/externals.d.ts +19 -0
  148. package/lib/owlly/stage/externals.js +24 -0
  149. package/lib/owlly/stage/index.d.ts +4 -0
  150. package/lib/owlly/stage/index.js +6 -0
  151. package/lib/owlly/stage/owlly.d.ts +38 -0
  152. package/lib/owlly/stage/owlly.js +168 -0
  153. package/lib/owlly/stage/stage.d.ts +108 -0
  154. package/lib/owlly/stage/stage.js +234 -0
  155. package/lib/owlly/utils/alignment-utils.d.ts +20 -0
  156. package/lib/owlly/utils/alignment-utils.js +63 -0
  157. package/lib/owlly/utils/basic-calc.d.ts +18 -0
  158. package/lib/owlly/utils/basic-calc.js +129 -0
  159. package/lib/owlly/utils/basic-tools.d.ts +71 -0
  160. package/lib/owlly/utils/basic-tools.js +235 -0
  161. package/lib/owlly/utils/bvh-tree.d.ts +105 -0
  162. package/lib/owlly/utils/bvh-tree.js +539 -0
  163. package/lib/owlly/utils/camera.d.ts +37 -0
  164. package/lib/owlly/utils/camera.js +50 -0
  165. package/lib/owlly/utils/cube-texture-cache.d.ts +25 -0
  166. package/lib/owlly/utils/cube-texture-cache.js +143 -0
  167. package/lib/owlly/utils/device-utils.d.ts +18 -0
  168. package/lib/owlly/utils/device-utils.js +41 -0
  169. package/lib/owlly/utils/environment-utils.d.ts +37 -0
  170. package/lib/owlly/utils/environment-utils.js +73 -0
  171. package/lib/owlly/utils/event-hub.d.ts +50 -0
  172. package/lib/owlly/utils/event-hub.js +106 -0
  173. package/lib/owlly/utils/events.d.ts +219 -0
  174. package/lib/owlly/utils/events.js +219 -0
  175. package/lib/owlly/utils/geometry-utils.d.ts +119 -0
  176. package/lib/owlly/utils/geometry-utils.js +622 -0
  177. package/lib/owlly/utils/helper.d.ts +6 -0
  178. package/lib/owlly/utils/helper.js +24 -0
  179. package/lib/owlly/utils/index.d.ts +14 -0
  180. package/lib/owlly/utils/index.js +17 -0
  181. package/lib/owlly/utils/lru-cache.d.ts +26 -0
  182. package/lib/owlly/utils/lru-cache.js +109 -0
  183. package/lib/owlly/utils/map-utils.d.ts +7 -0
  184. package/lib/owlly/utils/map-utils.js +52 -0
  185. package/lib/owlly/utils/number-utils.d.ts +8 -0
  186. package/lib/owlly/utils/number-utils.js +72 -0
  187. package/lib/owlly/utils/panorama-model-util.d.ts +46 -0
  188. package/lib/owlly/utils/panorama-model-util.js +245 -0
  189. package/lib/owlly/utils/path-utils.d.ts +80 -0
  190. package/lib/owlly/utils/path-utils.js +728 -0
  191. package/lib/owlly/utils/svgutils.d.ts +138 -0
  192. package/lib/owlly/utils/svgutils.js +561 -0
  193. package/lib/owlly/utils/texture-cache.d.ts +29 -0
  194. package/lib/owlly/utils/texture-cache.js +115 -0
  195. package/lib/owlly/utils/tile-util.d.ts +187 -0
  196. package/lib/owlly/utils/tile-util.js +456 -0
  197. package/lib/owlly/utils/time-profiler.d.ts +21 -0
  198. package/lib/owlly/utils/time-profiler.js +48 -0
  199. package/lib/owlly/view/camera-view.d.ts +35 -0
  200. package/lib/owlly/view/camera-view.js +101 -0
  201. package/lib/owlly/view/index.d.ts +3 -0
  202. package/lib/owlly/view/index.js +5 -0
  203. package/lib/owlly/view/orthographic-view.d.ts +40 -0
  204. package/lib/owlly/view/orthographic-view.js +94 -0
  205. package/lib/owlly/view/perspective-view.d.ts +40 -0
  206. package/lib/owlly/view/perspective-view.js +95 -0
  207. package/lib/owlly/view/svg-map-view.d.ts +46 -0
  208. package/lib/owlly/view/svg-map-view.js +144 -0
  209. package/lib/owlly/view/view.d.ts +146 -0
  210. package/lib/owlly/view/view.js +317 -0
  211. package/lib/prod/owlly.esm.js +93462 -0
  212. package/lib/prod/owlly.esm.js.map +1 -0
  213. package/lib/prod/owlly.esm.min.js +54 -0
  214. package/lib/prod/owlly.iife.js +93560 -0
  215. package/lib/prod/owlly.iife.js.map +1 -0
  216. package/lib/prod/owlly.iife.min.js +69 -0
  217. package/lib/prod/owlly.miniapp.js +73845 -0
  218. package/lib/prod/owlly.miniapp.js.map +1 -0
  219. package/lib/prod/owlly.miniapp.min.js +63 -0
  220. package/lib/prod/src/external/lines/line-geometry.d.ts +9 -0
  221. package/lib/prod/src/external/lines/line-material.d.ts +10 -0
  222. package/lib/prod/src/external/lines/line-segments-2.d.ts +7 -0
  223. package/lib/prod/src/external/lines/line-segments-geometry.d.ts +15 -0
  224. package/lib/prod/src/external/loaders/gltf-loader.d.ts +77 -0
  225. package/lib/prod/src/external/orbit-controls.d.ts +44 -0
  226. package/lib/prod/src/external/renderers/css-2d-renderer.d.ts +16 -0
  227. package/lib/prod/src/external/renderers/css-3d-renderer.d.ts +18 -0
  228. package/lib/prod/src/external/transform-controls.d.ts +106 -0
  229. package/lib/prod/src/external/util/buffer-geometry-utils.d.ts +45 -0
  230. package/lib/prod/src/owlly/controller/aerial-element-controller.d.ts +65 -0
  231. package/lib/prod/src/owlly/controller/basic-controller.d.ts +324 -0
  232. package/lib/prod/src/owlly/controller/camera-controller.d.ts +37 -0
  233. package/lib/prod/src/owlly/controller/controller.d.ts +61 -0
  234. package/lib/prod/src/owlly/controller/index.d.ts +2 -0
  235. package/lib/prod/src/owlly/controller/mouse-indicator-controller.d.ts +34 -0
  236. package/lib/prod/src/owlly/controller/orbit-control.d.ts +147 -0
  237. package/lib/prod/src/owlly/controller/panorama-adjust-controller.d.ts +45 -0
  238. package/lib/prod/src/owlly/controller/panorama-controller.d.ts +441 -0
  239. package/lib/prod/src/owlly/controller/panorama-transform-controller.d.ts +66 -0
  240. package/lib/prod/src/owlly/controller/plane-controller.d.ts +43 -0
  241. package/lib/prod/src/owlly/controller/texture-controller.d.ts +183 -0
  242. package/lib/prod/src/owlly/controller/tile-panorama-controller.d.ts +308 -0
  243. package/lib/prod/src/owlly/controller/transform-controller.d.ts +106 -0
  244. package/lib/prod/src/owlly/element/bottom-nav-element.d.ts +65 -0
  245. package/lib/prod/src/owlly/element/camera.d.ts +82 -0
  246. package/lib/prod/src/owlly/element/dom-2d-element.d.ts +35 -0
  247. package/lib/prod/src/owlly/element/dom-3d-element.d.ts +27 -0
  248. package/lib/prod/src/owlly/element/dom-label-2d.d.ts +116 -0
  249. package/lib/prod/src/owlly/element/element.d.ts +53 -0
  250. package/lib/prod/src/owlly/element/floor-model.d.ts +83 -0
  251. package/lib/prod/src/owlly/element/gif-kit/Gif.d.ts +96 -0
  252. package/lib/prod/src/owlly/element/gif-kit/GifColor.d.ts +21 -0
  253. package/lib/prod/src/owlly/element/gif-kit/GifCompressedCodesToByteArrayConverter.d.ts +20 -0
  254. package/lib/prod/src/owlly/element/gif-kit/GifFrame.d.ts +31 -0
  255. package/lib/prod/src/owlly/element/gif-kit/GifImage.d.ts +23 -0
  256. package/lib/prod/src/owlly/element/gif-kit/GifParser.d.ts +17 -0
  257. package/lib/prod/src/owlly/element/gif-kit/GifPresenter.d.ts +20 -0
  258. package/lib/prod/src/owlly/element/gif-kit/GifVersion.d.ts +10 -0
  259. package/lib/prod/src/owlly/element/gltf-mesh-element.d.ts +31 -0
  260. package/lib/prod/src/owlly/element/index.d.ts +6 -0
  261. package/lib/prod/src/owlly/element/map-kit/area.d.ts +24 -0
  262. package/lib/prod/src/owlly/element/map-kit/block-set.d.ts +39 -0
  263. package/lib/prod/src/owlly/element/map-kit/block.d.ts +77 -0
  264. package/lib/prod/src/owlly/element/map-kit/index.d.ts +3 -0
  265. package/lib/prod/src/owlly/element/map-kit/shape.d.ts +131 -0
  266. package/lib/prod/src/owlly/element/mesh-element.d.ts +22 -0
  267. package/lib/prod/src/owlly/element/mesh-line-2d.d.ts +82 -0
  268. package/lib/prod/src/owlly/element/meshline-o.d.ts +64 -0
  269. package/lib/prod/src/owlly/element/panorama-group.d.ts +241 -0
  270. package/lib/prod/src/owlly/element/panorama.d.ts +132 -0
  271. package/lib/prod/src/owlly/element/path-group.d.ts +69 -0
  272. package/lib/prod/src/owlly/element/path.d.ts +99 -0
  273. package/lib/prod/src/owlly/element/placeable-2d.d.ts +158 -0
  274. package/lib/prod/src/owlly/element/polygon-mesh.d.ts +107 -0
  275. package/lib/prod/src/owlly/element/ring-element.d.ts +79 -0
  276. package/lib/prod/src/owlly/element/sphere-mesh.d.ts +28 -0
  277. package/lib/prod/src/owlly/element/svg-floor-model.d.ts +22 -0
  278. package/lib/prod/src/owlly/element/svg-floors.d.ts +27 -0
  279. package/lib/prod/src/owlly/element/tile-panorama-group.d.ts +335 -0
  280. package/lib/prod/src/owlly/element/tile-panorama.d.ts +162 -0
  281. package/lib/prod/src/owlly/element/tile-plane.d.ts +114 -0
  282. package/lib/prod/src/owlly/element/video-element.d.ts +33 -0
  283. package/lib/prod/src/owlly/geometries/ExtrudeGeometry2.d.ts +15 -0
  284. package/lib/prod/src/owlly/index.d.ts +13 -0
  285. package/lib/prod/src/owlly/overlay/canvas-overlay.d.ts +96 -0
  286. package/lib/prod/src/owlly/overlay/css-2d-overlay.d.ts +14 -0
  287. package/lib/prod/src/owlly/overlay/css-3d-overlay.d.ts +16 -0
  288. package/lib/prod/src/owlly/overlay/index.d.ts +5 -0
  289. package/lib/prod/src/owlly/overlay/label-overlay.d.ts +62 -0
  290. package/lib/prod/src/owlly/overlay/overlay.d.ts +14 -0
  291. package/lib/prod/src/owlly/overlay/path-overlay.d.ts +39 -0
  292. package/lib/prod/src/owlly/overlay/path-overlay2.d.ts +35 -0
  293. package/lib/prod/src/owlly/overlay/poi-overlay-3d.d.ts +278 -0
  294. package/lib/prod/src/owlly/overlay/poi-overlay.d.ts +277 -0
  295. package/lib/prod/src/owlly/owlly-2d/index.d.ts +28 -0
  296. package/lib/prod/src/owlly/screen/index.d.ts +1 -0
  297. package/lib/prod/src/owlly/screen/screen.d.ts +73 -0
  298. package/lib/prod/src/owlly/stage/__test__/stage.spec.d.ts +1 -0
  299. package/lib/prod/src/owlly/stage/externals.d.ts +19 -0
  300. package/lib/prod/src/owlly/stage/index.d.ts +3 -0
  301. package/lib/prod/src/owlly/stage/owlly.d.ts +38 -0
  302. package/lib/prod/src/owlly/stage/stage.d.ts +108 -0
  303. package/lib/prod/src/owlly/utils/alignment-utils.d.ts +20 -0
  304. package/lib/prod/src/owlly/utils/basic-calc.d.ts +18 -0
  305. package/lib/prod/src/owlly/utils/basic-tools.d.ts +71 -0
  306. package/lib/prod/src/owlly/utils/bvh-tree.d.ts +105 -0
  307. package/lib/prod/src/owlly/utils/camera.d.ts +37 -0
  308. package/lib/prod/src/owlly/utils/cube-texture-cache.d.ts +25 -0
  309. package/lib/prod/src/owlly/utils/device-utils.d.ts +18 -0
  310. package/lib/prod/src/owlly/utils/environment-utils.d.ts +37 -0
  311. package/lib/prod/src/owlly/utils/event-hub.d.ts +50 -0
  312. package/lib/prod/src/owlly/utils/events.d.ts +219 -0
  313. package/lib/prod/src/owlly/utils/geometry-utils.d.ts +119 -0
  314. package/lib/prod/src/owlly/utils/helper.d.ts +6 -0
  315. package/lib/prod/src/owlly/utils/index.d.ts +13 -0
  316. package/lib/prod/src/owlly/utils/lru-cache.d.ts +26 -0
  317. package/lib/prod/src/owlly/utils/map-utils.d.ts +7 -0
  318. package/lib/prod/src/owlly/utils/number-utils.d.ts +8 -0
  319. package/lib/prod/src/owlly/utils/panorama-model-util.d.ts +46 -0
  320. package/lib/prod/src/owlly/utils/path-utils.d.ts +80 -0
  321. package/lib/prod/src/owlly/utils/svgutils.d.ts +138 -0
  322. package/lib/prod/src/owlly/utils/texture-cache.d.ts +29 -0
  323. package/lib/prod/src/owlly/utils/tile-util.d.ts +187 -0
  324. package/lib/prod/src/owlly/utils/time-profiler.d.ts +21 -0
  325. package/lib/prod/src/owlly/view/__test__/perspective-view.spec.d.ts +0 -0
  326. package/lib/prod/src/owlly/view/camera-view.d.ts +35 -0
  327. package/lib/prod/src/owlly/view/index.d.ts +3 -0
  328. package/lib/prod/src/owlly/view/orthographic-view.d.ts +40 -0
  329. package/lib/prod/src/owlly/view/perspective-view.d.ts +40 -0
  330. package/lib/prod/src/owlly/view/svg-map-view.d.ts +46 -0
  331. package/lib/prod/src/owlly/view/view.d.ts +146 -0
  332. package/lib/src/owlly/controller/texture-controller.d.ts +3 -1
  333. package/lib/src/owlly/controller/texture-controller.js +16 -1
  334. package/lib/src/owlly/controller/texture-controller.js.map +1 -1
  335. package/lib/src/owlly/controller/tile-panorama-controller.js +4 -0
  336. package/lib/src/owlly/controller/tile-panorama-controller.js.map +1 -1
  337. package/lib/src/owlly/element/tile-panorama.d.ts +1 -0
  338. package/lib/src/owlly/element/tile-panorama.js +16 -3
  339. package/lib/src/owlly/element/tile-panorama.js.map +1 -1
  340. package/lib/src/owlly/element/tile-plane.d.ts +9 -0
  341. package/lib/src/owlly/element/tile-plane.js +27 -0
  342. package/lib/src/owlly/element/tile-plane.js.map +1 -1
  343. package/lib/src/owlly/overlay/poi-overlay-3d.js.map +1 -1
  344. package/lib/src/owlly/overlay/poi-overlay.js.map +1 -1
  345. package/lib/src/owlly/stage/owlly.js +7 -1
  346. package/lib/src/owlly/stage/owlly.js.map +1 -1
  347. package/lib/src/owlly/stage/stage.js +2 -0
  348. package/lib/src/owlly/stage/stage.js.map +1 -1
  349. package/lib/src/web/main.rpeng.mes.plane.js.map +1 -1
  350. package/package.json +16 -7
  351. package/src/owlly/controller/texture-controller.ts +18 -1
  352. package/src/owlly/controller/tile-panorama-controller.ts +3 -1
  353. package/src/owlly/element/tile-panorama.ts +14 -0
  354. package/src/owlly/element/tile-plane.ts +26 -0
  355. package/src/owlly/overlay/poi-overlay-3d.ts +0 -4
  356. package/src/owlly/overlay/poi-overlay.ts +0 -4
  357. package/src/owlly/stage/owlly.ts +6 -1
  358. package/src/owlly/stage/stage.ts +2 -0
  359. package/src/web/main.rpeng.mes.plane.ts +0 -6
@@ -0,0 +1,1411 @@
1
+ /* eslint-disable max-len */
2
+ import TWEEN from '@tweenjs/tween.js';
3
+ import { SceneUtils } from 'three/examples/jsm/utils/SceneUtils.js';
4
+ import { Externals, NS_THREE } from '../stage/externals';
5
+ import { BasicTools } from '../utils/basic-tools';
6
+ import { Overlay } from './overlay';
7
+ import { OwllyEvents, Events } from '../utils/events';
8
+ import { Env, EnvironmentUtils } from '../utils/environment-utils';
9
+ var MouseState;
10
+ (function (MouseState) {
11
+ MouseState[MouseState["IDLE"] = 0] = "IDLE";
12
+ MouseState[MouseState["DOWN"] = 1] = "DOWN";
13
+ MouseState[MouseState["MOVE"] = 2] = "MOVE";
14
+ })(MouseState || (MouseState = {}));
15
+ /**
16
+ * POI覆盖层, 可以展示POI图标与文字, 存在图标时以图标中心为中心, 否则为文字中心
17
+ * @example
18
+ * ```typescript
19
+ * const poiOverlay = new PoiOverlay();
20
+ * // 任意View
21
+ * view.addOverlay(poiOverlay);
22
+ * ```
23
+ */
24
+ class PoiOverlay extends Overlay {
25
+ constructor(canvas) {
26
+ super();
27
+ this.needRender = false;
28
+ if (EnvironmentUtils.GetEnv() === Env.Miniapp) {
29
+ if (!canvas)
30
+ throw Error('poi-overlay need a offscreenCanvas');
31
+ PoiOverlay.canvas = canvas;
32
+ }
33
+ else if (!PoiOverlay.canvas) {
34
+ PoiOverlay.canvas = document.createElement('canvas');
35
+ }
36
+ // fix: poi名字太长展示不全
37
+ const dpr = EnvironmentUtils.GetGlobalDPR();
38
+ PoiOverlay.canvas.width = 500 * dpr;
39
+ PoiOverlay.canvas.height = 500 * dpr;
40
+ PoiOverlay.ctx = PoiOverlay.canvas.getContext('2d');
41
+ }
42
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
+ // get canvas(): any {
44
+ // return PoiOverlay.canvas;
45
+ // }
46
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
+ // get ctx(): any {
48
+ // return PoiOverlay.canvas.getContext('2d');
49
+ // }
50
+ init(parent) {
51
+ const { THREE } = Externals.getInstance();
52
+ this.rectMap = new Map();
53
+ this.parent = parent;
54
+ this.scene = new THREE.Scene();
55
+ const width = parent.getViewWidth();
56
+ const height = parent.getViewHeight();
57
+ this.renderCamera = new NS_THREE.OrthographicCamera(-width / 2, width / 2, height / 2, -height / 2, 0.1, 1000);
58
+ this.renderCamera.up.set(0, 1, 0);
59
+ this.renderCamera.position.set(0, 0, 50);
60
+ this.renderCamera.lookAt(0, 0, 0);
61
+ this.camera = this.parent.camera;
62
+ this.renderer = this.parent.renderer;
63
+ // const canvas = this.canvas;
64
+ // canvas.width = parent.getViewWidth();
65
+ // canvas.height = parent.getViewHeight();
66
+ // this.canvas = canvas; // 离屏canvas
67
+ this.pois = new Set();
68
+ this.enabled = true;
69
+ this.orderPois = BasicTools.debounce(this.orderPoisByLevel.bind(this), 50);
70
+ this.listeners = {
71
+ pointerDown: (e) => { this.onPointerDown(e); },
72
+ pointerUp: (e) => { this.onPointerUp(e); },
73
+ touchStart: (e) => { this.onTouchStart(e); },
74
+ touchEnd: (e) => { this.onTouchEnd(e); },
75
+ };
76
+ this.mouseState = MouseState.IDLE;
77
+ this.mousePositionBuffer = new THREE.Vector2();
78
+ this.parent.on(OwllyEvents.MOUSE_DOWN, this.listeners.pointerDown);
79
+ this.parent.on(OwllyEvents.MOUSE_UP, this.listeners.pointerUp);
80
+ this.parent.on(OwllyEvents.TOUCH_START, this.listeners.touchStart);
81
+ this.parent.on(OwllyEvents.TOUCH_END, this.listeners.touchEnd);
82
+ }
83
+ update() {
84
+ if (this.renderThisFrame || Array.from(this.pois).reduce((r, p) => (p.update() || r), false)) {
85
+ this.renderThisFrame = false;
86
+ this.needRender = true;
87
+ return true;
88
+ }
89
+ return false;
90
+ }
91
+ forceRenderInThisFrame() {
92
+ this.renderThisFrame = true;
93
+ }
94
+ render() {
95
+ if (!this.enabled)
96
+ return;
97
+ const { THREE } = Externals.getInstance();
98
+ const frustum = new THREE.Frustum();
99
+ frustum.setFromProjectionMatrix(new THREE.Matrix4().multiplyMatrices(this.parent.camera.projectionMatrix, this.parent.camera.matrixWorldInverse));
100
+ const viewWidth = this.parent.getViewWidth();
101
+ const viewHeight = this.parent.getViewHeight();
102
+ const euler = new THREE.Euler();
103
+ euler.setFromQuaternion(this.parent.camera.quaternion, 'ZYX');
104
+ this.checkUpdate();
105
+ if (this.needRender || this.renderThisFrame) {
106
+ this.rectMap.clear();
107
+ const inFrustumPois = [];
108
+ this.pois.forEach((p) => {
109
+ p.draw();
110
+ const { isInFrustum } = p.calcPosAndSize(frustum, viewWidth / 2, viewHeight / 2);
111
+ if (isInFrustum) {
112
+ inFrustumPois.push(p);
113
+ }
114
+ });
115
+ this.recalculateVisibilities(inFrustumPois); // 计算可见性
116
+ Array.from(this.pois).forEach((p, index) => {
117
+ p.updatePosition(viewWidth / 2, viewHeight / 2, index);
118
+ });
119
+ this.renderer.clearDepth();
120
+ this.renderer.render(this.scene, this.renderCamera);
121
+ }
122
+ this.renderThisFrame = false;
123
+ this.needRender = false;
124
+ }
125
+ orderPoisByLevel() {
126
+ const pois = Array.from(this.pois);
127
+ pois.sort((p, q) => p.getLevel() - q.getLevel());
128
+ this.pois = new Set(pois);
129
+ this.renderThisFrame = true;
130
+ }
131
+ recalculateVisibilities(pois) {
132
+ // 碰撞测试
133
+ const range = [];
134
+ let first = true;
135
+ Array.from(pois)
136
+ .sort((p, q) => (q.collision ? -1 : (q.getLevel() - p.getLevel())))
137
+ .forEach((poi) => {
138
+ const { xMin, yMin, xMax, yMax, } = poi.getBoundingRect(); // 最小级别的碰撞检测盒
139
+ if (!poi.collision) {
140
+ poi.setHidden(false);
141
+ range.push([xMin, xMax, yMin, yMax]);
142
+ first = false;
143
+ return;
144
+ }
145
+ const { xMin: oXMin, yMin: oYMin, xMax: oXMax, yMax: oYMax, } = poi.getOuterRect(); // 最外层碰撞检测盒
146
+ if (first) {
147
+ range.push([xMin, xMax, yMin, yMax]);
148
+ first = false;
149
+ poi.setHidden(false);
150
+ return;
151
+ }
152
+ const valid = !range.some(([lx, rx, by, ty]) => {
153
+ const xIntersect = xMax < lx || xMin > rx; // x方向不重叠
154
+ const yIntersect = yMax < by || yMin > ty; // y 方向不重叠
155
+ return !xIntersect && !yIntersect;
156
+ });
157
+ if (valid) {
158
+ range.push([xMin, xMax, yMin, yMax]);
159
+ poi.setHidden(false);
160
+ }
161
+ else if (poi.collisionMode === 'outer') {
162
+ poi.setHidden(true); // 全部隐藏
163
+ }
164
+ else if (poi.collisionMode === 'icon' || poi.collisionMode === 'label') {
165
+ const subvalid = !range.some(([lx, rx, by, ty]) => {
166
+ const xIntersect = oXMax < lx || oXMin > rx; // x方向不重叠
167
+ const yIntersect = oYMax < by || oYMin > ty; // y 方向不重叠
168
+ return !xIntersect && !yIntersect;
169
+ });
170
+ if (subvalid) {
171
+ range.push([xMin, xMax, yMin, yMax]);
172
+ poi.setHidden(true, true); // 部分显示
173
+ }
174
+ else {
175
+ poi.setHidden(true); // 全部隐藏
176
+ }
177
+ }
178
+ });
179
+ }
180
+ checkUpdate() {
181
+ // 检查更新
182
+ const { THREE } = Externals.getInstance();
183
+ if (this.renderThisFrame)
184
+ return;
185
+ const poiNeedUpdate = Array.from(this.pois).some((p) => p.update());
186
+ if (poiNeedUpdate) {
187
+ this.renderThisFrame = true;
188
+ return;
189
+ }
190
+ const { camera } = this.parent;
191
+ const { quaternion, position, zoom, up, } = camera;
192
+ // 检查平移
193
+ const curPos = position.clone();
194
+ const curQuaternion = quaternion.clone();
195
+ const curZoom = zoom;
196
+ if (!this.prevPosition) {
197
+ this.prevPosition = curPos.clone();
198
+ this.prevQuaternion = curQuaternion.clone();
199
+ this.prevZoom = curZoom;
200
+ this.renderThisFrame = true;
201
+ return;
202
+ }
203
+ const quat1 = new THREE.Quaternion().setFromUnitVectors(up, new THREE.Vector3(0, 1, 0));
204
+ const lookAtVector1 = new THREE.Vector3(0, 0, -1).applyQuaternion(this.prevQuaternion);
205
+ lookAtVector1.applyQuaternion(quat1);
206
+ const spherical1 = new THREE.Spherical();
207
+ spherical1.setFromVector3(lookAtVector1);
208
+ const quat2 = new THREE.Quaternion().setFromUnitVectors(up, new THREE.Vector3(0, 1, 0));
209
+ const lookAtVector2 = new THREE.Vector3(0, 0, -1).applyQuaternion(curQuaternion);
210
+ lookAtVector2.applyQuaternion(quat2);
211
+ const spherical2 = new THREE.Spherical();
212
+ spherical2.setFromVector3(lookAtVector2);
213
+ // eslint-disable-next-line max-len
214
+ if (Math.abs(spherical1.phi * (180 / Math.PI) - spherical2.phi * (180 / Math.PI)) + Math.abs(spherical1.theta * (180 / Math.PI) - spherical2.theta * (180 / Math.PI)) > 0.0001) {
215
+ this.prevPosition = curPos.clone();
216
+ this.prevQuaternion = curQuaternion.clone();
217
+ this.prevZoom = curZoom;
218
+ this.renderThisFrame = true;
219
+ return;
220
+ }
221
+ const viewWidth = this.parent.getViewWidth();
222
+ const viewHeight = this.parent.getViewHeight();
223
+ const curPagePos = curPos.clone().project(camera);
224
+ const curPagePosX = (curPagePos.x - 1) / 2 * viewWidth;
225
+ const curPagePosY = (1 - curPagePos.y) / 2 * viewHeight;
226
+ curPagePos.set(curPagePosX, curPagePosY, 0);
227
+ const prevPagePos = this.prevPosition.clone().project(camera);
228
+ const prevPagePosX = (prevPagePos.x - 1) / 2 * viewWidth;
229
+ const prevPagePosY = (1 - prevPagePos.y) / 2 * viewHeight;
230
+ prevPagePos.set(prevPagePosX, prevPagePosY, 0);
231
+ if (curPagePos.distanceTo(prevPagePos) > 0.0001) {
232
+ // console.log('检测到平移更新', prevPagePos, curPagePos, curPos, curPos.x, curPos.y, this.prevPosition.x, this.prevPosition.y, camera, quaternion);
233
+ // 平移
234
+ this.prevPosition = curPos.clone();
235
+ this.prevQuaternion = curQuaternion.clone();
236
+ this.prevZoom = curZoom;
237
+ this.renderThisFrame = true;
238
+ return;
239
+ }
240
+ // 非线性, zoom越小, 更新频率越快
241
+ // curZoom > this.prevZoom 时 在放大 zoom变大相同大小带来的更新减缓
242
+ // curZoom < this.prevZoom 时 在减小 zoom变小相同大小带来的更新加快
243
+ if (this.prevZoom !== curZoom
244
+ && (Math.abs((curZoom - this.prevZoom) / curZoom) > 0.0001)
245
+ || (Math.abs((this.prevZoom - curZoom) / this.prevZoom) > 0.0001)) {
246
+ // console.log('检测到zoom更新');
247
+ this.prevPosition = curPos.clone();
248
+ this.prevQuaternion = curQuaternion.clone();
249
+ this.prevZoom = curZoom;
250
+ this.renderThisFrame = true;
251
+ return;
252
+ }
253
+ this.renderThisFrame = false;
254
+ }
255
+ dispose() {
256
+ this.parent.off(OwllyEvents.MOUSE_DOWN, this.listeners.pointerDown);
257
+ this.parent.off(OwllyEvents.MOUSE_UP, this.listeners.pointerUp);
258
+ this.parent.off(OwllyEvents.TOUCH_START, this.listeners.touchStart);
259
+ this.parent.off(OwllyEvents.TOUCH_END, this.listeners.touchEnd);
260
+ this.clearPoi();
261
+ if (PoiOverlay.canvas) {
262
+ PoiOverlay.canvas.remove();
263
+ PoiOverlay.canvas = null;
264
+ }
265
+ if (PoiOverlay.ctx) {
266
+ PoiOverlay.ctx = null;
267
+ }
268
+ }
269
+ onPointerDown(e) {
270
+ const { clientX, clientY } = e;
271
+ const [left, top] = this.parent.getViewOffset();
272
+ const x = clientX - left;
273
+ const y = clientY - top;
274
+ let target = null;
275
+ Array.from(this.rectMap).some(([rect, poi]) => {
276
+ // v.visible && ( !v.hide || v.subHide)
277
+ const { xMin, yMin, xMax, yMax, } = rect;
278
+ const box2 = new NS_THREE.Box2(new NS_THREE.Vector2(xMin, yMin), new NS_THREE.Vector2(xMax, yMax));
279
+ if (box2.containsPoint(new NS_THREE.Vector2(x, y))) {
280
+ target = poi;
281
+ return true;
282
+ }
283
+ return false;
284
+ });
285
+ if (target) {
286
+ this.onNodePointerDown(target, x, y, e.button);
287
+ }
288
+ }
289
+ onPointerUp(e) {
290
+ const { THREE } = Externals.getInstance();
291
+ const { clientX, clientY } = e;
292
+ const [left, top] = this.parent.getViewOffset();
293
+ const x = clientX - left;
294
+ const y = clientY - top;
295
+ const distance = new THREE.Vector2(x, y).distanceToSquared(this.mousePositionBuffer);
296
+ this.emit(Events.POI_UP, this.eventTarget, e.button);
297
+ if (this.mouseState === MouseState.DOWN && distance < 100) {
298
+ this.emit(Events.POI_CLICKED, this.eventTarget, e.button);
299
+ }
300
+ this.mouseState = MouseState.IDLE;
301
+ }
302
+ onTouchStart(e) {
303
+ const { clientX, clientY } = e.touches[0];
304
+ const [left, top] = this.parent.getViewOffset();
305
+ const x = clientX - left;
306
+ const y = clientY - top;
307
+ let target = null;
308
+ Array.from(this.rectMap).some(([rect, poi]) => {
309
+ // v.visible && ( !v.hide || v.subHide)
310
+ const { xMin, yMin, xMax, yMax, } = rect;
311
+ const box2 = new NS_THREE.Box2(new NS_THREE.Vector2(xMin, yMin), new NS_THREE.Vector2(xMax, yMax));
312
+ if (box2.containsPoint(new NS_THREE.Vector2(x, y))) {
313
+ target = poi;
314
+ return true;
315
+ }
316
+ return false;
317
+ });
318
+ if (target) {
319
+ this.onNodePointerDown(target, x, y, 0);
320
+ }
321
+ }
322
+ onTouchEnd(e) {
323
+ const { THREE } = Externals.getInstance();
324
+ const { clientX, clientY } = e.changedTouches[0];
325
+ const [left, top] = this.parent.getViewOffset();
326
+ const x = clientX - left;
327
+ const y = clientY - top;
328
+ const distance = new THREE.Vector2(x, y).distanceToSquared(this.mousePositionBuffer);
329
+ this.emit(Events.POI_UP, this.eventTarget, 0);
330
+ if (this.mouseState === MouseState.DOWN && distance < 100) {
331
+ this.emit(Events.POI_CLICKED, this.eventTarget, 0);
332
+ }
333
+ this.mouseState = MouseState.IDLE;
334
+ }
335
+ onNodePointerDown(target, x, y, button = 0) {
336
+ if (this.mouseState !== MouseState.IDLE)
337
+ return;
338
+ this.mouseState = MouseState.DOWN;
339
+ this.mousePositionBuffer.set(x, y);
340
+ this.eventTarget = target;
341
+ this.emit(Events.POI_DOWN, target, button);
342
+ }
343
+ /**
344
+ * 新建POI
345
+ * @param position POI在3D空间中的位置
346
+ */
347
+ createPoi(position) {
348
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
349
+ const poi = new Poi();
350
+ poi.setParent(this);
351
+ this.renderThisFrame = true;
352
+ poi.setPosition(position);
353
+ if (!this.pois)
354
+ throw Error('poiOverlay need bind a view, use view.addOverlay()');
355
+ this.pois.add(poi);
356
+ this.scene.add(poi.group);
357
+ return poi;
358
+ }
359
+ setRectMap(rect, ele) {
360
+ this.rectMap.set(rect, ele);
361
+ }
362
+ /**
363
+ * 删除POI
364
+ * @param poi 待删除的POI
365
+ */
366
+ removePoi(poi) {
367
+ this.pois.delete(poi);
368
+ this.scene.remove(poi.group);
369
+ poi.dispose();
370
+ this.renderThisFrame = true;
371
+ }
372
+ clearPoi() {
373
+ const pois = Array.from(this.pois);
374
+ pois.forEach((poi) => {
375
+ this.scene.remove(poi.group);
376
+ });
377
+ this.pois.clear();
378
+ this.renderThisFrame = true;
379
+ }
380
+ /**
381
+ * 设置覆盖层可见性 兼容旧poi
382
+ * @param visible 覆盖层是否可见
383
+ */
384
+ setVisibility(visible) {
385
+ this.visible = visible;
386
+ this.enabled = visible;
387
+ }
388
+ setEnabled(value) {
389
+ this.enabled = value;
390
+ }
391
+ resize(viewWidth, viewHeight) {
392
+ this.updateCameraAspect(viewWidth, viewHeight);
393
+ this.renderThisFrame = true;
394
+ }
395
+ updateCameraAspect(viewWidth, viewHeight) {
396
+ const width = viewWidth;
397
+ const height = viewHeight;
398
+ this.renderCamera.left = -width / 2;
399
+ this.renderCamera.right = width / 2;
400
+ this.renderCamera.top = height / 2;
401
+ this.renderCamera.bottom = -height / 2;
402
+ this.renderCamera.updateProjectionMatrix();
403
+ }
404
+ }
405
+ PoiOverlay.canvas = document.createElement('canvas');
406
+ PoiOverlay.ctx = PoiOverlay.canvas.getContext('2d');
407
+ class Poi {
408
+ constructor(position) {
409
+ this._renderThisFrame = false;
410
+ const { THREE } = Externals.getInstance();
411
+ this.dpr = EnvironmentUtils.GetGlobalDPR();
412
+ this.isFlipY = false;
413
+ this.position = position || new THREE.Vector3();
414
+ this.group = new NS_THREE.Group();
415
+ this.textVisibility = true;
416
+ this.iconVisibility = true;
417
+ this.iconInCircle = false;
418
+ this.iconCircleOptions = {
419
+ width: 0,
420
+ color: '#ffffff',
421
+ };
422
+ this.textPosInfo = {
423
+ anchor: 'center',
424
+ offsetX: 0,
425
+ offsetY: 0,
426
+ anchorOffsetX: 0,
427
+ anchorOffsetY: 0,
428
+ };
429
+ this.iconPosInfo = {
430
+ anchor: 'center',
431
+ offsetX: 0,
432
+ offsetY: 0,
433
+ anchorOffsetX: 0,
434
+ anchorOffsetY: 0,
435
+ };
436
+ this.level = 1;
437
+ this.isInFrustum = false;
438
+ this.animationEnabled = false;
439
+ this.text = null;
440
+ this.icon = null;
441
+ this.rect = null;
442
+ this.boundingBox = null;
443
+ this.overlapArea = { x: 0, y: 0 };
444
+ this.visible = true; // 检查是否用到
445
+ this.hide = false;
446
+ this.subHide = false;
447
+ this.rotation = 0;
448
+ this.autoRotation = false;
449
+ this.collision = true;
450
+ this.collisionMode = 'outer';
451
+ this.iconRect = {
452
+ xMin: 0,
453
+ yMin: 0,
454
+ xMax: 0,
455
+ yMax: 0,
456
+ };
457
+ this.textRect = {
458
+ xMin: 0,
459
+ yMin: 0,
460
+ xMax: 0,
461
+ yMax: 0,
462
+ };
463
+ this.boundingRect = {
464
+ xMin: 0,
465
+ yMin: 0,
466
+ xMax: 0,
467
+ yMax: 0,
468
+ };
469
+ this.outerRect = {
470
+ xMin: 0,
471
+ yMin: 0,
472
+ xMax: 0,
473
+ yMax: 0,
474
+ };
475
+ this.visibilityAnimation = {
476
+ anim: null,
477
+ from: 1,
478
+ to: 1,
479
+ current: 1,
480
+ };
481
+ this.text = null;
482
+ this.textWidth = 0;
483
+ this.textHeight = 0;
484
+ this.icon = null;
485
+ this.iconOptions = {
486
+ size: [20, 20],
487
+ src: null,
488
+ };
489
+ this.labelOptions = {
490
+ fontSize: 12,
491
+ padding: 0,
492
+ content: null,
493
+ };
494
+ this.rectOptions = {
495
+ width: 0,
496
+ height: 0,
497
+ fill: 0xff0000,
498
+ opacity: 0.5,
499
+ offsetX: 0,
500
+ offsetY: 0,
501
+ };
502
+ this.visiblePartWhenCollision = 'none';
503
+ this.subAreaOpacity = 1;
504
+ this.abandonedAreaOpacity = 1;
505
+ this.screenPosition = { x: 0, y: 0 };
506
+ this.labelOpacity = 1;
507
+ this.iconOpacity = 1;
508
+ }
509
+ set renderThisFrame(value) {
510
+ this._renderThisFrame = value;
511
+ }
512
+ get renderThisFrame() {
513
+ return this._renderThisFrame;
514
+ }
515
+ dispose() {
516
+ if (this.group) {
517
+ BasicTools.dispose(this.group, true);
518
+ }
519
+ this.parent = null;
520
+ this.iconCircleMaterial = null;
521
+ this.iconMaterial = null;
522
+ this.textMaterial = null;
523
+ this.icon = null;
524
+ this.rect = null;
525
+ this.boundingBox = null;
526
+ this.group = null;
527
+ }
528
+ setParent(parent) {
529
+ this.parent = parent;
530
+ }
531
+ setPosition(position, tolerance = 0.0001) {
532
+ if (position.distanceTo(this.position) < tolerance)
533
+ return;
534
+ this.position.copy(position);
535
+ this.renderThisFrame = true;
536
+ }
537
+ setOpacity(labelOpacity = this.labelOpacity, iconOpacity = this.iconOpacity) {
538
+ this.labelOpacity = labelOpacity;
539
+ this.iconOpacity = iconOpacity;
540
+ }
541
+ /**
542
+ * 设置旋转角度
543
+ * @param rotation 旋转角度
544
+ */
545
+ setRotation(rotation, tolerance = 0.0001) {
546
+ if (Math.abs(rotation - this.rotation) < tolerance)
547
+ return;
548
+ this.group.rotateZ(rotation - this.rotation);
549
+ this.rotation = rotation;
550
+ this.renderThisFrame = true;
551
+ }
552
+ /**
553
+ * 设置是否碰撞
554
+ * @param collision 是否碰撞
555
+ */
556
+ setCollision(collision) {
557
+ this.collision = collision;
558
+ this.renderThisFrame = true;
559
+ }
560
+ /**
561
+ * 设置碰撞模式
562
+ * @param mode 碰撞模式 label || icon || outer(默认)
563
+ */
564
+ setCollisionMode(mode) {
565
+ this.collisionMode = mode;
566
+ this.renderThisFrame = true;
567
+ }
568
+ setLabelVisibility(visible) {
569
+ this.textVisibility = visible;
570
+ this.renderThisFrame = true;
571
+ }
572
+ setIconVisiblity(visible) {
573
+ this.iconVisibility = visible;
574
+ this.renderThisFrame = true;
575
+ }
576
+ setHideModeWhenCollision(mode) {
577
+ // 即将废弃
578
+ if (mode === 'all') {
579
+ this.setVisiblePartWhenCollision('none');
580
+ }
581
+ else if (mode === 'none') {
582
+ this.setVisiblePartWhenCollision('all');
583
+ }
584
+ else {
585
+ this.setVisiblePartWhenCollision(mode);
586
+ }
587
+ }
588
+ // 碰撞下的显隐: 全部显示 / 全部隐藏 / label隐藏 / icon隐藏
589
+ setVisiblePartWhenCollision(part) {
590
+ this.visiblePartWhenCollision = part;
591
+ }
592
+ setCollisionOverlap(x, y) {
593
+ this.overlapArea = { x, y };
594
+ this.renderThisFrame = true;
595
+ }
596
+ /**
597
+ * 设置POI层级
598
+ * @param level 层级
599
+ */
600
+ setLevel(level, forceOrder = false) {
601
+ this.level = level;
602
+ this.renderThisFrame = true;
603
+ this.parent.orderPois(forceOrder);
604
+ }
605
+ /**
606
+ * 获取POI层级
607
+ */
608
+ getLevel() {
609
+ return this.level;
610
+ }
611
+ /**
612
+ * 设置POI可见性
613
+ * @param visible 可见性
614
+ */
615
+ setVisibility(visible) {
616
+ if (this.visible !== visible)
617
+ this.renderThisFrame = true;
618
+ this.visible = visible;
619
+ }
620
+ /**
621
+ * 设置POI是否暂时隐藏
622
+ * @param hide true 全部隐藏 false: 根据 hideModeWhenCollision 做显隐判断
623
+ */
624
+ setHidden(hide, subHide = false) {
625
+ // 优先级 hide > subHide
626
+ // hide 为 false 完全显示
627
+ // hide === true && subHide === true 部分显示
628
+ // hide === true && subHide === false 全部隐藏
629
+ if (!this.animationEnabled) {
630
+ if (this.hide !== hide || this.subHide !== subHide) {
631
+ this.hide = hide;
632
+ this.subHide = subHide;
633
+ this.renderThisFrame = true;
634
+ }
635
+ }
636
+ else {
637
+ // 在动画中 判断终点是否相同
638
+ // eslint-disable-next-line no-nested-ternary
639
+ const to = !hide ? 1 : (subHide ? 0.5 : 0);
640
+ if (this.visibilityAnimation.anim && to === this.visibilityAnimation.to)
641
+ return;
642
+ // 不在动画中 判断 hide === this.hide && subHide === this.subHide
643
+ if (!this.visibilityAnimation.anim && (hide === this.hide && subHide === this.subHide))
644
+ return;
645
+ if (this.visibilityAnimation.anim) { // 假设之前在执行, ani.stop()
646
+ this.visibilityAnimation.anim.stop();
647
+ this.visibilityAnimation.anim = null;
648
+ }
649
+ const start = { subAreaOpacity: this.subAreaOpacity, abandonedAreaOpacity: this.abandonedAreaOpacity };
650
+ const end = { subAreaOpacity: 0, abandonedAreaOpacity: 0 };
651
+ if (hide) { // hide = true 隐藏 || 部分显示
652
+ if (subHide) {
653
+ // 部分显示
654
+ end.subAreaOpacity = 1;
655
+ end.abandonedAreaOpacity = 0;
656
+ }
657
+ else {
658
+ // 全部隐藏
659
+ end.subAreaOpacity = 0;
660
+ end.abandonedAreaOpacity = 0;
661
+ }
662
+ }
663
+ else { // !hide 完全展示
664
+ end.subAreaOpacity = 1;
665
+ end.abandonedAreaOpacity = 1;
666
+ }
667
+ let subMaterials = [];
668
+ const abandonedMaterials = [];
669
+ switch (this.visiblePartWhenCollision) {
670
+ case 'all':
671
+ if (this.text) {
672
+ subMaterials.push(this.textMaterial);
673
+ }
674
+ // if (this.rect) {
675
+ // subMaterials.push(this.rectMaterial);
676
+ // }
677
+ if (this.icon) {
678
+ subMaterials.push(this.iconMaterial);
679
+ if (this.iconCircleMaterial && this.iconCircleMaterial.visible) {
680
+ subMaterials.push(this.iconCircleMaterial);
681
+ }
682
+ }
683
+ break;
684
+ case 'none':
685
+ if (this.text) {
686
+ abandonedMaterials.push(this.textMaterial);
687
+ }
688
+ if (this.icon) {
689
+ abandonedMaterials.push(this.iconMaterial);
690
+ if (this.iconCircleMaterial && this.iconCircleMaterial.visible) {
691
+ abandonedMaterials.push(this.iconCircleMaterial);
692
+ }
693
+ }
694
+ break;
695
+ case 'label':
696
+ // eslint-disable-next-line max-len
697
+ subMaterials = [this.textMaterial, this.rectMaterial];
698
+ if (this.text) {
699
+ subMaterials.push(this.textMaterial);
700
+ }
701
+ if (this.icon) {
702
+ abandonedMaterials.push(this.iconMaterial);
703
+ if (this.iconCircleMaterial && this.iconCircleMaterial.visible) {
704
+ abandonedMaterials.push(this.iconCircleMaterial);
705
+ }
706
+ }
707
+ break;
708
+ case 'icon':
709
+ if (this.text) {
710
+ abandonedMaterials.push(this.textMaterial);
711
+ }
712
+ if (this.icon) {
713
+ subMaterials.push(this.iconMaterial);
714
+ if (this.iconCircleMaterial && this.iconCircleMaterial.visible) {
715
+ subMaterials.push(this.iconCircleMaterial);
716
+ }
717
+ }
718
+ break;
719
+ default:
720
+ break;
721
+ }
722
+ this.visibilityAnimation.from = this.visibilityAnimation.current;
723
+ // eslint-disable-next-line no-nested-ternary
724
+ this.visibilityAnimation.to = !hide ? 1 : (subHide ? 0.5 : 0);
725
+ // 动画
726
+ const duration = 300;
727
+ this.visibilityAnimation.anim = new TWEEN.Tween(start).to(end, duration).onUpdate((cur) => {
728
+ this.subAreaOpacity = cur.subAreaOpacity;
729
+ this.abandonedAreaOpacity = cur.abandonedAreaOpacity;
730
+ subMaterials.forEach((areaM) => {
731
+ areaM.opacity = cur.subAreaOpacity;
732
+ });
733
+ abandonedMaterials.forEach((areaM) => {
734
+ areaM.opacity = cur.abandonedAreaOpacity;
735
+ });
736
+ }).start()
737
+ .onComplete(() => {
738
+ this.visibilityAnimation.anim = null;
739
+ this.visibilityAnimation.from = null;
740
+ this.visibilityAnimation.current = null;
741
+ this.visibilityAnimation.to = null;
742
+ this.hide = hide;
743
+ this.subHide = subHide;
744
+ });
745
+ }
746
+ }
747
+ /**
748
+ * 设置Rect是否可见
749
+ * @param withRect 可见性
750
+ */
751
+ setRect(withRect) {
752
+ this.withRect = withRect;
753
+ this.renderThisFrame = true;
754
+ }
755
+ /**
756
+ * 设置Rect默认宽高 未废弃, 不发挥作用
757
+ * @param withRect 可见性
758
+ */
759
+ setRectDefSize(width, height) {
760
+ this.rectOptions.width = width;
761
+ this.rectOptions.height = height;
762
+ this.renderThisFrame = true;
763
+ }
764
+ /**
765
+ * 设置Rect背景色 未废弃, 不发挥作用
766
+ * @param color
767
+ */
768
+ setRectFill(color) {
769
+ this.rectOptions.fill = color;
770
+ this.renderThisFrame = true;
771
+ }
772
+ /**
773
+ * 设置Rect偏移 未废弃, 不发挥作用
774
+ * @param x
775
+ * @param y
776
+ */
777
+ setRectOffset(x = 0, y = 0) {
778
+ this.rectOptions.offsetX = x;
779
+ this.rectOptions.offsetY = y;
780
+ this.renderThisFrame = true;
781
+ }
782
+ setIconImage(src) {
783
+ if (this.iconOptions && this.iconOptions.src === src)
784
+ return;
785
+ this.iconOptions.src = src;
786
+ this.clearIcon();
787
+ this.renderThisFrame = true;
788
+ }
789
+ setIconSize(width, height) {
790
+ this.iconSize = [width, height];
791
+ this.iconOptions.size = [width, height];
792
+ this.renderThisFrame = true;
793
+ }
794
+ /**
795
+ * 设置POI中icon的显示
796
+ */
797
+ setIconShowInCircle(lineWidth, lineColor) {
798
+ this.iconInCircle = true;
799
+ this.iconCircleOptions = {
800
+ width: lineWidth,
801
+ color: lineColor,
802
+ };
803
+ }
804
+ drawIcon() {
805
+ const { src, size } = this.iconOptions;
806
+ if (!src)
807
+ return;
808
+ if (this.icon
809
+ && this.group.getObjectByName('poi_icon')
810
+ && !!this.iconInCircle === !!this.iconCircleMaterial)
811
+ return;
812
+ if (!Poi.ImageMaterialMap.has(src)) {
813
+ Poi.ImageMaterialMap.set(src, 'dealing');
814
+ const loader = new NS_THREE.TextureLoader();
815
+ loader.load(src, (texture) => {
816
+ texture.needsUpdate = true;
817
+ texture.magFilter = NS_THREE.LinearFilter;
818
+ // fix: ios 16.4 纹理变黑块
819
+ texture.minFilter = NS_THREE.NearestFilter;
820
+ texture.flipY = this.isFlipY;
821
+ const material = new NS_THREE.MeshBasicMaterial({
822
+ map: texture,
823
+ transparent: true,
824
+ opacity: this.iconOpacity,
825
+ });
826
+ material.needsUpdate = true;
827
+ material.visible = true;
828
+ Poi.ImageMaterialMap.set(src, material);
829
+ });
830
+ }
831
+ else if (Poi.ImageMaterialMap.get(src) === 'dealing') {
832
+ this.renderThisFrame = true;
833
+ }
834
+ else {
835
+ if (this.icon)
836
+ this.group.remove(this.icon);
837
+ this.iconMaterial = Poi.ImageMaterialMap.get(src).clone();
838
+ this.iconMaterial.opacity = this.iconOpacity;
839
+ const { width: cWidth, color: cColor } = this.iconCircleOptions;
840
+ const ifDrawCircle = cWidth && this.iconInCircle;
841
+ if (ifDrawCircle) {
842
+ this.iconCircleMaterial = new NS_THREE.MeshBasicMaterial({
843
+ color: cColor,
844
+ transparent: true,
845
+ opacity: this.iconOpacity,
846
+ });
847
+ }
848
+ const mats = ifDrawCircle ? [
849
+ this.iconCircleMaterial,
850
+ this.iconMaterial,
851
+ ] : [
852
+ this.iconMaterial,
853
+ ];
854
+ const iconGeo = ifDrawCircle ? new NS_THREE.CircleGeometry(size[0] / 2, 30) : new NS_THREE.PlaneGeometry(size[0], size[1]);
855
+ const icon = SceneUtils.createMultiMaterialObject(iconGeo, mats);
856
+ this.icon = icon;
857
+ if (this.icon) {
858
+ // console.log('cWidth', size[0], cWidth);
859
+ if (this.icon.children.length > 1) {
860
+ this.icon.children[1].scale.set(size[0] / (cWidth + size[0]), size[0] / (cWidth + size[0]), 1);
861
+ }
862
+ this.icon.renderOrder = 3;
863
+ this.icon.name = 'poi_icon';
864
+ this.group.add(this.icon);
865
+ this.renderThisFrame = true;
866
+ }
867
+ }
868
+ }
869
+ clearIcon() {
870
+ if (!this.icon)
871
+ return;
872
+ if (this.group) {
873
+ this.group.remove(this.icon);
874
+ }
875
+ this.icon.children.forEach((mesh) => {
876
+ if (mesh.geometry) {
877
+ mesh.geometry.dispose();
878
+ }
879
+ });
880
+ if (this.iconMaterial) {
881
+ this.iconMaterial.dispose();
882
+ this.iconMaterial = null;
883
+ }
884
+ if (this.iconCircleMaterial) {
885
+ this.iconCircleMaterial.dispose();
886
+ this.iconCircleMaterial = null;
887
+ }
888
+ this.icon = null;
889
+ }
890
+ /**
891
+ * 设置图标相对(0,0)的位置
892
+ * @param direction: x / y value: + / - 表示方向
893
+ * x = 2 的时候, 表示label 中心 和 icon 中心 同一条y轴, label 右边框 距离 icon 左边框2个单位
894
+ */
895
+ setIconAnchor(anchor) {
896
+ this.iconPosInfo.anchor = anchor;
897
+ this.renderThisFrame = true;
898
+ }
899
+ /**
900
+ * 设置图标反转
901
+ */
902
+ setIconFlipY(flipY) {
903
+ this.isFlipY = flipY;
904
+ }
905
+ setIconOffset(x, y) {
906
+ this.iconPosInfo.anchorOffsetX = x;
907
+ this.iconPosInfo.anchorOffsetY = y;
908
+ this.renderThisFrame = true;
909
+ }
910
+ /**
911
+ * 设置文字字体大小
912
+ * @param fontSize 字号, 单位为px
913
+ */
914
+ setFontSize(fontSize) {
915
+ this.labelOptions.fontSize = fontSize;
916
+ this.renderThisFrame = true;
917
+ }
918
+ setFontPadding(fPadding) {
919
+ this.labelOptions.padding = fPadding;
920
+ this.renderThisFrame = true;
921
+ }
922
+ setLabelText(text) {
923
+ this.labelOptions.content = text;
924
+ this.renderThisFrame = true;
925
+ }
926
+ drawText() {
927
+ if (!this.labelOptions.content)
928
+ return;
929
+ if (this.group.getObjectByName('poi_text'))
930
+ return;
931
+ const dpr = this.dpr;
932
+ const { fontSize, padding, content } = this.labelOptions;
933
+ PoiOverlay.ctx.font = `${fontSize * dpr}px sans-serif`;
934
+ PoiOverlay.ctx.fillStyle = 'black';
935
+ const textSize = PoiOverlay.ctx.measureText(content);
936
+ const textWidth = Math.ceil(textSize.width) + 10 + (padding * 2);
937
+ const textHeight = (fontSize + 5 + (padding * 2)) * dpr;
938
+ this.textWidth = textWidth / dpr;
939
+ this.textHeight = textHeight / dpr;
940
+ this.setRectDefSize(this.textWidth, this.textHeight); // 根据text占据位置自动设置rect大小
941
+ PoiOverlay.ctx.clearRect(0, 0, textWidth, textHeight);
942
+ PoiOverlay.ctx.fillText(content, padding * dpr, (fontSize + padding) * dpr);
943
+ const textImageData = PoiOverlay.ctx.getImageData(0, 0, textWidth, textHeight);
944
+ this.textMaterial = new NS_THREE.MeshBasicMaterial({
945
+ transparent: true,
946
+ map: new NS_THREE.DataTexture(Uint8Array.from(textImageData.data), textWidth, textHeight, NS_THREE.RGBAFormat),
947
+ side: NS_THREE.DoubleSide,
948
+ opacity: this.labelOpacity,
949
+ });
950
+ this.text = new NS_THREE.Mesh(new NS_THREE.PlaneGeometry(this.textWidth, this.textHeight), this.textMaterial);
951
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
952
+ this.text.material.map.flipY = true;
953
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
954
+ this.text.material.map.flipX = true;
955
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
956
+ this.text.material.map.needsUpdate = true;
957
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
958
+ this.text.material.map.magFilter = NS_THREE.LinearFilter;
959
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
960
+ this.text.material.visible = true;
961
+ this.text.name = 'poi_text';
962
+ this.text.renderOrder = 4;
963
+ const { offsetX, offsetY, } = this.recalcOffset(this.textWidth, this.textHeight, this.textPosInfo.anchor, this.textPosInfo.anchorOffsetX, this.textPosInfo.anchorOffsetY);
964
+ this.textPosInfo.offsetX = offsetX;
965
+ this.textPosInfo.offsetY = offsetY;
966
+ this.group.add(this.text);
967
+ }
968
+ recalcOffset(width, height, anchor, anchorOffsetX, anchorOffsetY) {
969
+ // 在已有text宽高情况下计算 textOffsetX 和 textOffsetY
970
+ let offsetX = 0;
971
+ let offsetY = 0;
972
+ switch (anchor) {
973
+ case 'center':
974
+ // 默认
975
+ offsetX = anchorOffsetX;
976
+ offsetY = anchorOffsetY;
977
+ break;
978
+ case 'left':
979
+ offsetX = width / 2 + anchorOffsetX;
980
+ offsetY = anchorOffsetY;
981
+ break;
982
+ case 'right':
983
+ offsetX = -width / 2 + anchorOffsetX;
984
+ offsetY = anchorOffsetY;
985
+ break;
986
+ case 'top':
987
+ offsetX = anchorOffsetX;
988
+ offsetY = -height / 2 + anchorOffsetY;
989
+ break;
990
+ case 'bottom':
991
+ offsetX = anchorOffsetX;
992
+ offsetY = height / 2 + anchorOffsetY;
993
+ break;
994
+ case 'topleft':
995
+ offsetX = width / 2 + anchorOffsetX;
996
+ offsetY = -height / 2 + anchorOffsetY;
997
+ break;
998
+ case 'topright':
999
+ offsetX = -width / 2 + anchorOffsetX;
1000
+ offsetY = -height / 2 + anchorOffsetY;
1001
+ break;
1002
+ case 'bottomleft':
1003
+ offsetX = width / 2 + anchorOffsetX;
1004
+ offsetY = height / 2 + anchorOffsetY;
1005
+ break;
1006
+ case 'bottomright':
1007
+ offsetX = -width / 2 + anchorOffsetX;
1008
+ offsetY = height / 2 + anchorOffsetY;
1009
+ break;
1010
+ default:
1011
+ break;
1012
+ }
1013
+ return { offsetX, offsetY };
1014
+ }
1015
+ /**
1016
+ * 设置POI文字相对(0,0)的位置。在有icon 和 无icon时锚点不同
1017
+ * @param direction: x / y value: + / - 表示方向
1018
+ * x = 2 的时候, 表示label 中心 和 icon 中心 同一条y轴, label 右边框 距离 icon 左边框2个单位
1019
+ */
1020
+ setLabelAnchor(anchor) {
1021
+ // center label的锚点在 position
1022
+ // top position在label 上方线条的中心
1023
+ // left position在label 左边线条的中心
1024
+ this.textPosInfo.anchor = anchor;
1025
+ this.renderThisFrame = true;
1026
+ }
1027
+ setLabelOffset(x, y) {
1028
+ this.textPosInfo.anchorOffsetX = x;
1029
+ this.textPosInfo.anchorOffsetY = y;
1030
+ this.renderThisFrame = true;
1031
+ }
1032
+ getLabelAnchor() {
1033
+ return this.textPosInfo.anchor;
1034
+ }
1035
+ getLabelOffset() {
1036
+ const { anchorOffsetX, anchorOffsetY } = this.textPosInfo;
1037
+ return { x: anchorOffsetX, y: anchorOffsetY };
1038
+ }
1039
+ calcBoundingSize() {
1040
+ const pos = this.screenPosition;
1041
+ const textOffsetX = this.textPosInfo.offsetX;
1042
+ const textOffsetY = this.textPosInfo.offsetY;
1043
+ const iconOffsetX = this.iconPosInfo.offsetX;
1044
+ const iconOffsetY = this.iconPosInfo.offsetY;
1045
+ const label = {
1046
+ xMin: this.text ? pos.x - this.textWidth / 2 + textOffsetX : pos.x,
1047
+ xMax: this.text ? pos.x + this.textWidth / 2 + textOffsetX : pos.x,
1048
+ yMin: this.text ? pos.y - this.textHeight / 2 - textOffsetY : pos.y,
1049
+ yMax: this.text ? pos.y + this.textHeight / 2 - textOffsetY : pos.y,
1050
+ };
1051
+ const icon = {
1052
+ xMin: this.icon ? pos.x - this.iconOptions.size[0] / 2 + iconOffsetX : pos.x,
1053
+ xMax: this.icon ? pos.x + this.iconOptions.size[0] / 2 + iconOffsetX : pos.x,
1054
+ yMin: this.icon ? pos.y - this.iconOptions.size[1] / 2 - iconOffsetY : pos.y,
1055
+ yMax: this.icon ? pos.y + this.iconOptions.size[1] / 2 - iconOffsetY : pos.y,
1056
+ };
1057
+ let xMax = Math.max(icon.xMax, label.xMax);
1058
+ let xMin = Math.min(icon.xMin, label.xMin);
1059
+ let yMax = Math.max(icon.yMax, label.yMax);
1060
+ let yMin = Math.min(icon.yMin, label.yMin);
1061
+ this.iconRect = {
1062
+ xMin: this.icon ? pos.x - this.iconOptions.size[0] / 2 + iconOffsetX : pos.x,
1063
+ xMax: this.icon ? pos.x + this.iconOptions.size[0] / 2 + iconOffsetX : pos.x,
1064
+ yMin: this.icon ? pos.y - this.iconOptions.size[1] / 2 - iconOffsetY : pos.y,
1065
+ yMax: this.icon ? pos.y + this.iconOptions.size[1] / 2 - iconOffsetY : pos.y,
1066
+ };
1067
+ this.textRect = {
1068
+ xMin: this.text ? pos.x - this.textWidth / 2 + textOffsetX : pos.x,
1069
+ xMax: this.text ? pos.x + this.textWidth / 2 + textOffsetX : pos.x,
1070
+ yMin: this.text ? pos.y - this.textHeight / 2 - textOffsetY : pos.y,
1071
+ yMax: this.text ? pos.y + this.textHeight / 2 - textOffsetY : pos.y,
1072
+ };
1073
+ this.outerRect = {
1074
+ xMax, xMin, yMax, yMin,
1075
+ };
1076
+ if (this.collisionMode === 'icon') {
1077
+ xMax = icon.xMax;
1078
+ xMin = icon.xMin;
1079
+ yMax = icon.yMax;
1080
+ yMin = icon.yMin;
1081
+ }
1082
+ else if (this.collisionMode === 'label') {
1083
+ xMax = label.xMax;
1084
+ xMin = label.xMin;
1085
+ yMax = label.yMax;
1086
+ yMin = label.yMin;
1087
+ }
1088
+ // 得到 x 的 最大(> 0)和最小(< 0), y 的 最大(>0)和最小(<0)
1089
+ this.boundingRect.xMax = xMax;
1090
+ this.boundingRect.yMax = yMax;
1091
+ this.boundingRect.xMin = xMin;
1092
+ this.boundingRect.yMin = yMin;
1093
+ }
1094
+ drawRect() {
1095
+ if (!this.withRect || !this.labelOptions.content)
1096
+ return;
1097
+ if (this.rect && this.group.getObjectByName('poi_rect'))
1098
+ return;
1099
+ this.rect = new NS_THREE.Group();
1100
+ const rWidth = this.rectOptions.width || this.textWidth;
1101
+ const rHeight = this.rectOptions.height || this.textHeight;
1102
+ const cornerR = 10;
1103
+ const x = 0;
1104
+ const y = 0;
1105
+ const rightT1 = [x + rWidth / 2 - cornerR, y + rHeight / 2];
1106
+ const rightT2 = [x + rWidth / 2, y + rHeight / 2 - cornerR];
1107
+ const rightB1 = [x + rWidth / 2, y - rHeight / 2 + cornerR];
1108
+ const rightB2 = [x + rWidth / 2 - cornerR, y - rHeight / 2];
1109
+ const leftB1 = [x - rWidth / 2 + cornerR, y - rHeight / 2];
1110
+ const leftB2 = [x - rWidth / 2, y - rHeight / 2 + cornerR];
1111
+ const leftT1 = [x - rWidth / 2, y + rHeight / 2 - cornerR];
1112
+ const leftT2 = [x - rWidth / 2 + cornerR, y + rHeight / 2];
1113
+ const rectShape = new NS_THREE.Shape();
1114
+ rectShape.moveTo(rightT1[0], rightT1[1]);
1115
+ rectShape.bezierCurveTo(rightT1[0], rightT1[1], x + rWidth / 2, y + rHeight / 2, rightT2[0], rightT2[1]);
1116
+ rectShape.moveTo(rightB1[0], rightB1[1]);
1117
+ rectShape.bezierCurveTo(rightB1[0], rightB1[1], x + rWidth / 2, y - rHeight / 2, rightB2[0], rightB2[1]);
1118
+ rectShape.moveTo(leftB1[0], leftB1[1]);
1119
+ rectShape.bezierCurveTo(leftB1[0], leftB1[1], x - rWidth / 2, y - rHeight / 2, leftB2[0], leftB2[1]);
1120
+ rectShape.moveTo(leftT1[0], leftT1[1]);
1121
+ rectShape.bezierCurveTo(leftT1[0], leftT1[1], x - rWidth / 2, y + rHeight / 2, leftT2[0], leftT2[1]);
1122
+ rectShape.moveTo(rightT1[0], rightT1[1]);
1123
+ const geometry = new NS_THREE.ShapeGeometry(rectShape);
1124
+ const material = new NS_THREE.MeshBasicMaterial({
1125
+ color: 0x0000ff,
1126
+ transparent: true,
1127
+ opacity: 0.5,
1128
+ });
1129
+ this.rectMaterial = material;
1130
+ const mesh = new NS_THREE.Mesh(geometry, material);
1131
+ rectShape.autoClose = true;
1132
+ const points = rectShape.getPoints();
1133
+ const geometryPoints = new NS_THREE.BufferGeometry().setFromPoints(points);
1134
+ const line = new NS_THREE.Line(geometryPoints, new NS_THREE.LineBasicMaterial({ color: 0xff0000 }));
1135
+ line.position.set(0, 0, 0);
1136
+ this.rect.add(mesh);
1137
+ this.rect.add(line);
1138
+ this.rect.renderOrder = 2;
1139
+ this.rect.name = 'poi_rect';
1140
+ this.group.add(this.rect);
1141
+ }
1142
+ drawBoundingBox() {
1143
+ if (!this.withBoundingBox)
1144
+ return;
1145
+ if (this.group.getObjectByName('poi_bounding_rect'))
1146
+ return;
1147
+ if (this.outerRect.xMin === 0 && this.outerRect.xMax === 0)
1148
+ return;
1149
+ const { xMax, yMax, xMin, yMin, } = this.outerRect;
1150
+ this.boundingBox = new NS_THREE.Group();
1151
+ const cornerR = 10;
1152
+ const x = 0;
1153
+ const y = 0;
1154
+ const width = xMax - xMin;
1155
+ const height = yMax - yMin;
1156
+ const rightT1 = [x + width / 2 - cornerR, y + height / 2];
1157
+ const rightT2 = [x + width / 2, y + height / 2 - cornerR];
1158
+ const rightB1 = [x + width / 2, y - height / 2 + cornerR];
1159
+ const rightB2 = [x + width / 2 - cornerR, y - height / 2];
1160
+ const leftB1 = [x - width / 2 + cornerR, y - height / 2];
1161
+ const leftB2 = [x - width / 2, y - height / 2 + cornerR];
1162
+ const leftT1 = [x - width / 2, y + height / 2 - cornerR];
1163
+ const leftT2 = [x - width / 2 + cornerR, y + height / 2];
1164
+ const rectShape = new NS_THREE.Shape();
1165
+ rectShape.moveTo(rightT1[0], rightT1[1]);
1166
+ rectShape.bezierCurveTo(rightT1[0], rightT1[1], x + width / 2, y + height / 2, rightT2[0], rightT2[1]);
1167
+ rectShape.moveTo(rightB1[0], rightB1[1]);
1168
+ rectShape.bezierCurveTo(rightB1[0], rightB1[1], x + width / 2, y - height / 2, rightB2[0], rightB2[1]);
1169
+ rectShape.moveTo(leftB1[0], leftB1[1]);
1170
+ rectShape.bezierCurveTo(leftB1[0], leftB1[1], x - width / 2, y - height / 2, leftB2[0], leftB2[1]);
1171
+ rectShape.moveTo(leftT1[0], leftT1[1]);
1172
+ rectShape.bezierCurveTo(leftT1[0], leftT1[1], x - width / 2, y + height / 2, leftT2[0], leftT2[1]);
1173
+ rectShape.moveTo(rightT1[0], rightT1[1]);
1174
+ const geometry = new NS_THREE.ShapeGeometry(rectShape);
1175
+ const material = new NS_THREE.MeshBasicMaterial({
1176
+ color: 0xff0000,
1177
+ transparent: true,
1178
+ opacity: 0.5,
1179
+ });
1180
+ const mesh = new NS_THREE.Mesh(geometry, material);
1181
+ rectShape.autoClose = true;
1182
+ const points = rectShape.getPoints();
1183
+ const geometryPoints = new NS_THREE.BufferGeometry().setFromPoints(points);
1184
+ const line = new NS_THREE.Line(geometryPoints, new NS_THREE.LineBasicMaterial({ color: 0xff0000, linewidth: 2 }));
1185
+ line.position.set(0, 0, 0);
1186
+ this.boundingBox.name = 'poi_bounding_rect';
1187
+ this.boundingBox.add(mesh);
1188
+ this.boundingBox.add(line);
1189
+ this.boundingBox.renderOrder = 0;
1190
+ this.group.add(this.boundingBox);
1191
+ }
1192
+ setBoundingBox() {
1193
+ this.withBoundingBox = true;
1194
+ }
1195
+ /** @ignore */
1196
+ getBoundingRect() {
1197
+ const { x: ox, y: oy } = this.overlapArea;
1198
+ const { xMin: xmin, yMin: ymin, xMax: xmax, yMax: ymax, } = this.boundingRect;
1199
+ return {
1200
+ xMin: xmin + ox,
1201
+ yMin: ymin + oy,
1202
+ xMax: xmax - ox,
1203
+ yMax: ymax - oy,
1204
+ };
1205
+ }
1206
+ /** @ignore */
1207
+ getOuterRect() {
1208
+ const { x: ox, y: oy } = this.overlapArea;
1209
+ const { xMin: xmin, yMin: ymin, xMax: xmax, yMax: ymax, } = this.outerRect;
1210
+ return {
1211
+ xMin: xmin + ox,
1212
+ yMin: ymin + oy,
1213
+ xMax: xmax - ox,
1214
+ yMax: ymax - oy,
1215
+ };
1216
+ }
1217
+ setAnimationEnabled(value) {
1218
+ this.animationEnabled = value;
1219
+ }
1220
+ // 获取旋转角度
1221
+ calcPoiRotation(cameraDeg) {
1222
+ if (this.autoRotation) {
1223
+ return cameraDeg + this.rotation;
1224
+ }
1225
+ return this.rotation;
1226
+ }
1227
+ getVisibility() {
1228
+ return this.visible;
1229
+ }
1230
+ calcPosAndSize(frustum, widthHalf, heightHalf) {
1231
+ if (!this.parent) {
1232
+ return { isInFrustum: this.isInFrustum };
1233
+ }
1234
+ let isInFrustum = this.visible && frustum.containsPoint(this.position);
1235
+ if (isInFrustum) {
1236
+ const p = this.position.clone().project(this.parent.camera);
1237
+ this.screenPosition = { x: (p.x + 1) * widthHalf, y: (1 - p.y) * heightHalf };
1238
+ this.calcBoundingSize();
1239
+ // 计算与view是否相交
1240
+ if (this.outerRect.xMin < 0 || this.outerRect.xMax > widthHalf * 2 || this.outerRect.yMin < 0 || this.outerRect.yMax > heightHalf * 2) {
1241
+ isInFrustum = false;
1242
+ }
1243
+ }
1244
+ this.isInFrustum = isInFrustum;
1245
+ return {
1246
+ isInFrustum: this.isInFrustum,
1247
+ };
1248
+ }
1249
+ draw() {
1250
+ this.drawText();
1251
+ this.drawIcon();
1252
+ this.drawRect();
1253
+ this.drawBoundingBox();
1254
+ }
1255
+ updatePosition(// 根据已计算出的position, offset, visible 等更新渲染位置, 显隐
1256
+ widthHalf, heightHalf, index) {
1257
+ if (!this.group)
1258
+ return;
1259
+ if (!this.isInFrustum) {
1260
+ this.hide = true;
1261
+ this.subHide = false;
1262
+ this.group.visible = false;
1263
+ return;
1264
+ }
1265
+ this.group.visible = this.visible;
1266
+ if (!this.visible) {
1267
+ return;
1268
+ }
1269
+ const textOffsetX = this.textPosInfo.offsetX;
1270
+ const textOffsetY = this.textPosInfo.offsetY;
1271
+ const iconOffsetX = this.iconPosInfo.offsetX;
1272
+ const iconOffsetY = this.iconPosInfo.offsetY;
1273
+ const zIndex = index * 0.0001; // index是根据level递增排序的
1274
+ this.group.position.set(this.screenPosition.x - widthHalf, heightHalf - this.screenPosition.y, zIndex);
1275
+ if (this.text) {
1276
+ this.text.position.set(textOffsetX, textOffsetY, 0);
1277
+ }
1278
+ if (this.rect) {
1279
+ this.rect.position.set(textOffsetX, textOffsetY, 0);
1280
+ }
1281
+ if (this.icon) {
1282
+ this.icon.position.set(iconOffsetX, iconOffsetY, 0);
1283
+ }
1284
+ if (this.boundingBox) {
1285
+ const pos2dx = (this.outerRect.xMax + this.outerRect.xMin) / 2;
1286
+ const pos2dy = (this.outerRect.yMax + this.outerRect.yMin) / 2;
1287
+ this.boundingBox.position.set(pos2dx - this.screenPosition.x, this.screenPosition.y - pos2dy, 0);
1288
+ }
1289
+ const animating = this.visibilityAnimation.anim; // onComplete 时候会销毁
1290
+ const groupVisible = !!animating || (!animating && (!this.hide || this.subHide));
1291
+ this.group.visible = groupVisible;
1292
+ // console.log('groupVisible', groupVisible, !this.hide, this.subHide, (!this.hide || this.subHide));
1293
+ // subArea 和 abandonedArea 的展示
1294
+ // 1- 根据碰撞检测结果和碰撞类型判断group icon text 的显示
1295
+ // 2- 上一步通过, 则判断 当前是否设置了 iconVisibility 和 textVisibility
1296
+ if (groupVisible && (!animating || !this.animationEnabled)) { // 显示 && 动画执行完 || 无设置动画效果
1297
+ let subAreas = [];
1298
+ let abandonedAreas = [];
1299
+ switch (this.visiblePartWhenCollision) {
1300
+ case 'all':
1301
+ subAreas = [this.group];
1302
+ abandonedAreas = [];
1303
+ break;
1304
+ case 'none':
1305
+ subAreas = [];
1306
+ abandonedAreas = [this.group];
1307
+ break;
1308
+ case 'label':
1309
+ subAreas = [];
1310
+ if (this.text) {
1311
+ subAreas.push(this.text);
1312
+ }
1313
+ if (this.rect) {
1314
+ subAreas.push(this.rect);
1315
+ }
1316
+ if (this.icon) {
1317
+ abandonedAreas.push(this.icon);
1318
+ }
1319
+ break;
1320
+ case 'icon':
1321
+ if (this.icon) {
1322
+ subAreas.push(this.icon);
1323
+ }
1324
+ if (this.text) {
1325
+ abandonedAreas.push(this.text);
1326
+ }
1327
+ if (this.rect) {
1328
+ abandonedAreas.push(this.rect);
1329
+ }
1330
+ break;
1331
+ default:
1332
+ subAreas = [];
1333
+ abandonedAreas = [this.group];
1334
+ break;
1335
+ }
1336
+ if (this.subHide) { // 部分显示
1337
+ subAreas.forEach((area) => {
1338
+ area.visible = true;
1339
+ if (area instanceof NS_THREE.Group) {
1340
+ area.children.forEach((child) => {
1341
+ child.visible = true;
1342
+ });
1343
+ }
1344
+ });
1345
+ abandonedAreas.forEach((area) => {
1346
+ area.visible = false;
1347
+ if (area instanceof NS_THREE.Group) {
1348
+ area.children.forEach((child) => {
1349
+ child.visible = false;
1350
+ });
1351
+ }
1352
+ });
1353
+ }
1354
+ else if (!this.hide) { // 全部显示
1355
+ subAreas.forEach((area) => {
1356
+ area.visible = true;
1357
+ if (area instanceof NS_THREE.Group) {
1358
+ area.children.forEach((child) => {
1359
+ child.visible = true;
1360
+ });
1361
+ }
1362
+ });
1363
+ abandonedAreas.forEach((area) => {
1364
+ area.visible = true;
1365
+ if (area instanceof NS_THREE.Group) {
1366
+ area.children.forEach((child) => {
1367
+ child.visible = true;
1368
+ });
1369
+ }
1370
+ });
1371
+ }
1372
+ if (this.icon && !this.iconVisibility) { // 独立设置了icon不允许显示
1373
+ this.icon.visible = false;
1374
+ }
1375
+ if (this.text && !this.textVisibility) { // 独立设置了text不允许显示
1376
+ this.text.visible = false;
1377
+ }
1378
+ }
1379
+ if (!groupVisible) {
1380
+ // do nothing
1381
+ }
1382
+ else if (this.subHide) {
1383
+ if (this.parent) {
1384
+ // 部分显示
1385
+ if (this.visiblePartWhenCollision === 'icon') {
1386
+ this.parent.setRectMap(this.iconRect, this);
1387
+ }
1388
+ else {
1389
+ this.parent.setRectMap(this.textRect, this);
1390
+ }
1391
+ }
1392
+ }
1393
+ else if (this.parent) {
1394
+ // fix: poi-click 不触发
1395
+ this.parent.setRectMap(this.textRect, this);
1396
+ this.parent.setRectMap(this.iconRect, this);
1397
+ }
1398
+ // this.renderThisFrame = true;
1399
+ }
1400
+ update() {
1401
+ const needRender = this.renderThisFrame || (this.isInFrustum && !!this.iconOptions.src && !this.icon);
1402
+ this.renderThisFrame = false;
1403
+ return needRender;
1404
+ }
1405
+ setPoiId(poiId) {
1406
+ this.poiId = poiId;
1407
+ }
1408
+ }
1409
+ Poi.ImageMaterialMap = new Map();
1410
+ Poi.ImageMaterialMap = new Map();
1411
+ export { PoiOverlay, Poi };