@realsee/five-webgpu 1.0.0-alpha.5 → 1.0.0-alpha.6

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 (304) hide show
  1. package/ai_guides/api.md +9 -8
  2. package/ai_guides/features/camera-animation.md +1 -1
  3. package/ai_guides/features/event.md +0 -1
  4. package/ai_guides/features/five.md +8 -8
  5. package/ai_guides/features/gesture.md +1 -1
  6. package/ai_guides/features/load-external-model.md +6 -6
  7. package/ai_guides/features/load-progress.md +2 -2
  8. package/ai_guides/features/mode.md +3 -23
  9. package/ai_guides/features/model.md +1 -1
  10. package/ai_guides/features/state.md +2 -2
  11. package/ai_guides/features/ultra-hdr.md +41 -32
  12. package/ai_guides/quick-start.md +2 -2
  13. package/ai_guides/release_notes/6.8.md +2 -2
  14. package/ai_guides/support.md +0 -4
  15. package/docs/assets/hierarchy.js +1 -1
  16. package/docs/assets/navigation.js +1 -1
  17. package/docs/assets/search.js +1 -1
  18. package/docs/classes/index.AdaptiveLuminancePass.html +1 -1
  19. package/docs/classes/index.BoundingMesh.html +1 -1
  20. package/docs/classes/index.EffectComposer.html +1 -1
  21. package/docs/classes/index.EyeDomeLightingPass.html +1 -1
  22. package/docs/classes/index.Five.html +68 -67
  23. package/docs/classes/index.FivePass.html +1 -1
  24. package/docs/classes/index.FlowingFireworks3DPass.html +1 -1
  25. package/docs/classes/index.FlowingLight2DPass.html +1 -1
  26. package/docs/classes/index.FlowingLight3DPass.html +1 -1
  27. package/docs/classes/index.GaussianBlurPass.html +1 -1
  28. package/docs/classes/index.InternalWebGPURenderer.html +4 -4
  29. package/docs/classes/index.Model.html +1 -1
  30. package/docs/classes/index.ModelScene.html +1 -1
  31. package/docs/classes/index.NetworkSubscribe.html +1 -1
  32. package/docs/classes/index.PBMCustomNode.html +8 -8
  33. package/docs/classes/index.PBMGaussianSplattingNodeMaterial.html +8 -6
  34. package/docs/classes/index.PBMGaussianSplattingObject.html +10 -4
  35. package/docs/classes/index.PBMGaussianSplattingRenderMesh.html +26 -15
  36. package/docs/classes/index.PBMGroup.html +1 -1
  37. package/docs/classes/index.PBMMesh.html +1 -1
  38. package/docs/classes/index.PBMMeshBasicMaterial.html +11 -7
  39. package/docs/classes/index.PBMMeshBasicNodeMaterial.html +11 -7
  40. package/docs/classes/index.PBMMeshPanoOnlyMaterial.html +11 -7
  41. package/docs/classes/index.PBMMeshPanoOnlyNodeMaterial.html +11 -7
  42. package/docs/classes/index.PBMMeshPhongMaterial.html +11 -7
  43. package/docs/classes/index.PBMMeshPhongNodeMaterial.html +11 -7
  44. package/docs/classes/index.PBMMeshPhysicalMaterial.html +11 -7
  45. package/docs/classes/index.PBMMeshPhysicalNodeMaterial.html +11 -7
  46. package/docs/classes/index.PBMPanoFilter.html +8 -8
  47. package/docs/classes/index.PBMPointCloud.html +1 -1
  48. package/docs/classes/index.PBMSkinnedMesh.html +1 -1
  49. package/docs/classes/index.PBMUpdateable.html +1 -1
  50. package/docs/classes/index.PanoCircleMesh.html +1 -1
  51. package/docs/classes/index.PanoCircleMeshCustom.html +5 -5
  52. package/docs/classes/index.PanoCircleMeshSolid.html +1 -1
  53. package/docs/classes/index.Parameter.html +1 -1
  54. package/docs/classes/index.Subscribe.html +1 -1
  55. package/docs/classes/index.TextureLoader.html +4 -1
  56. package/docs/classes/index.Tile3D.html +23 -21
  57. package/docs/classes/index.TileNode.html +1 -1
  58. package/docs/classes/index.Tileset.html +4 -4
  59. package/docs/classes/index.TrajectoryNode.html +3 -3
  60. package/docs/classes/index.Work.html +20 -18
  61. package/docs/classes/index.WorkResolvedObserver.html +22 -22
  62. package/docs/documents/api.html +11 -10
  63. package/docs/documents/features_camera-animation.html +1 -1
  64. package/docs/documents/features_event.html +0 -1
  65. package/docs/documents/features_five.html +7 -7
  66. package/docs/documents/features_gesture.html +1 -1
  67. package/docs/documents/features_load-external-model.html +6 -6
  68. package/docs/documents/features_load-progress.html +1 -1
  69. package/docs/documents/features_mode.html +5 -15
  70. package/docs/documents/features_model.html +1 -1
  71. package/docs/documents/features_state.html +1 -1
  72. package/docs/documents/features_ultra-hdr.html +50 -44
  73. package/docs/documents/quick-start.html +1 -1
  74. package/docs/documents/release_notes_6.8.html +2 -2
  75. package/docs/documents/support.html +1 -3
  76. package/docs/functions/index.customNodesCacheKey.html +1 -1
  77. package/docs/functions/index.parseWork.html +1 -1
  78. package/docs/functions/index.workToJson.html +1 -1
  79. package/docs/hierarchy.html +1 -1
  80. package/docs/interfaces/index.AddableObject.html +1 -1
  81. package/docs/interfaces/index.AjaxOptions.html +1 -1
  82. package/docs/interfaces/index.BaseEvent.html +2 -2
  83. package/docs/interfaces/index.Clock.html +24 -0
  84. package/docs/interfaces/index.EventCallback.html +49 -47
  85. package/docs/interfaces/index.FiveInitArgs.html +49 -40
  86. package/docs/interfaces/index.GainmapCfgData.html +15 -0
  87. package/docs/interfaces/index.GestureEvent.html +2 -2
  88. package/docs/interfaces/index.IPBMMaterial.html +10 -6
  89. package/docs/interfaces/index.ImageOptions.html +1 -1
  90. package/docs/interfaces/index.IntersectEvent.html +2 -2
  91. package/docs/interfaces/index.IntersectMesh.html +1 -1
  92. package/docs/interfaces/index.IntersectMeshInterface.html +1 -1
  93. package/docs/interfaces/index.Intersection.html +1 -1
  94. package/docs/interfaces/index.LoosePanoWork.html +2 -2
  95. package/docs/interfaces/index.LooseWork.html +2 -2
  96. package/docs/interfaces/index.LooseWorkInitial.html +2 -2
  97. package/docs/interfaces/index.LooseWorkModel.html +2 -2
  98. package/docs/interfaces/index.LooseWorkObserver.html +2 -2
  99. package/docs/interfaces/index.LooseWorkPanorama.html +4 -3
  100. package/docs/interfaces/index.LooseWorkWithExtrinsics.html +15 -9
  101. package/docs/interfaces/index.ModeChangeEvent.html +2 -2
  102. package/docs/interfaces/index.ModelControllerCustomInitArgs.html +1 -1
  103. package/docs/interfaces/index.ModelEvent.html +2 -2
  104. package/docs/interfaces/index.ModelSceneEvent.html +2 -2
  105. package/docs/interfaces/index.ModelTileEvent.html +2 -2
  106. package/docs/interfaces/index.MovePanoOptions.html +1 -1
  107. package/docs/interfaces/index.NetworkAbortError.html +1 -1
  108. package/docs/interfaces/index.NetworkFirbiddenError.html +1 -1
  109. package/docs/interfaces/index.NetworkOptions.html +1 -1
  110. package/docs/interfaces/index.NetworkProxyError.html +1 -1
  111. package/docs/interfaces/index.NetworkResourceEvent.html +2 -2
  112. package/docs/interfaces/index.NetworkResponseError.html +1 -1
  113. package/docs/interfaces/index.NetworkTimeoutError.html +1 -1
  114. package/docs/interfaces/index.ObjectEvent.html +2 -2
  115. package/docs/interfaces/index.PBMClipperParameter.html +2 -2
  116. package/docs/interfaces/index.PBMCustomNodeContext.html +60 -12
  117. package/docs/interfaces/index.PBMCustomNodeOptions.html +4 -4
  118. package/docs/interfaces/index.PBMCustomNodePanoContext.html +12 -5
  119. package/docs/interfaces/index.PBMCustomNodeSlots.html +6 -6
  120. package/docs/interfaces/index.PBMPanoDepth.html +5 -5
  121. package/docs/interfaces/index.PBMPanoFilterValue.html +2 -2
  122. package/docs/interfaces/index.PBMPanoGainmap.html +6 -0
  123. package/docs/interfaces/index.PBMPanoPicture.html +9 -8
  124. package/docs/interfaces/index.PBMRefinedScreen.html +2 -2
  125. package/docs/interfaces/index.PanoCircleMeshCustomOptions.html +2 -2
  126. package/docs/interfaces/index.PanoCircleMeshInterface.html +1 -1
  127. package/docs/interfaces/index.PanoEvent.html +2 -2
  128. package/docs/interfaces/index.PanoTextureEvent.html +2 -2
  129. package/docs/interfaces/index.PanoramaControllerCustomInitArgs.html +9 -9
  130. package/docs/interfaces/index.PanoramaLikeControllerCustomInitArgs.html +1 -1
  131. package/docs/interfaces/index.ParameterMaterialValue.html +1 -1
  132. package/docs/interfaces/index.ParameterTilesetValue.html +1 -1
  133. package/docs/interfaces/index.ParameterValue.html +1 -1
  134. package/docs/interfaces/index.Pose.html +1 -1
  135. package/docs/interfaces/index.RenderEvent.html +2 -2
  136. package/docs/interfaces/index.ResolvedParameterValue.html +1 -1
  137. package/docs/interfaces/index.State.html +1 -1
  138. package/docs/interfaces/index.StateEvent.html +2 -2
  139. package/docs/interfaces/index.TextureOptions.html +1 -1
  140. package/docs/interfaces/index.TilesetOptions.html +7 -2
  141. package/docs/interfaces/index.TopviewControllerCustomInitArgs.html +1 -1
  142. package/docs/interfaces/index.VRPanoramaControllerCustomInitArgs.html +37 -0
  143. package/docs/interfaces/index.ViewLayer.html +23 -21
  144. package/docs/interfaces/index.WorkCubeHdrGainmapImage.html +10 -0
  145. package/docs/interfaces/index.WorkCubeImage.html +5 -9
  146. package/docs/interfaces/index.WorkImage.html +8 -12
  147. package/docs/interfaces/index.WorkInitial.html +8 -8
  148. package/docs/interfaces/index.WorkModel.html +8 -8
  149. package/docs/interfaces/index.WorkModelLayer.html +6 -6
  150. package/docs/interfaces/index.WorkObserver.html +23 -23
  151. package/docs/interfaces/index.WorkPanoramaJson.html +3 -2
  152. package/docs/interfaces/index.WorkTile.html +8 -12
  153. package/docs/interfaces/index.WorksEvent.html +2 -2
  154. package/docs/interfaces/index.XRControllerEvent.html +2 -2
  155. package/docs/interfaces/index.XRGestureEvent.html +2 -2
  156. package/docs/interfaces/index.XRSessionEvent.html +2 -2
  157. package/docs/modules/index.html +1 -1
  158. package/docs/types/index.ControllerCustomInitTypes.html +3 -2
  159. package/docs/types/index.ControllerEventTypes.html +25 -23
  160. package/docs/types/index.EventTypes.html +26 -26
  161. package/docs/types/index.Mode.html +2 -1
  162. package/docs/types/index.ParseOptions.html +14 -8
  163. package/docs/variables/index.GSPLAT_PIPELINE_AUTO.html +2 -0
  164. package/docs/variables/index.GSPLAT_PIPELINE_RASTER_CPU_SORT.html +2 -0
  165. package/docs/variables/index.GSPLAT_PIPELINE_RASTER_GPU_SORT.html +2 -0
  166. package/docs/variables/index.PROXY_CONTROLLER_EVENT_NAMES.html +1 -1
  167. package/docs/variables/index.controllersDefaultInitArgs.html +1 -1
  168. package/five/application/controllers.d.ts +4 -0
  169. package/five/application/events.d.ts +1 -1
  170. package/five/application/five.d.ts +4 -1
  171. package/five/application/fiveInitArgs.d.ts +13 -0
  172. package/five/application/mode.d.ts +2 -0
  173. package/five/cardboard/helper.d.ts +2 -0
  174. package/five/cardboard/index.d.ts +13 -0
  175. package/five/cardboard/sensor.d.ts +158 -0
  176. package/five/controllers/base.d.ts +3 -0
  177. package/five/controllers/events.d.ts +5 -3
  178. package/five/controllers/panorama.d.ts +2 -2
  179. package/five/controllers/vrPanorama.d.ts +56 -0
  180. package/five/core/panoVideo.d.ts +4 -1
  181. package/five/core/tiling.d.ts +25 -11
  182. package/five/gaussian-splatting/gpu-sort/prefixSumKernel.d.ts +65 -0
  183. package/five/gaussian-splatting/gpu-sort/radixSortModule.d.ts +128 -0
  184. package/five/gaussian-splatting/gpu-sort/shaders/prefixSum.d.ts +2 -0
  185. package/five/gaussian-splatting/gpu-sort/shaders/radixHistogram.d.ts +2 -0
  186. package/five/gaussian-splatting/gpu-sort/shaders/radixReorder.d.ts +2 -0
  187. package/five/gaussian-splatting/gpu-sort/shaders/sortKeygen.d.ts +2 -0
  188. package/five/gaussian-splatting/gpu-sort/sortAdapter.d.ts +234 -0
  189. package/five/gaussian-splatting/pipelines/cpuSortPipeline.d.ts +159 -0
  190. package/five/gaussian-splatting/pipelines/gpuSortPipeline.d.ts +98 -0
  191. package/five/gaussian-splatting/pipelines/gsplatPipeline.d.ts +104 -0
  192. package/five/gaussian-splatting/pipelines/pipelineMode.d.ts +42 -0
  193. package/five/gaussian-splatting/pipelines/sortThrottle.d.ts +45 -0
  194. package/five/index.d.ts +4 -1
  195. package/five/index.js +272 -269
  196. package/five/index.mjs +6979 -4610
  197. package/five/meshes/panoCircleMeshCustom.d.ts +1 -0
  198. package/five/model/index.d.ts +1 -1
  199. package/five/model/materials/pbmGaussianSplattingNodeMaterial.d.ts +4 -0
  200. package/five/model/materials/pbmMaterial.d.ts +113 -18
  201. package/five/model/materials/tsl/defines.d.ts +6 -1
  202. package/five/model/materials/tsl/outputBuilder.d.ts +1 -12
  203. package/five/model/materials/tsl/panoColor.d.ts +8 -2
  204. package/five/model/materials/tsl/utils.d.ts +13 -0
  205. package/five/model/objects/pbmGaussianSplattingObject.d.ts +9 -0
  206. package/five/model/objects/pbmGaussianSplattingRenderMesh.d.ts +67 -101
  207. package/five/model/tile3d/index.d.ts +2 -0
  208. package/five/model/tile3d/tileset.d.ts +5 -0
  209. package/five/model/tile3d/trajectory-content.d.ts +53 -0
  210. package/five/texture/loader.d.ts +6 -0
  211. package/five/types/cube.d.ts +0 -1
  212. package/five/utils/detector.d.ts +11 -1
  213. package/five/utils/error.d.ts +1 -0
  214. package/five/utils/event.d.ts +17 -1
  215. package/five/utils/gainmap-data.d.ts +23 -0
  216. package/five/work/index.d.ts +1 -1
  217. package/five/work/looseWorkType.d.ts +2 -1
  218. package/five/work/work.d.ts +30 -7
  219. package/five/work/workJsonType.d.ts +2 -1
  220. package/gltf-loader/gltf-object.d.ts +17 -0
  221. package/gltf-loader/index.d.ts +45 -0
  222. package/gltf-loader/index.js +255 -0
  223. package/gltf-loader/index.mjs +302 -0
  224. package/package.json +6 -1
  225. package/plugins/BackgroundPlugin/Controller.d.ts +20 -0
  226. package/plugins/BackgroundPlugin/index.d.ts +5 -0
  227. package/plugins/BackgroundPlugin/typings.d.ts +44 -0
  228. package/plugins/CSS2DPlugin/Controller.d.ts +59 -0
  229. package/plugins/CSS2DPlugin/index.d.ts +5 -0
  230. package/plugins/CSS2DPlugin/typing.d.ts +31 -0
  231. package/plugins/CSS3DPlugin/Controller.d.ts +64 -0
  232. package/plugins/CSS3DPlugin/index.d.ts +5 -0
  233. package/plugins/CSS3DPlugin/typing.d.ts +33 -0
  234. package/plugins/FloorplanPlugin/Controller.d.ts +100 -0
  235. package/plugins/FloorplanPlugin/index.d.ts +5 -0
  236. package/plugins/FloorplanPlugin/render/assets.d.ts +9 -0
  237. package/plugins/FloorplanPlugin/render/index.d.ts +35 -0
  238. package/plugins/FloorplanPlugin/render/isPointInPolygon.d.ts +5 -0
  239. package/plugins/FloorplanPlugin/render/renderFloor.d.ts +22 -0
  240. package/plugins/FloorplanPlugin/render/roomLabelVisibility.d.ts +10 -0
  241. package/plugins/FloorplanPlugin/typing.d.ts +156 -0
  242. package/plugins/FloorplanPlugin/typings/floorplanData.d.ts +112 -0
  243. package/plugins/FloorplanPlugin/typings/floorplanServerData.d.ts +78 -0
  244. package/plugins/FloorplanPlugin/typings/index.d.ts +2 -0
  245. package/plugins/FloorplanPlugin/utils/changeMode.d.ts +5 -0
  246. package/plugins/FloorplanPlugin/utils/changeModelCanvasOpacity.d.ts +6 -0
  247. package/plugins/FloorplanPlugin/utils/correctFiveState.d.ts +11 -0
  248. package/plugins/FloorplanPlugin/utils/equal.d.ts +9 -0
  249. package/plugins/FloorplanPlugin/utils/filter.d.ts +8 -0
  250. package/plugins/FloorplanPlugin/utils/fiveModelLoad.d.ts +6 -0
  251. package/plugins/FloorplanPlugin/utils/formatData.d.ts +6 -0
  252. package/plugins/FloorplanPlugin/utils/formatPosition.d.ts +33 -0
  253. package/plugins/FloorplanPlugin/utils/getDistanceFromModel.d.ts +6 -0
  254. package/plugins/FloorplanPlugin/utils/getPxmm.d.ts +19 -0
  255. package/plugins/FloorplanPlugin/utils/isTruelyObject.d.ts +4 -0
  256. package/plugins/FloorplanPlugin/utils/nearlyEqual.d.ts +8 -0
  257. package/plugins/FloorplanPlugin/utils/to.d.ts +5 -0
  258. package/plugins/Object3DHelperPlugin/Controller.d.ts +99 -0
  259. package/plugins/Object3DHelperPlugin/Controllers/BaseController.d.ts +142 -0
  260. package/plugins/Object3DHelperPlugin/Controllers/BoundingBoxController.d.ts +16 -0
  261. package/plugins/Object3DHelperPlugin/Controllers/MoveController.d.ts +66 -0
  262. package/plugins/Object3DHelperPlugin/Controllers/RotateController.d.ts +61 -0
  263. package/plugins/Object3DHelperPlugin/FiveControllerWrapper.d.ts +17 -0
  264. package/plugins/Object3DHelperPlugin/Helper/BaseHelper.d.ts +97 -0
  265. package/plugins/Object3DHelperPlugin/Helper/BoundingBoxHelper.d.ts +16 -0
  266. package/plugins/Object3DHelperPlugin/Helper/MoveHelper.d.ts +37 -0
  267. package/plugins/Object3DHelperPlugin/Helper/RotateHelper.d.ts +93 -0
  268. package/plugins/Object3DHelperPlugin/constant.d.ts +27 -0
  269. package/plugins/Object3DHelperPlugin/index.d.ts +6 -0
  270. package/plugins/Object3DHelperPlugin/typing.d.ts +143 -0
  271. package/plugins/Object3DHelperPlugin/utils/ArrowGroup.d.ts +22 -0
  272. package/plugins/Object3DHelperPlugin/utils/CenterHandle.d.ts +23 -0
  273. package/plugins/Object3DHelperPlugin/utils/PlaneHandle.d.ts +19 -0
  274. package/plugins/Object3DHelperPlugin/utils/calculateScaleByCamera.d.ts +5 -0
  275. package/plugins/Object3DHelperPlugin/utils/cameraHooks.d.ts +3 -0
  276. package/plugins/Object3DHelperPlugin/utils/direction.d.ts +14 -0
  277. package/plugins/Object3DHelperPlugin/utils/getMouseRaycaster.d.ts +5 -0
  278. package/plugins/Object3DHelperPlugin/utils/getOrthographicCameraDirection.d.ts +8 -0
  279. package/plugins/Object3DHelperPlugin/utils/setObjectQuaternion.d.ts +8 -0
  280. package/plugins/Object3DHelperPlugin/utils/solidGuide.d.ts +27 -0
  281. package/plugins/Object3DHelperPlugin/utils/tipsDom.d.ts +8 -0
  282. package/plugins/PanoAnimePlugin/Controller.d.ts +49 -0
  283. package/plugins/PanoAnimePlugin/index.d.ts +5 -0
  284. package/plugins/PanoAnimePlugin/typing.d.ts +37 -0
  285. package/plugins/index.d.ts +6 -0
  286. package/plugins/index.js +393 -3
  287. package/plugins/index.mjs +3421 -92
  288. package/plugins/thirdParty/CSS2DRenderer.d.ts +37 -0
  289. package/plugins/thirdParty/CSS3DRenderer.d.ts +45 -0
  290. package/plugins/thirdParty/OrbitControls.d.ts +78 -0
  291. package/plugins/thirdParty/domevents.d.ts +36 -0
  292. package/plugins/utils/clamp.d.ts +2 -0
  293. package/plugins/utils/uuid.d.ts +2 -0
  294. package/react/index.js +2 -2
  295. package/react/index.mjs +2 -2
  296. package/umd/five-gltf-loader.js +255 -0
  297. package/umd/five-plugins.js +461 -3
  298. package/umd/five-react.js +2 -2
  299. package/umd/five.js +350 -347
  300. package/docs/interfaces/index.PBMHDRConfig.html +0 -12
  301. package/five/gaussian-splatting/worker/dataWorker.d.ts +0 -1
  302. package/five/three-version-check.d.ts +0 -1
  303. package/five/utils/hdr-data.d.ts +0 -13
  304. package/five/utils/shaderContentFix.d.ts +0 -7
package/plugins/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @license
3
3
  * @realsee/five-webgpu
4
- * Generated: 8/31/2026
5
- * Version: 1.0.0-alpha.5
4
+ * Generated: 2026/9/24
5
+ * Version: 1.0.0-alpha.6
6
6
  * Terms:
7
7
  * Realsee SDK License Agreement
8
8
  * Update: July 28, 2021
@@ -252,4 +252,394 @@
252
252
  * No amendment to or modification of this Agreement will be binding unless in
253
253
  * writing and signed by Realsee. You and Realsee hereto confirm that this
254
254
  * Agreement and all related documents shall be drafted in English.
255
- */Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("@realsee/five-webgpu"),l=require("three/webgpu");l=s(l,1);function u(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function d(e){return/^https?:\/\/|^\/\//.test(e)||/^data:/.test(e)}function f(e,t){return d(t)?t:`${e}${t}`}var p;(function(e){class t{constructor(e,t){this.hooks=new c.Subscribe,this.staticPrefix=`//vr-image-4.realsee-cdn.cn`,this.five=e,t!=null&&t.staticPrefix&&(this.staticPrefix=t.staticPrefix)}getCurrentState(){return this.state}absoluteUrl(e){return f(this.staticPrefix,e)}}e.Controller=t})(p||(p={}));var m=class{constructor(e,t,n,r,i){this.R=e,this.Q=t,this.A=n,this.B=r,this.C=i,this.cov=NaN,this.x=NaN}filter(e,t=0){if(isNaN(this.x))this.x=1/this.C*e,this.cov=1/this.C*this.Q*(1/this.C);else{let n=this.A*this.x+this.B*t,r=this.A*this.cov*this.A+this.R,i=r*this.C*(1/(this.C*r*this.C+this.Q));this.x=n+i*(e-this.C*n),this.cov=r-i*this.C*r}return this.x}},h=class extends p.Controller{updateState(e,t){let n=this.state;this.state=Object.assign(Object.assign({},this.state),e),this.hooks.emit(`stateChange`,{state:this.state,prevState:n,userAction:t})}constructor(e,t){var n,r,i;super(e),this.boundingAABB=null,this.cancelAnimation=null,this.boundsSet=!1,this.keyframes=[],this.five=e,this.state={enabled:!0,visible:!0},this.duration=(n=t==null?void 0:t.duration)==null?5e3:n,this.curveHeight=(r=t==null?void 0:t.curveHeight)==null?1.5:r,this.pointDuration=(i=t==null?void 0:t.pointDuration)==null?3e3:i}load(){return u(this,void 0,void 0,function*(){})}enable(e){var t;if(this.state.enabled)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this.updateState({enabled:!0},n)}disable(e){var t;if(this.state.enabled===!1)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this.updateState({enabled:!1},n)}dispose(){this.disable(),this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null);try{let e=this.findRenderMesh();e&&(e.material.aggregationEnabled=!1,e.material.aggregationProgress=1)}catch(e){}}extractKeyframes(e){let t=[];if(!e.content.data)throw Error(`轨迹数据未加载`);let n=e.content.data.positionArray,r=n.length/3,i=.01,a=.1,o=new m(i,a,1,0,1),s=new m(i,a,1,0,1),c=new m(i,a,1,0,1),u=new Float32Array(r);for(let e=0;e<r;e++)if(e===0)u[e]=0;else{let t=new l.Vector3(n[(e-1)*3],n[(e-1)*3+1],n[(e-1)*3+2]);u[e]=new l.Vector3(n[e*3],n[e*3+1],n[e*3+2]).distanceTo(t)+u[e-1]}for(let i=0;i<r;i++){let a=new l.Vector3(0,0,0),d=0;for(let e=i-5;e<i+6;e++)e>=0&&e<r&&(a.add(new l.Vector3(n[e*3],n[e*3+1],n[e*3+2])),d++);a.divideScalar(d).applyMatrix4(e.transform);let f=o.filter(a.x),p=s.filter(a.y),m=c.filter(a.z);t.push({position:new l.Vector3(f,p,m),location:u[i]})}return t}computeAABB2D(e){let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let a of e)a.position.x<t&&(t=a.position.x),a.position.x>n&&(n=a.position.x),a.position.z<r&&(r=a.position.z),a.position.z>i&&(i=a.position.z);return{min:new l.Vector2(t,r),max:new l.Vector2(n,i)}}findClosestKeyframeToRay(e,t){let n=1/0,r=t[0].position.clone(),i=new l.Vector3;for(let a of t){e.closestPointToPoint(a.position,i);let t=i.distanceTo(a.position);t<n&&(n=t,r=a.position.clone())}return r}findRenderMesh(){let e=null;if(this.five.scene.traverse(t=>{if(e)return;let n=t,r=n.material;r&&r.isPBMGaussianSplattingMaterial&&(e=n)}),!e)throw Error(`未找到 GaussianSplatting 渲染网格`);return e}loadTrajectoryDataIfNeeded(e){return u(this,void 0,void 0,function*(){var t,n,r,i,a,o,s,l;if((t=e.content)!=null&&t.data)return;if(((n=e.content)==null?void 0:n.loadState)===`LOADING`){yield new Promise(t=>{let n=c.AnimationFrameLoop.shared.add(()=>{var r;let i=(r=e.content)==null?void 0:r.loadState;(i===`READY`||i===`FAILED`||i===`UNLOADED`)&&(n(),t())})});return}let u=(r=this.five.model.viewLayers)==null?void 0:r[0],d=u==null?void 0:u.fetcher,f=u==null?void 0:u.search,p=(i=e.content)==null?void 0:i.uri;if(!d||!p)return;let m=f?p.includes(`?`)?`${p}&${f.replace(/^\?/,``)}`:`${p}${f.startsWith(`?`)?f:`?${f}`}`:p;e.content.loadState=`LOADING`;try{let t=yield(0,c.loadPly)(m,{type:`geometry`,customPropertyMapping:{time:{itemType:`uint32`,itemNames:[`time_milisec`]}},fetcher:d}),n=t.scene,r=n.getAttribute(`position`),i=n.getAttribute(`time`),u=(a=r==null?void 0:r.array)==null?new Float32Array:a,f=(o=i==null?void 0:i.array)==null?new Uint32Array:o;e.content.data={uri:m,byteLength:(s=t.byteLength)==null?0:s,memoryUsage:(l=t.memoryUsage)==null?0:l,positionArray:u,timeArray:f,object:null},e.content.loadState=`READY`}catch(t){console.warn(`[GaussianSplattingEntranceAnimationPlugin] trajectory ply 加载失败,将使用 3DGS AABB 回退`,t),e.content.data=void 0,e.content.loadState=`FAILED`}})}computeGSSceneBounds(){let e=new l.Box3,t=new l.Box3;return this.five.scene.traverse(n=>{let r=n;(r==null?void 0:r.boundingBox)instanceof l.Box3&&!r.boundingBox.isEmpty()&&(t.copy(r.boundingBox),r.matrixWorld&&t.applyMatrix4(r.matrixWorld),e.union(t))}),e.isEmpty()?null:e}getCameraCurve(){return u(this,void 0,void 0,function*(){var e,t,n,r,i,a,o,s,c,u;let d=(r=(n=(t=(e=this.five.model.viewLayers)==null?void 0:e[0])==null?void 0:t.trajectories)==null?void 0:n[0])==null?(s=(o=(a=(i=this.five.model.viewLayers)==null?void 0:i[0])==null?void 0:a.scene)==null?void 0:o.trajectories)==null?void 0:s[0]:r,f=null,p=null;if(d&&(yield this.loadTrajectoryDataIfNeeded(d),(c=d.content)!=null&&c.data&&((u=d.content.data.positionArray)==null?void 0:u.length)>=6&&(f=this.extractKeyframes(d),f.length>=2?p=this.computeAABB2D(f):f=null)),!f||!p){let e=this.computeGSSceneBounds();if(!e)throw Error(`未找到可用于计算入场曲线的 3DGS 边界或轨迹`);p={min:new l.Vector2(e.min.x,e.min.z),max:new l.Vector2(e.max.x,e.max.z)};let t=(p.min.x+p.max.x)/2,n=(p.min.y+p.max.y)/2,r=(e.min.y+e.max.y)/2,i=Math.max(p.max.x-p.min.x,p.max.y-p.min.y)*.5;f=[];let a=0,o=null;for(let e=0;e<16;e++){let s=e/16*Math.PI*2,c=new l.Vector3(t+Math.cos(s)*i,r,n+Math.sin(s)*i);o&&(a+=c.distanceTo(o)),f.push({position:c,location:a}),o=c}}this.keyframes=f,this.boundingAABB=p;let m=this.curveHeight,h=new l.Vector3((p.min.x+p.max.x)/2,m,(p.min.y+p.max.y)/2),g=(p.max.x-p.min.x)/2,_=(p.max.y-p.min.y)/2,v=Math.sqrt(g*g+_*_),y=e=>{let t=new l.Vector3().subVectors(e,h);return t.length()<.001&&t.set(1,0,0),h.clone().add(t.normalize().multiplyScalar(v))},b=new l.Vector3(f[0].position.x,m,f[0].position.z),x=y(b),S=new l.Vector3().subVectors(h,b).normalize(),C=new l.Ray(b,S),w=new l.Vector3(-S.z,0,S.x).normalize(),T=new l.Ray(h,w),E=this.findClosestKeyframeToRay(T,f),D=y(new l.Vector3(E.x,m,E.z)),O=this.findClosestKeyframeToRay(C,f),k=y(new l.Vector3(O.x,m,O.z));return new l.CatmullRomCurve3([x,D,k],!1,`centripetal`,.5)})}setBounding(e,t,n){let r=this.findRenderMesh();r.material.aggregationBoundsMin.copy(e),r.material.aggregationBoundsMax.copy(t),this.boundsSet=!0}setBounds(){if(!this.boundingAABB)throw Error(`请先调用 getCameraCurve 计算轨迹边界`);let e=this.boundingAABB,t=this.findRenderMesh(),n=new l.Vector3(e.min.x,0,e.min.y),r=new l.Vector3(e.max.x,3,e.max.y);t.material.aggregationBoundsMin.copy(n),t.material.aggregationBoundsMax.copy(r),this.boundsSet=!0}normalizedPointDuration(){let e=this.pointDuration;return e<=0?.01:Math.min(e<=1?e:e/this.duration,1)}resetToPointCloud(){return u(this,void 0,void 0,function*(){this.boundingAABB||(yield this.getCameraCurve()),this.setBounds();let e=this.findRenderMesh().material;e.aggregationEnabled=!0,e.aggregationProgress=0,e.aggregationPointDuration=this.normalizedPointDuration(),this.five.needsRender=!0,this.five.modelSceneNeedsRender=!0})}startAggregation(){if(!this.boundsSet)throw Error(`请先调用 setBounds 设置聚合边界`);let e=this.findRenderMesh().material;e.aggregationEnabled=!0,e.aggregationProgress=0,e.aggregationPointDuration=this.normalizedPointDuration(),this.five.needsRender=!0;let t=performance.now(),n=this.duration;this.cancelAnimation=c.AnimationFrameLoop.shared.add(()=>{let r=performance.now()-t,i=Math.min(r/n,1);e.aggregationProgress=i*i*(3-2*i),this.five.needsRender=!0,this.five.modelSceneNeedsRender=!0,i>=1&&(e.aggregationEnabled=!1,this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null))})}playEntrance(){return u(this,void 0,void 0,function*(){let e=yield this.getCameraCurve(),t=this.boundingAABB,n=new l.Vector3((t.min.x+t.max.x)/2,this.curveHeight,(t.min.y+t.max.y)/2),r=e.getPointAt(0),i=new c.Camera(90).copy(this.five.camera);i.position.copy(r),i.lookAt(n),i.computePose(0),this.five.setState(Object.assign({},i.pose)),this.setBounds();let a=this.findRenderMesh().material;a.aggregationEnabled=!0,a.aggregationProgress=0,a.aggregationPointDuration=this.normalizedPointDuration(),this.five.needsRender=!0;let o=this.duration,s=performance.now();return new Promise(t=>{this.cancelAnimation=c.AnimationFrameLoop.shared.add(()=>{let r=performance.now()-s,c=Math.min(r/o,1),l=c*c*(3-2*c);a.aggregationProgress=l,this.five.modelSceneNeedsRender=!0;let u=e.getPointAt(l);i.position.copy(u),i.lookAt(n),i.computePose(0),this.five.setState(Object.assign({},i.pose)),this.five.needsRender=!0,c>=1&&(a.aggregationEnabled=!1,a.aggregationProgress=1,this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null),t())})})})}},g=(e,t)=>new h(e,t);Object.defineProperty(exports,"BasePlugin",{enumerable:!0,get:function(){return p}}),exports.GaussianSplattingEntranceAnimationPlugin=g;
255
+ */Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("@realsee/five-webgpu"),l=require("three/webgpu");l=s(l,1);let u=require("three/tsl");function d(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function f(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function p(e){return/^https?:\/\/|^\/\//.test(e)||/^data:/.test(e)}function m(e,t){return p(t)?t:`${e}${t}`}var h;(function(e){class t{constructor(e,t){this.hooks=new c.Subscribe,this.staticPrefix=`//vr-image-4.realsee-cdn.cn`,this.five=e,t!=null&&t.staticPrefix&&(this.staticPrefix=t.staticPrefix)}getCurrentState(){return this.state}absoluteUrl(e){return m(this.staticPrefix,e)}}e.Controller=t})(h||(h={}));var g=class extends h.Controller{constructor(e,t){super(e),this.data={},this.pluginName=`BackgroundPlugin`,this._onFiveCameraUpdate=e=>{let t=(Math.PI/2-Math.max(e.latitude,0))/(Math.PI/2),n=Math.max(.2-t,0)*10;this.gradientBg&&(this.gradientBg.style.transform=`translateY(-${(1-t)*50}%)`),this.groundBg&&(this.groundBg.style.backgroundImage=`radial-gradient(circle, #2E303350 ${n*100}%, transparent ${n*120}%)`)},this._addEventListener=()=>{this.five.on(`cameraUpdate`,this._onFiveCameraUpdate)},this._removeEventListener=()=>{this.five.off(`cameraUpdate`,this._onFiveCameraUpdate)},this.load=()=>f(this,void 0,void 0,function*(){}),this.setState=(e,t={})=>{},this.enable=()=>{var e;let t=(e=this.five.getElement())==null?void 0:e.parentNode;if(!t){this.five.ready().then(()=>this.enable());return}this.state.enabled||(this._onFiveCameraUpdate(this.five.getPose(),!1),this.gradientBg&&t.appendChild(this.gradientBg),this.groundBg&&t.appendChild(this.groundBg),this.style&&document.head.appendChild(this.style),this._addEventListener(),this.hooks.emit(`enable`,{userAction:!0}),this.state.enabled=!0)},this.disable=(e={})=>{var t,n,r,i;this.state.enabled&&((n=(t=this.gradientBg)==null?void 0:t.parentNode)==null||n.removeChild(this.gradientBg),(i=(r=this.groundBg)==null?void 0:r.parentNode)==null||i.removeChild(this.groundBg),this.style&&document.head.removeChild(this.style),this._removeEventListener(),this.hooks.emit(`disable`,{userAction:!0}),this.state.enabled=!1)},this.dispose=()=>{this._removeEventListener(),this.hooks.emit(`disable`,{userAction:!0}),this.state.enabled=!1},this.state={enabled:!1},!(typeof document>`u`)&&(this.gradientBg=document.createElement(`div`),this.groundBg=document.createElement(`div`),this.style=document.createElement(`style`),this.gradientBg.className=`BackgroundPluginBg`,this.groundBg.className=`BackgroundPluginGroundBg`,this.style.innerHTML=`
256
+ .BackgroundPluginBg {
257
+ position: absolute;
258
+ top: 0;
259
+ right: 0;
260
+ left: 0;
261
+ height: 200%;
262
+ background: linear-gradient(#0A0B0D, #2E3033);
263
+ z-index: -1;
264
+ pointerEvents: none;
265
+ }
266
+ .BackgroundPluginGroundBg {
267
+ position: absolute;
268
+ top: 0;
269
+ right: 0;
270
+ left: 0;
271
+ bottom: 0;
272
+ background-image: radial-gradient(circle, #2E303350 0, transparent 0);
273
+ z-index: -1;
274
+ pointerEvents: none;
275
+ }
276
+ `,this.enable())}},_=(e,t)=>new g(e,t);function v(e,t,n){if(n){let r=new l.Vector3().subVectors(e.position,n).applyQuaternion(e.quaternion.clone().invert()).applyQuaternion(t).add(n);e.position.copy(r)}e.quaternion.copy(t)}function y(e){return e==null}var b=class extends l.Object3D{removeChildren(){for(;this.children.length>0;)this.remove(this.children[0]);return this}add(...e){let t=e.filter(Boolean);return t.length===0?this:super.add(...t)}addIfNotExists(...e){return e.forEach(e=>{this.children.includes(e)||this.add(e)}),this}remove(...e){if(e.length===0)return this;let t=e.filter(Boolean);return super.remove(...t)}removeFromParent(){let e=this.parent;return e!==null&&e.remove(this),this}get helperObject(){return this}constructor(e,t){var n,r;super(),this.originObject3D=e,this.onRender=(n=t==null?void 0:t.onRender)==null?(()=>{}):n,this.positionFrom=(r=t==null?void 0:t.positionFrom)==null?`objectPosition`:r}render(){this.onRender()}enable(){this.parent&&(this.parent.children.includes(this)||this.parent.add(this))}disable(){this.removeFromParent()}show(){this.visible=!0,this.render()}hide(){this.visible=!1,this.render()}raycasterIntersectObject(e,t=[]){return e.intersectObject(this,!0,t)}initialPosition(e){this.positionFrom===`objectPosition`?this.position.copy(this.originObject3D.position):this.positionFrom===`boundingBox`||this.positionFrom===`boundingSphere`?this.position.copy(new l.Box3().expandByObject(this.originObject3D).getCenter(new l.Vector3)):this.positionFrom instanceof l.Vector3?this.position.copy(this.positionFrom):this.positionFrom instanceof Function&&this.position.copy(this.positionFrom(this.originObject3D)),e&&this.position.add(e)}setScaleByCamera(e){}initQuaternion(e){if(this.quaternion.set(0,0,0,1),e&&(e.xAxis||e.yAxis||e.zAxis)){let t=e.xAxis instanceof Function?e.xAxis():e.xAxis,n=e.yAxis instanceof Function?e.yAxis():e.yAxis,r=e.zAxis instanceof Function?e.zAxis():e.zAxis,i=t==null?void 0:t.clone(),a=n==null?void 0:n.clone(),o=r==null?void 0:r.clone();if(i&&!a&&!a){let e=new l.Quaternion().setFromUnitVectors(new l.Vector3(1,0,0),i.normalize());this.applyQuaternion(e)}if(a&&!i&&!o){let e=new l.Quaternion().setFromUnitVectors(new l.Vector3(0,1,0),a.normalize());this.applyQuaternion(e)}if(o&&!i&&!a){let e=new l.Quaternion().setFromUnitVectors(new l.Vector3(0,0,1),o.normalize());this.applyQuaternion(e)}if([i,a,o].filter(e=>!y(e)).length>=2){i||(i=new l.Vector3().crossVectors(a,o).normalize()),a||(a=new l.Vector3().crossVectors(i,o).normalize()),o||(o=new l.Vector3().crossVectors(i,a).normalize()),i.applyQuaternion(this.quaternion),a.applyQuaternion(this.quaternion),o.applyQuaternion(this.quaternion);let e=new l.Matrix4().makeBasis(i,a,o),t=new l.Quaternion().setFromRotationMatrix(e);this.quaternion.copy(t)}}}applyHelperScaleMatrix4(e,t){this.scale.applyMatrix4(e)}setHelperQuaternion(e,t){this.initQuaternion(),t?v(this,this.quaternion.clone().premultiply(e),t):this.quaternion.premultiply(e)}applyHelperQuaternion(e,t){if(t){let n=new l.Vector3().subVectors(this.position,t).applyQuaternion(e).add(t);this.position.copy(n)}this.applyQuaternion(e)}dispose(){this.removeFromParent()}},x=class extends b{},S=class extends b{},C=class extends b{},w=class extends l.Group{constructor(e){super(),this.direction=e||`x`}};l.Line;var T=class extends l.Mesh{constructor(e,t,n){super(e,t),this.direction=n||`x`}},E={X:16730698,Y:54927,Z:3368703},D=class{static get X(){return new l.Color(E.X).convertSRGBToLinear().clone()}static get Y(){return new l.Color(E.Y).convertSRGBToLinear().clone()}static get Z(){return new l.Color(E.Z).convertSRGBToLinear().clone()}},O={ROTATE_HELPER:9992,MOVE_HELPER:9993,SCALE_HELPER_LINE:9994,SCALE_HELPER_SPHERE:9995,MOVE_HELPER_ARROW:10001,MOVE_HELPER_CENTER:10002,DRAG_GUIDE_LINE:10003,DRAG_FACE_PATCH:10004},k=class extends w{constructor(e){var t;super(e.direction),this.lineHeight=.5,this.arrowHeight=.1,this.name=`ArrowGroup`;let n=new l.Color((t=e.color)==null?16214315:t),r=()=>new l.MeshBasicMaterial({color:n,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1}),i=new l.ConeGeometry(.04,this.arrowHeight,32);this.arrow=new T(i,r(),e.direction),this.arrow.name=`arrow-${e.direction}`,this.arrow.renderOrder=O.MOVE_HELPER_ARROW;let a=new l.ConeGeometry(.04,this.arrowHeight,32);this.arrowNeg=new T(a,r(),e.direction),this.arrowNeg.name=`arrow-neg-${e.direction}`,this.arrowNeg.renderOrder=O.MOVE_HELPER_ARROW;let o=.004,s=new l.CylinderGeometry(o,o,this.lineHeight,32);this.line=new T(s,r(),e.direction),this.line.name=`line-${e.direction}`,this.line.renderOrder=O.MOVE_HELPER_ARROW,this.formatGeometries(),this.add(this.arrow,this.arrowNeg,this.line)}formatGeometries(){let e=this.lineHeight,t=this.arrowHeight;this.arrow.geometry.translate(0,e+t/2,0),this.arrowNeg.geometry.rotateZ(Math.PI),this.arrowNeg.geometry.translate(0,-(e+t/2),0),this.line.geometry.translate(0,e/2,0),this.direction===`x`?(this.arrow.geometry.rotateX(Math.PI/2),this.arrow.geometry.rotateY(Math.PI/2),this.arrowNeg.geometry.rotateX(Math.PI/2),this.arrowNeg.geometry.rotateY(Math.PI/2),this.line.geometry.rotateX(Math.PI/2),this.line.geometry.rotateY(Math.PI/2)):this.direction===`z`&&(this.arrow.geometry.rotateX(Math.PI/2),this.arrowNeg.geometry.rotateX(Math.PI/2),this.line.geometry.rotateX(Math.PI/2))}},ee=class extends w{constructor(e){var t,n;super(`plane`),this.name=`CenterHandle`,this.faceNormals=[new l.Vector3(1,0,0),new l.Vector3(-1,0,0),new l.Vector3(0,1,0),new l.Vector3(0,-1,0),new l.Vector3(0,0,1),new l.Vector3(0,0,-1)],this.baseColor=new l.Color((t=e==null?void 0:e.color)==null?16419862:t);let r=(n=e==null?void 0:e.size)==null?.05:n,i=new l.Color(16755008).convertSRGBToLinear();this.faceMaterials=Array.from({length:6},()=>new l.MeshBasicMaterial({color:i,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1,side:l.FrontSide}));let a=new l.BoxGeometry(r,r,r),o=new l.Mesh(a,this.faceMaterials);o.direction=`plane`,o.renderOrder=O.MOVE_HELPER_CENTER,o.name=`center-plane-handle`,this.cube=o,this.add(this.cube)}update(e){let t=new l.Vector3().subVectors(e.position,this.cube.getWorldPosition(new l.Vector3)).normalize(),n=this.cube.getWorldQuaternion(new l.Quaternion),r=this.faceNormals.map((e,r)=>{let i=e.clone().applyQuaternion(n).dot(t);return{index:r,angle:Math.acos(Math.abs(i))}});r.sort((e,t)=>e.angle-t.angle);let i=[new l.Color(16755008).convertSRGBToLinear(),new l.Color(16419862).convertSRGBToLinear(),new l.Color(13921032).convertSRGBToLinear()];r.forEach((e,t)=>{let n=Math.floor(t/2);this.faceMaterials[e.index].color.copy(i[n])})}},te=class extends w{constructor(e){var t,n,r;super(e.direction),this.name=`PlaneHandle`;let i=(t=e.size)==null?.12:t,a=(n=e.offset)==null?.12:n,o=new l.Color((r=e.color)==null?16776960:r),s=new l.BoxGeometry(i,i,.005),c=new l.MeshBasicMaterial({color:o,transparent:!0,opacity:.4,depthTest:!1,depthWrite:!1,side:l.DoubleSide});switch(this.handle=new l.Mesh(s,c),this.handle.direction=e.direction,this.handle.renderOrder=O.MOVE_HELPER_ARROW,this.handle.name=`plane-handle-${e.direction}`,e.direction){case`xy`:this.handle.position.set(a,a,0);break;case`xz`:this.handle.position.set(a,0,a),this.handle.rotation.x=-Math.PI/2;break;case`yz`:this.handle.position.set(0,a,a),this.handle.rotation.y=Math.PI/2;break}this.add(this.handle)}};function ne(e,t,n){let r=e.position.distanceTo(t),i=e.fov,a=e.distance||3,o=r/3,s=i/90,c=a/3,l=o*s*c,u=(n==null?void 0:n.min)||.6,d=n==null?void 0:n.max;return u&&l<u?u:d&&l>d?d:l}function re(e){let{latitude:t,longitude:n}=e,r=new l.Vector3;return ie-t<.03?r.set(0,1,0):A(0,n)?r.set(0,0,1):A(Math.PI,n)?r.set(0,0,-1):A(ie,n)?r.set(1,0,0):r.set(-1,0,0),r}var ie=Number((Math.PI/2).toFixed(5));function A(e,t){return typeof e!=`number`||typeof t!=`number`?!1:Math.abs(e-t)<.001}function ae(e,t){return oe(document.createElement(t==null?`div`:t),e)}function oe(e,t){if(!t)return e;for(let n in t)n&&t[n]&&(e.style[n]=t[n]);return e}function se(e){let t=ae(Object.assign({position:`absolute`,display:`block`,borderRadius:`4px`,paddingTop:`1px`,paddingBottom:`1px`,paddingLeft:`4px`,paddingRight:`4px`,pointerEvents:`none`,userSelect:`none`,zIndex:`99999`,backgroundColor:`rgba(0,0,0,0.7)`,fontSize:`12px`,color:`#fff`,letterSpacing:`0`,lineHeight:`18px`},e)),n=()=>{t.style.display!==`block`&&t.style.top&&t.style.left&&(t.style.display=`block`)};return{element:t,show:n,hide:()=>{t.style.display=`none`,t.style.top=``,t.style.left=``},setLeftTop:(e,r)=>{t.style.left=e,t.style.top=r,n()}}}var ce=class extends x{constructor(e,t){super(e,t),this.name=`MoveHelper`,(t==null?void 0:t.xArrowEnable)!==!1&&(this.xArrow=new k({direction:`x`,color:D.X})),(t==null?void 0:t.yArrowEnable)!==!1&&(this.yArrow=new k({direction:`y`,color:D.Y})),(t==null?void 0:t.zArrowEnable)!==!1&&(this.zArrow=new k({direction:`z`,color:D.Z})),(t==null?void 0:t.centerHandleEnable)!==!1&&(this.centerHandle=new ee),(t==null?void 0:t.xyPlaneEnable)!==!1&&(this.xyPlane=new te({direction:`xy`,color:D.Z})),(t==null?void 0:t.xzPlaneEnable)!==!1&&(this.xzPlane=new te({direction:`xz`,color:D.Y})),(t==null?void 0:t.yzPlaneEnable)!==!1&&(this.yzPlane=new te({direction:`yz`,color:D.X})),t!=null&&t.container&&(t==null?void 0:t.moveTipsEnable)!==!1&&(this.container=t.container,this.moveTips=se({display:`none`}),this.container.appendChild(this.moveTips.element)),this.add(...[this.xArrow,this.yArrow,this.zArrow,this.centerHandle,this.xyPlane,this.xzPlane,this.yzPlane].filter(Boolean))}update(e){if(this.xArrow&&(this.xArrow.visible=!0),this.yArrow&&(this.yArrow.visible=!0),this.zArrow&&(this.zArrow.visible=!0),this.centerHandle&&this.centerHandle.update(e),e.type===`OrthographicCamera`){let t=new l.Vector3(1,0,0).applyQuaternion(this.quaternion),n=new l.Vector3(0,1,0).applyQuaternion(this.quaternion),r=new l.Vector3(0,0,1).applyQuaternion(this.quaternion),i=e.pose,a=re(i),o=.0872665;Math.abs(t.angleTo(a)-0)<o||Math.abs(t.angleTo(a)-Math.PI)<o?this.xArrow&&(this.xArrow.visible=!1):Math.abs(n.angleTo(a)-0)<o||Math.abs(n.angleTo(a)-Math.PI)<o?this.yArrow&&(this.yArrow.visible=!1):(Math.abs(r.angleTo(a)-0)<o||Math.abs(r.angleTo(a)-Math.PI)<o)&&this.zArrow&&(this.zArrow.visible=!1)}}show(){var e;super.show(),this.xArrow&&this.add(this.xArrow),this.yArrow&&this.add(this.yArrow),this.zArrow&&this.add(this.zArrow),this.centerHandle&&this.add(this.centerHandle),this.xyPlane&&this.add(this.xyPlane),this.xzPlane&&this.add(this.xzPlane),this.yzPlane&&this.add(this.yzPlane),(e=this.moveTips)==null||e.hide()}setScaleByCamera(e){this.scale.setScalar(ne(e,this.position))}showDraggingHelper(e){this.xArrow&&(e.includes(`x`)?this.add(this.xArrow):this.remove(this.xArrow)),this.yArrow&&(e.includes(`y`)?this.add(this.yArrow):this.remove(this.yArrow)),this.zArrow&&(e.includes(`z`)?this.add(this.zArrow):this.remove(this.zArrow)),this.centerHandle&&(e.includes(`plane`)?this.add(this.centerHandle):this.remove(this.centerHandle)),this.xyPlane&&(e.includes(`xy`)?this.add(this.xyPlane):this.remove(this.xyPlane)),this.xzPlane&&(e.includes(`xz`)?this.add(this.xzPlane):this.remove(this.xzPlane)),this.yzPlane&&(e.includes(`yz`)?this.add(this.yzPlane):this.remove(this.yzPlane))}dispose(){var e,t;this.remove(...[this.xArrow,this.yArrow,this.zArrow,this.centerHandle,this.xyPlane,this.xzPlane,this.yzPlane].filter(Boolean)),(t=(e=this.moveTips)==null?void 0:e.element)==null||t.remove(),super.dispose()}},le=class extends C{constructor(e,t){super(e,t),this.name=`RotateHelper`,this.children=[],(t==null?void 0:t.yzCircleEnable)!==!1&&(this.xCircle=new j({direction:`x`,color:D.X})),(t==null?void 0:t.xzCircleEnable)!==!1&&(this.yCircle=new j({direction:`y`,color:D.Y})),(t==null?void 0:t.xyCircleEnable)!==!1&&(this.zCircle=new j({direction:`z`,color:D.Z})),t!=null&&t.container&&(t==null?void 0:t.angleTipsEnable)!==!1&&(this.container=t==null?void 0:t.container,this.angleTips=se({display:`none`}),this.container.appendChild(this.angleTips.element)),this.add(...[this.xCircle,this.yCircle,this.zCircle].filter(Boolean)),this.show()}hide(){this.children.forEach(e=>e.hide())}show(){var e;this.children.forEach(e=>e.showCircle()),(e=this.angleTips)==null||e.hide()}setScaleByCamera(e){this.scale.setScalar(ne(e,this.position))}update(e){if(e.type===`OrthographicCamera`)return;let t=this.helperObject.position.clone().sub(e.position).normalize(),n=new l.Vector3(1,0,0).applyQuaternion(this.quaternion),r=new l.Vector3(0,1,0).applyQuaternion(this.quaternion),i=new l.Vector3(0,0,1).applyQuaternion(this.quaternion),a=t.angleTo(n),o=t.angleTo(r),s=t.angleTo(i),c=Math.PI/2,u=o>=c,d=s>=c,f=a>=c;if(this.xCircle){let e=this.xCircle.circle.gapAngle;u&&d?this.xCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,e,Math.PI/2-e*2):u&&!d?this.xCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI/2+e,Math.PI/2-e*2):!u&&d?this.xCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI/2*3+e,Math.PI/2-e*2):!u&&!d&&(this.xCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI+e,Math.PI/2-e*2)),this.xCircle.angleSector&&(this.xCircle.angleSector.offsetAngle=e=>e,u&&d||u&&!d?this.xCircle.angleSector.baseAxes=new l.Vector3(0,0,1):!u&&d?(this.xCircle.angleSector.baseAxes=new l.Vector3(0,-1,0),this.xCircle.angleSector.offsetAngle=e=>e-Math.PI/2):!u&&!d&&(this.xCircle.angleSector.baseAxes=new l.Vector3(0,0,-1),this.xCircle.angleSector.offsetAngle=e=>e-Math.PI))}if(this.yCircle){this.yCircle.angleSector.offsetAngle=e=>e;let e=this.yCircle.circle.gapAngle;f&&d?this.yCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,e,Math.PI/2-e*2):f&&!d?this.yCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI/2*3+e,Math.PI/2-e*2):!f&&d?this.yCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI/2+e,Math.PI/2-e*2):!f&&!d&&(this.yCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI+e,Math.PI/2-e*2)),f&&d?this.yCircle.angleSector.baseAxes=new l.Vector3(1,0,0):f&&!d?(this.yCircle.angleSector.baseAxes=new l.Vector3(0,0,-1),this.yCircle.angleSector.offsetAngle=e=>e-Math.PI/2):!f&&d?(this.yCircle.angleSector.baseAxes=new l.Vector3(0,0,1),this.yCircle.angleSector.offsetAngle=e=>e+Math.PI/2):!f&&!d&&(this.yCircle.angleSector.baseAxes=new l.Vector3(-1,0,0),this.yCircle.angleSector.offsetAngle=e=>e+Math.PI)}if(this.zCircle){this.zCircle.angleSector.offsetAngle=e=>e;let e=this.zCircle.circle.gapAngle;f&&u?this.zCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,e,Math.PI/2-e*2):f&&!u?this.zCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI/2*3+e,Math.PI/2-e*2):!f&&u?this.zCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI/2+e,Math.PI/2-e*2):!f&&!u&&(this.zCircle.circle.geometry=new l.RingGeometry(.3,.35,20,8,Math.PI+e,Math.PI/2-e*2)),this.zCircle.angleSector&&(f&&u?this.zCircle.angleSector.baseAxes=new l.Vector3(1,0,0):f&&!u?(this.zCircle.angleSector.baseAxes=new l.Vector3(0,-1,0),this.zCircle.angleSector.offsetAngle=e=>e-Math.PI/2):!f&&u?(this.zCircle.angleSector.baseAxes=new l.Vector3(0,1,0),this.zCircle.angleSector.offsetAngle=e=>e+Math.PI/2):!f&&!u&&(this.zCircle.angleSector.baseAxes=new l.Vector3(-1,0,0),this.zCircle.angleSector.offsetAngle=e=>e+Math.PI))}}showDraggingHelper(e){var t;this.hide(),this.children.filter(t=>e.includes(t.direction)).forEach(e=>e.showRing()),(t=this.angleTips)==null||t.show()}dispose(){var e,t;this.removeFromParent(),(t=(e=this.angleTips)==null?void 0:e.element)==null||t.remove()}},j=class extends l.Group{constructor(e){super(),this.direction=e.direction,this.circle=new ue(e),this.ring=new de(e),this.angleSector=new fe(e),this.add(this.circle,this.ring,this.angleSector),this.direction===`y`?this.rotation.x=Math.PI/2:this.direction===`x`&&(this.rotation.y=-Math.PI/2)}showCircle(){this.add(this.circle),this.remove(this.ring,this.angleSector)}showRing(){this.add(this.ring,this.angleSector),this.remove(this.circle)}hide(){this.remove(this.ring,this.angleSector,this.circle)}},ue=class extends l.Mesh{constructor(e){var t;super(),this.gapAngle=.02,this.geometry=new l.RingGeometry(.3,.35,20,8,this.gapAngle,Math.PI/2-this.gapAngle*2),this.material=new l.MeshBasicMaterial({opacity:.6,transparent:!0,color:(t=e.color)==null?16777215:t,side:l.DoubleSide,depthTest:!1}),this.direction=e.direction,this.renderOrder=O.ROTATE_HELPER,this.geometry.name=`RotateHelperCircleGeometry-${this.direction}`}},de=class extends l.Group{constructor(e){super(),this.direction=e.direction;let t=.015,n=Array(8).fill(null).map((e,n)=>{let r=new l.RingGeometry(.3,.35,20,8,Math.PI/4*n+t,Math.PI/4-t*2),i=new l.MeshBasicMaterial({opacity:1,color:16777215,depthTest:!1,depthWrite:!1,transparent:!0,side:l.DoubleSide}),a=new l.Mesh(r,i);return a.name=`AxesDashedRing-${this.direction}-${n}`,a});this.add(...n)}},fe=class extends l.Mesh{constructor(e){var t;switch(super(),this.offsetAngle=e=>e,e.direction){case`x`:this.baseAxes=new l.Vector3(0,0,1);break;case`y`:this.baseAxes=new l.Vector3(1,0,0);break;case`z`:this.baseAxes=new l.Vector3(1,0,0);break}this.geometry=new l.CircleGeometry(.3505,48,0,1e-4),this.material=new l.MeshBasicMaterial({opacity:.4,color:(t=e.color)==null?16777215:t,depthTest:!1,depthWrite:!1,transparent:!0,side:l.DoubleSide}),this.direction=e.direction,this.angleDirection=1}setClockwiseDirection(){this.angleDirection=-1}setCounterClockwiseDirection(){this.angleDirection=1}toggleDirection(){this.angleDirection=this.angleDirection===1?-1:1}setBaseAxes(e){this.baseAxes=e.clone().normalize()}getDirection(){return this.angleDirection===-1?`clockwise`:`counterclockwise`}},pe=class extends S{constructor(e){super(e),this.name=`BoundingBoxHelper`,this.positionAttribute=new l.BufferAttribute(new Float32Array(24),3),this.box=this.createBox(),this.outline=this.createOutline(),this.add(this.box,this.outline),this.update()}initQuaternion(){this.quaternion.copy(this.originObject3D.quaternion),this.scale.copy(this.originObject3D.scale)}setHelperQuaternion(e,t){v(this,e,t)}raycasterIntersectObject(e,t){return e.intersectObject(this,!1,t)}raycast(e,t){this.box.raycast(e,t)}update(){let e=new l.Box3,t=new l.Matrix4().copy(this.originObject3D.matrixWorld).invert(),n=new l.Vector3;if(this.originObject3D.updateMatrixWorld(!0),this.originObject3D.traverse(r=>{let i=r.geometry;if(!i)return;r.updateMatrixWorld(!0);let a=new l.Matrix4().multiplyMatrices(t,r.matrixWorld);if(i.isBufferGeometry){let t=i,r=t.attributes.position;if(r)for(let t=0,i=r.count;t<i;t++)n.fromBufferAttribute(r,t).applyMatrix4(a),e.expandByPoint(n);let o=t.attributes.instanceStart,s=t.attributes.instanceEnd;if(o)for(let t=0,r=o.count;t<r;t++)n.fromBufferAttribute(o,t).applyMatrix4(a),e.expandByPoint(n);if(s)for(let t=0,r=s.count;t<r;t++)n.fromBufferAttribute(s,t).applyMatrix4(a),e.expandByPoint(n)}else if(i.vertices){let t=i.vertices;for(let r of t)n.copy(r).applyMatrix4(a),e.expandByPoint(n)}}),e.isEmpty())return;let{min:r,max:i}=e;this.positionAttribute.setXYZ(0,i.x,i.y,i.z),this.positionAttribute.setXYZ(1,r.x,i.y,i.z),this.positionAttribute.setXYZ(2,r.x,r.y,i.z),this.positionAttribute.setXYZ(3,i.x,r.y,i.z),this.positionAttribute.setXYZ(4,i.x,i.y,r.z),this.positionAttribute.setXYZ(5,r.x,i.y,r.z),this.positionAttribute.setXYZ(6,r.x,r.y,r.z),this.positionAttribute.setXYZ(7,i.x,r.y,r.z),this.positionAttribute.needsUpdate=!0}createOutline(){let e=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),t=new l.BufferGeometry;t.setIndex(new l.BufferAttribute(e,1)),t.setAttribute(`position`,this.positionAttribute);let n=new l.LineBasicMaterial({color:64767,linewidth:1,opacity:1,toneMapped:!1}),r=new l.LineSegments(t,n);return r.matrixAutoUpdate=!1,r}createBox(){let e=new Uint16Array([0,1,2,0,2,3,0,3,7,0,7,4,0,4,5,0,5,1,6,1,5,6,2,1,6,5,4,6,4,7,6,3,2,6,7,3]),t=new l.BufferGeometry;t.setIndex(new l.BufferAttribute(e,1)),t.setAttribute(`position`,this.positionAttribute);let n=new l.MeshBasicMaterial({color:64767,opacity:.1,depthTest:!1,transparent:!0});return new l.Mesh(t,n)}},M=new Map;function me(e){if(M.has(e))return M.get(e).hooks;let t=new c.Subscribe,n=null,r,i=()=>{n=requestAnimationFrame(i);let a=e.projectionMatrix.toArray().join(`,`)+e.matrixWorld.toArray().join(`,`);a!==r&&(r=a,t.emit(`cameraUpdate`))};return i(),M.set(e,{hooks:t,dispose:()=>{M.delete(e),cancelAnimationFrame(n)}}),t}function he(e){return arguments.length===0?[]:Array.isArray(e)?e:[e]}var N=class{updateOtherControllers(e){this.otherControllers=e}getIsDragging(){return this.isDragging}constructor(e,t){var n,r,i;this.preventTapDefaultEvent=!1,this.disposers=[],this.isDragging=!1,this.enabled=!1,this.name=`BaseController`,this.onWantsTapGesture=e=>{if(this.getIntersectObject(e))return!1},this.updateHelperScale=()=>{`update`in this.helperObject3D&&typeof this.helperObject3D.update==`function`&&this.helperObject3D.update(this.camera),this.helperObject3D.setScaleByCamera(this.camera)},this.getBox=()=>(this.boundingBox||(this.boundingBox=new l.Box3().expandByObject(this.originObject3D)),this.boundingBox),this.hooks=(n=e.sharedHooks)==null?new c.Subscribe:n,this.internalHooks=(r=e.sharedInternalHooks)==null?new c.Subscribe:r,this.camera=e.camera,this.model=e.model,this.originObject3D=e.originObject3D,this.helperObject3D=e.helperObject3D,this.container=e.container,this.scene=e.scene,this.domEvents=e.domEvents,this.onRender=(i=e.onRender)==null?(()=>{}):i,this.config=t==null?{}:t,this.otherControllers=e.otherControllers,this.initialHelperPosition(),this.initialHelperQuaternion(),this.updateHelperScale(),this.cameraHooks=me(this.camera),this.enable();let a=this.onSetOriginObjectScale.bind(this),o=this.onSetOriginObjectRotate.bind(this),s=this.onSetOriginObjectPosition.bind(this),u=this.onApplyOriginObjectScale.bind(this),d=this.onApplyOriginObjectRotate.bind(this),f=this.onApplyOriginObjectPosition.bind(this),p=this.initialHelperPosition.bind(this);this.cameraHooks.on(`cameraUpdate`,this.updateHelperScale),this.internalHooks.on(`initialHelperPosition`,p),this.internalHooks.on(`setObjectScale`,a),this.internalHooks.on(`setObjectRotate`,o),this.internalHooks.on(`setObjectPosition`,s),this.internalHooks.on(`applyObjectPosition`,f),this.internalHooks.on(`applyObjectRotate`,d),this.internalHooks.on(`applyObjectScale`,u),this.hooks.on(`moveEnd`,this.updateHelperScale),this.internalHooks.on(`setObjectPosition`,this.updateHelperScale),this.internalHooks.on(`initialHelperPosition`,this.updateHelperScale),this.disposers.push(()=>{this.cameraHooks.off(`cameraUpdate`,this.updateHelperScale),this.internalHooks.off(`initialHelperPosition`,p),this.internalHooks.off(`setObjectScale`,a),this.internalHooks.off(`setObjectRotate`,o),this.internalHooks.off(`setObjectPosition`,s),this.internalHooks.off(`applyObjectPosition`,f),this.internalHooks.off(`applyObjectRotate`,d),this.internalHooks.off(`applyObjectScale`,u),this.hooks.off(`moveEnd`,this.updateHelperScale),this.internalHooks.off(`setObjectPosition`,this.updateHelperScale),this.internalHooks.off(`initialHelperPosition`,this.updateHelperScale)})}initialHelperPosition(){this.helperObject3D.initialPosition(this.calculateOffset(this.config.offset))}initialHelperQuaternion(){this.helperObject3D.initQuaternion(this.config)}enable(){this.enabled||(this.enabled=!0,this.scene.add(this.helperObject3D),this.helperObject3D.enable(),this.render())}disable(){this.enabled&&(this.enabled=!1,this.helperObject3D.disable(),this.render())}show(){this.helperObject3D.show(),this.render()}hide(){this.helperObject3D.hide(),this.render()}dispose(){var e;(e=this.disposers)==null||e.forEach(e=>e==null?void 0:e()),this.helperObject3D.dispose(),this.render()}applyHelperMatrix4(e){this.helperObject3D.applyMatrix4(e)}applyHelperQuaternion(e,t){this.helperObject3D.applyHelperQuaternion(e,t)}applyHelperScaleMatrix4(e,t){this.helperObject3D.applyHelperScaleMatrix4(e,t)}onWantsGesture(e,t,n){if(this.isDragging)return!1}onIntersectionOnModelUpdate(e){}onApplyOriginObjectScale(e){this.applyHelperScaleMatrix4(e.matrix,e.origin)}onApplyOriginObjectRotate(e){let t=e.origin;if(t){let n=new l.Vector3().subVectors(this.helperObject3D.position,t).applyQuaternion(e.quaternion).add(t);this.helperObject3D.position.copy(n)}}onApplyOriginObjectPosition(e){this.applyHelperMatrix4(e.matrix)}onSetOriginObjectScale(e){this.helperObject3D.scale.copy(e),this.updateOffsetByScale(e)}onSetOriginObjectRotate(e,t){}onSetOriginObjectPosition(e){this.helperObject3D.position.copy(e.clone().add(this.calculateOffset(this.config.offset)))}render(){this.onRender()}updateOffsetByScale(e){if(this.boundingBox&&this.config.offset){let t=this.originObject3D.position,n=new l.Vector3().subVectors(this.boundingBox.max,t).multiply(e).add(t),r=new l.Vector3().subVectors(this.boundingBox.min,t).multiply(e).add(t),i=this.calculateOffset(this.config.offset,{min:r,max:n});this.helperObject3D.initialPosition(i)}}hoverListener(e,t=16777215,n=1){let r=he(e).filter(e=>!y(e)),i=[];for(let e of r)if(e.material||e instanceof l.Group){let r=e instanceof l.Group?e.children.filter(e=>e instanceof l.Mesh):[e];r.forEach(e=>{var t,n,r,i;let a=e.material;Array.isArray(a)?(e.__originalColor__=(t=e.__originalColor__)==null?a.map(e=>e.color.clone()):t,e.__originalOpacity__=(n=e.__originalOpacity__)==null?a.map(e=>e.opacity):n):(e.__originalColor__=(r=e.__originalColor__)==null?a.color.clone():r,e.__originalOpacity__=(i=e.__originalOpacity__)==null?a.opacity:i)});let a=()=>{r.forEach(e=>{if(e.name===`ScaleHelperTransparentGroup`){if(e.children[0]){let r=e.children[0].material;r.color.set(t),r.opacity=n}}else{let r=e.material;Array.isArray(r)?r.forEach(e=>{e.color.set(t),e.opacity=n}):(r.color.set(t),r.opacity=n)}}),this.render()},o=()=>{r.forEach(e=>{if(e.name===`ScaleHelperTransparentGroup`){if(e.children[0]){let t=e.children[0].material;t.color.set(16776960),t.opacity=1}}else{let t=e.material;if(Array.isArray(t)){let n=e.__originalColor__,r=e.__originalOpacity__;t.forEach((e,t)=>{n&&n[t]&&e.color.copy(n[t]),r&&r[t]!==void 0&&(e.opacity=r[t])})}else t.color.copy(e.__originalColor__),t.opacity=e.__originalOpacity__}}),this.render()},s=e=>{this.isDragging||a()},c=e=>{this.isDragging||o()};for(let e of r)this.domEvents.addEventListener(e,`mouseover`,s),this.domEvents.addEventListener(e,`mouseout`,c),this.hooks.on(`moveStart`,a),this.hooks.on(`moveEnd`,o),this.hooks.on(`rotateEnd`,o),this.hooks.on(`scaleEnd`,o),i.push(()=>{this.domEvents.removeEventListener(e,`mouseover`,s),this.domEvents.removeEventListener(e,`mouseout`,c),this.hooks.off(`moveStart`,a),this.hooks.off(`moveEnd`,o),this.hooks.off(`rotateEnd`,o),this.hooks.off(`scaleEnd`,o)})}return()=>i.forEach(e=>e==null?void 0:e())}getIntersectObject(e){let t=this.camera.position,n=this.helperObject3D;if(!n)return;let r=this.helperObject3D.raycasterIntersectObject(e)[0];if(!r)return;let i=r;if(i.object=n,this.model.intersectRaycaster){let n=this.model.intersectRaycaster(e)[0];if(n&&n.point.distanceTo(t)<i.point.distanceTo(t))return}return i.object}calculateOffset(e,t){let n=new l.Vector3(0,0,0);if(!e)return n;let r=()=>t||this.getBox();if(typeof e.x==`number`)n.setX(e.x);else if(typeof e.x==`object`){let t=r();n.setX((t.max.x-t.min.x)*e.x.percents)}if(typeof e.y==`number`)n.setY(e.y);else if(typeof e.y==`object`){let t=r();n.setY((t.max.y-t.min.y)*e.y.percents)}if(typeof e.z==`number`)n.setZ(e.z);else if(typeof e.z==`object`){let t=r();n.setZ((t.max.z-t.min.z)*e.z.percents)}return n}};function ge(e,t){let n=10,r=10,i=e.isPerspectiveCamera,a=e.isOrthographicCamera;if(i){let i=e,a=i.position.distanceTo(t),o=i.fov*Math.PI/180;r=2*Math.tan(o/2)*a,n=r*i.aspect}else if(a){let t=e;n=Math.abs(t.right-t.left),r=Math.abs(t.top-t.bottom)}let o=Math.sqrt(n*n+r*r),s=o*.8,c=Math.min(n,r)*.25,l=o*1.2;return Math.max(c,Math.min(s,l))}var _e=class{constructor(e,t,n){this.camera=e,this.container=t,this.defaults=Object.assign({},n||{})}createSolidLine(e,t,n){let r=Object.assign(Object.assign({color:16777215,renderOrder:O.DRAG_GUIDE_LINE},this.defaults),n||{}),i=t.clone().normalize(),a=this.computeInfiniteLineLength(e),o=e.clone().add(i.clone().multiplyScalar(-a)),s=e.clone().add(i.clone().multiplyScalar(a)),c=new Float32Array([o.x,o.y,o.z,s.x,s.y,s.z]),u=new l.BufferGeometry;u.setAttribute(`position`,new l.BufferAttribute(c,3));let d=new l.LineBasicMaterial({color:r.color,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.65}),f=new l.Line(u,d);return f.renderOrder=r.renderOrder,f}updateSolidLine(e,t,n,r){let i=n.clone().normalize(),a=this.computeInfiniteLineLength(t),o=t.clone().add(i.clone().multiplyScalar(-a)),s=t.clone().add(i.clone().multiplyScalar(a)),c=new Float32Array([o.x,o.y,o.z,s.x,s.y,s.z]),u=e.geometry,d=u.getAttribute(`position`);d&&d.itemSize===3&&d.array.length===c.length?(d.array.set(c),d.needsUpdate=!0):u.setAttribute(`position`,new l.BufferAttribute(c,3)),(r==null?void 0:r.color)!==void 0&&e.material.color.setHex(r.color)}computeInfiniteLineLength(e){return ge(this.camera,e)*10}dispose(e){if(!e)return;e.geometry.dispose();let t=e.material;Array.isArray(t)?t.forEach(e=>e.dispose()):t.dispose()}updateDefaults(e){this.defaults=Object.assign(Object.assign({},this.defaults),e)}};function ve(e,t,n){let{top:r,left:i,width:a,height:o}=t.getBoundingClientRect();return n&&(i+=a*n.left,r+=o*(1-n.bottom-n.height),a*=n.width,o*=n.height),new l.Vector2((e.x-i)/a*2-1,-(e.y-r)/o*2+1)}function ye(e,t,n){if(!t||!n||!e)return;let r=ve(t,n);if(Math.abs(r.x)===1||Math.abs(r.y)===1)return;let i=new l.Raycaster;return i.setFromCamera(r,e),i.params.Points&&(i.params.Points.threshold=.1),i}function be(e){let{raycaster:t,line:n,clampToLine:r=!0}=e,i=new l.Plane().setFromNormalAndCoplanarPoint(t.ray.direction.clone().normalize(),new l.Vector3),a=i.projectPoint(n.start,new l.Vector3),o=i.projectPoint(n.end,new l.Vector3),s=new l.Line3(a,o),c=s.closestPointToPoint(t.ray.origin,r,new l.Vector3),u=c.distanceTo(o),d=c.distanceTo(a),f=s.distance();if(u>d&&u>f){let e=-c.distanceTo(a)/f,t=n.start.clone().sub(n.end).normalize();return n.start.clone().sub(t.clone().multiplyScalar(e*n.distance()))}else{let e=c.distanceTo(a)/f;return new l.Vector3().lerpVectors(n.start,n.end,e)}}var xe=class extends N{get moveByMouseEnable(){return this._moveByMouse.enabled}constructor(...e){var t,n,r,i,a;super(...e),this.name=`MoveController`,this.solidGuide=new _e(this.camera,this.container,(n=(t=this.config)==null?void 0:t.solidGuide)==null?{}:n),this._moveByMouse={enabled:!1},this.dragStart=e=>{if(this.moveByMouseEnable||this.isDragging)return;let t=e==null?void 0:e.intersect;if(!t)return this.dragEnd();let n=(t==null?void 0:t.object).direction;if(!n)return this.dragEnd();let r=new l.Vector3(1,0,0),i=new l.Vector3(0,1,0),a=new l.Vector3(0,0,1),o=(()=>{switch(n){case`x`:return r;case`y`:return i;case`z`:return a;case`xy`:case`xz`:case`yz`:case`plane`:return}})(),s=t.point.clone();if(n===`xy`||n===`xz`||n===`yz`){let e=(()=>{switch(n){case`xy`:return a;case`xz`:return i;case`yz`:return r}})(),t=new l.Plane().setFromNormalAndCoplanarPoint(e,s),o=s.clone();this.startInfo={draggingDirection:n,startVectorProject:o,line:new l.Line3(o.clone(),o.clone()),plane:t}}else if(n===`plane`){let e=this.camera.position.clone(),t=s.clone(),r=t.clone().sub(e).normalize(),i=new l.Plane().setFromNormalAndCoplanarPoint(r,t),a=t.clone();this.startInfo={draggingDirection:n,startVectorProject:a,line:new l.Line3(a.clone(),a.clone()),plane:i}}else{if(!o)return this.dragEnd();let e=new l.Line3(s.clone().sub(o.normalize()),s.clone().add(o.normalize()));this.startInfo={draggingDirection:n,startVectorProject:s,line:e};try{let e=o.clone().normalize(),t=this.helperObject3D.getWorldPosition(new l.Vector3),n=this.solidGuide.createSolidLine(t,e,{color:16777215,renderOrder:O.DRAG_GUIDE_LINE});this.scene.add(n),this.dragGuideLine=n}catch(e){}}let c=(()=>{switch(n){case`plane`:return[];case`xy`:return[`x`,`y`,`xy`];case`xz`:return[`x`,`z`,`xz`];case`yz`:return[`y`,`z`,`yz`];default:return[n]}})();this.helperObject3D.showDraggingHelper(c),this.hooks.emit(`moveStart`,n),this.isDragging=!0,this.setTipsText(this.originObject3D.position),this.setTipsPosition(s)},this.dragging=e=>{if(!this.isDragging||!this.startInfo)return;let t=`touches`in e?e.touches[0].clientX:e.x,n=`touches`in e?e.touches[0].clientY:e.y,r=ye(this.camera,{x:t,y:n},this.container);return r?(this.move(r),!1):this.dragEnd()},this.dragEnd=()=>{if(this.isDragging){if(this.startInfo=void 0,this.isDragging=!1,this.dragGuideLine){this.scene.remove(this.dragGuideLine),this.dragGuideLine.geometry.dispose();let e=this.dragGuideLine.material;Array.isArray(e)?e.forEach(e=>e.dispose()):e.dispose(),this.dragGuideLine=void 0}this.helperObject3D.show(),this.hooks.emit(`moveEnd`)}};let o=this.helperObject3D;if(this.hoverListener([o.xArrow,o.yArrow,o.zArrow,(r=o.xyPlane)==null?void 0:r.handle,(i=o.xzPlane)==null?void 0:i.handle,(a=o.yzPlane)==null?void 0:a.handle]),o.centerHandle&&o.centerHandle instanceof ee){let e=o.centerHandle,t=e.cube;this.domEvents.addEventListener(t,`mouseover`,()=>{this.isDragging||(Array.isArray(t.material)&&t.material.forEach(e=>{e.color.set(16777215)}),this.render())}),this.domEvents.addEventListener(t,`mouseout`,()=>{this.isDragging||(e.update(this.camera),this.render())})}let s=this.show.bind(this),c=this.hide.bind(this),u=()=>{this.helperObject3D.update(this.camera),this.isDragging&&this.updateDragGuideLineScale(),this.render()};u(),this.domEvents.addEventListener(this.helperObject3D,`mousedown`,this.dragStart),document.addEventListener(`mousemove`,this.dragging),document.addEventListener(`mouseup`,this.dragEnd),this.domEvents.addEventListener(this.helperObject3D,`touchstart`,this.dragStart),document.addEventListener(`touchmove`,this.dragging),document.addEventListener(`touchend`,this.dragEnd),this.hooks.on(`rotateStart`,c),this.hooks.on(`rotateEnd`,s),this.hooks.on(`scaleStart`,c),this.hooks.on(`scaleEnd`,s),this.hooks.on(`moveByMouseEnable`,c),this.hooks.on(`moveByMouseDisable`,s),this.hooks.on(`updateOtherHelpers`,e=>{this.helperObject3D.update(e.camera),this.render()}),this.cameraHooks.on(`cameraUpdate`,u),this.disposers.push(()=>{this.domEvents.removeEventListener(this.helperObject3D,`mousedown`,this.dragStart),document.removeEventListener(`mousemove`,this.dragging),document.removeEventListener(`mouseup`,this.dragEnd),this.domEvents.removeEventListener(this.helperObject3D,`touchstart`,this.dragStart),document.removeEventListener(`touchmove`,this.dragging),document.removeEventListener(`touchend`,this.dragEnd),this.hooks.off(`rotateStart`,c),this.hooks.off(`rotateEnd`,s),this.hooks.off(`scaleStart`,c),this.hooks.off(`scaleEnd`,s),this.hooks.off(`moveByMouseEnable`,c),this.hooks.off(`moveByMouseDisable`,s),this.hooks.off(`updateOtherHelpers`),this.cameraHooks.off(`cameraUpdate`,u)}),this.moveByMouseEnable&&this.moveByMouse()}dispose(){var e;super.dispose(),(e=this.disposers)==null||e.forEach(e=>e==null?void 0:e())}moveByMouse(e){this._moveByMouse={enabled:!0,useFaceNormal:e==null?void 0:e.useFaceNormal},this.preventTapDefaultEvent=!0;let t=this.handleMouseDown.bind(this),n=this.handleMouseUp.bind(this);this.hooks.emit(`moveByMouseEnable`),setTimeout(()=>{this.container.addEventListener(`mousedown`,t),this.container.addEventListener(`mouseup`,n)}),this.mousedownEventListenerDisposer=()=>{this.container.removeEventListener(`mousedown`,t),this.container.removeEventListener(`mouseup`,n)}}disableMoveByMouse(){var e;this._moveByMouse={enabled:!1},this.preventTapDefaultEvent=!1,this.hooks.emit(`moveByMouseDisable`),(e=this.mousedownEventListenerDisposer)==null||e.call(this)}onIntersectionOnModelUpdate(e){var t,n,r;if(!this.moveByMouseEnable)return;let{point:i,face:a}=e;if(!this.hooks.emit(`wantToMove`,i)){if(this.originObject3D.position.copy(i),(this._moveByMouse.useFaceNormal===!0||typeof this._moveByMouse.useFaceNormal==`object`&&this._moveByMouse.useFaceNormal.enable!==!1)&&a!=null&&a.normal){let e=typeof this._moveByMouse.useFaceNormal==`object`&&this._moveByMouse.useFaceNormal.alignmentVector?this._moveByMouse.useFaceNormal.alignmentVector:{x:0,y:1,z:0},i=new l.Vector3((t=e.x)==null?0:t,(n=e.y)==null?0:n,(r=e.z)==null?0:r),o=typeof this._moveByMouse.useFaceNormal==`object`&&this._moveByMouse.useFaceNormal.fixedFaceNormal?this._moveByMouse.useFaceNormal.fixedFaceNormal(a.normal):a.normal;this.originObject3D.quaternion.setFromUnitVectors(i,o),this.internalHooks.emit(`setObjectRotate`,this.originObject3D.quaternion.clone(),new l.Vector3)}this.internalHooks.emit(`setObjectPosition`,i),this.hooks.emit(`move`,i)}}handleMouseDown(e){let{x:t,y:n}=e;this.mouseInfo={x:t,y:n,mouseDownTimestamp:Date.now()}}handleMouseUp(e){if(!this.mouseInfo)return;let{x:t,y:n}=e;this.mouseInfo.x===t&&this.mouseInfo.y===n&&Date.now()-this.mouseInfo.mouseDownTimestamp<500&&(this.disableMoveByMouse(),this.mouseInfo=void 0)}updateDragGuideLineScale(){if(!this.dragGuideLine||!this.startInfo)return;let{line:e}=this.startInfo,t=e.end.clone().sub(e.start).normalize();if(t.lengthSq()<1e-6)return;let n=this.helperObject3D.getWorldPosition(new l.Vector3);this.solidGuide.updateSolidLine(this.dragGuideLine,n,t)}move(e){if(!this.startInfo)return this.dragEnd();let{line:t,startVectorProject:n}=this.startInfo,r=this.originObject3D,i=this.startInfo.draggingDirection===`plane`||this.startInfo.draggingDirection===`xy`||this.startInfo.draggingDirection===`xz`||this.startInfo.draggingDirection===`yz`,a;if(i){let t=this.startInfo.plane;if(!t)return;let n=new l.Vector3,r=t.normal.dot(e.ray.direction);if(Math.abs(r)<1e-6)return;let i=-(t.normal.dot(e.ray.origin)+t.constant)/r;if(i<0)return;n.copy(e.ray.origin.clone().add(e.ray.direction.clone().multiplyScalar(i))),a=n}else a=be({raycaster:e,line:t,clampToLine:!1});let o=r.position.clone(),s=a.clone().sub(n),c=new l.Matrix4;c.setPosition(s);let u=r.position.clone().applyMatrix4(c);if(this.hooks.emit(`wantToMove`,u))return;let d=u.clone();this.hooks.emit(`moveBefore`,d);let f=new l.Matrix4;f.setPosition(d.clone().sub(o)),r.position.copy(d),this.setTipsText(d),this.setTipsPosition(d),n.copy(a),this.internalHooks.emit(`applyObjectPosition`,{matrix:f}),this.hooks.emit(`move`,d)}setTipsText(e){var t;let n=(t=this.helperObject3D.moveTips)==null?void 0:t.element;if(!n||!this.startInfo)return;let r=this.startInfo.draggingDirection,i=e=>e.toFixed(3);switch(r){case`x`:n.innerText=`x: ${i(e.x)}`;break;case`y`:n.innerText=`y: ${i(e.y)}`;break;case`z`:n.innerText=`z: ${i(e.z)}`;break;case`xy`:n.innerText=`x: ${i(e.x)} y: ${i(e.y)}`;break;case`xz`:n.innerText=`x: ${i(e.x)} z: ${i(e.z)}`;break;case`yz`:n.innerText=`y: ${i(e.y)} z: ${i(e.z)}`;break;case`plane`:n.innerText=`x: ${i(e.x)} y: ${i(e.y)} z: ${i(e.z)}`;break}}setTipsPosition(e){let t=this.helperObject3D.moveTips;if(!t)return;let{x:n,y:r,z:i}=this.helperObject3D.getWorldPosition(new l.Vector3).clone().project(this.camera);if(i>1){t.hide();return}let a=this.container.getBoundingClientRect(),o=(n+1)/2*a.width,s=(-r+1)/2*a.height;t.setLeftTop(o+`px`,s+`px`)}},P=class{constructor(e,t,n,r,i,a,o,s,c){this.onFiveWantsTapGesture=e=>{if(!this.helperController)return;if(this.helperController.preventTapDefaultEvent)return!1;let t=this.helperController.onWantsTapGesture(e);return this.five.needsRender=!0,t},this.onFiveWantsGesture=(...e)=>{if(!this.helperController)return;let t=this.helperController.onWantsGesture(...e);return this.five.needsRender=!0,t},this.onFiveIntersectionOnModelUpdate=(...e)=>{this.helperController&&this.helperController.onIntersectionOnModelUpdate(...e)};let{camera:l,model:u,scene:d}=e,f=e.getElement();if(this.five=e,!l||!u||!f||!d)return;let p=c==null?d:c,m=()=>{e.needsRender=!0};this.helperController=new n({camera:l,model:u,domEvents:t,originObject3D:r,helperObject3D:i,container:f,scene:p,onRender:m,sharedHooks:o,sharedInternalHooks:s},a),e.on(`wantsTapGesture`,this.onFiveWantsTapGesture),e.on(`wantsGesture`,this.onFiveWantsGesture),e.on(`intersectionOnModelUpdate`,this.onFiveIntersectionOnModelUpdate)}dispose(){var e;this.five.off(`wantsTapGesture`,this.onFiveWantsTapGesture),this.five.off(`wantsGesture`,this.onFiveWantsGesture),this.five.off(`intersectionOnModelUpdate`,this.onFiveIntersectionOnModelUpdate),(e=this.helperController)==null||e.dispose()}},Se=new l.Quaternion,Ce=class extends N{get rotateCenter(){return this.helperObject3D.position.clone()}constructor(...e){var t,n,r;super(...e),this.name=`RotateController`,this.solidGuide=new _e(this.camera,this.container),this.snapGuideLines=[];let i=this.helperObject3D;this.hoverListener([(t=i.xCircle)==null?void 0:t.circle,(n=i.yCircle)==null?void 0:n.circle,(r=i.zCircle)==null?void 0:r.circle].filter(Boolean));let a=this.dragStart.bind(this),o=this.dragging.bind(this),s=this.dragEnd.bind(this),c=this.show.bind(this),l=this.hide.bind(this),u=()=>{this.helperObject3D.update(this.camera),this.render()};u(),this.domEvents.addEventListener(this.helperObject3D,`mousedown`,a),document.addEventListener(`mousemove`,o),document.addEventListener(`mouseup`,s),this.domEvents.addEventListener(this.helperObject3D,`touchstart`,a),document.addEventListener(`touchmove`,o),document.addEventListener(`touchend`,s),this.hooks.on(`moveStart`,l),this.hooks.on(`moveEnd`,c),this.hooks.on(`scaleStart`,l),this.hooks.on(`scaleEnd`,c),this.hooks.on(`moveByMouseEnable`,l),this.hooks.on(`moveByMouseDisable`,c),this.hooks.on(`updateOtherHelpers`,e=>{this.helperObject3D.update(e.camera),this.render()}),this.cameraHooks.on(`cameraUpdate`,u),this.disposers.push(()=>{this.domEvents.removeEventListener(this.helperObject3D,`mousedown`,a),document.removeEventListener(`mousemove`,o),document.removeEventListener(`mouseup`,s),this.domEvents.removeEventListener(this.helperObject3D,`touchstart`,a),document.removeEventListener(`touchmove`,o),document.removeEventListener(`touchend`,s),this.hooks.off(`moveStart`,l),this.hooks.off(`moveEnd`,c),this.hooks.off(`scaleStart`,l),this.hooks.off(`scaleEnd`,c),this.hooks.off(`moveByMouseEnable`,l),this.hooks.off(`moveByMouseDisable`,c),this.hooks.off(`updateOtherHelpers`),this.cameraHooks.off(`cameraUpdate`,u)})}setRotateAngle(e){let{x:t=0,y:n=0,z:r=0}=e,i=new l.Euler(l.MathUtils.degToRad(t),l.MathUtils.degToRad(n),l.MathUtils.degToRad(r)),a=new l.Quaternion().setFromEuler(i);if(this.hooks.emit(`wantToRotate`,a))return;let{originObject3D:o,rotateCenter:s}=this;v(o,a,s),this.internalHooks.emit(`setObjectRotate`,a,s),this.hooks.emit(`rotate`,a),this.render()}getEulerAngle(e,t){let{originObject3D:n}=this,r=new l.Euler().setFromQuaternion(n.quaternion),i={x:l.MathUtils.radToDeg(r.x),y:l.MathUtils.radToDeg(r.y),z:l.MathUtils.radToDeg(r.z)},a={x:e===`x`?t:i.x,y:e===`y`?t:i.y,z:e===`z`?t:i.z},o=new l.Euler(l.MathUtils.degToRad(a.x),l.MathUtils.degToRad(a.y),l.MathUtils.degToRad(a.z));return new l.Quaternion().setFromEuler(o)}onApplyOriginObjectRotate(e){this.isDragging||super.onApplyOriginObjectRotate(e)}onApplyOriginObjectScale(e){}dragStart(e){if(this.isDragging)return;this.helperObject3D.update(this.camera);let t=e==null?void 0:e.intersect;if(!t)return this.dragEnd();let n=(t==null?void 0:t.object).direction;if(!n)return this.dragEnd();let r=t.point;this.setTipsAngle(0);let i=r.clone();i.y+=.2,this.setTipsPosition(i);let a=new l.Quaternion,o=n===`x`?new l.Vector3(1,0,0):n===`y`?new l.Vector3(0,1,0):n===`z`?new l.Vector3(0,0,1):new l.Vector3(0,1,0),s=new l.Plane().setFromNormalAndCoplanarPoint(o,r),c=s.projectPoint(r.clone(),new l.Vector3).clone().sub(this.rotateCenter),u=this.getAngleHelper(n);if(!u)return this.dragEnd();let d=c.angleTo(u.baseAxes.clone().applyQuaternion(a)),f=u.offsetAngle(d);this.setAngleHelperStart(n,f),this.setAngleHelperLength(n,0),this.startInfo={direction:n,startVector:c,directionVector:o,plane:s,angleHelper:u,angle:0,helperQuaternion:a.clone(),startQuaternion:this.originObject3D.quaternion.clone()},Se=new l.Quaternion,this.helperObject3D.showDraggingHelper([n]),this.hooks.emit(`rotateStart`,n),this.isDragging=!0}getMatrix(){var e,t;return(t=(e=this.originObject3D)==null?void 0:e.ext)==null?void 0:t.matrix}getMatrixAngle(e,t){let n;if(e&&e.isMatrix4){n=new l.Quaternion,e.decompose(new l.Vector3,n,new l.Vector3);let r=new l.Euler().setFromQuaternion(n);if(t===`x`)return Math.round(l.MathUtils.radToDeg(r.z));if(t===`y`)return Math.round(l.MathUtils.radToDeg(r.y));if(t===`z`)return Math.round(l.MathUtils.radToDeg(r.x))}}parseAngleByDirection(e){var t,n;let r=(n=(t=this.originObject3D)==null?void 0:t.ext)==null?void 0:n.matrix,i;if(r&&r.isMatrix4){i=new l.Quaternion,r.decompose(new l.Vector3,i,new l.Vector3);let t=new l.Euler().setFromQuaternion(i);if(e===`x`)return Math.round(l.MathUtils.radToDeg(t.z));if(e===`y`)return Math.round(l.MathUtils.radToDeg(t.y));if(e===`z`)return Math.round(l.MathUtils.radToDeg(t.x))}}dragging(e){if(!this.isDragging)return;let t=`touches`in e?e.touches[0].clientX:e.x,n=`touches`in e?e.touches[0].clientY:e.y,r=ye(this.camera,{x:t,y:n},this.container);return r?(this.rotate(r),!1):this.dragEnd()}rotate(e){if(!this.startInfo)return this.dragEnd();let{startVector:t,plane:n,angleHelper:r,direction:i,helperQuaternion:a}=this.startInfo,{originObject3D:o}=this,s=e.ray.intersectPlane(n,new l.Vector3);if(!s)return;let c=this.rotateCenter.clone(),u=n.projectPoint(s.clone(),new l.Vector3).clone().sub(c),d=this.startInfo.directionVector.clone().normalize();u=u.clone().projectOnPlane(d).normalize().multiplyScalar(u.length());let f=new l.Quaternion().setFromUnitVectors(t.clone().normalize(),u.clone().normalize()),p=o.quaternion.clone().premultiply(f);if(t.angleTo(u)===0||this.hooks.emit(`wantToRotate`,p))return;let m=new l.Euler().setFromQuaternion(new l.Quaternion().setFromUnitVectors(t.clone().normalize().applyQuaternion(a.clone().invert()),u.clone().normalize().applyQuaternion(a.clone().invert())),`${i.toUpperCase()}${`XZY`.replace(i.toUpperCase(),``)}`)[i]*r.angleDirection,h=this.startInfo.angle,g=h+m,_=Math.PI/2,v=l.MathUtils.degToRad(5),y=l.MathUtils.degToRad(10),b=new l.Quaternion().setFromAxisAngle(d,g),x=this.startInfo.startQuaternion.clone().premultiply(b),S=this.extractAxisAngle(x,d),C=Math.round(S/_)*_,w=Math.abs(S-C);if(Math.abs(g)>y&&w<v){let e=C-S;g+=e}let T=g-h;this.startInfo.angle=g;let E=Math.abs(T)<1e-6&&Math.abs(m)>1e-6,D=this.snapGuideLines.length>0;E&&!D?this.showSnapGuideLines(i,c):!E&&D&&this.removeSnapGuideLines(),this.setAngleHelperLength(i,this.startInfo.angle),this.setTipsAngle(l.MathUtils.radToDeg(this.startInfo.angle));let O=new l.Quaternion().setFromAxisAngle(d,T);if(c){let e=new l.Vector3().subVectors(o.position,c).applyQuaternion(O).add(c);o.position.copy(e)}o.applyQuaternion(O),Se.premultiply(O),this.internalHooks.emit(`applyObjectRotate`,{quaternion:O,origin:c}),this.hooks.emit(`rotate`,o.quaternion),E||(this.startInfo.startVector=u)}dragEnd(){var e;this.isDragging&&(this.removeSnapGuideLines(),(e=this.startInfo)!=null&&e.lineMeshes&&this.startInfo.lineMeshes.forEach(e=>{this.scene.remove(e),e.geometry.dispose(),e.material instanceof l.Material&&e.material.dispose()}),this.startInfo=void 0,this.isDragging=!1,this.helperObject3D.show(),this.updateOtherHelpers(),this.hooks.emit(`rotateEnd`))}updateOtherHelpers(){this.hooks.emit(`updateOtherHelpers`,{camera:this.camera})}getAngleHelper(e){var t,n,r;switch(e){case`x`:return(t=this.helperObject3D.xCircle)==null?void 0:t.angleSector;case`y`:return(n=this.helperObject3D.yCircle)==null?void 0:n.angleSector;case`z`:return(r=this.helperObject3D.zCircle)==null?void 0:r.angleSector}}setAngleHelperStart(e,t){let n=this.getAngleHelper(e);if(!n){console.warn(`angleHelper is undefined`);return}if(n instanceof l.Mesh&&n.geometry instanceof l.CircleGeometry){let{radius:e,segments:r,thetaLength:i}=n.geometry.parameters;n.geometry=new l.CircleGeometry(e,r,t,i)}else console.warn(`only support THREE.CircleGeometry`)}setAngleHelperLength(e,t){let n=e===`x`||e===`y`?-t:t,r=n>=0?Math.max(n,.001):Math.min(n,-.001),i=this.getAngleHelper(e);if(i instanceof l.Mesh&&i.geometry instanceof l.CircleGeometry){let{radius:e,thetaStart:t}=i.geometry.parameters,n=Math.ceil(Math.abs(r)*(40/(2*Math.PI)));i.geometry=new l.CircleGeometry(e,n,t,r)}else console.warn(`only support THREE.CircleGeometry`)}setTipsAngle(e){var t;let n=(t=this.helperObject3D.angleTips)==null?void 0:t.element;n&&(n.innerText=`${e.toFixed(0)}°`)}setTipsPosition(e){let t=this.helperObject3D.angleTips;if(!t)return;let{x:n,y:r,z:i}=this.helperObject3D.getWorldPosition(new l.Vector3).clone().project(this.camera);if(i>1){t.hide();return}let a=this.container.getBoundingClientRect(),o=(n+1)/2*a.width,s=(-r+1)/2*a.height;t.setLeftTop(o+`px`,s+`px`)}extractAxisAngle(e,t){let n=t.clone().normalize(),r=e.x*n.x+e.y*n.y+e.z*n.z,i=e.w,a=2*Math.atan2(r,i);return Math.atan2(Math.sin(a),Math.cos(a))}showSnapGuideLines(e,t){this.removeSnapGuideLines();let n=(()=>{switch(e){case`x`:return[new l.Vector3(0,1,0),new l.Vector3(0,0,1)];case`y`:return[new l.Vector3(1,0,0),new l.Vector3(0,0,1)];case`z`:return[new l.Vector3(1,0,0),new l.Vector3(0,1,0)];default:return[]}})();for(let e of n){let n=this.solidGuide.createSolidLine(t,e,{color:16777215,renderOrder:O.DRAG_GUIDE_LINE});this.scene.add(n),this.snapGuideLines.push(n)}this.render()}removeSnapGuideLines(){for(let e of this.snapGuideLines)this.scene.remove(e),this.solidGuide.dispose(e);this.snapGuideLines=[]}},we=class extends N{constructor(...e){super(...e),this.name=`BoundingBoxController`;let t=()=>{this.syncWithObject(),this.render()};this.hooks.on(`moveEnd`,t),this.hooks.on(`rotateEnd`,t),this.hooks.on(`scaleEnd`,t),this.disposers.push(()=>{this.hooks.off(`moveEnd`,t),this.hooks.off(`rotateEnd`,t),this.hooks.off(`scaleEnd`,t)})}onApplyOriginObjectRotate(e){this.helperObject3D.applyHelperQuaternion(e.quaternion,e.origin)}onSetOriginObjectRotate(e,t){this.helperObject3D.setHelperQuaternion(e,t)}syncWithObject(){this.helperObject3D.position.copy(this.originObject3D.position),this.helperObject3D.quaternion.copy(this.originObject3D.quaternion),this.helperObject3D.scale.copy(this.originObject3D.scale);let e=this.helperObject3D;e.update&&e.update()}};function F(e,t){this._camera=e||null,this._domElement=t||document,this._raycaster=new l.Raycaster,this._selected=null,this._boundObjs={};var n=this;this._$onClick=function(){n._onClick.apply(n,arguments)},this._$onDblClick=function(){n._onDblClick.apply(n,arguments)},this._$onMouseMove=function(){n._onMouseMove.apply(n,arguments)},this._$onMouseDown=function(){n._onMouseDown.apply(n,arguments)},this._$onMouseUp=function(){n._onMouseUp.apply(n,arguments)},this._$onTouchMove=function(){n._onTouchMove.apply(n,arguments)},this._$onTouchStart=function(){n._onTouchStart.apply(n,arguments)},this._$onTouchEnd=function(){n._onTouchEnd.apply(n,arguments)},this._$onContextmenu=function(){n._onContextmenu.apply(n,arguments)},this._domElement.addEventListener(`click`,this._$onClick,!1),this._domElement.addEventListener(`dblclick`,this._$onDblClick,!1),this._domElement.addEventListener(`mousemove`,this._$onMouseMove,!1),this._domElement.addEventListener(`mousedown`,this._$onMouseDown,!1),this._domElement.addEventListener(`mouseup`,this._$onMouseUp,!1),this._domElement.addEventListener(`touchmove`,this._$onTouchMove,!1),this._domElement.addEventListener(`touchstart`,this._$onTouchStart,!1),this._domElement.addEventListener(`touchend`,this._$onTouchEnd,!1),this._domElement.addEventListener(`contextmenu`,this._$onContextmenu,!1)}F.prototype.destroy=function(){this._domElement.removeEventListener(`click`,this._$onClick,!1),this._domElement.removeEventListener(`dblclick`,this._$onDblClick,!1),this._domElement.removeEventListener(`mousemove`,this._$onMouseMove,!1),this._domElement.removeEventListener(`mousedown`,this._$onMouseDown,!1),this._domElement.removeEventListener(`mouseup`,this._$onMouseUp,!1),this._domElement.removeEventListener(`touchmove`,this._$onTouchMove,!1),this._domElement.removeEventListener(`touchstart`,this._$onTouchStart,!1),this._domElement.removeEventListener(`touchend`,this._$onTouchEnd,!1),this._domElement.removeEventListener(`contextmenu`,this._$onContextmenu,!1)},F.eventNames=[`click`,`dblclick`,`mouseover`,`mouseout`,`mousemove`,`mousedown`,`mouseup`,`contextmenu`,`touchstart`,`touchend`],F.prototype._getRelativeMouseXY=function(e){var t=e.target||e.srcElement;t.nodeType===3&&(t=t.parentNode);var n={x:0,y:0},r=t,i=getComputedStyle(r,null);n.y+=parseInt(i.getPropertyValue(`padding-top`),10),n.x+=parseInt(i.getPropertyValue(`padding-left`),10);do n.x+=r.offsetLeft,n.y+=r.offsetTop,i=getComputedStyle(r,null),n.x+=parseInt(i.getPropertyValue(`border-left-width`),10),n.y+=parseInt(i.getPropertyValue(`border-top-width`),10);while(r=r.offsetParent);var a={width:t===window?window.innerWidth:t.offsetWidth,height:t===window?window.innerHeight:t.offsetHeight};return{x:Number((e.pageX-n.x)/a.width)*2-1,y:-((e.pageY-n.y)/a.height)*2+1}},F.prototype._objectCtxInit=function(e){e._3xDomEvent={}},F.prototype._objectCtxDeinit=function(e){delete e._3xDomEvent},F.prototype._objectCtxIsInit=function(e){return!!e._3xDomEvent},F.prototype._objectCtxGet=function(e){return e._3xDomEvent},F.prototype.camera=function(e){return e&&(this._camera=e),this._camera},F.prototype.bind=function(e,t,n,r){console.assert(F.eventNames.indexOf(t)!==-1,`not available events:`+t),this._objectCtxIsInit(e)||this._objectCtxInit(e);var i=this._objectCtxGet(e);i[t+`Handlers`]||(i[t+`Handlers`]=[]),i[t+`Handlers`].push({callback:n,useCapture:r}),this._boundObjs[t]===void 0&&(this._boundObjs[t]=[]),this._boundObjs[t].push(e)},F.prototype.addEventListener=F.prototype.bind,F.prototype.unbind=function(e,t,n,r){console.assert(F.eventNames.indexOf(t)!==-1,`not available events:`+t),this._objectCtxIsInit(e)||this._objectCtxInit(e);var i=this._objectCtxGet(e);i[t+`Handlers`]||(i[t+`Handlers`]=[]);for(var a=i[t+`Handlers`],o=0;o<a.length;o++){var s=a[o];if(n==s.callback&&r==s.useCapture){a.splice(o,1);break}}var c=this._boundObjs[t].indexOf(e);this._boundObjs[t].splice(c,1)},F.prototype.removeEventListener=F.prototype.unbind,F.prototype._bound=function(e,t){var n=this._objectCtxGet(t);return n?!!n[e+`Handlers`]:!1},F.prototype._isObjectVisible=function(e){for(var t=e;t;){if(t.visible===!1)return!1;t=t.parent}return!0},F.prototype._filterVisibleObjects=function(e){var t=this;return e.filter(function(e){return t._isObjectVisible(e)})},F.prototype._onMove=function(e,t,n,r){var i=this._boundObjs[e];if(!(i===void 0||i.length===0)){var a=this._filterVisibleObjects(i);if(a.length!==0){var o=new l.Vector2;o.set(t,n),this._raycaster.setFromCamera(o,this._camera);var s=this._raycaster.intersectObjects(a),c=this;s=s.filter(function(e){return c._isObjectVisible(e.object)}),s.sort(function(e,t){var n=e.object.renderOrder||0,r=t.object.renderOrder||0;return n===r?e.distance-t.distance:r-n});var u=this._selected;if(s.length>0){var d,f,p,m=s[0],h=m.object;this._selected=h,p=this._bound(`mousemove`,h),u!=h&&(d=this._bound(`mouseover`,h),f=u&&this._bound(`mouseout`,u))}else f=u&&this._bound(`mouseout`,u),this._selected=null;p&&this._notify(`mousemove`,h,r,m),d&&this._notify(`mouseover`,h,r,m),f&&this._notify(`mouseout`,u,r,m)}}},F.prototype._onEvent=function(e,t,n,r){var i=this._boundObjs[e];if(!(i===void 0||i.length===0)){var a=this._filterVisibleObjects(i);if(a.length!==0){var o=new l.Vector2;o.set(t,n),this._raycaster.setFromCamera(o,this._camera);var s=this._raycaster.intersectObjects(a,!0),c=this;if(s=s.filter(function(e){return c._isObjectVisible(e.object)}),s.sort(function(e,t){var n=e.object.renderOrder||0,r=t.object.renderOrder||0;return n===r?e.distance-t.distance:r-n}),s.length!==0){for(var u=s[0],d=u.object,f=this._objectCtxGet(d),p=d.parent;f===void 0&&p;)f=this._objectCtxGet(p),p=p.parent;f&&this._notify(e,d,r,u)}}}},F.prototype._notify=function(e,t,n,r){var i=this._objectCtxGet(t),a=i?i[e+`Handlers`]:null;if(!i||!a||a.length===0){t.parent&&this._notify(e,t.parent,n,r);return}for(var a=i[e+`Handlers`],o=0;o<a.length;o++){var s=a[o],c=!0;s.callback({type:e,target:t,origDomEvent:n,intersect:r,stopPropagation:function(){c=!1}}),c&&s.useCapture===!1&&t.parent&&this._notify(e,t.parent,n,r)}},F.prototype._onMouseDown=function(e){return this._onMouseEvent(`mousedown`,e)},F.prototype._onMouseUp=function(e){return this._onMouseEvent(`mouseup`,e)},F.prototype._onMouseEvent=function(e,t){var n=this._getRelativeMouseXY(t);this._onEvent(e,n.x,n.y,t)},F.prototype._onMouseMove=function(e){var t=this._getRelativeMouseXY(e);this._onMove(`mousemove`,t.x,t.y,e),this._onMove(`mouseover`,t.x,t.y,e),this._onMove(`mouseout`,t.x,t.y,e)},F.prototype._onClick=function(e){this._onMouseEvent(`click`,e)},F.prototype._onDblClick=function(e){this._onMouseEvent(`dblclick`,e)},F.prototype._onContextmenu=function(e){this._onMouseEvent(`contextmenu`,e)},F.prototype._onTouchStart=function(e){return this._onTouchEvent(`touchstart`,e)},F.prototype._onTouchEnd=function(e){return this._onTouchEvent(`touchend`,e)},F.prototype._onTouchMove=function(e){if(e.touches.length==1){var t=Number(e.touches[0].pageX/window.innerWidth)*2-1,n=-(e.touches[0].pageY/window.innerHeight)*2+1;this._onMove(`mousemove`,t,n,e),this._onMove(`mouseover`,t,n,e),this._onMove(`mouseout`,t,n,e)}},F.prototype._onTouchEvent=function(e,t){var n=t.touches;if(n.length==0&&(n=t.changedTouches),n.length==1){var r=Number(n[0].pageX/window.innerWidth)*2-1,i=-(n[0].pageY/window.innerHeight)*2+1;this._onEvent(e,r,i,t)}};var Te=`Object3DHelperPlugin`,Ee=Te,De=()=>{console.error(`${Ee} is disposed`)},Oe=()=>{console.warn(`${Ee} is disabled`)},ke=()=>{console.error(`${Ee} is disabled`)},Ae=class{constructor(e){this.controllers={},this.state={visible:!0,enabled:!0,disposed:!1},this.hooks=new c.Subscribe,e&&this.addControllers(e),this.setState(this.state)}show(e){this.setState({visible:!0},e)}hide(e){this.setState({visible:!1},e)}enable(e){this.setState({enabled:!0},e)}disable(e){this.setState({enabled:!1},e)}dispose(){this.setState({disposed:!0})}setState(e,t){if(this.state.disposed||!this.state.enabled&&e.enabled!==!0&&e.disposed!==!0)return;let n=Object.assign({},this.state);this.state=Object.assign(Object.assign({},this.state),e),e.disposed!==void 0&&e.disposed!==n.disposed&&e.disposed&&this.handleDispose(),e.visible!==void 0&&this.handleVisible(e.visible),e.enabled!==void 0&&this.handleEnable(e.enabled),this.hooks.emit(`stateChange`,{state:this.state,prevState:n})}addControllers(e){this.controllers=Object.assign(Object.assign({},this.controllers),e),this.setState(this.state)}initialHelperMatrix(){this.everyControllerDo(e=>{e.initialHelperPosition(),e.initialHelperQuaternion()})}handleEnable(e,t=!0){e?(this.everyControllerDo(e=>e.enable()),this.hooks.emit(`enable`,{userAction:t})):(this.everyControllerDo(e=>e.disable()),this.hooks.emit(`disable`,{userAction:t}))}handleVisible(e,t=!0){e?(this.everyControllerDo(e=>e.show()),this.state.enabled&&this.hooks.emit(`show`,{userAction:t})):(this.everyControllerDo(e=>e.hide()),this.state.enabled&&this.hooks.emit(`hide`,{userAction:t}))}handleDispose(){Object.values(this.controllers).forEach(e=>{e==null||e.dispose()})}everyControllerDo(e){Object.values(this.controllers).forEach(t=>{t&&e(t)})}},je=class extends h.Controller{constructor(e){super(e),this.name=Te,this.state={visible:!0,enabled:!0,disposed:!1},this.objectHelperMap=new Map,this.five=e}show(e){return f(this,void 0,void 0,function*(){this.setState({visible:!0},e)})}hide(e){return f(this,void 0,void 0,function*(){this.setState({visible:!1},e)})}enable(e){this.setState({enabled:!0},e)}disable(e){this.setState({enabled:!1},e)}dispose(){this.setState({disposed:!0})}load(e){return f(this,void 0,void 0,function*(){})}setState(e,t){var n;if(this.state.disposed)return De();if(!this.state.enabled&&e.enabled!==!0&&e.disposed!==!0)return ke();let r=Object.assign({},this.state);this.state=Object.assign(Object.assign({},this.state),e),e.disposed!==void 0&&e.disposed!==r.disposed&&e.disposed&&this.handleDispose(),e.visible!==void 0&&e.visible!==r.visible&&this.handleVisible(e.visible),e.enabled!==void 0&&e.enabled!==r.enabled&&this.handleEnable(e.enabled),this.hooks.emit(`stateChange`,{state:this.state,prevState:r,userAction:(n=t==null?void 0:t.userAction)==null?!0:n})}getObject3DHelper(e){return this.objectHelperMap.get(e)}addObject3DHelper(e,t={}){var n,r;if(!e){console.error(`Object3D is undefined`);return}if(this.objectHelperMap.has(e)){console.warn(`Object3DHelperPlugin: object3D ${e.name} already has helper`);return}let i=new Ae,a=[],o=(n=this.five.getElement())==null?void 0:n.parentElement;this.five.camera;let s=Object.assign(Object.assign({},{moveHelper:!0,rotateHelper:!0,boundingBoxHelper:!1,moveHelperTips:!1,positionFrom:`objectPosition`}),t),{moveHelper:u,rotateHelper:d,boundingBoxHelper:f}=s,p=new l.Group;s.helperOffset&&p.position.copy(s.helperOffset),this.five.scene.add(p);let m=i.hooks,h=new c.Subscribe,g=new F(this.five.camera,this.five.getElement()),_=e=>{if(e)return typeof e==`boolean`?e:e.enable},v={};if(_(u)){let t=Object.assign(Object.assign({},this.getConfig(s.moveHelper)),s),n=new ce(e,Object.assign({container:o==null?void 0:o,moveTipsEnable:(r=s.moveHelperTips)==null?!1:r},t)),i=new P(this.five,g,xe,e,n,t,m,h,p);v.moveController=i.helperController,a.push(()=>i.dispose())}if(_(d)){let t=Object.assign(Object.assign({},this.getConfig(s.rotateHelper)),s),n=new le(e,Object.assign({container:o==null?void 0:o},t)),r=new P(this.five,g,Ce,e,n,t,m,h,p);v.rotateController=r.helperController,a.push(()=>r.dispose())}if(_(f)){let t=new pe(e),n=new P(this.five,g,we,e,t,void 0,m,h,p);v.boundingBoxController=n.helperController,a.push(()=>n.dispose())}return Object.values(v).forEach(e=>{e&&typeof e.updateOtherControllers==`function`&&e.updateOtherControllers(v)}),i.addControllers(v),this.objectHelperMap.set(e,{helper:i,disposers:a,helperGroup:p}),i.controllers}removeObject3DHelper(e){if(!this.objectHelperMap.has(e))return;let{helper:t,disposers:n,helperGroup:r}=this.objectHelperMap.get(e);this.objectHelperMap.delete(e),t.dispose(),n==null||n.forEach(e=>e==null?void 0:e()),r.parent&&r.parent.remove(r)}handleEnable(e,t=!0){e?(this.everyHelperDo(e=>e.enable()),this.hooks.emit(`enable`,{userAction:t})):(this.everyHelperDo(e=>e.disable()),this.hooks.emit(`disable`,{userAction:t})),this.state.enabled=e}handleVisible(e,t=!0){e?(this.everyHelperDo(e=>e.show()),this.actionIfStateIsEnabled(()=>this.hooks.emit(`show`,{userAction:t}))):(this.everyHelperDo(e=>e.hide()),this.actionIfStateIsEnabled(()=>this.hooks.emit(`hide`,{userAction:t}))),this.state.visible=e}handleDispose(){this.objectHelperMap.forEach(({helper:e,disposers:t,helperGroup:n})=>{e.dispose(),t==null||t.forEach(e=>e==null?void 0:e()),n.parent&&n.parent.remove(n)}),this.objectHelperMap.clear()}everyHelperDo(e){this.objectHelperMap.forEach(({helper:t,disposers:n})=>{t&&e(t,n)})}actionIfStateIsEnabled(e,t){if(this.state.enabled)return e();t!=null&&t.warnLog&&Oe()}getConfig(e){if(e&&typeof e!=`boolean`&&e.enable)return e}},Me=e=>new je(e);function Ne(e,t,n){return e<t?t:e>n?n:e}function Pe(){let e={map:(0,u.texture)(new l.Texture),progress:(0,u.uniform)(0),opacity:(0,u.uniform)(0)},t=(0,u.Fn)(()=>{let t=(0,u.uv)(),n=(0,u.varying)(u.positionGeometry);(0,u.Discard)(t.y.greaterThan(e.progress));let r=e.map.sample(t),i=(0,u.vec4)((0,u.vec3)(1,1,1),e.progress.sub(n.y).mul(.7)),a=i.add((0,u.vec4)(r.rgb,r.a.mul(n.y.oneMinus()))),o=(0,u.select)(e.progress.equal(1),a,i);return(0,u.vec4)(o.rgb,o.a.mul(e.opacity))}),n=new l.NodeMaterial;return n.fragmentNode=t(),n.transparent=!0,n.depthTest=!1,{material:n,u:e}}var Fe=[1,5,2,6,3,7,4,8,9,13,10,14,11,15,12,16],Ie=512,Le=512,I=128,Re=class extends h.Controller{get config(){return Object.assign({},this._config)}updateState(e,t){let n=this.state;this.state=Object.assign(Object.assign({},this.state),e),this.hooks.emit(`stateChange`,{state:this.state,prevState:n,userAction:t})}updateConfig(e,t={}){var n;let r=this.config,i=Object.assign(Object.assign({},r),e);this._config=i,this.hooks.emit(`configChange`,{prevConfig:r,config:i,userAction:(n=t.userAction)==null?!0:n})}constructor(e,t){super(e),this.group=new l.Group,this.materialUniforms=Pe(),this.mesh=(()=>{let e=new l.CylinderGeometry(.12,.12,1,32,1,!0);return e.translate(0,.5,0),new l.Mesh(e,this.materialUniforms.material)})(),this.panoMesh=new c.PanoCircleMesh({scale:1.5}),this.stop=()=>{},this.drawLine=(e,t)=>{if(!this.ctx)return;let n=(()=>{var t;return 32*((t=Fe[e])==null?0:t)})(),r=(1-(t+e*150)%1200/1200)*640,i=this.ctx.createLinearGradient(0,r-I,0,r);i.addColorStop(0,`rgba(255,255,255,0)`),i.addColorStop(.5,`rgba(255,255,255,1)`),i.addColorStop(1,`rgba(255,255,255,0)`),this.ctx.fillStyle=i,this.ctx.fillRect(n,r-I,3,I)},this.anime=e=>{if(!this.ctx||!this.startTime)return;this.ctx.clearRect(0,0,Ie,Le);for(let t=0;t<16;t++)this.drawLine(t,e-this.startTime);let t=Ne((e-this.startTime)/1e3,0,1),n=Ne((e-this.startTime)/300,0,this.config.maxOpacity);this.panoMesh.setOpacity(n),this.materialUniforms.u.progress.value=t,this.materialUniforms.u.opacity.value=n,this.canvasTexture&&(this.canvasTexture.needsUpdate=!0),this.five.needsRender=!0},this.dispose=()=>{this.disable()},this.five=e;let n={enabled:!1,visible:!0};this.state=Object.assign(n,t==null?void 0:t.initialState);let r=Object.assign(Object.assign({},t==null?void 0:t.config),{maxOpacity:1});this._config=r,!(typeof document>`u`)&&(this.canvas=document.createElement(`canvas`),this.ctx=this.canvas.getContext(`2d`),this.canvas.width=Ie,this.canvas.height=Le,this.ctx.shadowColor=`rgba(255,255,255,0.5)`,this.ctx.shadowBlur=6,this.ctx.shadowOffsetX=0,this.ctx.shadowOffsetY=0,this.canvasTexture=new l.CanvasTexture(this.canvas),this.materialUniforms.u.map.value=this.canvasTexture,this.group.add(this.mesh),this.panoMesh.setProgress(1),this.panoMesh.setOpacity(0),this.group.add(this.panoMesh),this.state.enabled&&this._enable({userAction:!1}))}load(e){return f(this,void 0,void 0,function*(){})}_enable(e){this.mesh.position.copy(this.five.observers[this.five.state.panoIndex].standingPosition),this.panoMesh.position.copy(this.five.observers[this.five.state.panoIndex].standingPosition),this.five.ready().then(()=>{this.five.scene.add(this.group),this.stop=c.AnimationFrameLoop.shared.add((e,t)=>{this.startTime||(this.startTime=e),this.panoMesh.updateTime(e,t),this.anime(e)})})}_disable(e){this.five.scene.remove(this.group),this.panoMesh.setOpacity(0),this.startTime=void 0,this.stop(),this.five.needsRender=!0}enable(e){var t;if(!this.ctx||this.state.enabled||!this.five.observers[this.five.state.panoIndex])return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this.updateState({enabled:!0},n),this._enable({userAction:n})}disable(e){var t;if(this.state.enabled===!1)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this.updateState({enabled:!1},n),this._disable({userAction:n})}setState(e,t={}){let n=this.state,r=t.userAction===void 0?!0:t.userAction;if(this.updateState(e,r),e.enabled!==void 0&&n.enabled!==e.enabled){let t={userAction:r};e.enabled?this._enable(t):this._disable(t)}}},ze=(e,t)=>new Re(e,t),Be=class extends l.Object3D{constructor(e=document.createElement(`div`)){super(),this.isCSS2DObject=!0,this.element=e,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.center=new l.Vector2(.5,.5),this.addEventListener(`removed`,function(){this.traverse(function(e){e.element&&e.element instanceof Element&&e.element.parentNode!==null&&e.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this.center=e.center.clone(),this}},L=new l.Vector3,Ve=new l.Matrix4,He=new l.Matrix4,Ue=new l.Vector3,We=new l.Vector3,Ge=class{constructor(e={}){let t=this,n,r,i,a,o={objects:new WeakMap},s=e.element===void 0?document.createElement(`div`):e.element;s.style.overflow=`hidden`,this.domElement=s,this.sortObjects=!0,this.getSize=function(){return{width:n,height:r}},this.render=function(e,n){e.updateMatrixWorld(),n.parent===null&&n.updateMatrixWorld(),Ve.copy(n.matrixWorldInverse),He.multiplyMatrices(n.projectionMatrix,Ve),l(e,e,n),t.sortObjects&&f(e)},this.setSize=function(e,t){n=e,r=t,i=n/2,a=r/2,s.style.width=e+`px`,s.style.height=t+`px`};function c(e){e.isCSS2DObject&&(e.element.style.display=`none`);for(let t=0,n=e.children.length;t<n;t++)c(e.children[t])}function l(e,n,r){if(e.visible===!1){c(e);return}if(e.isCSS2DObject){L.setFromMatrixPosition(e.matrixWorld),L.applyMatrix4(He);let c=L.z>=-1&&L.z<=1&&e.layers.test(r.layers)===!0,l=e.element;l.style.display=c===!0?``:`none`,c===!0&&(e.onBeforeRender(t,n,r),l.style.transform=`translate(`+-100*e.center.x+`%,`+-100*e.center.y+`%)translate(`+(L.x*i+i)+`px,`+(-L.y*a+a)+`px)`,l.parentNode!==s&&s.appendChild(l),e.onAfterRender(t,n,r));let d={distanceToCameraSquared:u(r,e)};o.objects.set(e,d)}for(let t=0,i=e.children.length;t<i;t++)l(e.children[t],n,r)}function u(e,t){return Ue.setFromMatrixPosition(e.matrixWorld),We.setFromMatrixPosition(t.matrixWorld),Ue.distanceToSquared(We)}function d(e){let t=[];return e.traverseVisible(function(e){e.isCSS2DObject&&t.push(e)}),t}function f(e){let t=d(e).sort(function(e,t){return e.renderOrder===t.renderOrder?o.objects.get(e).distanceToCameraSquared-o.objects.get(t).distanceToCameraSquared:t.renderOrder-e.renderOrder}),n=t.length;for(let e=0,r=t.length;e<r;e++)t[e].element.style.zIndex=n-e}}},Ke=`#five-CSS2DPlugin {
277
+ position: absolute;
278
+ pointer-events: none;
279
+ user-select: none;
280
+ top: 0;
281
+ left: 0;
282
+ }
283
+
284
+ .five-CSS2DPlugin-X {
285
+ --timeout: 300ms;
286
+ transition: opacity ease-in-out var(--timeout);
287
+ }
288
+
289
+ .five-CSS2DPlugin-hidden {
290
+ opacity: 0;
291
+ }
292
+
293
+ #five-CSS2DPlugin .five-CSS2DPlugin-hidden * {
294
+ pointer-events: none;
295
+ }
296
+ `;function qe(){return((1+Math.random())*parseInt(`10000`,36)|0).toString(36).substring(1)}function Je(){let e=qe()+qe().substr(0,2)+Date.now().toString(36),t=e.length,n=``,r=Math.floor(Math.random()*Math.pow(2,t));for(let i=0;i<t;i++){let t=e[i];t>=`a`&&t<=`z`&&r>>i&1&&(t=t.toUpperCase()),n+=t}return`u-`+n}var Ye=class extends h.Controller{updateState(e,t){let n=this.state;this.state=Object.assign(Object.assign({},this.state),e),this.hooks.emit(`stateChange`,{state:this.state,prevState:n,userAction:t})}constructor(e,t){super(e),this.scene=new l.Scene,this.styleSheet=new CSSStyleSheet,this.camera=new l.PerspectiveCamera,this.createCSS2DObject=({id:e=Je(),name:t,innerHTML:n,center:r,position:i,visible:a=!0,timeout:o})=>{let s=document.createElement(`div`);s.className=`five-CSS2DPlugin-X`,a||s.classList.add(`five-CSS2DPlugin-hidden`),o&&s.style.setProperty(`--timeout`,o+`ms`),s.innerHTML=n;let c=new Be(s);return c.userData={id:e,_visible:a,_timeout:o,get visible(){return this._visible},set visible(e){e?s.classList.remove(`five-CSS2DPlugin-hidden`):s.classList.add(`five-CSS2DPlugin-hidden`),this._visible=e},get timeout(){return this._timeout},set timeout(e){s.style.setProperty(`--timeout`,e+`ms`),this._timeout=e}},r&&c.center.copy(r),i&&c.position.copy(i),t&&(c.name=t),c},this.render=()=>{this.camera.fov=this.five.camera.fov,this.camera.aspect=this.five.camera.aspect,this.camera.position.copy(this.five.camera.position),this.camera.rotation.copy(this.five.camera.rotation),this.camera.updateProjectionMatrix(),this.renderer.render(this.scene,this.camera)},this._addEventListener=()=>{this.five.on(`render.prepare`,this.render),this.appendToFiveContainer()},this._removeEventListener=()=>{var e;this.five.off(`render.prepare`,this.render),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=void 0},this.dispose=()=>{this.removeAll(),this._disable({userAction:!1})},this.five=e,this.renderer=new Ge,this.renderer.domElement.id=`five-CSS2DPlugin`,this.styleSheet.replaceSync(Ke),document&&document.adoptedStyleSheets.push(this.styleSheet);let n={enabled:!0,visible:!0};this.state=Object.assign(n,t==null?void 0:t.initialState),this.state.enabled?this._enable({userAction:!1}):this.styleSheet.disabled=!0}load(e){return f(this,void 0,void 0,function*(){})}appendToFiveContainer(){var e;if(!this.five.renderer)return;let t=this.five.getElement();if(!(t!=null&&t.parentElement))return;let{x:n,y:r}=this.five.renderer.getSize(new l.Vector2);t.parentElement.appendChild(this.renderer.domElement),this.renderer.setSize(n,r),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=new ResizeObserver(()=>{var e;if(!this.five.renderer)return;let t=(e=this.five.getElement())==null?void 0:e.getBoundingClientRect();if(!t)return;let{x:n,y:r,width:i,height:a}=t;this.renderer.setSize(i,a),this.renderer.domElement.style.left=n+`px`,this.renderer.domElement.style.top=r+`px`,this.render()}),this.resizeObserver.observe(t)}add(...e){this.scene.add(...e),this.render()}remove(e){this.scene.remove(e),e.traverse(e=>{e instanceof Be&&e.element.remove()}),this.render()}removeAll(){this.scene.remove(...this.scene.children),this.render()}fadeInObjects(...e){for(let t of e)t.userData.visible=!0;this.render()}fadeOutObjects(...e){for(let t of e)t.userData.visible=!1;this.render()}_enable(e){this.styleSheet.disabled=!1,this.updateState({enabled:!0},e.userAction),this._addEventListener(),this.render()}_disable(e){this.styleSheet.disabled=!0,this.updateState({enabled:!1},e.userAction),this._removeEventListener()}enable(e){var t;if(this.state.enabled)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this._enable({userAction:n})}disable(e){var t;if(this.state.enabled===!1)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this._disable({userAction:n})}show(e){this.renderer.domElement.style.display=`block`,this.updateState({visible:!0},!0),this.render()}hide(e){this.renderer.domElement.style.display=`none`,this.updateState({visible:!1},!0)}},Xe=(e,t)=>new Ye(e,t),R=new l.Vector3,Ze=new l.Quaternion,z=new l.Vector3,B=class extends l.Object3D{constructor(e=document.createElement(`div`)){super(),this.isCSS3DObject=!0,this.element=e,this.element.style.position=`absolute`,this.element.style.userSelect=`none`,this.element.setAttribute(`draggable`,!1),this.addEventListener(`removed`,function(){this.traverse(function(e){e.element&&e.element instanceof Element&&e.element.parentNode!==null&&e.element.remove()})})}copy(e,t){return super.copy(e,t),this.element=e.element.cloneNode(!0),this}},Qe=class extends B{constructor(e){super(e),this.isCSS3DSprite=!0,this.rotation2D=0}copy(e,t){return super.copy(e,t),this.rotation2D=e.rotation2D,this}},V=new l.Matrix4,$e=new l.Matrix4,et=class{constructor(e={}){let t=this,n,r,i,a,o={camera:{style:``},objects:new WeakMap},s=e.element===void 0?document.createElement(`div`):e.element;s.style.overflow=`hidden`,this.domElement=s;let c=document.createElement(`div`);c.style.transformOrigin=`0 0`,c.style.pointerEvents=`none`,s.appendChild(c);let l=document.createElement(`div`);l.style.transformStyle=`preserve-3d`,c.appendChild(l),this.getSize=function(){return{width:n,height:r}};let u=!0,d=new Set;this.markDirty=function(){u=!0},this.updateSpriteSet=function(e){d.clear(),e.traverse(function(e){e.isCSS3DSprite&&d.add(e)})};function f(e,n,r){if(e.visible===!1)return;let i=e.layers.test(r.layers)===!0,a=e.element;if(a.style.display=i===!0?``:`none`,i===!0){e.onBeforeRender(t,n,r),V.copy(r.matrixWorldInverse),V.transpose(),e.rotation2D!==0&&V.multiply($e.makeRotationZ(e.rotation2D)),e.matrixWorld.decompose(R,Ze,z),V.setPosition(R),V.scale(z),V.elements[3]=0,V.elements[7]=0,V.elements[11]=0,V.elements[15]=1;let i=h(V),s=o.objects.get(e);(s===void 0||s.style!==i)&&(a.style.transform=i,o.objects.set(e,{style:i})),a.parentNode!==l&&l.appendChild(a),e.onAfterRender(t,n,r)}}this.render=function(e,t){let n=t.projectionMatrix.elements[5]*a;e.updateMatrixWorld(),t.parent===null&&t.updateMatrixWorld();let r,s;t.isOrthographicCamera&&(r=-(t.right+t.left)/2,s=(t.top+t.bottom)/2);let c=t.isOrthographicCamera?`scale(`+n+`)translate(`+p(r)+`px,`+p(s)+`px)`+m(t.matrixWorldInverse):`translateZ(`+n+`px)`+m(t.matrixWorldInverse),h=(t.isPerspectiveCamera?`perspective(`+n+`px) `:``)+c+` translate(`+i+`px,`+a+`px)`;if(o.camera.style!==h&&(l.style.transform=h,o.camera.style=h),u)_(e,e,t,c),u=!1;else if(d.size>0)for(let n of d)f(n,e,t)},this.setSize=function(e,t){n=e,r=t,i=n/2,a=r/2,s.style.width=e+`px`,s.style.height=t+`px`,c.style.width=e+`px`,c.style.height=t+`px`,l.style.width=e+`px`,l.style.height=t+`px`};function p(e){return Math.abs(e)<1e-10?0:e}function m(e){let t=e.elements;return`matrix3d(`+p(t[0])+`,`+p(-t[1])+`,`+p(t[2])+`,`+p(t[3])+`,`+p(t[4])+`,`+p(-t[5])+`,`+p(t[6])+`,`+p(t[7])+`,`+p(t[8])+`,`+p(-t[9])+`,`+p(t[10])+`,`+p(t[11])+`,`+p(t[12])+`,`+p(-t[13])+`,`+p(t[14])+`,`+p(t[15])+`)`}function h(e){let t=e.elements;return`translate(-50%,-50%) matrix3d(${[t[0],t[1],t[2],t[3],-t[4],-t[5],-t[6],-t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15]].map(e=>Math.abs(e)<1e-10?0:e).join(`,`)})`}function g(e){e.isCSS3DObject&&(e.element.style.display=`none`);for(let t=0,n=e.children.length;t<n;t++)g(e.children[t])}function _(e,n,r,i){if(e.visible===!1){g(e);return}if(e.isCSS3DObject){let i=e.layers.test(r.layers)===!0,a=e.element;if(a.style.display=i===!0?``:`none`,i===!0){e.onBeforeRender(t,n,r);let i;e.isCSS3DSprite?(V.copy(r.matrixWorldInverse),V.transpose(),e.rotation2D!==0&&V.multiply($e.makeRotationZ(e.rotation2D)),e.matrixWorld.decompose(R,Ze,z),V.setPosition(R),V.scale(z),V.elements[3]=0,V.elements[7]=0,V.elements[11]=0,V.elements[15]=1,i=h(V)):i=h(e.matrixWorld);let s=o.objects.get(e);if(s===void 0||s.style!==i){a.style.transform=i;let t={style:i};o.objects.set(e,t)}a.parentNode!==l&&l.appendChild(a),e.onAfterRender(t,n,r)}}for(let t=0,a=e.children.length;t<a;t++)_(e.children[t],n,r,i)}}},tt=`#five-CSS3DPlugin {
297
+ position: absolute;
298
+ pointer-events: none;
299
+ user-select: none;
300
+ transform-origin: left top;
301
+ }
302
+
303
+ .five-CSS3DPlugin-X {
304
+ --timeout: 300ms;
305
+ transition: opacity ease-in-out var(--timeout);
306
+ }
307
+
308
+ .five-CSS3DPlugin-hidden {
309
+ opacity: 0;
310
+ }
311
+
312
+ #five-CSS3DPlugin .five-CSS3DPlugin-hidden * {
313
+ pointer-events: none;
314
+ }
315
+ `,nt=class extends h.Controller{updateState(e,t){let n=this.state;this.state=Object.assign(Object.assign({},this.state),e),this.hooks.emit(`stateChange`,{state:this.state,prevState:n,userAction:t})}constructor(e,t){super(e),this.scene=new l.Scene,this.styleSheet=new CSSStyleSheet,this.camera=new l.PerspectiveCamera,this.cacheMap=new WeakMap,this.createCSS3DObject=({id:e=Je(),name:t,innerHTML:n,sprite:r,normal:i,position:a,scalar:o=.00216,visible:s=!0,timeout:c})=>{let u=document.createElement(`div`);u.className=`five-CSS3DPlugin-X`,s||u.classList.add(`five-CSS3DPlugin-hidden`),c&&u.style.setProperty(`--timeout`,c+`ms`),u.innerHTML=n;let d=r?new Qe(u):new B(u);if(d.userData={id:e,_visible:s,_timeout:c,get visible(){return this._visible},set visible(e){e?u.classList.remove(`five-CSS3DPlugin-hidden`):u.classList.add(`five-CSS3DPlugin-hidden`),this._visible=e},get timeout(){return this._timeout},set timeout(e){u.style.setProperty(`--timeout`,e+`ms`),this._timeout=e}},i){let e=new l.Vector3(0,0,1),t=new l.Quaternion().setFromUnitVectors(e,i.clone().normalize());d.quaternion.copy(t)}return a&&d.position.copy(a),o&&d.scale.setScalar(o),t&&(d.name=t),d},this.render=()=>{this.camera.fov=this.five.camera.fov,this.camera.aspect=this.five.camera.aspect,this.camera.position.copy(this.five.camera.position),this.camera.rotation.copy(this.five.camera.rotation),this.camera.updateProjectionMatrix(),this.renderer.render(this.scene,this.camera)},this.forceRender=()=>{this.renderer.markDirty(),this.render()},this._addEventListener=()=>{this.five.on(`render.prepare`,this.render),this.appendToFiveContainer()},this._removeEventListener=()=>{var e;this.five.off(`render.prepare`,this.render),(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=void 0},this.dispose=()=>{this.removeAll(),this._disable({userAction:!1})},this.five=e,this.renderer=new et,this.renderer.domElement.id=`five-CSS3DPlugin`,this.styleSheet.replaceSync(tt),/Chrome/.test(navigator.userAgent)&&!/Edge|Edg|OPR/.test(navigator.userAgent)&&this.styleSheet.insertRule(`#five-CSS3DPlugin * { transform-style: preserve-3d; }`),document&&document.adoptedStyleSheets.push(this.styleSheet);let n={enabled:!0,visible:!0};this.state=Object.assign(n,t==null?void 0:t.initialState),this.state.enabled?this._enable({userAction:!1}):this.styleSheet.disabled=!0}load(e){return f(this,void 0,void 0,function*(){})}appendToFiveContainer(){var e;if(!this.five.renderer)return;let t=this.five.getElement();if(!(t!=null&&t.parentElement))return;let{x:n,y:r}=this.five.renderer.getSize(new l.Vector2);t.parentElement.appendChild(this.renderer.domElement),this.renderer.setSize(n*2,r*2),this.renderer.domElement.style.width=n*2+`px`,this.renderer.domElement.style.height=r*2+`px`,this.renderer.domElement.style.transform=`scale(0.5)`,(e=this.resizeObserver)==null||e.disconnect(),this.resizeObserver=new ResizeObserver(()=>{var e;if(!this.five.renderer)return;let t=(e=this.five.getElement())==null?void 0:e.getBoundingClientRect();if(!t)return;let{x:n,y:r,width:i,height:a}=t;this.renderer.setSize(i*2,a*2),this.renderer.domElement.style.left=n+`px`,this.renderer.domElement.style.top=r+`px`,this.renderer.domElement.style.width=i*2+`px`,this.renderer.domElement.style.height=a*2+`px`,this.render()}),this.resizeObserver.observe(t)}add(...e){this.scene.add(...e),this.renderer.updateSpriteSet(this.scene),this.forceRender()}remove(e){this.scene.remove(e),e.traverse(e=>{e instanceof B&&e.element.remove()}),this.renderer.updateSpriteSet(this.scene),this.forceRender()}removeAll(){this.scene.remove(...this.scene.children),this.renderer.updateSpriteSet(this.scene),this.forceRender()}fadeInObjects(...e){for(let t of e)t.userData.visible=!0;this.render()}fadeOutObjects(...e){for(let t of e)t.userData.visible=!1;this.render()}_enable(e){this.styleSheet.disabled=!1,this.updateState({enabled:!0},e.userAction),this._addEventListener(),this.render()}_disable(e){this.styleSheet.disabled=!0,this.updateState({enabled:!1},e.userAction),this._removeEventListener()}enable(e){var t;if(this.state.enabled)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this._enable({userAction:n})}disable(e){var t;if(this.state.enabled===!1)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this._disable({userAction:n})}show(e){this.renderer.domElement.style.display=`block`,this.updateState({visible:!0},!0),this.forceRender()}hide(e){this.renderer.domElement.style.display=`none`,this.updateState({visible:!1},!0)}},rt=(e,t)=>new nt(e,t);function it(e){return f(this,void 0,void 0,function*(){return Promise.all(e.map(e=>f(this,void 0,void 0,function*(){if(!e.svg_url)return{url:e.url,index:e.index};let t=yield fetch(e.svg_url).then(e=>e.text()).catch(()=>void 0);return{url:e.url,index:e.index,svgUrl:e.svg_url,svgContent:t}})))})}function at(e){let{room_type:t,floor_type:n,room_label:r,observer_indexs:i,customized_name:a,dimension:o}=e,s=d(e,[`room_type`,`floor_type`,`room_label`,`observer_indexs`,`customized_name`,`dimension`]);return Object.assign(Object.assign({},s),{roomType:t,floorType:n,roomLabel:{position:r.position,positionInImage:r.position_in_image},observerIndexs:i,customizedName:a,dimension:o?{width:o.width,height:o.height,vertical:o.vertical,horizontal:o.horizontal}:void 0})}function ot(e){let{floor_name:t,floor_index:n,rooms:r}=e,i=d(e,[`floor_name`,`floor_index`,`rooms`]);return Object.assign(Object.assign({},i),{floorName:t,floorIndex:n,rooms:r.map(at)})}function st(e){return{floorIndex:e.floor_index,positionInImage:e.position_in_image}}function ct(e){return{positionInImage:e.position_in_image,northRad:e.north_rad,roomId:e.room_id,floorIndex:e.floor_index}}function lt(e){return f(this,void 0,void 0,function*(){var t,n;let{computed_data:r}=e;return{outlines:yield it((t=e.outlines)==null?[]:t),bounding:r.bounding,floorDatas:r.floor_datas.map(ot),entrance:r.entrance?ct(r.entrance):null,observers:((n=r.observers)==null?[]:n).map(st)}})}function H(e,t,n=2){return Number(e.toFixed(n))===Number(t.toFixed(n))}function ut(e,t,n=2){let r=Math.PI*2,i=e=>(e%r+r)%r,a=i(e),o=i(t),s=Math.min(Math.abs(a-o),r-Math.abs(a-o));return Number(s.toFixed(n))===0}function U(e){return f(this,void 0,void 0,function*(){try{return[null,yield e]}catch(e){return e instanceof Error?[e,null]:[Error(String(e)),null]}})}function dt(e){return Object.prototype.toString.call(e)===`[object Object]`&&!!e.isVector3}function ft(e,t){return Object.keys(e).every(n=>{let r=t[n],i=e[n];return r===void 0||i===void 0?!0:n===`longitude`||n===`latitude`?ut(r,i,2):typeof r==`number`&&typeof i==`number`?H(r,i,2):dt(i)&&dt(r)?i.distanceTo(r)<.01:r===i})}function pt(e,t){return f(this,void 0,void 0,function*(){let[n]=yield U(e.changeMode(...t));if(n)throw Error(`change mode canceled`);yield new Promise(t=>{e.once(`initAnimationWillStart`,()=>{e.once(`initAnimationEnded`,()=>t())})});let r=t[1];if(r&&!ft(r,e.getCurrentState()))throw Error(`pose 与预期不符`)})}function mt(e,t,n){let r=e.modelScene.boundingBox,i=r.isEmpty()?10:Math.pow(Math.pow(r.max.x-r.min.x+1,2)+Math.pow(r.max.y-r.min.y+1,2)+Math.pow(r.max.z-r.min.z+1,2),1/2),a=i/2/Math.tan(Math.PI*t/360);return n<1&&(a/=n),Number.isNaN(a)?i:a}function W(e,t){let n=Object.assign({},e);for(let e of t)delete n[e];return n}function ht(e,t){if(e.currentMode!==t.mode)return!1;let n=e.getCurrentState(),r=e.camera.fov;return!(!H(n.latitude,t.latitude,2)||!H(n.longitude,t.longitude,2)||t.fov!==void 0&&!H(r,t.fov,2)||t.offset&&n.offset.distanceTo(t.offset)>.01)}function gt(e,t){return f(this,arguments,void 0,function*(e,t,n=!0){var r;if(ht(e,t))return;let i=e.getCurrentState();if(e.currentMode!==t.mode){let r=e.models.find(t=>t.name===e.state.workCode),i=typeof t.fov==`number`?t.fov:80;r&&(t.distance=mt(e,i,e.camera.aspect));let[a]=yield U(pt(e,[t.mode,t,void 0,n]));if(a)throw a;return}let{latitude:a,longitude:o,fov:s}=i,c=(r=t.fov)==null?s:r,l=Math.min(1e3,Math.max(200,Math.abs(a-Math.PI/2)*1e3,(o>Math.PI?Math.PI*2-o:o)*500,Number.isFinite(c)?Math.abs(s-c)*10:1/0)),[u]=yield U(e.updateCamera(W(t,[`mode`]),l,n));if(u)throw Error(`UpdateCameraError`)})}function _t(e,t,n=300){let r=e.getElement();if(!r)return;r.style.opacity=t+``;let i=r.parentElement;if(i)for(let e=0;e<i.children.length;e++){let n=i.children[e];n instanceof HTMLElement&&n.dataset.infive===`1`&&(n.style.opacity=t+``)}r.style.transition=n===0?`none`:`opacity ${n}ms linear`,n!==0&&Promise.race([new Promise(e=>r.addEventListener(`transitionend`,()=>e(),{once:!0})),new Promise(e=>setTimeout(e,n))]).then(()=>{r.style.transition=`none`})}function vt(e,t){var n,r;let i=(r=(n=e.work)==null?void 0:n.observers)==null?[]:r;if(t>(i.length?Math.max(...i.map(e=>e.floorIndex)):0))return e.modelScene.boundingBox.max.y;let a=i.filter(e=>e.floorIndex===t).map(e=>e.standingPosition.y);return a.length?Math.max(...a):e.modelScene.boundingBox.min.y}function yt(e,t,n=3){let r=e.modelScene.boundingBox;return n===3?(r.max.y+r.min.y)/2:n===2?vt(e,t+1):vt(e,t)}function bt(e,t,n,r){let i=yt(e,n,r==null?void 0:r.attachedTo),a=new l.Vector3(0,i,0),o=new l.Vector3(1,i,0),s=a.clone().project(e.camera),c=o.clone().project(e.camera);return Math.abs((c.x-s.x)/1e3)*(t.getBoundingClientRect().width/2)}function xt(e){var t;return((t=e.models)==null?void 0:t.filter(t=>t.name===e.state.workCode)[0])||e.model}function St(e){var t;return!!((t=xt(e))!=null&&t.loaded)}function Ct(e){return f(this,void 0,void 0,function*(){return new Promise(t=>{if(St(e)){t();return}let n=r=>{r===xt(e)&&(e.off(`modelLoaded`,n),t())};e.on(`modelLoaded`,n)})})}function G(e){return Object.prototype.toString.call(e)===`[object Object]`}function K(e,t){return!!(e===t||typeof e==`number`&&typeof t==`number`&&Number.isNaN(e)&&Number.isNaN(t))}function wt(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length?n.every(n=>K(e[n],t[n])):!1}function Tt(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length?n.every(n=>q(e[n],t[n])):!1}function Et(e,t){return e.length===t.length?e.every((e,n)=>K(e,t[n])):!1}function Dt(e,t){return e.length===t.length?e.every((e,n)=>q(e,t[n])):!1}function Ot(e,t){return K(e,t)?!0:G(e)&&G(t)?wt(e,t):Array.isArray(e)&&Array.isArray(t)?Et(e,t):!1}function q(e,t){return K(e,t)?!0:G(e)&&G(t)?Tt(e,t):Array.isArray(e)&&Array.isArray(t)?Dt(e,t):!1}function kt(e,t,n={deep:!1}){return n.deep?q(e,t):Ot(e,t)}function J(e,t={}){let n=``,{needZ:r,format:i}=t;return(r?e.slice().concat(e[0]):e.slice()).forEach((e,t)=>{let{x:r,y:a}=i?i(e):e,o=`${r},${a}`;n+=(t===0?`M`:`L`)+o}),n+(r?`Z`:``)}function At({x:e,y:t},n){let{max:r,min:i}=n;return{x:e-i.x,y:r.y-t}}function jt(e,t){let[n,r]=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let[o,s]=t[e],[c,l]=t[a];s>r!=l>r&&n<(c-o)*(r-s)/(l-s)+o&&(i=!i)}return i}function Mt(e,t,n){if(t.width===0||t.height===0)return!1;let r=e.path.map(({x:e,y:t})=>[e,t]),{x:i,y:a}=e.roomLabel.position,o=t.width/2,s=t.height/2,c=i*n,l=a*n,u=r.map(([e,t])=>[e*n,t*n]);return[[c+o,l-s],[c-o,l-s],[c-o,l+s],[c+o,l+s]].every(e=>jt(e,u))}var Nt=`data:image/png;base64,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`,Pt=e=>e*180/Math.PI;function Y(e,t){let n=document.createElement(e);return t&&(n.className=t),n}function X(e,t){let n=document.createElementNS(`http://www.w3.org/2000/svg`,e);if(t)for(let e in t)n.setAttribute(e,t[e]);return n}function Ft(e){let t=Y(`div`,`floorplan-plugin__missing-floor`),{imageURL:n,imageWidth:r=200,imageHeight:i=120,text:a,textFontSize:o=14}=e.missingFloorConfig;if(n){let e=Y(`img`);e.src=n,e.alt=`缺省楼层展位图`,e.style.width=r+`px`,e.style.height=i+`px`,e.style.maxWidth=`none`,t.appendChild(e)}if(a){let e=Y(`span`,`floorplan-plugin__missing-floor-text`);e.style.fontSize=o+`px`,e.textContent=a,t.appendChild(e)}return t}var It=0;function Lt(e,t){e.appendChild(X(`path`,{d:t,fill:`#2F313A`}))}function Rt(e,t){let n=`fpm-room-pattern-tile-${It++}`,r=X(`defs`),i=X(`pattern`,{id:n,x:`0`,y:`0`,width:`12`,height:`12`,patternUnits:`userSpaceOnUse`,patternTransform:`scale(50 50)`});i.appendChild(X(`rect`,{x:`0`,y:`0`,width:`12`,height:`12`,fill:`#323747`})),i.appendChild(X(`path`,{d:`M0 6 h 12 M6 0 v 12`,stroke:`#ffffff`,"stroke-opacity":`0.06`,"stroke-width":`0.5`,fill:`none`})),r.appendChild(i),e.appendChild(r),e.appendChild(X(`path`,{d:t,fill:`url(#${n})`}))}function zt(e,t){let n=`fpm-room-pattern-wood-1-${It++}`,r=`fpm-room-pattern-wood-2-${It++}`,i=X(`defs`),a=X(`pattern`,{id:n,x:`0`,y:`0`,width:`12`,height:`50`,patternUnits:`userSpaceOnUse`,patternTransform:`scale(50 50)`});a.appendChild(X(`rect`,{x:`0`,y:`0`,width:`6`,height:`50`,fill:`none`,stroke:`#4B4B57`,"stroke-width":`0.5`}));let o=X(`pattern`,{id:r,x:`6`,y:`25`,width:`12`,height:`50`,patternUnits:`userSpaceOnUse`,patternTransform:`scale(50 50)`});o.appendChild(X(`rect`,{x:`0`,y:`0`,width:`6`,height:`50`,fill:`none`,stroke:`#4B4B57`,"stroke-width":`0.5`})),i.appendChild(a),i.appendChild(o),e.appendChild(i),e.appendChild(X(`path`,{d:t,fill:`#43434D`})),e.appendChild(X(`path`,{d:t,fill:`url(#${n})`})),e.appendChild(X(`path`,{d:t,fill:`url(#${r})`}))}function Bt(e){let{vertical:t,horizontal:n}=e;if(!(!t||t.length<2||!n||n.length<2))return`${J([{x:t[1].x,y:t[1].y+53},{x:t[1].x-60,y:t[1].y+124},{x:t[1].x+60,y:t[1].y+124}],{needZ:!0})} ${J([{x:t[0].x,y:t[0].y-53},{x:t[0].x-60,y:t[0].y-124},{x:t[0].x+60,y:t[0].y-124}],{needZ:!0})} ${J([{x:n[0].x+53,y:n[0].y},{x:n[0].x+124,y:n[0].y+60},{x:n[0].x+124,y:n[0].y-60}],{needZ:!0})} ${J([{x:n[1].x-53,y:n[1].y},{x:n[1].x-124,y:n[1].y+60},{x:n[1].x-124,y:n[1].y-60}],{needZ:!0})}`}function Vt(e,t,n){let r=Y(`div`,`floorplan-plugin__room-material`),{bounding:i}=t,a=i.max.x-i.min.x,o=i.max.y-i.min.y,s=n.roomLabelsEnable&&n.roomDimensionEnable;for(let t of e.rooms){let e=J(t.path.map(e=>At(e,i)),{needZ:!0}),n=X(`svg`,{width:`100%`,height:`100%`,viewBox:`0 0 ${a} ${o}`});if(t.floorType===1?Lt(n,e):t.floorType===0?zt(n,e):Rt(n,e),r.appendChild(n),s&&t.dimension){let e=Bt(t.dimension);if(e){let t=X(`svg`,{width:`100%`,height:`100%`,viewBox:`0 0 ${a} ${o}`});t.appendChild(X(`path`,{d:e,fill:`#969696`,stroke:`#969696`,"stroke-width":`1`,"fill-rule":`evenodd`})),r.appendChild(t)}}}return r}function Ht(e,t,n){let r=Y(`div`,`floorplan-plugin__room-highlight`),{bounding:i}=t,a=X(`svg`,{width:`100%`,height:`100%`,viewBox:`0 0 ${i.max.x-i.min.x} ${i.max.y-i.min.y}`});for(let t of e.rooms){let e=X(`path`,{d:J(t.path,{needZ:!0,format:e=>At(e,i)}),id:`${n.floorIndex}_${t.id}`}),r=n.highlightData[`${n.floorIndex}_${t.id}`];r&&(r.fill&&(e.style.fill=r.fill),r.opacity!==void 0&&e.style.setProperty(`--opacity`,String(r.opacity)),e.style.pointerEvents=r.disabled?`none`:`auto`),e.addEventListener(`mouseenter`,()=>n.onRoomHover(t)),e.addEventListener(`mouseleave`,()=>n.onRoomHover(null)),a.appendChild(e)}return r.appendChild(a),r}function Ut(e,t){let n=Y(`div`,`floorplan-plugin__base-image`),r=e.outlines[t];if(r!=null&&r.svgContent)n.innerHTML=r.svgContent;else if(r!=null&&r.url){let e=Y(`img`);e.src=r.url,e.alt=`floorplan image`,n.appendChild(e)}return n}function Wt(e){var t;let n=Y(`div`,`floorplan-plugin__items`);for(let r of(t=e.items)==null?[]:t){let e=Y(`div`,`floorplan-plugin__item`);e.style.left=r.positionInImage.x*100+`%`,e.style.top=r.positionInImage.y*100+`%`,e.style.width=r.width*100+`%`,e.style.height=r.height*100+`%`;let t=Y(`img`,`floorplan-plugin__item-img`);if(t.src=r.src,t.alt=``,t.style.transform=`rotate(${r.rotateZ}deg) scaleX(${r.rotateX?-1:1}) scaleY(${r.rotateY?-1:1})`,e.appendChild(t),r.notes){let t=Y(`span`,`floorplan-plugin__item-notes`);t.textContent=r.notes,e.appendChild(t)}n.appendChild(e)}return n}function Gt(e,t,n,r){var i,a;let o=Y(`div`,`floorplan-plugin__room-label-item`);o.style.left=e.roomLabel.positionInImage.x*100+`%`,o.style.top=e.roomLabel.positionInImage.y*100+`%`;let s=r===e.id,{bounding:c}=t,l=c.max.x-c.min.x;o.dataset.roomId=e.id,o.dataset.roomLabelX=String(e.roomLabel.position.x),o.dataset.roomLabelY=String(e.roomLabel.position.y),o.dataset.boundingWidth=String(l);let u=(i=n.getLabelElement)==null?void 0:i.call(n,e);if(u)return o.appendChild(u),o;let d=Y(`div`,`floorplan-plugin__room-part1`);if(n.roomNameEnable){let t=Y(`span`,`floorplan-plugin__room-name`);t.textContent=n.roomNameOtherTypeEnable?e.name:e.roomType===`100900000012`?(a=e.customizedName)==null?e.name:a:e.name,d.appendChild(t)}if(n.roomAreaEnable&&e.size){let t=Y(`span`,`floorplan-plugin__room-area`);t.textContent=n.getRoomAreaText(e.size),d.appendChild(t)}if(o.appendChild(d),n.roomDimensionEnable&&e.dimension){let t=Y(`span`,`floorplan-plugin__room-size`);t.textContent=n.getRoomDimensionText(e.dimension.width,e.dimension.height),o.appendChild(t)}return s&&(o.style.opacity=`1`,d.style.opacity=`1`),o}function Kt(e,t,n,r){let i=Y(`div`,`floorplan-plugin__room-labels`);for(let a of e.rooms)i.appendChild(Gt(a,t,n,r));return i}function qt(e,t,n,r){let i=e.observers[t];if(!i)return;let a=Y(`div`,`floorplan-plugin__camera-position`);a.style.left=i.positionInImage.x*100+`%`,a.style.top=i.positionInImage.y*100+`%`;let o=Y(`div`,`floorplan-plugin__camera-rotate`),s=document.body.clientWidth,c=document.body.clientHeight,l=`${(s<500||c<500?17:37)/16}rem`;return o.style.width=l,o.style.height=l,o.style.left=`-`+l,o.style.top=`-`+l,o.style.transform=`rotate(${-Pt(n)+45}deg)`,o.style.transformOrigin=`${l} ${l}`,o.style.backgroundImage=`url(${r||`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAMAAAANf8AYAAAC2VBMVEUAAACCnP+Dn/+Enf+HqP+Gp/+Fof+Gpf+IrP+Lsf+Dof+Cmv+Lsv+Mtf+Eo/+Bmf+JrP+Hqf+Env+Krv+Fo/+Pu/+Ms/+Qvv+Hqf+RwP+KsP+Fpf+Mtv+Gov+Bnf+Qv/+Nt/+Krv+Ho/+Rwf+Ouv+Emv+Amv+SxP+Sw/+NuP+Mtf/G0f6huP+Ot/+JrP+Jqv+Dnv+crf6Uqv////+QvP+PvP+Ms//J0/3p9/+Ux/+Ouf+Krf+Iqf+Fpv+/zf6WsP+MpP+RqP+Uyf+Jy//V3P6Yuf+Qqf+Rqv/5/f+Sxf+Jy/////+Lx/+Ouf+Nw/+Owv+PwP+Jr/+Jq/+VvP+Vuv/c4v+Fnf+btP+InP+Blf/3+P6Txf+Jzf+Jyf+NxP+Qwf/t8/6Svv+Tvf/O1f7Czv3T2f6cu/+qvP7a4fvo7v77/v/o9//p9//0+v////+Vy//w9//k8/+B1f/v9/+D0/+UyP/u9v+D0v/i8f+F0v/g7/+G0P+KzP+Hz/////+Lx//s8/+Puf/h7P+Mxv/w9f7q8v/q8f2RwP/r8f6JrP/t8v6RvP/l6f7////j6P6VvP/f5/7q8P7a4P/U2f6au/+ZuP+ewf+auP+iu//n6f2Fn//j6P/h4fn9/v/4/P/3/P/o9v/l9P+F1P+B1f/i8v+UyP+J0f+E0f/h7//r8v6Izf/g7v/q8v6Pv//f7P7f7f/g7f+Lxf+MyP+Mw//k7v6Ow/+Ov//v8/2Pu//t8f+Tvv/p8P6Uu//q7v/i6P2Xvf+WuP/L1vypu//Azv7K0/zy8v/l8v/A4P/o9f/x+f+I0f/j8v+J0P/s9v/h8P+I0P/t9v/r9P6Lyv+Lyf/s9P/g7P+Myv/s8/7j7v+Jrv/q8P2Uwf+Epf+TuP/a3vzh5f3w8P/a4P20v//Nzfzx8f/Pz/Cg0P/f7//u9f/q8v7o8v7s8/7s8v3w9f+Sv/+TuP+Gp//s8fr///8/HFXHAAAA8nRSTlMANUQ/Z2JJXXaKTjCPmVMre3E6gFiylLxsxoVYnk5JwaOFU8utOjrV0KieQS2icWwzMC4Dt7aTQvjfrHprXD0zMyvpvUxGNjH+2sK9raeYkoiAcF5TUi0rKCYY2cy3pIJ/eGpEQDcxLx0S/Pv19PPu7Ovr5+Tk4eDe3NXU09DIsq2opKCViYN9e3V1cmZlXllVTk1GQDs2NTMwJw0K/vn28u/u5+Pj3tjNycjGw8DAua2pqJ6SjYyMf3BvaWNgWk5NSTc3MxT79PHw6efl2trY19PHurWysqWZe2xkXVlUPjo6OSskCO7Qzs6+vKCedmhdN1av0hoAAAV1SURBVEjHjZT3P9RxHMe1nCjcObo4cjpX5w53l7pUbnBGkr2TPZJKmiqVEQlJhGjvvfcm2nvvvXf5C3q/P98bkuR1D7+9n16v1/vzvtPrnAade/ty6anHJfFHOjkfXbe07PGxkuL4oqIjCzoDjHtxurzsRHmFStokjBDG/59JrwurOF2hkkUoIyKEQmFqatG3/xDnXlSGPZcKI5VKiVgsli+vrakpfNAx8UoVlpRWH6mUeMsVcm8vhah6WfXB3A6IlSlVKoE4KjxcgtNGRl1Ayzw9H+Z20DypMVkZZWKiUIi6oHj2PAbPs6Eh/+6/kBUpVUliIEQKGGcwGPbdiBpCQ/O//AMZJ218XW9igoHsGTwY7kopdMmSvTvbz/VGmiyhCARwWJ/Ss5CQ9pl3zVJZJCEwEszb6BtaGxrCn3XIyZP3trW3rybBWTCB1jy0sNGHeWM7+BgzrX4kJu752E57mWA5mIjsMRVxgGkrJpPpRvtJSywt3X2rPUSMuUgqIIzx37vRaLQeqNKEhN03/womg/bYhDJBBzdqvjsqYeHCHdfa1k9BF0QoEyuwoOadWc4sFutoXNzWGW2W3Axd8E3AxAZ6WNGeEoDl7EwPho/T0cDAtswb2Bi6kFx2VkwaDYgRI5zo9EUGRIGHD82e+ufrJ8uo+l31oQogYMJiOdFh2BQ03NTscEDAn8wKgQCeUsRTI8QEMhkYDDc1NTMLMuNwLAP8/a9Pbl0mJQlXhvVtrO2YNLce3Uew6IvAAsYtLS17gvwLCrKR0d3la0DsgdG3NiZVMBZacMh8L9CB2NjsS61eRiCtB4YH/Q21CMQKAgLnh1hYWAyJ3b9/40Qd09woppJhFytAnIPpBmBCCBjvjdrn59eKSU+SRWkZphu40IMBgRpAAMBmO7DZbL/786+s0TIpKqXOhgqGCKcnhOrd28HBlmj+2LFZWia9KjkqnHoa3BmsjG7wKIgDuSzQw9F29Gh+3jDunTseWas1zKtKYbiIsrEjZdAF2iPiYOvIz+Nyuebm5h6+HuvGa2xU0qhwBbkzayzjDO8y3IwgbAdHPp87zNx8sIvLYN/tvhc1TF1lWqSEwaMWgG3ABpIB4sC2HY2Ei0sf0O2YmLWr1CdQGRYp8SK3ic/ZnRWMLqQ+2xGRwUD069dvV8zcuRom+rlA6Y2MbgGmhAGEz4VYSPQF5cyZM6GFYl6eTlN6ixi6aE6PqDLQZRi4EKI/KOfGFjUzqCKsXu6l2RpuAKJxiI1tHhcQJAYOHDhgwOZZs4ZSTHR5lQQYPDW1DS4aELQxdyEIAANGjtk8c6aaqTslk8gVwIAN0w3rAEL2bMtHm12AIOHqenXaNDWztEwo9hKJGHjR6OO0yDSI1IGdoQ0iY0a6Tt+06fKUDRQzqKw8Qlxr1AXrwNqwDvGBA+BrGUDc3d3Xr5+SQZj0E2ERqXIjPAJYNUbD18FoWEeDbHLPzLyQ4ePjQ5i3x1RCubfmpqkjMMNo6KOJ5uqe+f58C9GoaD29XyVSYS1h4DftKeWDDN4AbACZMZAsExEKghWUNKXWhlPfA2P1qjmUT556a9jmQotWi/VOFael1lR7ep4JfRZy8nhpwtG4wMMB/gdi9/nNH+vhezsmJ+fG5quX12fomHl6J+KFy88uA2RJyJPE4wkL4wIPBfgXxO5HxGN7zNw5W2bNnLZhio+OmaR3LD6tplrLfKeYAwX7/O6Dje/2dpniwuKiwoMHH+bn7723Z8/uHTu2fpg9+3p29sYrWVnr1l1cO2HCUFCGT+tshUcWLPj6IDf37ued27Z9unXz2owZU6dOnnxp4sQ1q1ePH79KN6vbQWc1SrfrTit6lO5NO6/F8yZNmofBfgNTwRQLsPLsHQAAAABJRU5ErkJggg==`})`,a.appendChild(o),a}var Z=1e3,Q=180;function Jt(e,t,n,r){let i=e===`top`||e===`bottom`,a=n.max.x-n.min.x-(Z-Q)*2,o=n.max.y-n.min.y-(Z-Q)*2,s=t.map(([e,t])=>i?[e.x,t.x]:[e.y,t.y]).flat().sort((e,t)=>e-t).filter((e,t,n)=>t===0||e!==n[t-1]),c=s.map(e=>({left:i?(e-n.min.x-Z+Q)/a:0,bottom:i?0:(e-n.min.y-Z+Q)/o}));c.unshift({left:0,bottom:0}),c.push(i?{left:1,bottom:0}:{left:0,bottom:1});let l=s.length?s[s.length-1]-s[0]:0,u=s.map((e,t,r)=>{let s=t===0?0:e-r[t-1],c=t===0?0:(e+r[t-1])/2;return{left:i?(c-n.min.x-Z+Q)/a:0,bottom:i?0:(c-n.min.y-Z+Q)/o,distance:s}}).filter(({distance:e})=>l?e/l>.1:!1),d=Y(`div`,`floorplan-plugin__rule-labels floorplan-plugin__rule-labels--${e}${i?` is-row`:``}`);d.style.width=i?`100%`:`0.0625rem`,d.style.height=i?`0.0625rem`:`100%`,d.appendChild(Y(`div`,`floorplan-plugin__rule-line`));let f=Y(`div`,`floorplan-plugin__rule-scale-wrapper${i?` is-row`:``}`);for(let{left:e,bottom:t}of c){let n=Y(`div`,`floorplan-plugin__rule-scale`);n.style.left=e*100+`%`,n.style.bottom=t*100+`%`,f.appendChild(n)}d.appendChild(f);let p=Y(`div`,`floorplan-plugin__rule-text-wrapper`);for(let{left:e,bottom:t,distance:n}of u){let a=Y(`div`,`floorplan-plugin__rule-text-item`);a.style.left=e*100+`%`,a.style.bottom=t*100+`%`;let o=Y(`div`,`floorplan-plugin__rule-text${i?` is-row`:``}`);o.textContent=r(n),a.appendChild(o),p.appendChild(a)}return d.appendChild(p),d}function Yt(e,t,n){let r=t.bounding,i=r.max.x-r.min.x,a=r.max.y-r.min.y,o=i-(Z-Q)*2,s=a-(Z-Q)*2,c=Y(`div`,`floorplan-plugin__rule-labels-wrapper`);c.style.width=o/i*100+`%`,c.style.height=s/a*100+`%`;let l=e.rules;for(let e of[`top`,`right`,`bottom`,`left`]){let t=l[e];!t||t.length===0||c.appendChild(Jt(e,t,r,n.getRuleDistanceText))}return c}function Xt(e,t){var n;let r=(n=e.entrance)==null?void 0:n.northRad;if(typeof r!=`number`)return;let i=Y(`div`,`floorplan-plugin__compass`),a=Pt(r);i.style.transform=`translateX(-50%) translateZ(10px) rotate(${-a+90}deg)`;let o=Y(`div`,`floorplan-plugin__compass-image`);o.style.backgroundImage=`url(${Nt})`,i.appendChild(o);let s=Y(`span`,`floorplan-plugin__compass-text`);return s.textContent=t,i.appendChild(s),i}function Zt(e){var t,n;let{floorplanData:r,floorIndex:i,config:a}=e,o=r.floorDatas[i],s=Y(`div`,`floorplan-plugin__floor`);if(!(o.rooms.length>0||o.is_has_wall))return s.appendChild(Ft(a)),s;if(s.appendChild(Vt(o,r,a)),(a.highlightEnable||a.hoverEnable)&&s.appendChild(Ht(o,r,e)),s.appendChild(Ut(r,i)),s.appendChild(Wt(o)),a.roomLabelsEnable&&s.appendChild(Kt(o,r,a,(n=(t=e.store.roomOnMouse)==null?void 0:t.id)==null?null:n)),a.ruleLabelsEnable&&s.appendChild(Yt(o,r,a)),a.cameraEnable){let t=qt(r,e.panoIndex,e.lastPanoramaLongitude,a.cameraImageUrl);t&&s.appendChild(t)}if(a.compassEnable){let e=Xt(r,a.northDesc);e&&s.appendChild(e)}return s}function Qt(e,t,n,r){let i=e.querySelector(`.floorplan-plugin__room-labels`);if(!i)return;let a=i.clientWidth;if(!a)return;let o=t.floorDatas[n],s=new Map(o.rooms.map(e=>[e.id,e])),{max:c,min:l}=t.bounding,u=a/(c.x-l.x);i.querySelectorAll(`.floorplan-plugin__room-label-item`).forEach(e=>{if(!r){e.style.opacity=`1`;return}let t=e.dataset.roomId,n=t?s.get(t):void 0;if(!n)return;let i=e.querySelector(`.floorplan-plugin__room-part1`),a=e.querySelector(`.floorplan-plugin__room-size`),o=Mt(n,{width:e.clientWidth,height:e.clientHeight},u),c=i?Mt(n,{width:i.clientWidth,height:i.clientHeight},u):o;e.style.opacity=o||c?`1`:`0`,i&&(i.style.opacity=c?`1`:`0`),a&&(a.style.opacity=o?`0.6`:`0`)})}var $t=class{constructor(){this.floorElements=new Map,this.currentFloorIndex=-1,this.isVisible=!1,this.rootElement=document.createElement(`div`),this.rootElement.className=`floorplan-plugin__main`}render(e){let{floorplanData:t,config:n}=e;this.rootElement.style.transitionDuration=e.duration+`ms`,e.visible!==this.isVisible&&(this.isVisible=e.visible,e.visible?(this.rootElement.classList.remove(`floorplan-plugin__main--visible`),requestAnimationFrame(()=>{this.rootElement.classList.add(`floorplan-plugin__main--visible`)})):this.rootElement.classList.remove(`floorplan-plugin__main--visible`));let r=new Set(t.floorDatas.map(e=>e.floorIndex));for(let[e,t]of this.floorElements)r.has(e)||(t.remove(),this.floorElements.delete(e));for(let r of t.floorDatas){let i=Zt({floorplanData:t,floorIndex:r.floorIndex,panoIndex:e.panoIndex,lastPanoramaLongitude:e.lastPanoramaLongitude,config:n,highlightData:e.highlightData,store:e.store,onRoomHover:e.onRoomHover}),a=this.floorElements.get(r.floorIndex);a?this.rootElement.replaceChild(i,a):this.rootElement.appendChild(i),this.floorElements.set(r.floorIndex,i)}this.currentFloorIndex!==e.floorIndex&&(this.currentFloorIndex=e.floorIndex);for(let[t,n]of this.floorElements)n.classList.toggle(`floorplan-plugin__floor--is-current`,t===e.floorIndex);let i=this.floorElements.get(e.floorIndex);i&&requestAnimationFrame(()=>{Qt(i,t,e.floorIndex,n.adaptiveRoomLabelVisibleEnable)})}updateLabelsVisibility(e,t,n){let r=this.floorElements.get(t);r&&Qt(r,e,t,n)}dispose(){this.rootElement.remove(),this.floorElements.clear()}},en=`.floorplan-plugin__main {
316
+ position: absolute;
317
+ pointer-events: none;
318
+ opacity: 0;
319
+ transition-property: opacity;
320
+ transition-timing-function: linear;
321
+ }
322
+
323
+ .floorplan-plugin__main--visible {
324
+ opacity: 1;
325
+ }
326
+
327
+ .floorplan-plugin__floor {
328
+ position: absolute;
329
+ left: 0;
330
+ top: 0;
331
+ width: 100%;
332
+ height: 100%;
333
+ opacity: 0;
334
+ pointer-events: none;
335
+ }
336
+
337
+ .floorplan-plugin__floor--is-current {
338
+ opacity: 1;
339
+ pointer-events: auto;
340
+ }
341
+
342
+ /* ============ missing floor ============ */
343
+ .floorplan-plugin__missing-floor {
344
+ position: absolute;
345
+ left: 50%;
346
+ top: 50%;
347
+ transform: translate(-50%, -50%);
348
+ display: flex;
349
+ flex-direction: column;
350
+ align-items: center;
351
+ }
352
+ .floorplan-plugin__missing-floor-text {
353
+ margin-top: 12px;
354
+ color: #fff;
355
+ opacity: 0.3;
356
+ white-space: nowrap;
357
+ }
358
+
359
+ /* ============ room material ============ */
360
+ .floorplan-plugin__room-material {
361
+ position: absolute;
362
+ left: 0;
363
+ top: 0;
364
+ width: 100%;
365
+ height: 100%;
366
+ }
367
+ .floorplan-plugin__room-material svg {
368
+ position: absolute;
369
+ left: 0;
370
+ top: 0;
371
+ width: 100%;
372
+ height: 100%;
373
+ overflow: visible;
374
+ }
375
+
376
+ /* ============ room highlight ============ */
377
+ .floorplan-plugin__room-highlight {
378
+ position: absolute;
379
+ width: 100%;
380
+ height: 100%;
381
+ }
382
+ .floorplan-plugin__room-highlight svg {
383
+ width: 100%;
384
+ height: 100%;
385
+ overflow: visible;
386
+ }
387
+ .floorplan-plugin__room-highlight path {
388
+ --opacity: 0;
389
+ opacity: var(--opacity);
390
+ fill: #fff;
391
+ pointer-events: auto;
392
+ }
393
+ .floorplan-plugin__room-highlight path:hover {
394
+ opacity: calc(var(--opacity) + 0.1);
395
+ }
396
+ /* main 未展示时,子元素显式设置的 pointer-events:auto 会覆盖父级 none,这里强制统一关闭交互 */
397
+ .floorplan-plugin__main:not(.floorplan-plugin__main--visible) * {
398
+ pointer-events: none !important;
399
+ }
400
+
401
+ /* ============ base image ============ */
402
+ .floorplan-plugin__base-image {
403
+ position: absolute;
404
+ z-index: 10;
405
+ width: 100%;
406
+ height: 100%;
407
+ pointer-events: none;
408
+ }
409
+ .floorplan-plugin__base-image img {
410
+ width: 100%;
411
+ height: 100%;
412
+ }
413
+ .floorplan-plugin__base-image svg [type='lineGroup'] path {
414
+ fill: #ffffff;
415
+ stroke: #ffffff;
416
+ }
417
+ .floorplan-plugin__base-image svg [type='lineItemGroup'] g g g g {
418
+ stroke: #ffffff;
419
+ }
420
+
421
+ /* ============ items ============ */
422
+ .floorplan-plugin__items {
423
+ width: 100%;
424
+ height: 100%;
425
+ position: absolute;
426
+ left: 0;
427
+ top: 0;
428
+ z-index: 20;
429
+ pointer-events: none;
430
+ }
431
+ .floorplan-plugin__item {
432
+ position: absolute;
433
+ display: flex;
434
+ flex-flow: column;
435
+ align-items: center;
436
+ line-height: 1;
437
+ color: #fff;
438
+ transform: translate(-50%, -50%);
439
+ white-space: nowrap;
440
+ transition: opacity 300ms;
441
+ }
442
+ .floorplan-plugin__item-img {
443
+ width: 100%;
444
+ height: 100%;
445
+ }
446
+ .floorplan-plugin__item-notes {
447
+ position: absolute;
448
+ top: 50%;
449
+ left: 50%;
450
+ transform: translate(-50%, -50%);
451
+ padding: 4px;
452
+ line-height: 1;
453
+ border-radius: 4px;
454
+ color: #fff;
455
+ background: rgba(0, 0, 0, 0.6);
456
+ font-size: 12px;
457
+ }
458
+
459
+ /* ============ room labels ============ */
460
+ .floorplan-plugin__room-labels {
461
+ width: 100%;
462
+ height: 100%;
463
+ position: absolute;
464
+ left: 0;
465
+ top: 0;
466
+ z-index: 20;
467
+ pointer-events: none;
468
+ }
469
+ .floorplan-plugin__room-label-item {
470
+ position: absolute;
471
+ display: flex;
472
+ flex-flow: column;
473
+ align-items: center;
474
+ line-height: 1;
475
+ color: #fff;
476
+ transform: translate(-50%, -50%);
477
+ white-space: nowrap;
478
+ transition: opacity 300ms;
479
+ font-size: 12px;
480
+ }
481
+ .floorplan-plugin__room-part1 {
482
+ display: flex;
483
+ flex-flow: column;
484
+ align-items: center;
485
+ color: #fff;
486
+ white-space: nowrap;
487
+ transition: opacity 300ms;
488
+ }
489
+ .floorplan-plugin__room-name {
490
+ font-size: 12px;
491
+ }
492
+ .floorplan-plugin__room-area {
493
+ opacity: 0.6;
494
+ line-height: 1.25;
495
+ margin-top: 2px;
496
+ font-size: 10px;
497
+ }
498
+ .floorplan-plugin__room-size {
499
+ font-size: 10px;
500
+ transition: opacity 300ms;
501
+ }
502
+
503
+ /* ============ camera ============ */
504
+ .floorplan-plugin__camera-position {
505
+ pointer-events: none;
506
+ position: absolute;
507
+ width: 0;
508
+ height: 0;
509
+ }
510
+ .floorplan-plugin__camera-rotate {
511
+ position: absolute;
512
+ background-repeat: no-repeat;
513
+ background-size: 100%;
514
+ }
515
+
516
+ /* ============ rule labels ============ */
517
+ .floorplan-plugin__rule-labels-wrapper {
518
+ position: absolute;
519
+ top: 50%;
520
+ left: 50%;
521
+ transform: translate(-50%, -50%);
522
+ pointer-events: none;
523
+ }
524
+ .floorplan-plugin__rule-labels {
525
+ position: absolute;
526
+ display: flex;
527
+ }
528
+ .floorplan-plugin__rule-labels--top {
529
+ left: 0;
530
+ top: -1.25rem;
531
+ }
532
+ .floorplan-plugin__rule-labels--bottom {
533
+ left: 0;
534
+ bottom: -1.25rem;
535
+ }
536
+ .floorplan-plugin__rule-labels--left {
537
+ top: 0;
538
+ left: -1.25rem;
539
+ }
540
+ .floorplan-plugin__rule-labels--right {
541
+ top: 0;
542
+ right: -1.25rem;
543
+ }
544
+ .floorplan-plugin__rule-line {
545
+ background: #fff;
546
+ opacity: 0.2;
547
+ width: 100%;
548
+ height: 100%;
549
+ }
550
+ .floorplan-plugin__rule-scale-wrapper {
551
+ position: absolute;
552
+ width: 0.3125rem;
553
+ height: 100%;
554
+ left: 50%;
555
+ top: 0;
556
+ transform: translateX(-50%);
557
+ }
558
+ .floorplan-plugin__rule-labels.is-row .floorplan-plugin__rule-scale-wrapper {
559
+ width: 100%;
560
+ height: 0.3125rem;
561
+ top: 50%;
562
+ left: 0;
563
+ transform: translateY(-50%);
564
+ }
565
+ .floorplan-plugin__rule-scale {
566
+ position: absolute;
567
+ background: #fff;
568
+ opacity: 0.2;
569
+ width: 100%;
570
+ height: 0.0625rem;
571
+ }
572
+ .floorplan-plugin__rule-labels.is-row .floorplan-plugin__rule-scale {
573
+ width: 0.0625rem;
574
+ height: 100%;
575
+ }
576
+ .floorplan-plugin__rule-text-wrapper {
577
+ position: absolute;
578
+ }
579
+ .floorplan-plugin__rule-labels--top .floorplan-plugin__rule-text-wrapper {
580
+ width: 100%;
581
+ height: 0;
582
+ top: 0.625rem;
583
+ }
584
+ .floorplan-plugin__rule-labels--bottom .floorplan-plugin__rule-text-wrapper {
585
+ width: 100%;
586
+ height: 0;
587
+ bottom: 0.625rem;
588
+ }
589
+ .floorplan-plugin__rule-labels--left .floorplan-plugin__rule-text-wrapper {
590
+ width: 0;
591
+ height: 100%;
592
+ left: 0.625rem;
593
+ }
594
+ .floorplan-plugin__rule-labels--right .floorplan-plugin__rule-text-wrapper {
595
+ width: 0;
596
+ height: 100%;
597
+ right: 0.625rem;
598
+ }
599
+ .floorplan-plugin__rule-text-item {
600
+ width: 0;
601
+ height: 0;
602
+ position: absolute;
603
+ transform: rotate(90deg);
604
+ }
605
+ .floorplan-plugin__rule-labels.is-row .floorplan-plugin__rule-text-item {
606
+ transform: rotate(0);
607
+ }
608
+ .floorplan-plugin__rule-text {
609
+ width: max-content;
610
+ transform: translate(-50%, -50%);
611
+ font-size: 0.625rem;
612
+ color: #fff;
613
+ opacity: 0.35;
614
+ }
615
+
616
+ /* ============ compass ============ */
617
+ .floorplan-plugin__compass {
618
+ position: absolute;
619
+ left: 50%;
620
+ top: -46px;
621
+ width: 231px;
622
+ height: 41px;
623
+ transform-origin: center 184px;
624
+ }
625
+ .floorplan-plugin__compass-image {
626
+ width: 100%;
627
+ height: 100%;
628
+ position: absolute;
629
+ left: 0;
630
+ top: 0;
631
+ opacity: 0.1;
632
+ background-repeat: no-repeat;
633
+ background-size: 100% 100%;
634
+ }
635
+ .floorplan-plugin__compass-text {
636
+ position: absolute;
637
+ left: 50%;
638
+ top: 15px;
639
+ transform: translateX(-50%);
640
+ opacity: 0.2;
641
+ font-weight: bold;
642
+ font-size: 10px;
643
+ color: #fff;
644
+ }
645
+ `,tn=500,nn=.01;function rn(e){let{latitude:t,longitude:n}=e,r=Math.abs(t-Math.PI/2)>5*Math.PI/180,i=n>Math.PI/180*5&&n<Math.PI/180*355;return r||i}function an(e){let{latitude:t,longitude:n}=e,r=Math.abs(t-Math.PI/2)<10*Math.PI/180,i=n<Math.PI/180*30||n>Math.PI/180*330;return r&&i}var on=class extends h.Controller{constructor(e,t){var n,r,i;super(e),this.name=`FloorplanPlugin`,this.renderer=new $t,this.styleSheet=new CSSStyleSheet,this.panoIndex=0,this.floorIndex=0,this.lastPanoramaLongitude=0,this.size={width:0,height:0},this.hasAddedEventListener=!1,this.isHiddenByHideFunc=!1,this.highlightData={},this.store={roomOnMouse:null},this.dispose=()=>{var e,t;this.removeEventListener(),(e=this.resizeObserver)==null||e.disconnect(),(t=this.removeExtraElement)==null||t.call(this),this.removeExtraElement=void 0,this.pendingCameraUpdateFrame!==void 0&&cancelAnimationFrame(this.pendingCameraUpdateFrame),this.pendingResizeFrame!==void 0&&cancelAnimationFrame(this.pendingResizeFrame),this.renderer.dispose(),this.wrapper=void 0,this.data=void 0,this.hooks.emit(`dispose`)},this.show=(...e)=>f(this,[...e],void 0,function*(e={}){var t;if(!this.state.enabled||!this.showPromise&&this.state.visible)return;let n=(t=e.userAction)==null?!0:t;return this.updateState({visible:!0},n),this._show(e)}),this.hide=(...e)=>f(this,[...e],void 0,function*(e={}){var t;this.state.enabled&&(this.isHiddenByHideFunc=!0,this.state.visible!==!1&&(this.updateState({visible:!1},(t=e.userAction)==null?!0:t),this._hide(e)))}),this.highlight=e=>{this.state.config.highlightEnable&&(this.highlightData=e,this.renderCurrent())},this.unhighlight=()=>{this.highlightData={},this.renderCurrent()},this.updateShowState=e=>{this.showState=Object.assign(Object.assign({},this.showState),e)},this.onRoomHover=e=>{this.store.roomOnMouse=e},this.handleClick=()=>{if(this.state.visible&&this.hooks.emit(`click`,this.store.roomOnMouse))return!1},this.onFiveModelLoaded=()=>{var e,t,n;this.state.enabled!==!1&&(this.floorIndex=(n=(t=(e=this.five.work)==null?void 0:e.observers[this.panoIndex])==null?void 0:t.floorIndex)==null?0:n,this.renderCurrent())},this.onFiveModeChange=e=>{e!==this.showState.mode&&(this.updateState({visible:!1},!1),this._hide({userAction:!1}))},this.onFiveInertiaPan=(e,t)=>{t&&(this.state.visible||this.state.config.autoShowEnable!==!1&&(this.isHiddenByHideFunc||this.five.currentMode===this.showState.mode&&an(this.getRelativePose(this.five.getCurrentState()))&&(this.updateState({visible:!0},!0),this._show({isAutoShow:!0}))))},this.onFivePanoArrived=e=>{var t,n;this.five.work&&(this.panoIndex=e,this.floorIndex=(n=(t=this.five.work.observers[e])==null?void 0:t.floorIndex)==null?this.floorIndex:n)},this.onFiveCameraUpdate=(e,t)=>{this.state.visible&&(this.showPromise||(this.scheduleCameraUpdate(),rn(this.getRelativePose(this.five.getCurrentState()))&&(this.updateState({visible:!1},t),this._hide({userAction:t}))))},this.onFiveWantsPanGesture=(e,t)=>{if(this.five.currentMode===this.showState.mode&&this.state.config.autoShowEnable!==!1&&t&&this.state.visible)return this.five.updateCamera(W(this.showState,[`mode`,`offset`]),0),!1},this.onFiveWantsTapGesture=()=>this.handleClick(),this.onFiveWantsChangeMode=(e,t)=>{t===`Panorama`&&e===this.showState.mode&&(this.lastPanoramaLongitude=this.five.getCurrentState().longitude)},this.onModelShownFloorChange=e=>{var t,n,r;if(this.floorIndex!==e){if(e===null){this.floorIndex=(r=(n=(t=this.five.work)==null?void 0:t.observers[this.panoIndex])==null?void 0:n.floorIndex)==null?this.floorIndex:r;return}this.floorIndex=e,this.updateSize(),this.renderCurrent()}},this._show=e=>f(this,void 0,void 0,function*(){var t;if(!this.state.enabled)return;if(!((t=this.five.model)!=null&&t.loaded))throw Error(`ModelNotLoaded`);if(!this.data)throw Error(`DataNotLoaded`);if(this.showPromise)return this.showPromise;let n=Object.assign({floorIndex:this.floorIndex,modelOpacity:this.state.config.modelOpacity,immediately:!1,isAutoShow:!1,userAction:!0},e),r=()=>f(this,void 0,void 0,function*(){var e;this.hooks.emit(`show`,{userAction:n.userAction,auto:n.isAutoShow});let t=!1,r;this.showRejection=e=>{t=!0,r=e};let[i]=yield U(gt(this.five,this.showState,n.userAction));if(i)throw i;if(t)throw Error(r||`UnknownError`);if(!this.updateSize())throw Error(`UpdateSizeError`);this.updatePosition(),this.floorIndex=n.floorIndex,(e=this.five.model)==null||e.show(this.floorIndex)});return this.isHiddenByHideFunc=!1,this.showPromise=r().then(()=>{this.showPromise=void 0,this.showRejection=void 0;let e=n.immediately?0:tn;_t(this.five,n.modelOpacity,e),this.renderWithDuration(e),this.hooks.emit(`showAnimationEnded`,{auto:n.isAutoShow,userAction:n.userAction})}).catch(e=>{if(this.showPromise=void 0,this.showRejection=void 0,this.updateState({visible:!1},n.userAction),!n.isAutoShow)throw e}),this.showPromise}),this._hide=e=>{var t;(t=this.showRejection)==null||t.call(this,`BreakOffByHide`),this.showPromise=void 0;let n=Object.assign({userAction:!0,isAutoHide:!1},e);_t(this.five,1,0),this.hooks.emit(`hide`,{auto:n.isAutoHide,userAction:n.userAction}),this.renderCurrent()},this.five=e,this.styleSheet.replaceSync(en),typeof document<`u`&&document.adoptedStyleSheets.push(this.styleSheet),this.showState=Object.assign({mode:`Mapview`,longitude:0,latitude:Math.PI/2,fov:80},t==null?void 0:t.showState);let a={northDesc:`北`,modelOpacity:nn,cameraEnable:!0,highlightEnable:!1,hoverEnable:!0,compassEnable:!0,autoShowEnable:!0,ruleLabelsEnable:!0,roomLabelsEnable:!0,roomAreaEnable:!0,roomNameEnable:!0,roomNameOtherTypeEnable:!0,roomDimensionEnable:!0,cameraImageUrl:void 0,attachedTo:3,getLabelElement:void 0,adaptiveRoomLabelVisibleEnable:!0,missingFloorConfig:{imageWidth:200,imageHeight:120,text:`暂无平面图`,textFontSize:14},i18n:e=>e,getRoomAreaText:e=>(e/1e6).toFixed(1)+`㎡`,getRoomDimensionText:(e,t)=>(e/1e3).toFixed(1)+`m × `+(t/1e3).toFixed(1)+`m`,getRuleDistanceText:e=>e.toString()},o=Object.assign(Object.assign(Object.assign({},a),t==null?void 0:t.config),{missingFloorConfig:Object.assign(Object.assign({},a.missingFloorConfig),(n=t==null?void 0:t.config)==null?void 0:n.missingFloorConfig)});this.state={enabled:!0,visible:!1,config:o},Object.assign(this.state,W((r=t==null?void 0:t.initialState)==null?{}:r,[`config`])),this.panoIndex=(i=e.state.panoIndex)==null?0:i,this.initContainer(),Ct(e).then(this.onFiveModelLoaded),e.once(`dispose`,this.dispose),this.state.enabled?this.addEventListener():this.styleSheet.disabled=!0}load(e,t){return f(this,arguments,void 0,function*(e,t,n=!0){let r=`data`in e?e.data:e,i=this.data;this.data=yield lt(r),this.hooks.emit(`dataLoaded`,this.data),this.hooks.emit(`dataChange`,this.data,i),t&&this.updateState(t,n),this.updateSize(),this.updatePosition(),this.renderCurrent()})}loadItems(e){this.data&&(this.data.floorDatas.forEach((t,n)=>{t.items=e[n]}),this.renderCurrent())}appendTo(e){this.wrapper=e,this.state.enabled&&(e.appendChild(this.renderer.rootElement),this.observeResize(e),this.registerExtraElement(),this.updateSize(),this.updatePosition(),this.renderCurrent())}enable(e={}){var t;if(this.state.enabled)return;let n=(t=e.userAction)==null?!0:t;this.updateState({enabled:!0},n),this._enable({userAction:n})}disable(e={}){var t;if(!this.state.enabled)return;let n=(t=e.userAction)==null?!0:t;this.updateState({enabled:!1},n),this._disable({userAction:n})}setState(e,t={}){var n;let r=this.state,i=(n=t.userAction)==null?!0:n;this.updateState(e,i),e.enabled!==void 0&&r.enabled!==e.enabled&&(e.enabled?this._enable({userAction:i}):this._disable({userAction:i})),e.visible!==void 0&&r.visible!==e.visible&&(e.visible?this._show({userAction:i}):this._hide({userAction:i}))}changeConfigs(e,t=!0){this.updateState({config:Object.assign(Object.assign({},this.state.config),e)},t),this.renderCurrent()}updateSize(){if(!this.data||!this.wrapper)return!1;let{min:e,max:t}=this.data.bounding,n=t.x-e.x,r=t.y-e.y,i=this.getPxmmWithRotation(),a=Math.ceil(n*i),o=Math.ceil(r*i);return this.size.width===a&&this.size.height===o?!0:(this.renderer.rootElement.style.width=a+`px`,this.renderer.rootElement.style.height=o+`px`,this.size={width:a,height:o},!0)}updatePosition(){if(!this.wrapper)return;let e=yt(this.five,this.floorIndex,this.state.config.attachedTo),t=this.five.modelScene.boundingBox.getCenter(new l.Vector3);t.y=e;let n=t.clone().project(this.five.camera),r=(n.x+1)/2,i=-(n.y-1)/2;this.renderer.rootElement.style.position=`absolute`,this.renderer.rootElement.style.left=r*100+`%`,this.renderer.rootElement.style.top=i*100+`%`,this.renderer.rootElement.style.transform=`translate(-50%, -50%)`}getPxmmWithRotation(){if(!this.wrapper)return 0;let e={attachedTo:this.state.config.attachedTo};return bt(this.five,this.wrapper,this.floorIndex,e)}updateState(e,t){let n=this.state,r=e.config?Object.assign(Object.assign({},n.config),e.config):n.config;this.state=Object.assign(Object.assign(Object.assign({},this.state),e),{config:r}),!kt(this.state,n,{deep:!0})&&this.hooks.emit(`stateChange`,{state:this.state,prevState:n,userAction:t})}initContainer(){this.renderer.rootElement.classList.add(`floorplan-plugin`)}registerExtraElement(){var e;(e=this.removeExtraElement)==null||e.call(this),this.removeExtraElement=this.five.addExtraElement(this.renderer.rootElement)}observeResize(e){var t;(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=new ResizeObserver(()=>{this.scheduleResizeUpdate()}),this.resizeObserver.observe(e)}scheduleResizeUpdate(){this.pendingResizeFrame===void 0&&(this.pendingResizeFrame=requestAnimationFrame(()=>{this.pendingResizeFrame=void 0,this.updateSize(),this.updatePosition(),this.data&&this.renderer.updateLabelsVisibility(this.data,this.floorIndex,this.state.config.adaptiveRoomLabelVisibleEnable)}))}renderCurrent(){this.data&&this.renderer.render({visible:this.state.visible,duration:0,panoIndex:this.panoIndex,floorIndex:this.floorIndex,floorplanData:this.data,lastPanoramaLongitude:this.lastPanoramaLongitude,config:this.state.config,highlightData:this.highlightData,store:this.store,onRoomHover:this.onRoomHover})}addEventListener(){if(!this.state.enabled||this.hasAddedEventListener)return;this.hasAddedEventListener=!0;let e=this.five;e.on(`modeChange`,this.onFiveModeChange),e.on(`interiaPan`,this.onFiveInertiaPan),e.on(`panoArrived`,this.onFivePanoArrived),e.on(`cameraUpdate`,this.onFiveCameraUpdate),e.on(`wantsPanGesture`,this.onFiveWantsPanGesture),e.on(`wantsTapGesture`,this.onFiveWantsTapGesture),e.on(`wantsChangeMode`,this.onFiveWantsChangeMode),e.on(`modelShownFloorChange`,this.onModelShownFloorChange)}removeEventListener(){this.hasAddedEventListener=!1;let e=this.five;e.off(`modeChange`,this.onFiveModeChange),e.off(`interiaPan`,this.onFiveInertiaPan),e.off(`panoArrived`,this.onFivePanoArrived),e.off(`cameraUpdate`,this.onFiveCameraUpdate),e.off(`wantsPanGesture`,this.onFiveWantsPanGesture),e.off(`wantsTapGesture`,this.onFiveWantsTapGesture),e.off(`wantsChangeMode`,this.onFiveWantsChangeMode),e.off(`modelShownFloorChange`,this.onModelShownFloorChange)}scheduleCameraUpdate(){this.pendingCameraUpdateFrame===void 0&&(this.pendingCameraUpdateFrame=requestAnimationFrame(()=>{this.pendingCameraUpdateFrame=void 0,this.updatePosition(),this.updateSize()}))}getRelativePose(e){let t=this.showState.longitude||0,n=((e.longitude-t)%(2*Math.PI)+2*Math.PI)%(2*Math.PI);return{latitude:e.latitude,longitude:n}}_enable(e){this.styleSheet.disabled=!1,this.addEventListener(),this.wrapper&&(this.wrapper.appendChild(this.renderer.rootElement),this.registerExtraElement()),this.hooks.emit(`enable`,{userAction:e.userAction}),this.state.visible&&this._show({userAction:e.userAction})}_disable(e){var t,n;this.styleSheet.disabled=!0,(t=this.showRejection)==null||t.call(this,`BreakOffByDisable`),this.showPromise=void 0,this.renderer.rootElement.remove(),(n=this.removeExtraElement)==null||n.call(this),this.removeExtraElement=void 0,this.removeEventListener(),this.hooks.emit(`disable`,{userAction:e.userAction})}renderWithDuration(e){this.data&&this.renderer.render({visible:this.state.visible,duration:e,panoIndex:this.panoIndex,floorIndex:this.floorIndex,floorplanData:this.data,lastPanoramaLongitude:this.lastPanoramaLongitude,config:this.state.config,highlightData:this.highlightData,store:this.store,onRoomHover:this.onRoomHover})}},sn=(e,t)=>new on(e,t),$=class{constructor(e,t,n,r,i){this.R=e,this.Q=t,this.A=n,this.B=r,this.C=i,this.cov=NaN,this.x=NaN}filter(e,t=0){if(isNaN(this.x))this.x=1/this.C*e,this.cov=1/this.C*this.Q*(1/this.C);else{let n=this.A*this.x+this.B*t,r=this.A*this.cov*this.A+this.R,i=r*this.C*(1/(this.C*r*this.C+this.Q));this.x=n+i*(e-this.C*n),this.cov=r-i*this.C*r}return this.x}},cn=class extends h.Controller{updateState(e,t){let n=this.state;this.state=Object.assign(Object.assign({},this.state),e),this.hooks.emit(`stateChange`,{state:this.state,prevState:n,userAction:t})}constructor(e,t){var n,r,i;super(e),this.boundingAABB=null,this.cancelAnimation=null,this.boundsSet=!1,this.keyframes=[],this.five=e,this.state={enabled:!0,visible:!0},this.duration=(n=t==null?void 0:t.duration)==null?5e3:n,this.curveHeight=(r=t==null?void 0:t.curveHeight)==null?1.5:r,this.pointDuration=(i=t==null?void 0:t.pointDuration)==null?3e3:i}load(){return f(this,void 0,void 0,function*(){})}enable(e){var t;if(this.state.enabled)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this.updateState({enabled:!0},n)}disable(e){var t;if(this.state.enabled===!1)return;let n=(t=e==null?void 0:e.userAction)==null?!0:t;this.updateState({enabled:!1},n)}dispose(){this.disable(),this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null);try{let e=this.findRenderMesh();e&&(e.material.aggregationEnabled=!1,e.material.aggregationProgress=1)}catch(e){}}extractKeyframes(e){let t=[];if(!e.content.data)throw Error(`轨迹数据未加载`);let n=e.content.data.positionArray,r=n.length/3,i=.01,a=.1,o=new $(i,a,1,0,1),s=new $(i,a,1,0,1),c=new $(i,a,1,0,1),u=new Float32Array(r);for(let e=0;e<r;e++)if(e===0)u[e]=0;else{let t=new l.Vector3(n[(e-1)*3],n[(e-1)*3+1],n[(e-1)*3+2]);u[e]=new l.Vector3(n[e*3],n[e*3+1],n[e*3+2]).distanceTo(t)+u[e-1]}for(let i=0;i<r;i++){let a=new l.Vector3(0,0,0),d=0;for(let e=i-5;e<i+6;e++)e>=0&&e<r&&(a.add(new l.Vector3(n[e*3],n[e*3+1],n[e*3+2])),d++);a.divideScalar(d).applyMatrix4(e.transform);let f=o.filter(a.x),p=s.filter(a.y),m=c.filter(a.z);t.push({position:new l.Vector3(f,p,m),location:u[i]})}return t}computeAABB2D(e){let t=1/0,n=-1/0,r=1/0,i=-1/0;for(let a of e)a.position.x<t&&(t=a.position.x),a.position.x>n&&(n=a.position.x),a.position.z<r&&(r=a.position.z),a.position.z>i&&(i=a.position.z);return{min:new l.Vector2(t,r),max:new l.Vector2(n,i)}}findClosestKeyframeToRay(e,t){let n=1/0,r=t[0].position.clone(),i=new l.Vector3;for(let a of t){e.closestPointToPoint(a.position,i);let t=i.distanceTo(a.position);t<n&&(n=t,r=a.position.clone())}return r}findRenderMesh(){let e=null;if(this.five.scene.traverse(t=>{if(e)return;let n=t,r=n.material;r&&r.isPBMGaussianSplattingMaterial&&(e=n)}),!e)throw Error(`未找到 GaussianSplatting 渲染网格`);return e}loadTrajectoryDataIfNeeded(e){return f(this,void 0,void 0,function*(){var t,n,r,i,a,o,s,l;if((t=e.content)!=null&&t.data)return;if(((n=e.content)==null?void 0:n.loadState)===`LOADING`){yield new Promise(t=>{let n=c.AnimationFrameLoop.shared.add(()=>{var r;let i=(r=e.content)==null?void 0:r.loadState;(i===`READY`||i===`FAILED`||i===`UNLOADED`)&&(n(),t())})});return}let u=(r=this.five.model.viewLayers)==null?void 0:r[0],d=u==null?void 0:u.fetcher,f=u==null?void 0:u.search,p=(i=e.content)==null?void 0:i.uri;if(!d||!p)return;let m=f?p.includes(`?`)?`${p}&${f.replace(/^\?/,``)}`:`${p}${f.startsWith(`?`)?f:`?${f}`}`:p;e.content.loadState=`LOADING`;try{let t=yield(0,c.loadPly)(m,{type:`geometry`,customPropertyMapping:{time:{itemType:`uint32`,itemNames:[`time_milisec`]}},fetcher:d}),n=t.scene,r=n.getAttribute(`position`),i=n.getAttribute(`time`),u=(a=r==null?void 0:r.array)==null?new Float32Array:a,f=(o=i==null?void 0:i.array)==null?new Uint32Array:o;e.content.data={uri:m,byteLength:(s=t.byteLength)==null?0:s,memoryUsage:(l=t.memoryUsage)==null?0:l,positionArray:u,timeArray:f,object:null},e.content.loadState=`READY`}catch(t){console.warn(`[GaussianSplattingEntranceAnimationPlugin] trajectory ply 加载失败,将使用 3DGS AABB 回退`,t),e.content.data=void 0,e.content.loadState=`FAILED`}})}computeGSSceneBounds(){let e=new l.Box3,t=new l.Box3;return this.five.scene.traverse(n=>{let r=n;(r==null?void 0:r.boundingBox)instanceof l.Box3&&!r.boundingBox.isEmpty()&&(t.copy(r.boundingBox),r.matrixWorld&&t.applyMatrix4(r.matrixWorld),e.union(t))}),e.isEmpty()?null:e}getCameraCurve(){return f(this,void 0,void 0,function*(){var e,t,n,r,i,a,o,s,c,u;let d=(r=(n=(t=(e=this.five.model.viewLayers)==null?void 0:e[0])==null?void 0:t.trajectories)==null?void 0:n[0])==null?(s=(o=(a=(i=this.five.model.viewLayers)==null?void 0:i[0])==null?void 0:a.scene)==null?void 0:o.trajectories)==null?void 0:s[0]:r,f=null,p=null;if(d&&(yield this.loadTrajectoryDataIfNeeded(d),(c=d.content)!=null&&c.data&&((u=d.content.data.positionArray)==null?void 0:u.length)>=6&&(f=this.extractKeyframes(d),f.length>=2?p=this.computeAABB2D(f):f=null)),!f||!p){let e=this.computeGSSceneBounds();if(!e)throw Error(`未找到可用于计算入场曲线的 3DGS 边界或轨迹`);p={min:new l.Vector2(e.min.x,e.min.z),max:new l.Vector2(e.max.x,e.max.z)};let t=(p.min.x+p.max.x)/2,n=(p.min.y+p.max.y)/2,r=(e.min.y+e.max.y)/2,i=Math.max(p.max.x-p.min.x,p.max.y-p.min.y)*.5;f=[];let a=0,o=null;for(let e=0;e<16;e++){let s=e/16*Math.PI*2,c=new l.Vector3(t+Math.cos(s)*i,r,n+Math.sin(s)*i);o&&(a+=c.distanceTo(o)),f.push({position:c,location:a}),o=c}}this.keyframes=f,this.boundingAABB=p;let m=this.curveHeight,h=new l.Vector3((p.min.x+p.max.x)/2,m,(p.min.y+p.max.y)/2),g=(p.max.x-p.min.x)/2,_=(p.max.y-p.min.y)/2,v=Math.sqrt(g*g+_*_),y=e=>{let t=new l.Vector3().subVectors(e,h);return t.length()<.001&&t.set(1,0,0),h.clone().add(t.normalize().multiplyScalar(v))},b=new l.Vector3(f[0].position.x,m,f[0].position.z),x=y(b),S=new l.Vector3().subVectors(h,b).normalize(),C=new l.Ray(b,S),w=new l.Vector3(-S.z,0,S.x).normalize(),T=new l.Ray(h,w),E=this.findClosestKeyframeToRay(T,f),D=y(new l.Vector3(E.x,m,E.z)),O=this.findClosestKeyframeToRay(C,f),k=y(new l.Vector3(O.x,m,O.z));return new l.CatmullRomCurve3([x,D,k],!1,`centripetal`,.5)})}setBounding(e,t,n){let r=this.findRenderMesh();r.material.aggregationBoundsMin.copy(e),r.material.aggregationBoundsMax.copy(t),this.boundsSet=!0}setBounds(){if(!this.boundingAABB)throw Error(`请先调用 getCameraCurve 计算轨迹边界`);let e=this.boundingAABB,t=this.findRenderMesh(),n=new l.Vector3(e.min.x,0,e.min.y),r=new l.Vector3(e.max.x,3,e.max.y);t.material.aggregationBoundsMin.copy(n),t.material.aggregationBoundsMax.copy(r),this.boundsSet=!0}normalizedPointDuration(){let e=this.pointDuration;return e<=0?.01:Math.min(e<=1?e:e/this.duration,1)}resetToPointCloud(){return f(this,void 0,void 0,function*(){this.boundingAABB||(yield this.getCameraCurve()),this.setBounds();let e=this.findRenderMesh().material;e.aggregationEnabled=!0,e.aggregationProgress=0,e.aggregationPointDuration=this.normalizedPointDuration(),this.five.needsRender=!0,this.five.modelSceneNeedsRender=!0})}startAggregation(){if(!this.boundsSet)throw Error(`请先调用 setBounds 设置聚合边界`);let e=this.findRenderMesh().material;e.aggregationEnabled=!0,e.aggregationProgress=0,e.aggregationPointDuration=this.normalizedPointDuration(),this.five.needsRender=!0;let t=performance.now(),n=this.duration;this.cancelAnimation=c.AnimationFrameLoop.shared.add(()=>{let r=performance.now()-t,i=Math.min(r/n,1);e.aggregationProgress=i*i*(3-2*i),this.five.needsRender=!0,this.five.modelSceneNeedsRender=!0,i>=1&&(e.aggregationEnabled=!1,this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null))})}playEntrance(){return f(this,void 0,void 0,function*(){let e=yield this.getCameraCurve(),t=this.boundingAABB,n=new l.Vector3((t.min.x+t.max.x)/2,this.curveHeight,(t.min.y+t.max.y)/2),r=e.getPointAt(0),i=new c.Camera(90).copy(this.five.camera);i.position.copy(r),i.lookAt(n),i.computePose(0),this.five.setState(Object.assign({},i.pose)),this.setBounds();let a=this.findRenderMesh().material;a.aggregationEnabled=!0,a.aggregationProgress=0,a.aggregationPointDuration=this.normalizedPointDuration(),this.five.needsRender=!0;let o=this.duration,s=performance.now();return new Promise(t=>{this.cancelAnimation=c.AnimationFrameLoop.shared.add(()=>{let r=performance.now()-s,c=Math.min(r/o,1),l=c*c*(3-2*c);a.aggregationProgress=l,this.five.modelSceneNeedsRender=!0;let u=e.getPointAt(l);i.position.copy(u),i.lookAt(n),i.computePose(0),this.five.setState(Object.assign({},i.pose)),this.five.needsRender=!0,c>=1&&(a.aggregationEnabled=!1,a.aggregationProgress=1,this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null),t())})})})}},ln=(e,t)=>new cn(e,t);exports.BackgroundPlugin=_,Object.defineProperty(exports,"BasePlugin",{enumerable:!0,get:function(){return h}}),exports.CSS2DPlugin=Xe,exports.CSS3DPlugin=rt,exports.FloorplanPlugin=sn,exports.GaussianSplattingEntranceAnimationPlugin=ln,exports.Object3DHelperController=je,exports.Object3DHelperPlugin=Me,exports.PanoAnimePlugin=ze;