@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,678 @@
1
+ /* eslint-disable max-len */
2
+ import { Vector3, Vector2, BufferGeometry, InterleavedBuffer, InterleavedBufferAttribute, Mesh, ShaderMaterial, DoubleSide, NormalBlending, AddEquation, SrcAlphaFactor, OneMinusSrcAlphaFactor, TextureLoader, RepeatWrapping, Vector4, MathUtils as ThreeMath, MeshBasicMaterial, PlaneGeometry, } from 'three';
3
+ import Color from 'color';
4
+ import * as turf from '@turf/turf';
5
+ import { Element, ElementFrameContext } from './element';
6
+ // import { BasicCalcTool, TurningInfo, Helper } from '../utils';
7
+ import { BasicCalcTool } from '../utils';
8
+ class MeshLine2D extends Element {
9
+ constructor(points, options = { width: 0.3 }) {
10
+ super();
11
+ this.initialized = false;
12
+ this.ready = true;
13
+ this.points = [];
14
+ this.distances = [];
15
+ this.options = Object.assign({ textureMode: 'repeat' }, options);
16
+ if (!options.animateSpeed) {
17
+ this.options.animateSpeed = 0.01;
18
+ }
19
+ if (options.textureMode === 'tail') {
20
+ this.createTailArrow();
21
+ }
22
+ this.init(points);
23
+ }
24
+ calcPoints(points, scale = 0.30) {
25
+ const len = points.length;
26
+ if (len < 3)
27
+ return [];
28
+ const res = [];
29
+ const linePoints = points.map((v) => [v[0], v[1]]);
30
+ for (let i = 0; i < len; i++) {
31
+ const cur = new Vector2(...linePoints[i]);
32
+ const prev = i === 0 ? null : new Vector2(...linePoints[i - 1]);
33
+ const next = i === len - 1 ? null : new Vector2(...linePoints[i + 1]);
34
+ const formP2C = prev ? new Vector2().subVectors(cur, prev).normalize() : null;
35
+ const formC2N = next ? new Vector2().subVectors(next, cur).normalize() : null;
36
+ const fromP2N = formC2N && formP2C ? new Vector2().addVectors(formC2N, formP2C).normalize() : null;
37
+ // eslint-disable-next-line no-nested-ternary
38
+ const normal = i === 0 ? new Vector2(-formC2N.y, formC2N.x)
39
+ : (i === len - 1 ? new Vector2(-formP2C.y, formP2C.x)
40
+ : new Vector2(-fromP2N.y, fromP2N.x));
41
+ const n1 = new Vector2().addVectors(cur, normal.clone().multiplyScalar(-scale));
42
+ const n2 = new Vector2().addVectors(cur, normal.clone().multiplyScalar(scale));
43
+ res.push([n1.x, n1.y, 0], [n2.x, n2.y, 0], [normal.x, normal.y, 0]);
44
+ }
45
+ return res;
46
+ }
47
+ createTailArrow() {
48
+ const textureUrl = this.options.textureUrl;
49
+ new TextureLoader().load(textureUrl, (texture) => {
50
+ const fWidth = this.options.width || 0.3;
51
+ const renderPathWidth = this.options.strokeWidth ? fWidth + this.options.strokeWidth * 2 : this.options.width;
52
+ const width = this.options.textureSize ? this.options.textureSize[0] : renderPathWidth;
53
+ const height = this.options.textureSize ? this.options.textureSize[1] : width;
54
+ const planeG = new PlaneGeometry(width, height);
55
+ const color = this.options.color ? this.options.color : 0xffffff;
56
+ const material = new MeshBasicMaterial({
57
+ color: color,
58
+ map: texture,
59
+ transparent: true,
60
+ opacity: 1.0,
61
+ depthTest: false,
62
+ });
63
+ material.needsUpdate = true;
64
+ const plane = new Mesh(planeG, material);
65
+ plane.renderOrder = 2;
66
+ this.tailArrow = plane;
67
+ this.tailArrow.visible = false;
68
+ this.add(this.tailArrow);
69
+ });
70
+ }
71
+ // 返回 {point, normal: 法向量, scale: 沿着法向量增加/减少得到端点的 scale} 的格式、
72
+ orgPoints(points, normalScale = 0.3) {
73
+ // this.testLines = [];
74
+ // 得到路径上的拐点信息
75
+ const pLength = points.length;
76
+ const orgedPoints = this.calcPoints(points, normalScale); // 传入的一个点拓展为3个信息: 法向量 起 终
77
+ const vec3orgedPoint = orgedPoints.map((pt) => new Vector3(...pt));
78
+ const vec3Chunk = BasicCalcTool.chunk(vec3orgedPoint, 3);
79
+ const res = points.map((v, i) => ({
80
+ point: v,
81
+ normal: [vec3Chunk[i][2].x, vec3Chunk[i][2].y],
82
+ scale: 1.0,
83
+ }));
84
+ const v2Pts = points.map((v) => [v[0], v[1]]);
85
+ const turningPoints = BasicCalcTool.calcTurning(v2Pts);
86
+ if (!turningPoints.length)
87
+ return res;
88
+ const turningAreas = turningPoints.map((v) => {
89
+ const { startIndex, endIndex, angle } = v;
90
+ // angle < 180 右转 angle > 180 左转
91
+ const pickIndex = angle > 180 ? 1 : 0;
92
+ const line10 = startIndex > 0 ? vec3Chunk[startIndex - 2][pickIndex] : vec3Chunk[startIndex - 1][pickIndex];
93
+ const line11 = vec3Chunk[startIndex - 1][pickIndex];
94
+ const line1NormalizeVec = new Vector3().subVectors(line11, line10).normalize().multiplyScalar(normalScale);
95
+ const line12 = new Vector3().addVectors(line11, line1NormalizeVec);
96
+ const line13 = new Vector3().subVectors(line10, line1NormalizeVec);
97
+ const line20 = vec3Chunk[endIndex + 1][pickIndex];
98
+ const line21 = pLength > endIndex + 2 ? vec3Chunk[endIndex + 2][pickIndex] : vec3Chunk[endIndex][pickIndex];
99
+ const line2NormalizeVec = new Vector3().subVectors(line21, line20).normalize().multiplyScalar(normalScale);
100
+ const line22 = new Vector3().addVectors(line21, line2NormalizeVec);
101
+ const line23 = new Vector3().subVectors(line20, line2NormalizeVec);
102
+ const line1 = turf.lineString([[line13.x, line13.y], [line10.x, line10.y], [line11.x, line11.y], [line12.x, line12.y]]);
103
+ const line2 = turf.lineString([[line23.x, line23.y], [line20.x, line20.y], [line21.x, line21.y], [line22.x, line22.y]]);
104
+ const intersects = turf.lineIntersect(line1, line2);
105
+ if (!intersects.features[0]) {
106
+ // console.log('有拐角 但无相交');
107
+ return null;
108
+ }
109
+ const intersectCrd = intersects.features[0].geometry.coordinates;
110
+ // console.log('有交点', line1, line2, intersects, intersectCrd);
111
+ // 根据 endCrd 和 startCrd 取 向量作延长线s
112
+ const vecFromStE = new Vector2(points[endIndex][0] - points[startIndex - 1][0], points[endIndex][1] - points[startIndex - 1][1]).normalize().multiplyScalar(normalScale);
113
+ const p0 = [intersectCrd[0] - vecFromStE.x, intersectCrd[1] - vecFromStE.y];
114
+ const p2 = [intersectCrd[0] + vecFromStE.x, intersectCrd[1] + vecFromStE.y];
115
+ const normal = angle > 180 ? vecFromStE.normalize().multiplyScalar(-1) : vecFromStE.normalize().multiplyScalar(1);
116
+ // [p0, p2] 的连线中点就是intersectCrd
117
+ const p3 = [intersectCrd[0] - normal.y * normalScale, intersectCrd[1] + normal.x * normalScale];
118
+ const p4 = [intersectCrd[0] + normal.y * normalScale, intersectCrd[1] - normal.x * normalScale];
119
+ const poly = turf.featureCollection([
120
+ turf.point(p0),
121
+ turf.point(p4),
122
+ turf.point(p2),
123
+ turf.point(p3),
124
+ turf.point(p0),
125
+ ]);
126
+ // const lin1 = Helper.createLine([[p0[0], p0[1], 0], [p2[0], p2[1], 0]], '#ff0000', 3000);
127
+ // const lin2 = Helper.createLine([[p3[0], p3[1], 0], [p4[0], p4[1], 0]], '#00ff00', 3000);
128
+ // const lin3 = Helper.createLine([[p0[0], p0[1], 0], [p4[0], p4[1], 0], [p2[0], p2[1], 0], [p3[0], p3[1], 0]], '#0000ff', 3000);
129
+ // this.testLines.push(lin1);
130
+ // this.testLines.push(lin2);
131
+ // this.testLines.push(lin3);
132
+ const hull = turf.convex(poly);
133
+ return {
134
+ hull,
135
+ intersectCrd,
136
+ startIndex,
137
+ endIndex,
138
+ };
139
+ });
140
+ let inCurrentArea = 0;
141
+ let l = 0;
142
+ let ifInTuring = false;
143
+ while (l < pLength && turningAreas[inCurrentArea]) {
144
+ const [ls, le] = vec3Chunk[l];
145
+ const curHull = turningAreas[inCurrentArea].hull;
146
+ const curIntersectCrd = turningAreas[inCurrentArea].intersectCrd;
147
+ const nextIntersectCrd = turningAreas[inCurrentArea + 1] ? turningAreas[inCurrentArea + 1].intersectCrd : null;
148
+ const nextHull = turningAreas[inCurrentArea + 1] ? turningAreas[inCurrentArea + 1].hull : null;
149
+ const ifBoolinLs = turf.booleanWithin(turf.point([ls.x, ls.y]), curHull);
150
+ const ifBoolinLe = turf.booleanWithin(turf.point([le.x, le.y]), curHull);
151
+ const ifBoolin = ifBoolinLs || ifBoolinLe;
152
+ if (ifBoolin && ifBoolinLs) {
153
+ // 右转
154
+ ifInTuring = true;
155
+ const startCoord = new Vector3(...curIntersectCrd, 0);
156
+ let end = le;
157
+ // 判断 end 是否在 下一个 area
158
+ if (nextIntersectCrd && nextHull && turf.booleanWithin(turf.point([le.x, le.y]), nextHull)) {
159
+ end = new Vector3(nextIntersectCrd[0], nextIntersectCrd[1], nextIntersectCrd[2]);
160
+ }
161
+ // 缩放比例是: V<ls.x - le.x, ls.y - le.y> 的length
162
+ const oL = new Vector3().subVectors(le, ls).length();
163
+ const newL = new Vector3().subVectors(end, new Vector3(startCoord.x, startCoord.y, 0)).length();
164
+ const nv = new Vector3().subVectors(end, new Vector3(startCoord.x, startCoord.y, 0)).normalize();
165
+ res.splice(l, 1, {
166
+ point: [(startCoord.x + end.x) / 2, (startCoord.y + end.y) / 2, 0],
167
+ scale: newL / oL,
168
+ normal: [nv.x, nv.y],
169
+ });
170
+ }
171
+ else if (ifBoolin && ifBoolinLe) {
172
+ // 左转
173
+ // console.log('ifBoolin && ifBoolinLe', ifBoolinLs, ifBoolinLe);
174
+ ifInTuring = true;
175
+ const endCoord = new Vector3(...curIntersectCrd, 0);
176
+ let start = ls;
177
+ if (nextIntersectCrd && nextHull && turf.booleanWithin(turf.point([ls.x, ls.y]), nextHull)) {
178
+ start = new Vector3(nextIntersectCrd[0], nextIntersectCrd[1], nextIntersectCrd[2]);
179
+ }
180
+ const oL = new Vector3().subVectors(le, ls).length();
181
+ const newL = new Vector3().subVectors(start, new Vector3(endCoord.x, endCoord.y, 0)).length();
182
+ const nv = new Vector3().subVectors(new Vector3(endCoord.x, endCoord.y, 0), start).normalize();
183
+ res.splice(l, 1, {
184
+ point: [(endCoord.x + start.x) / 2, (endCoord.y + start.y) / 2, 0],
185
+ scale: newL / oL,
186
+ normal: [nv.x, nv.y],
187
+ });
188
+ }
189
+ else if (ifInTuring) {
190
+ l--; // 当前点需要再判断一次
191
+ ifInTuring = false;
192
+ inCurrentArea++;
193
+ }
194
+ l++;
195
+ }
196
+ return res;
197
+ }
198
+ init(pts) {
199
+ // const points = pts.map((v: any) => (v.length === 3 ? [+v[0].toFixed(4), +v[1].toFixed(4), +v[2].toFixed(4)] : v));
200
+ const points = pts;
201
+ const sWidth = this.options.strokeWidth || 0;
202
+ const fWidth = this.options.width ? this.options.width / 2 : 0.3;
203
+ const normalScale = sWidth + fWidth;
204
+ const res = this.orgPoints(points, normalScale);
205
+ this.orgedPoints = res;
206
+ this.points = [];
207
+ let firstDis = 0.1;
208
+ if (points.length > 1) {
209
+ const [first, second, secondLast, last] = [
210
+ points[0],
211
+ points[1],
212
+ points[points.length - 2],
213
+ points[points.length - 1],
214
+ ];
215
+ // TODO
216
+ const firstVec = new Vector3(...first);
217
+ const secondVec = new Vector3(...second);
218
+ const dirFirst = new Vector3().subVectors(firstVec, secondVec)
219
+ .normalize().multiplyScalar(firstVec.distanceTo(secondVec) * 0.05); // 增加端点[起始]
220
+ const head = firstVec.clone().add(dirFirst);
221
+ firstDis = dirFirst.length();
222
+ const secondLastVec = new Vector3(...secondLast);
223
+ const lastVec = new Vector3(...last);
224
+ const dirLast = new Vector3().subVectors(secondLastVec, lastVec)
225
+ .normalize().multiplyScalar(firstVec.distanceTo(secondVec) * 0.05);
226
+ const tail = lastVec.clone().sub(dirLast); // 增加端点[尾巴]
227
+ const originH = this.orgedPoints[0];
228
+ const originT = this.orgedPoints[this.orgedPoints.length - 1];
229
+ this.orgedPoints.unshift({
230
+ point: [head.x, head.y, head.z],
231
+ normal: originH.normal,
232
+ scale: 1.0,
233
+ });
234
+ this.orgedPoints.push({
235
+ point: [tail.x, tail.y, tail.z],
236
+ normal: originT.normal,
237
+ scale: 1.0,
238
+ });
239
+ this.points.push([head.x, head.y, head.z]);
240
+ this.points.push(...points);
241
+ this.points.push([tail.x, tail.y, tail.z]);
242
+ }
243
+ this.distances = [-firstDis];
244
+ for (let i = 1, l = this.points.length, prevVec = new Vector3(...this.points[0]), currentVec = new Vector3(); i < l; i += 1) {
245
+ currentVec.set(...this.points[i]);
246
+ this.distances.push(i === 1 ? 0 : this.distances[i - 1] + currentVec.distanceTo(prevVec));
247
+ prevVec.copy(currentVec);
248
+ }
249
+ this.bufferGeometry = new BufferGeometry();
250
+ const components = 9;
251
+ let [lx, ly, lz] = this.points[0];
252
+ let d = 0;
253
+ const vertices = [];
254
+ for (let i = 0; i < this.orgedPoints.length; i += 1) {
255
+ const [x, y, z] = this.orgedPoints[i].point;
256
+ const [normalX, normalY] = this.orgedPoints[i].normal;
257
+ const scale = this.orgedPoints[i].scale;
258
+ let nx = x - lx;
259
+ let ny = y - ly;
260
+ let nz = z - lz;
261
+ const l = Math.sqrt(nx * nx + ny * ny + nz * nz);
262
+ nx /= l;
263
+ ny /= l;
264
+ nz /= l;
265
+ d += l * 3;
266
+ if (this.options.strokeWidth) {
267
+ vertices.push(x, y, z, -2, d, this.distances[i], normalX, normalY, scale);
268
+ vertices.push(x, y, z, -1, d, this.distances[i], normalX, normalY, scale);
269
+ vertices.push(x, y, z, 1, d, this.distances[i], normalX, normalY, scale);
270
+ vertices.push(x, y, z, 2, d, this.distances[i], normalX, normalY, scale);
271
+ }
272
+ else {
273
+ vertices.push(x, y, z, -1, d, this.distances[i], normalX, normalY, scale);
274
+ vertices.push(x, y, z, 1, d, this.distances[i], normalX, normalY, scale);
275
+ }
276
+ lx = x;
277
+ ly = y;
278
+ lz = z;
279
+ }
280
+ const vertexBuffer = new Float32Array(vertices);
281
+ const pointToCrdsNum = this.options.strokeWidth ? 4 : 2; // 路线上的一个顶点会生成几个点
282
+ const verticesBuffer = new InterleavedBuffer(vertexBuffer, components); // 交叉存储, 表明多个类型的attributes(例如,顶点位置、法向量、UV 和颜色值)被存储到一个队列中。
283
+ // InterleavedBuffer( array : TypedArray 一个基于共享缓存的类型化队列, stride : Integer 每个顶点占用类型化队列的多少个元素 )
284
+ // InterleavedBufferAttribute(interleavedBuffer, itemSize 队列中每个矢量由多少个元素构成, offset 缓存队列中每个元素的起始位置的偏移量)
285
+ const lastAttrib = new InterleavedBufferAttribute(verticesBuffer, 4, 0, false);
286
+ this.bufferGeometry.setAttribute('last', lastAttrib);
287
+ const currentAttrib = new InterleavedBufferAttribute(verticesBuffer, 4, components * pointToCrdsNum, false);
288
+ this.bufferGeometry.setAttribute('current', currentAttrib);
289
+ const nextAttrib = new InterleavedBufferAttribute(verticesBuffer, 4, components * pointToCrdsNum * 2, false);
290
+ this.bufferGeometry.setAttribute('next', nextAttrib);
291
+ const texoffAttrib = new InterleavedBufferAttribute(verticesBuffer, 1, components * pointToCrdsNum + 4, false);
292
+ this.bufferGeometry.setAttribute('texoff', texoffAttrib);
293
+ const progressAttrib = new InterleavedBufferAttribute(verticesBuffer, 1, components * pointToCrdsNum + 5, false);
294
+ this.bufferGeometry.setAttribute('progress', progressAttrib);
295
+ const normalAttrib = new InterleavedBufferAttribute(verticesBuffer, 2, components * pointToCrdsNum + 6, false);
296
+ this.bufferGeometry.setAttribute('normalVec', normalAttrib);
297
+ const scaleAttrib = new InterleavedBufferAttribute(verticesBuffer, 1, components * pointToCrdsNum + 8, false);
298
+ this.bufferGeometry.setAttribute('normalScale', scaleAttrib);
299
+ const positionVertBuffer = new InterleavedBuffer(vertexBuffer.slice(components * pointToCrdsNum, vertices.length - components * pointToCrdsNum), components);
300
+ const positionAttrib = new InterleavedBufferAttribute(positionVertBuffer, 4, 0);
301
+ this.bufferGeometry.setAttribute('position', positionAttrib);
302
+ this.bufferGeometry.computeBoundingBox();
303
+ this.bufferGeometry.computeBoundingSphere();
304
+ this.bufferGeometry.computeVertexNormals();
305
+ let indices = [];
306
+ if (this.options.strokeWidth) {
307
+ const arr = [
308
+ 0, 1, 4,
309
+ 1, 4, 5,
310
+ 1, 2, 5,
311
+ 2, 5, 6,
312
+ 2, 3, 6,
313
+ 3, 6, 7,
314
+ ];
315
+ for (let i = 4; i < vertices.length / components - 8; i += 4) {
316
+ const curLineNum = i / 4 - 1;
317
+ const curInds = arr.map((v) => v + curLineNum * 4);
318
+ indices = [...indices, ...curInds];
319
+ }
320
+ }
321
+ else {
322
+ for (let i = 2; i < vertices.length / components - 4; i += 2) {
323
+ indices.push(i - 2, i - 1, i);
324
+ indices.push(i, i - 1, i + 1);
325
+ }
326
+ }
327
+ this.bufferGeometry.setIndex(indices);
328
+ const fillColor = this.options.color ? new Color(this.options.color) : new Color('rgb(255, 255, 255)').alpha(0.0);
329
+ const strokeColor = this.options.strokeColor ? new Color(this.options.strokeColor) : new Color('rgb(240, 68, 55)');
330
+ this.uniforms = {
331
+ stripTexture: {
332
+ type: 't',
333
+ value: null,
334
+ },
335
+ fillColor: {
336
+ type: 'v4',
337
+ value: new Vector4(fillColor.red() / 255, fillColor.green() / 255, fillColor.blue() / 255, fillColor.alpha()),
338
+ },
339
+ strokeColor: {
340
+ type: 'v4',
341
+ // eslint-disable-next-line max-len
342
+ value: new Vector4(strokeColor.red() / 255, strokeColor.green() / 255, strokeColor.blue() / 255, strokeColor.alpha()),
343
+ },
344
+ width: {
345
+ type: 'f',
346
+ value: this.options.width || 0.3,
347
+ },
348
+ strokeWidth: {
349
+ type: 'f',
350
+ value: this.options.strokeWidth || 0.1,
351
+ },
352
+ currentDistance: { type: 'f', value: this.options.current || 0 },
353
+ texOffset: { type: 'f', value: 0 },
354
+ fullLength: { type: 'f', value: this.distances[this.distances.length - 1] },
355
+ viewDistance: { type: 'f', value: this.options.viewDistance || 15 },
356
+ gradientDistance: { type: 'f', value: this.options.gradientDistance || 4 },
357
+ gradientEnabled: { value: this.options.gradientEnabled || false },
358
+ };
359
+ this.material = new ShaderMaterial({
360
+ fragmentShader: MeshLine2D.FragmentShader,
361
+ vertexShader: MeshLine2D.VertexShader,
362
+ uniforms: this.uniforms,
363
+ depthTest: false,
364
+ side: DoubleSide,
365
+ // wireframe: true,
366
+ transparent: true,
367
+ opacity: 1.0,
368
+ blending: NormalBlending,
369
+ blendEquation: AddEquation,
370
+ blendSrc: SrcAlphaFactor,
371
+ blendDst: OneMinusSrcAlphaFactor,
372
+ });
373
+ if (this.options.textureUrl && this.options.textureMode === 'repeat') {
374
+ new TextureLoader().load(this.options.textureUrl, (texture) => {
375
+ texture.wrapS = RepeatWrapping;
376
+ texture.wrapT = RepeatWrapping;
377
+ texture.generateMipmaps = true;
378
+ this.uniforms.stripTexture.value = texture;
379
+ this.needsUpdate = true;
380
+ });
381
+ }
382
+ else if (this.options.textureUrl && this.options.textureMode === 'tail') {
383
+ const lastDistance = this.distances[this.distances.length - 1];
384
+ this.updateTailArrowPos(lastDistance);
385
+ }
386
+ this.mesh = new Mesh(this.bufferGeometry, this.material);
387
+ this.add(this.mesh);
388
+ }
389
+ getBestView(currentPoint, fromDistance, toDistance) {
390
+ let nearPoint = this.getPointOnDistance(fromDistance + 0.2).point;
391
+ let curPoint = currentPoint;
392
+ // 过滤0.5米转角
393
+ let f = fromDistance + 1;
394
+ for (; f < (fromDistance + 10); f += 1) {
395
+ const scan = this.getPointOnDistance(f);
396
+ const dir1 = new Vector3().subVectors(scan.point, nearPoint);
397
+ const dir2 = new Vector3().subVectors(nearPoint, curPoint);
398
+ const rad = ThreeMath.radToDeg(dir1.angleTo(dir2));
399
+ if (rad > 30) {
400
+ nearPoint = this.getPointOnDistance(f + 0.5).point;
401
+ curPoint = scan.point;
402
+ break;
403
+ }
404
+ }
405
+ let maxDistance = 0;
406
+ for (let i = f; i < toDistance; i++) {
407
+ const scan = this.getPointOnDistance(i);
408
+ const dir1 = new Vector3().subVectors(scan.point, nearPoint);
409
+ const dir2 = new Vector3().subVectors(nearPoint, curPoint);
410
+ const rad = ThreeMath.radToDeg(dir1.angleTo(dir2));
411
+ if (rad > 32 && (i - fromDistance) > 10) {
412
+ maxDistance = i;
413
+ break;
414
+ }
415
+ if (rad > 20 && (i - fromDistance) > 15) {
416
+ maxDistance = i;
417
+ break;
418
+ }
419
+ }
420
+ return (maxDistance - fromDistance);
421
+ }
422
+ getPointOnDistance(distance) {
423
+ let left = 0;
424
+ const { distances, points } = this;
425
+ let right = points.length - 1;
426
+ let p = -1;
427
+ while (left < right - 1) {
428
+ p = Math.floor((left + right) / 2);
429
+ if (distances[p] > distance)
430
+ right = p;
431
+ else if (distances[p] < distance)
432
+ left = p;
433
+ else {
434
+ left = p;
435
+ break;
436
+ }
437
+ }
438
+ p = left;
439
+ if (p > -1) {
440
+ const from = new Vector3(...points[p]);
441
+ if (p === this.points.length - 1 || distance <= 0) {
442
+ return {
443
+ point: from,
444
+ index: p + 1,
445
+ };
446
+ }
447
+ const fromDist = this.distances[p];
448
+ const to = new Vector3(...this.points[p + 1]);
449
+ const toDist = this.distances[p + 1];
450
+ const distDiff = toDist - fromDist;
451
+ const vecDiff = to.clone().sub(from);
452
+ return {
453
+ point: from.clone().add(vecDiff.multiplyScalar((distance - fromDist) / distDiff)),
454
+ index: p + 1,
455
+ };
456
+ }
457
+ throw new Error(`Cannot find point on distance ${distance}`);
458
+ }
459
+ getNearestPoint(position, startDistance = 0) {
460
+ const pathLength = this.distances[this.distances.length - 1];
461
+ let precision = 8;
462
+ let best = new Vector3();
463
+ let bestLength = 0;
464
+ let bestDistance = Infinity;
465
+ let bestIndex = -1;
466
+ for (let scan, scanLength = startDistance, scanDistance; scanLength <= pathLength; scanLength += precision) {
467
+ scan = this.getPointOnDistance(scanLength);
468
+ scanDistance = position.distanceTo(scan.point);
469
+ if (scanDistance < bestDistance) {
470
+ best = scan.point;
471
+ bestLength = scanLength;
472
+ bestDistance = scanDistance;
473
+ bestIndex = scan.index;
474
+ }
475
+ }
476
+ let before;
477
+ let after;
478
+ let beforeLength;
479
+ let afterLength;
480
+ let beforeDistance;
481
+ let afterDistance;
482
+ precision /= 2;
483
+ while (precision > 0.1) {
484
+ beforeLength = bestLength - precision;
485
+ beforeDistance = position.distanceTo(before = this.getPointOnDistance(beforeLength).point);
486
+ afterLength = bestLength + precision;
487
+ afterDistance = position.distanceTo(after = this.getPointOnDistance(afterLength).point);
488
+ if (beforeLength >= 0 && beforeDistance < bestDistance) {
489
+ best = before;
490
+ bestLength = beforeLength;
491
+ bestDistance = beforeDistance;
492
+ }
493
+ else if (afterLength <= pathLength && afterDistance < bestDistance) {
494
+ best = after;
495
+ bestLength = afterLength;
496
+ bestDistance = afterDistance;
497
+ }
498
+ else {
499
+ precision /= 2;
500
+ }
501
+ }
502
+ return {
503
+ point: best,
504
+ distance: bestLength,
505
+ index: bestIndex,
506
+ };
507
+ }
508
+ update() {
509
+ const frameContext = new ElementFrameContext(this);
510
+ if (!this.initialized && this.ready) {
511
+ this.initialized = true;
512
+ frameContext.needUpdate = true;
513
+ }
514
+ else if (this.needsUpdate) {
515
+ frameContext.needUpdate = true;
516
+ this.needsUpdate = false;
517
+ }
518
+ if (this.options.animateEnabled) {
519
+ this.uniforms.texOffset.value -= this.options.animateSpeed;
520
+ frameContext.needUpdate = true;
521
+ }
522
+ if (this.initialized && !this.parent) {
523
+ frameContext.shouldPlaceElement = true;
524
+ }
525
+ return frameContext;
526
+ }
527
+ dispose() {
528
+ super.dispose();
529
+ this.remove(this.mesh);
530
+ this.material.dispose();
531
+ this.bufferGeometry.dispose();
532
+ }
533
+ setCurrent(current) {
534
+ this.uniforms.currentDistance.value = current;
535
+ this.needsUpdate = true;
536
+ }
537
+ getCurrent() {
538
+ return this.uniforms.currentDistance.value;
539
+ }
540
+ setViewDistance(value) {
541
+ this.uniforms.viewDistance.value = value;
542
+ const distance = value + this.uniforms.currentDistance.value;
543
+ if (this.options.textureUrl && this.options.textureMode === 'tail') {
544
+ if (!this.tailArrow) {
545
+ setTimeout(() => {
546
+ this.setViewDistance(value);
547
+ }, 1000);
548
+ return;
549
+ }
550
+ this.updateTailArrowPos(distance);
551
+ }
552
+ }
553
+ updateTailArrowPos(distance) {
554
+ if (!this.tailArrow) {
555
+ setTimeout(() => {
556
+ this.updateTailArrowPos(distance);
557
+ }, 1000);
558
+ return;
559
+ }
560
+ this.tailArrow.visible = true;
561
+ const { index } = this.getPointOnDistance(distance);
562
+ const orgedPoint = this.orgedPoints[index];
563
+ const x = orgedPoint.point[0];
564
+ const y = orgedPoint.point[1];
565
+ const z = orgedPoint.point[2];
566
+ const normal2 = [-orgedPoint.normal[1], orgedPoint.normal[0]];
567
+ const atan3 = Math.atan2(normal2[1], normal2[0]);
568
+ const rotationZ = atan3 + Math.PI / 2;
569
+ this.tailArrow.position.set(x, y, z);
570
+ this.tailArrow.rotation.z = rotationZ;
571
+ this.needsUpdate = true;
572
+ }
573
+ getViewDistance() {
574
+ return this.uniforms.viewDistance.value;
575
+ }
576
+ }
577
+ MeshLine2D.VertexShader = `
578
+ attribute vec4 last, current, next;
579
+ attribute vec2 normalVec;
580
+ attribute float normalScale;
581
+ attribute float texoff;
582
+ attribute float progress;
583
+
584
+ varying vec2 texcoord;
585
+ varying float vProgress;
586
+ varying float isBorder;
587
+
588
+ uniform float width;
589
+ uniform float texOffset;
590
+ uniform float strokeWidth;
591
+
592
+ float pi = 3.141592653589793;
593
+ float fwidth = width;
594
+ float swidth = strokeWidth;
595
+
596
+ vec4 transform(vec3 coord){
597
+ return projectionMatrix * modelViewMatrix * vec4(coord, 1.0);
598
+ }
599
+
600
+ void main(){
601
+ float off = 1.0;
602
+ if (current.w < 0.0 ) {
603
+ off = -1.0;
604
+ }
605
+ // float offsetW = fwidth / 2.0;
606
+ float offsetW = fwidth / 2.0 * normalScale;
607
+ isBorder = -1.0;
608
+ if (abs(current.w) > 1.0) {
609
+ offsetW = (swidth + (fwidth / 2.0)) * normalScale;
610
+ isBorder = 1.0;
611
+ }
612
+
613
+ vec2 dir = vec2(normalVec.x, normalVec.y)*off;
614
+ vec3 pos = vec3(current.xy + dir * offsetW, 0.0);
615
+
616
+ texcoord = vec2(off*0.5+0.5, texoff*0.2 + texOffset);
617
+ vProgress = progress;
618
+
619
+ gl_Position = transform(pos);
620
+ }
621
+ `;
622
+ MeshLine2D.FragmentShader = `
623
+ uniform sampler2D stripTexture;
624
+ uniform float currentDistance;
625
+ uniform float fullLength;
626
+ uniform float viewDistance;
627
+ uniform float gradientDistance;
628
+ uniform vec4 fillColor;
629
+ uniform vec4 strokeColor;
630
+ uniform bool gradientEnabled;
631
+
632
+ varying vec2 texcoord;
633
+ varying float vProgress;
634
+ varying float isBorder;
635
+
636
+ float opacity = 1.0;
637
+
638
+ void main(){
639
+ vec4 texColor = texture2D(stripTexture, texcoord);
640
+
641
+ float alpha = 1.0;
642
+ float cur = currentDistance;
643
+ float grad = gradientDistance;
644
+ float view = viewDistance;
645
+
646
+ if (gradientEnabled) {
647
+ if (vProgress < cur) {
648
+ alpha = 0.0;
649
+ } else {
650
+ if (vProgress > cur + view) {
651
+ alpha = 0.0;
652
+ } else {
653
+ if (fullLength <= cur + view) {
654
+ view = fullLength - cur;
655
+ if (view < 2.0 * grad) {
656
+ grad = view * 0.5;
657
+ }
658
+ }
659
+
660
+ if (vProgress > cur + grad) {
661
+ alpha = 1.0;
662
+ if (vProgress > cur + view - grad) {
663
+ alpha = abs(cur + view - vProgress) / grad * 1.0;
664
+ }
665
+ } else {
666
+ alpha = abs(vProgress - cur) / grad * 1.0;
667
+ }
668
+ }
669
+ }
670
+ }
671
+ if (isBorder > -0.99) {
672
+ gl_FragColor = vec4(strokeColor.rgb, opacity * alpha * strokeColor.a);
673
+ } else {
674
+ gl_FragColor = vec4((fillColor * (1.0 - texColor.a) + texColor * texColor.a).rgb, opacity * alpha * (fillColor.a * (1.0 - texColor.a) + texColor.a));
675
+ }
676
+ }
677
+ `;
678
+ export { MeshLine2D };