@realsee/five 6.8.0 → 6.8.1

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 (216) hide show
  1. package/ai_guides/features/flowing-light-2d-pass.md +64 -10
  2. package/ai_guides/features/flowing-light-3d-pass.md +64 -10
  3. package/docs/assets/hierarchy.js +1 -1
  4. package/docs/assets/navigation.js +1 -1
  5. package/docs/assets/search.js +1 -1
  6. package/docs/classes/five.AdaptiveLuminancePass.html +1 -1
  7. package/docs/classes/five.BoundingMesh.html +1 -1
  8. package/docs/classes/five.Camera.html +1 -1
  9. package/docs/classes/five.EyeDomeLightingPass.html +1 -1
  10. package/docs/classes/five.Five.html +1 -1
  11. package/docs/classes/five.FivePass.html +1 -1
  12. package/docs/classes/five.InternalWebGLRenderer.html +1 -1
  13. package/docs/classes/five.Model.html +1 -1
  14. package/docs/classes/five.ModelScene.html +1 -1
  15. package/docs/classes/five.NetworkSubscribe.html +1 -1
  16. package/docs/classes/five.PBMContainer.html +1 -1
  17. package/docs/classes/five.PBMCustomShader.html +1 -1
  18. package/docs/classes/five.PBMGSObject.html +1 -1
  19. package/docs/classes/five.PBMGroup.html +1 -1
  20. package/docs/classes/five.PBMMesh.html +1 -1
  21. package/docs/classes/five.PBMMeshMaterial.html +1 -1
  22. package/docs/classes/five.PBMPanoFilter.html +1 -1
  23. package/docs/classes/five.PBMPointCloud.html +1 -1
  24. package/docs/classes/five.PBMPointCloudMaterial.html +1 -1
  25. package/docs/classes/five.PBMSkinnedMesh.html +1 -1
  26. package/docs/classes/five.PBMUpdateable.html +1 -1
  27. package/docs/classes/five.PanoCircleMesh.html +1 -1
  28. package/docs/classes/five.PanoCircleMeshCustom.html +1 -1
  29. package/docs/classes/five.PanoCircleMeshSolid.html +1 -1
  30. package/docs/classes/five.Parameter.html +1 -1
  31. package/docs/classes/five.Scene.html +1 -1
  32. package/docs/classes/five.Subscribe.html +1 -1
  33. package/docs/classes/five.Tile3D.html +1 -1
  34. package/docs/classes/five.TileNode.html +1 -1
  35. package/docs/classes/five.TrajectoryNode.html +1 -1
  36. package/docs/classes/five.WorkResolvedObserver.html +1 -1
  37. package/docs/classes/gltf-loader.DDSLoader.html +1 -1
  38. package/docs/classes/gltf-loader.DRACOLoader.html +1 -1
  39. package/docs/classes/gltf-loader.GLTFLoader.html +1 -1
  40. package/docs/classes/gltf-loader.GLTFObject.html +1 -1
  41. package/docs/classes/gltf-loader.THREEGLTFLoader.html +1 -1
  42. package/docs/classes/line.Line.html +1 -1
  43. package/docs/classes/line.LineGeometry.html +1 -1
  44. package/docs/classes/line.LineMaterial.html +1 -1
  45. package/docs/classes/line.LineSegmentsGeometry.html +1 -1
  46. package/docs/classes/line.THREE_Line2.html +1 -1
  47. package/docs/classes/line.THREE_LineSegments2.html +1 -1
  48. package/docs/classes/plugins.BasePlugin.Controller.html +1 -1
  49. package/docs/classes/plugins.CSS2DObject.html +10 -0
  50. package/docs/classes/plugins.CSS2DRenderer.html +7 -0
  51. package/docs/classes/plugins.CSS3DObject.html +1 -1
  52. package/docs/classes/plugins.CSS3DSprite.html +1 -1
  53. package/docs/classes/plugins.Object3DHelperController.html +1 -1
  54. package/docs/classes/plugins.RoundedBoxGeometry.html +1 -1
  55. package/docs/classes/sticker.Sticker.html +1 -1
  56. package/docs/classes/vfx.Airflow.html +1 -1
  57. package/docs/classes/vfx.Flame.html +1 -1
  58. package/docs/classes/vfx.Particle.html +1 -1
  59. package/docs/classes/vfx.ParticleGPU.html +1 -1
  60. package/docs/classes/vfx.SpotLight.html +1 -1
  61. package/docs/documents/features_flowing-light-2d-pass.html +28 -15
  62. package/docs/documents/features_flowing-light-3d-pass.html +27 -14
  63. package/docs/functions/plugins.CSS2DPlugin.html +1 -0
  64. package/docs/functions/react.getPlugin.html +2 -0
  65. package/docs/functions/react.setPlugin.html +2 -0
  66. package/docs/functions/react.useFivePlugin.html +8 -0
  67. package/docs/functions/react.withFive.html +1 -1
  68. package/docs/hierarchy.html +1 -1
  69. package/docs/interfaces/five.AddableObject.html +1 -1
  70. package/docs/interfaces/five.AjaxOptions.html +1 -1
  71. package/docs/interfaces/five.BaseEvent.html +1 -1
  72. package/docs/interfaces/five.BaseExtendableEvent.html +1 -1
  73. package/docs/interfaces/five.EventCallback.html +1 -1
  74. package/docs/interfaces/five.GestureEvent.html +1 -1
  75. package/docs/interfaces/five.ImageOptions.html +1 -1
  76. package/docs/interfaces/five.IntersectEvent.html +1 -1
  77. package/docs/interfaces/five.IntersectMesh.html +1 -1
  78. package/docs/interfaces/five.IntersectMeshInterface.html +1 -1
  79. package/docs/interfaces/five.Intersection.html +1 -1
  80. package/docs/interfaces/five.LooseWorkWithExtrinsics.html +1 -1
  81. package/docs/interfaces/five.ModeChangeEvent.html +1 -1
  82. package/docs/interfaces/five.ModelControllerCustomInitArgs.html +1 -1
  83. package/docs/interfaces/five.ModelEvent.html +1 -1
  84. package/docs/interfaces/five.ModelSceneEvent.html +1 -1
  85. package/docs/interfaces/five.ModelTileEvent.html +1 -1
  86. package/docs/interfaces/five.MovePanoOptions.html +1 -1
  87. package/docs/interfaces/five.NetworkAbortError.html +1 -1
  88. package/docs/interfaces/five.NetworkFirbiddenError.html +1 -1
  89. package/docs/interfaces/five.NetworkOptions.html +1 -1
  90. package/docs/interfaces/five.NetworkProxyError.html +1 -1
  91. package/docs/interfaces/five.NetworkResourceEvent.html +1 -1
  92. package/docs/interfaces/five.NetworkResponseError.html +1 -1
  93. package/docs/interfaces/five.NetworkTimeoutError.html +1 -1
  94. package/docs/interfaces/five.ObjectEvent.html +1 -1
  95. package/docs/interfaces/five.PBMMaterial.html +1 -1
  96. package/docs/interfaces/five.PBMMeshMaterialParameters.html +1 -1
  97. package/docs/interfaces/five.PBMPointCloudMaterialParameters.html +1 -1
  98. package/docs/interfaces/five.PanoCircleMeshInterface.html +1 -1
  99. package/docs/interfaces/five.PanoEvent.html +1 -1
  100. package/docs/interfaces/five.PanoPrepareEvent.html +1 -1
  101. package/docs/interfaces/five.PanoTextureEvent.html +1 -1
  102. package/docs/interfaces/five.PanoramaControllerCustomInitArgs.html +1 -1
  103. package/docs/interfaces/five.PanoramaLikeControllerCustomInitArgs.html +1 -1
  104. package/docs/interfaces/five.ParameterMaterialValue.html +1 -1
  105. package/docs/interfaces/five.ParameterTilesetValue.html +1 -1
  106. package/docs/interfaces/five.ParameterValue.html +1 -1
  107. package/docs/interfaces/five.Pose.html +1 -1
  108. package/docs/interfaces/five.RenderEvent.html +1 -1
  109. package/docs/interfaces/five.ResolvedParameterValue.html +1 -1
  110. package/docs/interfaces/five.State.html +1 -1
  111. package/docs/interfaces/five.StateEvent.html +1 -1
  112. package/docs/interfaces/five.TextureOptions.html +1 -1
  113. package/docs/interfaces/five.TopviewControllerCustomInitArgs.html +1 -1
  114. package/docs/interfaces/five.VRPanoramaControllerCustomInitArgs.html +1 -1
  115. package/docs/interfaces/five.ViewLayer.html +1 -1
  116. package/docs/interfaces/five.WorkCubeImage.html +1 -1
  117. package/docs/interfaces/five.WorkImage.html +1 -1
  118. package/docs/interfaces/five.WorkObserver.html +1 -1
  119. package/docs/interfaces/five.WorkObserverProto.html +1 -1
  120. package/docs/interfaces/five.WorkTile.html +1 -1
  121. package/docs/interfaces/five.WorksEvent.html +1 -1
  122. package/docs/interfaces/five.XRControllerEvent.html +1 -1
  123. package/docs/interfaces/five.XRGestureEvent.html +1 -1
  124. package/docs/interfaces/five.XRPanoramaControllerCustomInitArgs.html +1 -1
  125. package/docs/interfaces/five.XRSessionEvent.html +1 -1
  126. package/docs/interfaces/plugins.BackgroundPluginController.html +1 -1
  127. package/docs/interfaces/plugins.BackgroundPluginType.EventMap.html +1 -1
  128. package/docs/interfaces/plugins.BasePlugin.State.html +1 -1
  129. package/docs/interfaces/plugins.CSS2DPluginController.html +49 -0
  130. package/docs/interfaces/plugins.CSS2DPluginType.Config.html +2 -0
  131. package/docs/interfaces/plugins.CSS2DPluginType.CreateCSS2DObjectType.html +8 -0
  132. package/docs/interfaces/plugins.CSS2DPluginType.EventMap.html +10 -0
  133. package/docs/interfaces/plugins.CSS2DPluginType.Params.html +4 -0
  134. package/docs/interfaces/plugins.CSS2DPluginType.State.html +8 -0
  135. package/docs/interfaces/plugins.CSS2DRendererParameters.html +2 -0
  136. package/docs/interfaces/plugins.CSS3DPluginController.html +12 -12
  137. package/docs/interfaces/plugins.CSS3DPluginType.EventMap.html +1 -1
  138. package/docs/interfaces/plugins.CSS3DPluginType.State.html +1 -1
  139. package/docs/interfaces/plugins.DynamicPathLinePluginController.html +1 -1
  140. package/docs/interfaces/plugins.DynamicPathLinePluginType.EventMap.html +1 -1
  141. package/docs/interfaces/plugins.DynamicPathLinePluginType.State.html +1 -1
  142. package/docs/interfaces/plugins.GaussianSplattingEntranceAnimationController.html +1 -1
  143. package/docs/interfaces/plugins.GaussianSplattingEntranceAnimationPluginType.EventMap.html +1 -1
  144. package/docs/interfaces/plugins.GaussianSplattingEntranceAnimationPluginType.State.html +1 -1
  145. package/docs/interfaces/plugins.ItemMaskController.html +1 -1
  146. package/docs/interfaces/plugins.ItemMaskPluginType.EventMap.html +1 -1
  147. package/docs/interfaces/plugins.ItemMaskPluginType.State.html +1 -1
  148. package/docs/interfaces/plugins.Object3DHelperPluginType.BaseController.html +1 -1
  149. package/docs/interfaces/plugins.Object3DHelperPluginType.BaseHelper.html +1 -1
  150. package/docs/interfaces/plugins.Object3DHelperPluginType.BoundingBoxController.html +1 -1
  151. package/docs/interfaces/plugins.Object3DHelperPluginType.MoveController.html +1 -1
  152. package/docs/interfaces/plugins.Object3DHelperPluginType.MoveHelperAbstract.html +1 -1
  153. package/docs/interfaces/plugins.Object3DHelperPluginType.RotateController.html +1 -1
  154. package/docs/interfaces/plugins.Object3DHelperPluginType.RotateHelperAbstract.html +1 -1
  155. package/docs/interfaces/plugins.OrientationPluginController.html +1 -1
  156. package/docs/interfaces/plugins.OrientationPluginType.EventMap.html +1 -1
  157. package/docs/interfaces/plugins.OrientationPluginType.State.html +1 -1
  158. package/docs/interfaces/plugins.PanoAnimeController.html +1 -1
  159. package/docs/interfaces/plugins.PanoAnimePluginType.EventMap.html +1 -1
  160. package/docs/interfaces/plugins.PanoAnimePluginType.State.html +1 -1
  161. package/docs/interfaces/plugins.PluginTemplateType.EventMap.html +1 -1
  162. package/docs/interfaces/plugins.PluginTemplateType.State.html +1 -1
  163. package/docs/interfaces/plugins.TrajectoryController.html +1 -1
  164. package/docs/interfaces/react.FiveAppProps.html +11 -0
  165. package/docs/interfaces/react.FiveInjectionTypes.html +1 -1
  166. package/docs/modules/plugins.CSS2DPluginType.html +1 -0
  167. package/docs/modules/plugins.html +1 -1
  168. package/docs/modules/react.html +1 -1
  169. package/docs/types/five.ParseOptions.html +1 -1
  170. package/docs/types/plugins.BasePlugin.EventMap.html +1 -1
  171. package/docs/types/plugins.CSS2DPluginType.PluginData.html +1 -0
  172. package/docs/types/plugins.CSS2DPluginType.ServerData.html +1 -0
  173. package/docs/variables/react.FiveApp.html +3 -0
  174. package/docs/variables/react.FiveAutoCanvas.html +3 -0
  175. package/five/index.js +5 -5
  176. package/five/index.mjs +65 -65
  177. package/five/renderer/postprocessing/passes/flowing-light-2d-pass.d.ts +6 -1
  178. package/five/renderer/postprocessing/passes/flowing-light-3d-pass.d.ts +3 -1
  179. package/gltf-loader/index.js +3 -3
  180. package/gltf-loader/index.mjs +3 -3
  181. package/line/index.js +3 -3
  182. package/line/index.mjs +3 -3
  183. package/package.json +1 -1
  184. package/plugins/CSS2DPlugin/Controller.d.ts +59 -0
  185. package/plugins/CSS2DPlugin/index.d.ts +5 -0
  186. package/plugins/CSS2DPlugin/typing.d.ts +30 -0
  187. package/plugins/index.d.ts +2 -0
  188. package/plugins/index.js +24 -4
  189. package/plugins/index.mjs +557 -393
  190. package/plugins/thirdParty/CSS2DRenderer.d.ts +37 -0
  191. package/react/autoCanvas.d.ts +9 -0
  192. package/react/fiveApp.d.ts +22 -0
  193. package/react/hooks/useFivePlugin.d.ts +26 -0
  194. package/react/index.d.ts +4 -0
  195. package/react/index.js +3 -3
  196. package/react/index.mjs +291 -175
  197. package/react/withFive.d.ts +1 -1
  198. package/shader-lib/index.js +2 -2
  199. package/shader-lib/index.mjs +2 -2
  200. package/sticker/index.js +3 -3
  201. package/sticker/index.mjs +3 -3
  202. package/umd/five-gltf-loader.js +3 -3
  203. package/umd/five-line.js +3 -3
  204. package/umd/five-plugins.js +24 -4
  205. package/umd/five-react.js +3 -3
  206. package/umd/five-shader-lib.js +2 -2
  207. package/umd/five-sticker.js +3 -3
  208. package/umd/five-vfx.js +2 -2
  209. package/umd/five-vue.js +2 -2
  210. package/umd/five.js +5 -5
  211. package/vfx/index.js +2 -2
  212. package/vfx/index.mjs +2 -2
  213. package/vue/index.js +2 -2
  214. package/vue/index.mjs +2 -2
  215. package/work-downloader/index.js +2 -2
  216. package/work-downloader/index.mjs +2 -2
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @license
3
3
  * @realsee/five
4
- * Generated: 4/17/2026
5
- * Version: 6.8.0
4
+ * Generated: 2026/4/28
5
+ * Version: 6.8.1
6
6
  * Terms:
7
7
  * Realsee SDK License Agreement
8
8
  * Update: July 28, 2021
@@ -349,7 +349,7 @@ void main() {
349
349
  }
350
350
  `,side:n.DoubleSide,visible:this.state.selectedId===`${e.category_name}${e.index}`,uniforms:{opacity:{value:this.state.mode===`box`?1:0}},depthWrite:!1,depthTest:!1,transparent:!0}),p=new n.Mesh(d,f);return p.position.copy(u),p.name=`${e.category_name}${e.index}`,p.userData.color=new n.Vector4(...e.mask_color.map(e=>e/255).reverse(),1),p.userData.visible_viewpoint=Object.keys(e.visible_viewpoint),p});this.group.add(...t)})}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)}}setMode(e){this.updateState({mode:e},!1),e===`mask`?(this.group.children.forEach(e=>{e.material.uniforms.opacity.value=0}),this.loadPanoMask(this.five.state.panoIndex)):e===`box`&&(this.itemMaskMesh.material.uniforms.color.value=new n.Vector4(0,0,0,1),this.group.children.forEach(e=>{e.material.uniforms.opacity.value=1}),this.five.needsRender=!0)}select(e,t){var n;this.updateState({selectedId:e==null?null:e},(n=t==null?void 0:t.userAction)==null?!1:n),this.group.children.forEach(t=>{t.material.visible=this.state.selectAll||t.name===e}),this.five.needsRender=!0}selectAll(e=!0){this.updateState({selectAll:!!e},!1),this.select()}_enable(e){this.five.on(`panoArrived`,this.onFivePanoArrived),this.five.on(`wantsMoveToPano`,this.onFiveWantsMoveToPano),this.five.on(`gesture.mousemove`,this.onFiveMouseMove),this.five.on(`wantsTapGesture`,this.onFiveTapGesture),this.five.on(`cameraUpdate`,this.onFiveCameraUpdate),this.five.scene.add(this.group),document.head.appendChild(this.style)}_disable(e){this.five.off(`panoArrived`,this.onFivePanoArrived),this.five.off(`wantsMoveToPano`,this.onFiveWantsMoveToPano),this.five.off(`gesture.mousemove`,this.onFiveMouseMove),this.five.off(`wantsTapGesture`,this.onFiveTapGesture),this.five.off(`cameraUpdate`,this.onFiveCameraUpdate),this.five.scene.remove(this.group),document.head.removeChild(this.style)}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),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})}},A=(e,t)=>new k(e,t),ee=(function(e,t,n,r){"use strict";var i=[``,`webkit`,`Moz`,`MS`,`ms`,`o`],a=t.createElement?t.createElement(`div`):r,o=`function`,s=Math.round,c=Math.abs,l=Date.now;function u(e,t,n){return setTimeout(v(e,n),t)}function d(e,t,n){return Array.isArray(e)?(f(e,n[t],n),!0):!1}function f(e,t,n){var i;if(e)if(e.forEach)e.forEach(t,n);else if(e.length!==r)for(i=0;i<e.length;)t.call(n,e[i],i,e),i++;else for(i in e)e.hasOwnProperty(i)&&t.call(n,e[i],i,e)}function p(t,n,r){var i=`DEPRECATED METHOD: `+n+`
351
351
  `+r+` AT
352
- `;return function(){var n=Error(`get-stack-trace`),r=n&&n.stack?n.stack.replace(/^[^\(]+?[\n$]/gm,``).replace(/^\s+at\s+/gm,``).replace(/^Object.<anonymous>\s*\(/gm,`{anonymous}()@`):`Unknown Stack Trace`,a=e.console&&(e.console.warn||e.console.log);return a&&a.call(e.console,i,r),t.apply(this,arguments)}}var m=typeof Object.assign==`function`?Object.assign:function(e){if(e===r||e===null)throw TypeError(`Cannot convert undefined or null to object`);for(var t=Object(e),n=1;n<arguments.length;n++){var i=arguments[n];if(i!==r&&i!==null)for(var a in i)i.hasOwnProperty(a)&&(t[a]=i[a])}return t},h=p(function(e,t,n){for(var i=Object.keys(t),a=0;a<i.length;)(!n||n&&e[i[a]]===r)&&(e[i[a]]=t[i[a]]),a++;return e},`extend`,"Use `assign`."),g=p(function(e,t){return h(e,t,!0)},`merge`,"Use `assign`.");function _(e,t,n){var r=t.prototype,i=e.prototype=Object.create(r);i.constructor=e,i._super=r,n&&m(i,n)}function v(e,t){return function(){return e.apply(t,arguments)}}function y(e,t){return typeof e==o?e.apply(t&&t[0]||r,t):e}function b(e,t){return e===r?t:e}function x(e,t,n){f(T(t),function(t){e.addEventListener(t,n,!1)})}function S(e,t,n){f(T(t),function(t){e.removeEventListener(t,n,!1)})}function C(e,t){for(;e;){if(e==t)return!0;e=e.parentNode}return!1}function w(e,t){return e.indexOf(t)>-1}function T(e){return e.trim().split(/\s+/g)}function E(e,t,n){if(e.indexOf&&!n)return e.indexOf(t);for(var r=0;r<e.length;){if(n&&e[r][n]==t||!n&&e[r]===t)return r;r++}return-1}function D(e){return Array.prototype.slice.call(e,0)}function O(e,t,n){for(var r=[],i=[],a=0;a<e.length;){var o=t?e[a][t]:e[a];E(i,o)<0&&r.push(e[a]),i[a]=o,a++}return n&&(r=t?r.sort(function(e,n){return e[t]>n[t]}):r.sort()),r}function k(e,t){for(var n,a,o=t[0].toUpperCase()+t.slice(1),s=0;s<i.length;){if(n=i[s],a=n?n+o:t,a in e)return a;s++}return r}var A=1;function ee(){return A++}function j(t){var n=t.ownerDocument||t;return n.defaultView||n.parentWindow||e}var te=/mobile|tablet|ip(ad|hone|od)|android/i,ne=`ontouchstart`in e,re=k(e,`PointerEvent`)!==r,ie=ne&&te.test(navigator.userAgent),M=`touch`,ae=`pen`,N=`mouse`,oe=`kinect`,se=25,P=1,F=2,I=4,L=8,R=1,ce=2,z=4,B=8,le=16,V=ce|z,H=B|le,ue=V|H,de=[`x`,`y`],fe=[`clientX`,`clientY`];function U(e,t){var n=this;this.manager=e,this.callback=t,this.element=e.element,this.target=e.options.inputTarget,this.domHandler=function(t){y(e.options.enable,[e])&&n.handler(t)},this.init()}U.prototype={handler:function(){},init:function(){this.evEl&&x(this.element,this.evEl,this.domHandler),this.evTarget&&x(this.target,this.evTarget,this.domHandler),this.evWin&&x(j(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&S(this.element,this.evEl,this.domHandler),this.evTarget&&S(this.target,this.evTarget,this.domHandler),this.evWin&&S(j(this.element),this.evWin,this.domHandler)}};function pe(e){var t;return t=e.options.inputClass||(re?Pe:ie?He:ne?We:ke),new t(e,me)}function me(e,t,n){var r=n.pointers.length,i=n.changedPointers.length,a=t&P&&r-i===0,o=t&(I|L)&&r-i===0;n.isFirst=!!a,n.isFinal=!!o,a&&(e.session={}),n.eventType=t,he(e,n),e.emit(`hammer.input`,n),e.recognize(n),e.session.prevInput=n}function he(e,t){var n=e.session,r=t.pointers,i=r.length;n.firstInput||(n.firstInput=ve(t)),i>1&&!n.firstMultiple?n.firstMultiple=ve(t):i===1&&(n.firstMultiple=!1);var a=n.firstInput,o=n.firstMultiple,s=o?o.center:a.center,u=t.center=ye(r);t.timeStamp=l(),t.deltaTime=t.timeStamp-a.timeStamp,t.angle=Ce(s,u),t.distance=Se(s,u),ge(n,t),t.offsetDirection=xe(t.deltaX,t.deltaY);var d=be(t.deltaTime,t.deltaX,t.deltaY);t.overallVelocityX=d.x,t.overallVelocityY=d.y,t.overallVelocity=c(d.x)>c(d.y)?d.x:d.y,t.scale=o?Te(o.pointers,r):1,t.rotation=o?we(o.pointers,r):0,t.maxPointers=n.prevInput?t.pointers.length>n.prevInput.maxPointers?t.pointers.length:n.prevInput.maxPointers:t.pointers.length,_e(n,t);var f=e.element;C(t.srcEvent.target,f)&&(f=t.srcEvent.target),t.target=f}function ge(e,t){var n=t.center,r=e.offsetDelta||{},i=e.prevDelta||{},a=e.prevInput||{};(t.eventType===P||a.eventType===I)&&(i=e.prevDelta={x:a.deltaX||0,y:a.deltaY||0},r=e.offsetDelta={x:n.x,y:n.y}),t.deltaX=i.x+(n.x-r.x),t.deltaY=i.y+(n.y-r.y)}function _e(e,t){var n=e.lastInterval||t,i=t.timeStamp-n.timeStamp,a,o,s,l;if(t.eventType!=L&&(i>se||n.velocity===r)){var u=t.deltaX-n.deltaX,d=t.deltaY-n.deltaY,f=be(i,u,d);o=f.x,s=f.y,a=c(f.x)>c(f.y)?f.x:f.y,l=xe(u,d),e.lastInterval=t}else a=n.velocity,o=n.velocityX,s=n.velocityY,l=n.direction;t.velocity=a,t.velocityX=o,t.velocityY=s,t.direction=l}function ve(e){for(var t=[],n=0;n<e.pointers.length;)t[n]={clientX:s(e.pointers[n].clientX),clientY:s(e.pointers[n].clientY)},n++;return{timeStamp:l(),pointers:t,center:ye(t),deltaX:e.deltaX,deltaY:e.deltaY}}function ye(e){var t=e.length;if(t===1)return{x:s(e[0].clientX),y:s(e[0].clientY)};for(var n=0,r=0,i=0;i<t;)n+=e[i].clientX,r+=e[i].clientY,i++;return{x:s(n/t),y:s(r/t)}}function be(e,t,n){return{x:t/e||0,y:n/e||0}}function xe(e,t){return e===t?R:c(e)>=c(t)?e<0?ce:z:t<0?B:le}function Se(e,t,n){n||(n=de);var r=t[n[0]]-e[n[0]],i=t[n[1]]-e[n[1]];return Math.sqrt(r*r+i*i)}function Ce(e,t,n){n||(n=de);var r=t[n[0]]-e[n[0]],i=t[n[1]]-e[n[1]];return Math.atan2(i,r)*180/Math.PI}function we(e,t){return Ce(t[1],t[0],fe)+Ce(e[1],e[0],fe)}function Te(e,t){return Se(t[0],t[1],fe)/Se(e[0],e[1],fe)}var Ee={mousedown:P,mousemove:F,mouseup:I},De=`mousedown`,Oe=`mousemove mouseup`;function ke(){this.evEl=De,this.evWin=Oe,this.pressed=!1,U.apply(this,arguments)}_(ke,U,{handler:function(e){var t=Ee[e.type];t&P&&(e.button===0||e.button===2)&&(this.pressed=!0),t&F&&e.which!==1&&(t=I),this.pressed&&(t&I&&(this.pressed=!1),this.callback(this.manager,t,{pointers:[e],changedPointers:[e],pointerType:N,srcEvent:e}))}});var Ae={pointerdown:P,pointermove:F,pointerup:I,pointercancel:L,pointerout:L},je={2:M,3:ae,4:N,5:oe},Me=`pointerdown`,Ne=`pointermove pointerup pointercancel`;e.MSPointerEvent&&!e.PointerEvent&&(Me=`MSPointerDown`,Ne=`MSPointerMove MSPointerUp MSPointerCancel`);function Pe(){this.evEl=Me,this.evWin=Ne,U.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}_(Pe,U,{handler:function(e){var t=this.store,n=!1,r=!1,i=Ae[e.type.toLowerCase().replace(`ms`,``)],a=je[e.pointerType]||e.pointerType,o=a==M,s=E(t,e.pointerId,`pointerId`);i&P&&(e.button===0||e.button===2||o)?s<0&&(t.push(e),s=t.length-1):i&(I|L)?n=!0:!o&&e.buttons===0&&(n=!0,r=!0,i=Ae.pointerup),!(s<0)&&(r||(t[s]=e),this.callback(this.manager,i,{pointers:t,changedPointers:[e],pointerType:a,srcEvent:t[s]}),n&&t.splice(s,1))}});var Fe={touchstart:P,touchmove:F,touchend:I,touchcancel:L},Ie=`touchstart`,Le=`touchstart touchmove touchend touchcancel`;function Re(){this.evTarget=Ie,this.evWin=Le,this.started=!1,U.apply(this,arguments)}_(Re,U,{handler:function(e){var t=Fe[e.type];if(t===P&&(this.started=!0),this.started){var n=ze.call(this,e,t);t&(I|L)&&n[0].length-n[1].length===0&&(this.started=!1),this.callback(this.manager,t,{pointers:n[0],changedPointers:n[1],pointerType:M,srcEvent:e})}}});function ze(e,t){var n=D(e.touches),r=D(e.changedTouches);return t&(I|L)&&(n=O(n.concat(r),`identifier`,!0)),[n,r]}var Be={touchstart:P,touchmove:F,touchend:I,touchcancel:L},Ve=`touchstart touchmove touchend touchcancel`;function He(){this.evTarget=Ve,this.targetIds={},U.apply(this,arguments)}_(He,U,{handler:function(e){var t=Be[e.type],n=Ue.call(this,e,t);n&&this.callback(this.manager,t,{pointers:n[0],changedPointers:n[1],pointerType:M,srcEvent:e})}});function Ue(e,t){var n=D(e.touches),r=this.targetIds;if(t&(P|F)&&n.length===1)return r[n[0].identifier]=!0,[n,n];var i,a,o=D(e.changedTouches),s=[],c=this.target;if(a=n.filter(function(e){return C(e.target,c)}),t===P)for(i=0;i<a.length;)r[a[i].identifier]=!0,i++;for(i=0;i<o.length;)r[o[i].identifier]&&s.push(o[i]),t&(I|L)&&delete r[o[i].identifier],i++;if(s.length)return[O(a.concat(s),`identifier`,!0),s]}var W=2500,G=25;function We(){U.apply(this,arguments);var e=v(this.handler,this);this.touch=new He(this.manager,e),this.mouse=new ke(this.manager,e),this.primaryTouch=null,this.lastTouches=[]}_(We,U,{handler:function(e,t,n){var r=n.pointerType==M,i=n.pointerType==N;if(!(i&&n.sourceCapabilities&&n.sourceCapabilities.firesTouchEvents)){if(r)Ge.call(this,t,n);else if(i&&qe.call(this,n))return;this.callback(e,t,n)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});function Ge(e,t){e&P?(this.primaryTouch=t.changedPointers[0].identifier,Ke.call(this,t)):e&(I|L)&&Ke.call(this,t)}function Ke(e){var t=e.changedPointers[0];if(t.identifier===this.primaryTouch){var n={x:t.clientX,y:t.clientY};this.lastTouches.push(n);var r=this.lastTouches;setTimeout(function(){var e=r.indexOf(n);e>-1&&r.splice(e,1)},W)}}function qe(e){for(var t=e.srcEvent.clientX,n=e.srcEvent.clientY,r=0;r<this.lastTouches.length;r++){var i=this.lastTouches[r],a=Math.abs(t-i.x),o=Math.abs(n-i.y);if(a<=G&&o<=G)return!0}return!1}var Je=a?k(a.style,`touchAction`):r,Ye=Je!==r,Xe=`compute`,Ze=`auto`,Qe=`manipulation`,K=`none`,$e=`pan-x`,et=`pan-y`,tt=it();function nt(e,t){this.manager=e,this.set(t)}nt.prototype={set:function(e){e==Xe&&(e=this.compute()),Ye&&this.manager.element.style&&tt[e]&&(this.manager.element.style[Je]=e),this.actions=e.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var e=[];return f(this.manager.recognizers,function(t){y(t.options.enable,[t])&&(e=e.concat(t.getTouchAction()))}),rt(e.join(` `))},preventDefaults:function(e){var t=e.srcEvent,n=e.offsetDirection;if(this.manager.session.prevented){t.preventDefault();return}var r=this.actions,i=w(r,K)&&!tt[K],a=w(r,et)&&!tt[et],o=w(r,$e)&&!tt[$e];if(i){var s=e.pointers.length===1,c=e.distance<2,l=e.deltaTime<250;if(s&&c&&l)return}if(!(o&&a)&&(i||a&&n&V||o&&n&H))return this.preventSrc(t)},preventSrc:function(e){this.manager.session.prevented=!0,e.preventDefault()}};function rt(e){if(w(e,K))return K;var t=w(e,$e),n=w(e,et);return t&&n?K:t||n?t?$e:et:w(e,Qe)?Qe:Ze}function it(){if(!Ye)return!1;var t={},n=e.CSS&&e.CSS.supports;return[`auto`,`manipulation`,`pan-y`,`pan-x`,`pan-x pan-y`,`none`].forEach(function(r){t[r]=n?e.CSS.supports(`touch-action`,r):!0}),t}var at=1,q=2,ot=4,J=8,Y=J,st=16,X=32;function Z(e){this.options=m({},this.defaults,e||{}),this.id=ee(),this.manager=null,this.options.enable=b(this.options.enable,!0),this.state=at,this.simultaneous={},this.requireFail=[]}Z.prototype={defaults:{},set:function(e){return m(this.options,e),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(e){if(d(e,`recognizeWith`,this))return this;var t=this.simultaneous;return e=ut(e,this),t[e.id]||(t[e.id]=e,e.recognizeWith(this)),this},dropRecognizeWith:function(e){return d(e,`dropRecognizeWith`,this)?this:(e=ut(e,this),delete this.simultaneous[e.id],this)},requireFailure:function(e){if(d(e,`requireFailure`,this))return this;var t=this.requireFail;return e=ut(e,this),E(t,e)===-1&&(t.push(e),e.requireFailure(this)),this},dropRequireFailure:function(e){if(d(e,`dropRequireFailure`,this))return this;e=ut(e,this);var t=E(this.requireFail,e);return t>-1&&this.requireFail.splice(t,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(e){return!!this.simultaneous[e.id]},emit:function(e){var t=this,n=this.state;function r(n){t.manager.emit(n,e)}n<J&&r(t.options.event+ct(n)),r(t.options.event),e.additionalEvent&&r(e.additionalEvent),n>=J&&r(t.options.event+ct(n))},tryEmit:function(e){if(this.canEmit())return this.emit(e);this.state=X},canEmit:function(){for(var e=0;e<this.requireFail.length;){if(!(this.requireFail[e].state&(X|at)))return!1;e++}return!0},recognize:function(e){var t=m({},e);if(!y(this.options.enable,[this,t])){this.reset(),this.state=X;return}this.state&(Y|st|X)&&(this.state=at),this.state=this.process(t),this.state&(q|ot|J|st)&&this.tryEmit(t)},process:function(e){},getTouchAction:function(){},reset:function(){}};function ct(e){return e&st?`cancel`:e&J?`end`:e&ot?`move`:e&q?`start`:``}function lt(e){return e==le?`down`:e==B?`up`:e==ce?`left`:e==z?`right`:``}function ut(e,t){var n=t.manager;return n?n.get(e):e}function Q(){Z.apply(this,arguments)}_(Q,Z,{defaults:{pointers:1},attrTest:function(e){var t=this.options.pointers;return t===0||e.pointers.length===t},process:function(e){var t=this.state,n=e.eventType,r=t&(q|ot),i=this.attrTest(e);return r&&(n&L||!i)?t|st:r||i?n&I?t|J:t&q?t|ot:q:X}});function dt(){Q.apply(this,arguments),this.pX=null,this.pY=null}_(dt,Q,{defaults:{event:`pan`,threshold:10,pointers:1,direction:ue},getTouchAction:function(){var e=this.options.direction,t=[];return e&V&&t.push(et),e&H&&t.push($e),t},directionTest:function(e){var t=this.options,n=!0,r=e.distance,i=e.direction,a=e.deltaX,o=e.deltaY;return i&t.direction||(t.direction&V?(i=a===0?R:a<0?ce:z,n=a!=this.pX,r=Math.abs(e.deltaX)):(i=o===0?R:o<0?B:le,n=o!=this.pY,r=Math.abs(e.deltaY))),e.direction=i,n&&r>t.threshold&&i&t.direction},attrTest:function(e){return Q.prototype.attrTest.call(this,e)&&(this.state&q||!(this.state&q)&&this.directionTest(e))},emit:function(e){this.pX=e.deltaX,this.pY=e.deltaY;var t=lt(e.direction);t&&(e.additionalEvent=this.options.event+t),this._super.emit.call(this,e)}});function ft(){Q.apply(this,arguments)}_(ft,Q,{defaults:{event:`pinch`,threshold:0,pointers:2},getTouchAction:function(){return[K]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.scale-1)>this.options.threshold||this.state&q)},emit:function(e){if(e.scale!==1){var t=e.scale<1?`in`:`out`;e.additionalEvent=this.options.event+t}this._super.emit.call(this,e)}});function $(){Z.apply(this,arguments),this._timer=null,this._input=null}_($,Z,{defaults:{event:`press`,pointers:1,time:251,threshold:9},getTouchAction:function(){return[Ze]},process:function(e){var t=this.options,n=e.pointers.length===t.pointers,r=e.distance<t.threshold,i=e.deltaTime>t.time;if(this._input=e,!r||!n||e.eventType&(I|L)&&!i)this.reset();else if(e.eventType&P)this.reset(),this._timer=u(function(){this.state=Y,this.tryEmit()},t.time,this);else if(e.eventType&I)return Y;return X},reset:function(){clearTimeout(this._timer)},emit:function(e){this.state===Y&&(e&&e.eventType&I?this.manager.emit(this.options.event+`up`,e):(this._input.timeStamp=l(),this.manager.emit(this.options.event,this._input)))}});function pt(){Q.apply(this,arguments)}_(pt,Q,{defaults:{event:`rotate`,threshold:0,pointers:2},getTouchAction:function(){return[K]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.rotation)>this.options.threshold||this.state&q)}});function mt(){Q.apply(this,arguments)}_(mt,Q,{defaults:{event:`swipe`,threshold:10,velocity:.3,direction:V|H,pointers:1},getTouchAction:function(){return dt.prototype.getTouchAction.call(this)},attrTest:function(e){var t=this.options.direction,n;return t&(V|H)?n=e.overallVelocity:t&V?n=e.overallVelocityX:t&H&&(n=e.overallVelocityY),this._super.attrTest.call(this,e)&&t&e.offsetDirection&&e.distance>this.options.threshold&&e.maxPointers==this.options.pointers&&c(n)>this.options.velocity&&e.eventType&I},emit:function(e){var t=lt(e.offsetDirection);t&&this.manager.emit(this.options.event+t,e),this.manager.emit(this.options.event,e)}});function ht(){Z.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}_(ht,Z,{defaults:{event:`tap`,pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[Qe]},process:function(e){var t=this.options,n=e.pointers.length===t.pointers,r=e.distance<t.threshold,i=e.deltaTime<t.time;if(this.reset(),e.eventType&P&&this.count===0)return this.failTimeout();if(r&&i&&n){if(e.eventType!=I)return this.failTimeout();var a=this.pTime?e.timeStamp-this.pTime<t.interval:!0,o=!this.pCenter||Se(this.pCenter,e.center)<t.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,!o||!a?this.count=1:this.count+=1,this._input=e,this.count%t.taps===0)return this.hasRequireFailures()?(this._timer=u(function(){this.state=Y,this.tryEmit()},t.interval,this),q):Y}return X},failTimeout:function(){return this._timer=u(function(){this.state=X},this.options.interval,this),X},reset:function(){clearTimeout(this._timer)},emit:function(){this.state==Y&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}});function gt(e,t){return t=t||{},t.recognizers=b(t.recognizers,gt.defaults.preset),new yt(e,t)}gt.VERSION=`2.0.7`,gt.defaults={domEvents:!1,touchAction:Xe,enable:!0,inputTarget:null,inputClass:null,preset:[[pt,{enable:!1}],[ft,{enable:!1},[`rotate`]],[mt,{direction:V}],[dt,{direction:V},[`swipe`]],[ht],[ht,{event:`doubletap`,taps:2},[`tap`]],[$]],cssProps:{userSelect:`none`,touchSelect:`none`,touchCallout:`none`,contentZooming:`none`,userDrag:`none`,tapHighlightColor:`rgba(0,0,0,0)`}};var _t=1,vt=2;function yt(e,t){this.options=m({},gt.defaults,t||{}),this.options.inputTarget=this.options.inputTarget||e,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=pe(this),this.touchAction=new nt(this,this.options.touchAction),bt(this,!0),f(this.options.recognizers,function(e){var t=this.add(new e[0](e[1]));e[2]&&t.recognizeWith(e[2]),e[3]&&t.requireFailure(e[3])},this)}yt.prototype={set:function(e){return m(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this},stop:function(e){this.session.stopped=e?vt:_t},recognize:function(e){var t=this.session;if(!t.stopped){this.touchAction.preventDefaults(e);var n,r=this.recognizers,i=t.curRecognizer;(!i||i&&i.state&Y)&&(i=t.curRecognizer=null);for(var a=0;a<r.length;)n=r[a],t.stopped!==vt&&(!i||n==i||n.canRecognizeWith(i))?n.recognize(e):n.reset(),!i&&n.state&(q|ot|J)&&(i=t.curRecognizer=n),a++}},get:function(e){if(e instanceof Z)return e;for(var t=this.recognizers,n=0;n<t.length;n++)if(t[n].options.event==e)return t[n];return null},add:function(e){if(d(e,`add`,this))return this;var t=this.get(e.options.event);return t&&this.remove(t),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e},remove:function(e){if(d(e,`remove`,this))return this;if(e=this.get(e),e){var t=this.recognizers,n=E(t,e);n!==-1&&(t.splice(n,1),this.touchAction.update())}return this},on:function(e,t){if(e!==r&&t!==r){var n=this.handlers;return f(T(e),function(e){n[e]=n[e]||[],n[e].push(t)}),this}},off:function(e,t){if(e!==r){var n=this.handlers;return f(T(e),function(e){t?n[e]&&n[e].splice(E(n[e],t),1):delete n[e]}),this}},emit:function(e,t){this.options.domEvents&&xt(e,t);var n=this.handlers[e]&&this.handlers[e].slice();if(!(!n||!n.length)){t.type=e,t.preventDefault=function(){t.srcEvent.preventDefault()};for(var r=0;r<n.length;)n[r](t),r++}},destroy:function(){this.element&&bt(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}};function bt(e,t){var n=e.element;if(n.style){var r;f(e.options.cssProps,function(i,a){r=k(n.style,a),t?(e.oldCssProps[r]=n.style[r],n.style[r]=i):n.style[r]=e.oldCssProps[r]||``}),t||(e.oldCssProps={})}}function xt(e,n){var r=t.createEvent(`Event`);r.initEvent(e,!0,!0),r.gesture=n,n.target.dispatchEvent(r)}return m(gt,{INPUT_START:P,INPUT_MOVE:F,INPUT_END:I,INPUT_CANCEL:L,STATE_POSSIBLE:at,STATE_BEGAN:q,STATE_CHANGED:ot,STATE_ENDED:J,STATE_RECOGNIZED:Y,STATE_CANCELLED:st,STATE_FAILED:X,DIRECTION_NONE:R,DIRECTION_LEFT:ce,DIRECTION_RIGHT:z,DIRECTION_UP:B,DIRECTION_DOWN:le,DIRECTION_HORIZONTAL:V,DIRECTION_VERTICAL:H,DIRECTION_ALL:ue,Manager:yt,Input:U,TouchAction:nt,TouchInput:He,MouseInput:ke,PointerEventInput:Pe,TouchMouseInput:We,SingleTouchInput:Re,Recognizer:Z,AttrRecognizer:Q,Tap:ht,Pan:dt,Swipe:mt,Pinch:ft,Rotate:pt,Press:$,on:x,off:S,each:f,merge:g,extend:h,assign:m,inherit:_,bindFn:v,prefixed:k}),gt})(typeof window<`u`?window:{},typeof document<`u`?document:{},`Hammer`),j=function(e,t){t===void 0&&console.warn(`THREE.OrbitControls: The second parameter "domElement" is now mandatory.`),t===document&&console.error(`THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.`),this.object=e,this.domElement=t,this.enabled=!0,this.target=new n.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={LEFT:n.MOUSE.ROTATE,MIDDLE:n.MOUSE.DOLLY,RIGHT:n.MOUSE.PAN},this.touches={ONE:n.TOUCH.ROTATE,TWO:n.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return u.phi},this.getAzimuthalAngle=function(){return u.theta},this.saveState=function(){r.target0.copy(r.target),r.position0.copy(r.object.position),r.zoom0=r.object.zoom},this.reset=function(){r.target.copy(r.target0),r.object.position.copy(r.position0),r.object.zoom=r.zoom0,r.object.updateProjectionMatrix(),r.dispatchEvent(i),r.update(),c=s.NONE},this.update=function(){var t=new n.Vector3,a=new n.Quaternion().setFromUnitVectors(e.up,new n.Vector3(0,1,0)),o=a.clone().inverse(),h=new n.Vector3,g=new n.Quaternion;return function(){var e=r.object.position;return t.copy(e).sub(r.target),t.applyQuaternion(a),u.setFromVector3(t),r.autoRotate&&c===s.NONE&&E(w()),r.enableDamping?(u.theta+=d.theta*r.dampingFactor,u.phi+=d.phi*r.dampingFactor):(u.theta+=d.theta,u.phi+=d.phi),u.theta=Math.max(r.minAzimuthAngle,Math.min(r.maxAzimuthAngle,u.theta)),u.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,u.phi)),u.makeSafe(),u.radius*=f,u.radius=Math.max(r.minDistance,Math.min(r.maxDistance,u.radius)),r.enableDamping===!0?r.target.addScaledVector(p,r.dampingFactor):r.target.add(p),t.setFromSpherical(u),t.applyQuaternion(o),e.copy(r.target).add(t),r.object.lookAt(r.target),r.enableDamping===!0?(d.theta*=1-r.dampingFactor,d.phi*=1-r.dampingFactor,p.multiplyScalar(1-r.dampingFactor)):(d.set(0,0,0),p.set(0,0,0)),f=1,m||h.distanceToSquared(r.object.position)>l||8*(1-g.dot(r.object.quaternion))>l?(r.dispatchEvent(i),h.copy(r.object.position),g.copy(r.object.quaternion),m=!1,!0):!1}}(),this.dispose=function(){r.domElement.removeEventListener(`contextmenu`,he,!1),r.domElement.removeEventListener(`mousedown`,V,!1),r.domElement.removeEventListener(`wheel`,de,!1),r.domElement.removeEventListener(`touchstart`,U,!1),r.domElement.removeEventListener(`touchend`,me,!1),r.domElement.removeEventListener(`touchmove`,pe,!1),document.removeEventListener(`mousemove`,H,!1),document.removeEventListener(`mouseup`,ue,!1),r.domElement.removeEventListener(`keydown`,fe,!1)};var r=this,i={type:`change`},a={type:`start`},o={type:`end`},s={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},c=s.NONE,l=1e-6,u=new n.Spherical,d=new n.Spherical,f=1,p=new n.Vector3,m=!1,h=new n.Vector2,g=new n.Vector2,_=new n.Vector2,v=new n.Vector2,y=new n.Vector2,b=new n.Vector2,x=new n.Vector2,S=new n.Vector2,C=new n.Vector2;function w(){return 2*Math.PI/60/60*r.autoRotateSpeed}function T(){return Math.pow(.95,r.zoomSpeed)}function E(e){d.theta-=e}function D(e){d.phi-=e}var O=function(){var e=new n.Vector3;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),p.add(e)}}(),k=function(){var e=new n.Vector3;return function(t,n){r.screenSpacePanning===!0?e.setFromMatrixColumn(n,1):(e.setFromMatrixColumn(n,0),e.crossVectors(r.object.up,e)),e.multiplyScalar(t),p.add(e)}}(),A=function(){var e=new n.Vector3;return function(t,n){var i=r.domElement;if(r.object.isPerspectiveCamera){var a=r.object.position;e.copy(a).sub(r.target);var o=e.length();o*=Math.tan(r.object.fov/2*Math.PI/180),O(2*t*o/i.clientHeight,r.object.matrix),k(2*n*o/i.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(O(t*(r.object.right-r.object.left)/r.object.zoom/i.clientWidth,r.object.matrix),k(n*(r.object.top-r.object.bottom)/r.object.zoom/i.clientHeight,r.object.matrix)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),r.enablePan=!1)}}();function ee(e){r.object.isPerspectiveCamera?f/=e:r.object.isOrthographicCamera?(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom*e)),r.object.updateProjectionMatrix(),m=!0):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),r.enableZoom=!1)}function j(e){r.object.isPerspectiveCamera?f*=e:r.object.isOrthographicCamera?(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/e)),r.object.updateProjectionMatrix(),m=!0):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),r.enableZoom=!1)}function te(e){h.set(e.clientX,e.clientY)}function ne(e){x.set(e.clientX,e.clientY)}function re(e){v.set(e.clientX,e.clientY)}function ie(e){g.set(e.clientX,e.clientY),_.subVectors(g,h).multiplyScalar(r.rotateSpeed);var t=r.domElement;E(2*Math.PI*_.x/t.clientHeight),D(2*Math.PI*_.y/t.clientHeight),h.copy(g),r.update()}function M(e){S.set(e.clientX,e.clientY),C.subVectors(S,x),C.y>0?ee(T()):C.y<0&&j(T()),x.copy(S),r.update()}function ae(e){y.set(e.clientX,e.clientY),b.subVectors(y,v).multiplyScalar(r.panSpeed),A(b.x,b.y),v.copy(y),r.update()}function N(e){e.deltaY<0?j(T()):e.deltaY>0&&ee(T()),r.update()}function oe(e){var t=!1;switch(e.keyCode){case r.keys.UP:A(0,r.keyPanSpeed),t=!0;break;case r.keys.BOTTOM:A(0,-r.keyPanSpeed),t=!0;break;case r.keys.LEFT:A(r.keyPanSpeed,0),t=!0;break;case r.keys.RIGHT:A(-r.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),r.update())}function se(e){if(e.touches.length==1)h.set(e.touches[0].pageX,e.touches[0].pageY);else{var t=.5*(e.touches[0].pageX+e.touches[1].pageX),n=.5*(e.touches[0].pageY+e.touches[1].pageY);h.set(t,n)}}function P(e){if(e.touches.length==1)v.set(e.touches[0].pageX,e.touches[0].pageY);else{var t=.5*(e.touches[0].pageX+e.touches[1].pageX),n=.5*(e.touches[0].pageY+e.touches[1].pageY);v.set(t,n)}}function F(e){var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY,r=Math.sqrt(t*t+n*n);x.set(0,r)}function I(e){r.enableZoom&&F(e),r.enablePan&&P(e)}function L(e){r.enableZoom&&F(e),r.enableRotate&&se(e)}function R(e){if(e.touches.length==1)g.set(e.touches[0].pageX,e.touches[0].pageY);else{var t=.5*(e.touches[0].pageX+e.touches[1].pageX),n=.5*(e.touches[0].pageY+e.touches[1].pageY);g.set(t,n)}_.subVectors(g,h).multiplyScalar(r.rotateSpeed);var i=r.domElement;E(2*Math.PI*_.x/i.clientHeight),D(2*Math.PI*_.y/i.clientHeight),h.copy(g)}function ce(e){if(e.touches.length==1)y.set(e.touches[0].pageX,e.touches[0].pageY);else{var t=.5*(e.touches[0].pageX+e.touches[1].pageX),n=.5*(e.touches[0].pageY+e.touches[1].pageY);y.set(t,n)}b.subVectors(y,v).multiplyScalar(r.panSpeed),A(b.x,b.y),v.copy(y)}function z(e){var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+n*n);S.set(0,i),C.set(0,Math.pow(S.y/x.y,r.zoomSpeed)),ee(C.y),x.copy(S)}function B(e){r.enableZoom&&z(e),r.enablePan&&ce(e)}function le(e){r.enableZoom&&z(e),r.enableRotate&&R(e)}function V(e){if(r.enabled!==!1){e.preventDefault(),r.domElement.focus?r.domElement.focus():window.focus();var t;switch(e.button){case 0:t=r.mouseButtons.LEFT;break;case 1:t=r.mouseButtons.MIDDLE;break;case 2:t=r.mouseButtons.RIGHT;break;default:t=-1}switch(t){case n.MOUSE.DOLLY:if(r.enableZoom===!1)return;ne(e),c=s.DOLLY;break;case n.MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(r.enablePan===!1)return;re(e),c=s.PAN}else{if(r.enableRotate===!1)return;te(e),c=s.ROTATE}break;case n.MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(r.enableRotate===!1)return;te(e),c=s.ROTATE}else{if(r.enablePan===!1)return;re(e),c=s.PAN}break;default:c=s.NONE}c!==s.NONE&&(document.addEventListener(`mousemove`,H,!1),document.addEventListener(`mouseup`,ue,!1),r.dispatchEvent(a))}}function H(e){if(r.enabled!==!1)switch(e.preventDefault(),c){case s.ROTATE:if(r.enableRotate===!1)return;ie(e);break;case s.DOLLY:if(r.enableZoom===!1)return;M(e);break;case s.PAN:if(r.enablePan===!1)return;ae(e);break}}function ue(e){r.enabled!==!1&&(document.removeEventListener(`mousemove`,H,!1),document.removeEventListener(`mouseup`,ue,!1),r.dispatchEvent(o),c=s.NONE)}function de(e){r.enabled===!1||r.enableZoom===!1||c!==s.NONE&&c!==s.ROTATE||(e.preventDefault(),e.stopPropagation(),r.dispatchEvent(a),N(e),r.dispatchEvent(o))}function fe(e){r.enabled===!1||r.enableKeys===!1||r.enablePan===!1||oe(e)}function U(e){if(r.enabled!==!1){switch(e.preventDefault(),e.touches.length){case 1:switch(r.touches.ONE){case n.TOUCH.ROTATE:if(r.enableRotate===!1)return;se(e),c=s.TOUCH_ROTATE;break;case n.TOUCH.PAN:if(r.enablePan===!1)return;P(e),c=s.TOUCH_PAN;break;default:c=s.NONE}break;case 2:switch(r.touches.TWO){case n.TOUCH.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;I(e),c=s.TOUCH_DOLLY_PAN;break;case n.TOUCH.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;L(e),c=s.TOUCH_DOLLY_ROTATE;break;default:c=s.NONE}break;default:c=s.NONE}c!==s.NONE&&r.dispatchEvent(a)}}function pe(e){if(r.enabled!==!1)switch(e.preventDefault(),e.stopPropagation(),c){case s.TOUCH_ROTATE:if(r.enableRotate===!1)return;R(e),r.update();break;case s.TOUCH_PAN:if(r.enablePan===!1)return;ce(e),r.update();break;case s.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;B(e),r.update();break;case s.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;le(e),r.update();break;default:c=s.NONE}}function me(e){r.enabled!==!1&&(r.dispatchEvent(o),c=s.NONE)}function he(e){r.enabled!==!1&&e.preventDefault()}r.domElement.addEventListener(`contextmenu`,he,!1),r.domElement.addEventListener(`mousedown`,V,!1),r.domElement.addEventListener(`wheel`,de,!1),r.domElement.addEventListener(`touchstart`,U,!1),r.domElement.addEventListener(`touchend`,me,!1),r.domElement.addEventListener(`touchmove`,pe,!1),r.domElement.addEventListener(`keydown`,fe,!1),r.domElement.tabIndex===-1&&(r.domElement.tabIndex=0),this.update()};j.prototype=Object.create(n.EventDispatcher.prototype),j.prototype.constructor=j;var te=function(e,t){j.call(this,e,t),this.mouseButtons.LEFT=n.MOUSE.PAN,this.mouseButtons.RIGHT=n.MOUSE.ROTATE,this.touches.ONE=n.TOUCH.PAN,this.touches.TWO=n.TOUCH.DOLLY_ROTATE};te.prototype=Object.create(n.EventDispatcher.prototype),te.prototype.constructor=te;var ne=new n.Vector3,re=new n.Quaternion,ie=new n.Vector3,M=class extends n.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}},ae=class extends M{constructor(e){super(e),this.isCSS3DSprite=!0,this.rotation2D=0}copy(e,t){return super.copy(e,t),this.rotation2D=e.rotation2D,this}},N=new n.Matrix4,oe=new n.Matrix4,se=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),N.copy(r.matrixWorldInverse),N.transpose(),e.rotation2D!==0&&N.multiply(oe.makeRotationZ(e.rotation2D)),e.matrixWorld.decompose(ne,re,ie),N.setPosition(ne),N.scale(ie),N.elements[3]=0,N.elements[7]=0,N.elements[11]=0,N.elements[15]=1;let i=h(N),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.autoUpdate===!0&&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?(N.copy(r.matrixWorldInverse),N.transpose(),e.rotation2D!==0&&N.multiply(oe.makeRotationZ(e.rotation2D)),e.matrixWorld.decompose(ne,re,ie),N.setPosition(ne),N.scale(ie),N.elements[3]=0,N.elements[7]=0,N.elements[11]=0,N.elements[15]=1,i=h(N)):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)}}};function P(e,t,r){let{top:i,left:a,width:o,height:s}=t.getBoundingClientRect();return r&&(a+=o*r.left,i+=s*(1-r.bottom-r.height),o*=r.width,s*=r.height),new n.Vector2((e.x-a)/o*2-1,-(e.y-i)/s*2+1)}var F=class extends n.BufferGeometry{constructor(e,t,r,i,a){super(),this.type=`RoundedBoxGeometry`,a=isNaN(a)?1:Math.max(1,Math.floor(a)),e=isNaN(e)?1:e,t=isNaN(t)?1:t,r=isNaN(r)?1:r,i=isNaN(i)?.15:i,i=Math.min(i,Math.min(e,Math.min(t,Math.min(r)))/2);let o=e/2-i,s=t/2-i,c=r/2-i;this.parameters={width:e,height:t,depth:r,radius:i,radiusSegments:a};let l=a+1,u=l*a+1<<3,d=new n.BufferAttribute(new Float32Array(u*3),3),f=new n.BufferAttribute(new Float32Array(u*3),3),p=[],m=[];new n.Vector3;let h=new n.Vector3,g=[],_=[],v=[],y=l*a,b=l*a+1;x(),C(),S(),w(),E(),T();function x(){let e=[new n.Vector3(1,1,1),new n.Vector3(1,1,-1),new n.Vector3(-1,1,-1),new n.Vector3(-1,1,1),new n.Vector3(1,-1,1),new n.Vector3(1,-1,-1),new n.Vector3(-1,-1,-1),new n.Vector3(-1,-1,1)];for(let e=0;e<8;e++)p.push([]),m.push([]);let t=Math.PI/2,r=new n.Vector3(o,s,c);for(let e=0;e<=a;e++){let n=e/a*t,o=Math.cos(n),s=Math.sin(n);if(e==a){h.set(0,1,0);let e=h.clone().multiplyScalar(i).add(r);p[0].push(e),g.push(e);let t=h.clone();m[0].push(t),_.push(t);continue}for(let e=0;e<=a;e++){let n=e/a*t;h.x=o*Math.cos(n),h.y=s,h.z=o*Math.sin(n);let c=h.clone().multiplyScalar(i).add(r);p[0].push(c),g.push(c);let l=h.clone().normalize();m[0].push(l),_.push(l)}}for(let t=1;t<8;t++)for(let n=0;n<p[0].length;n++){let r=p[0][n].clone().multiply(e[t]);p[t].push(r),g.push(r);let i=m[0][n].clone().multiply(e[t]);m[t].push(i),_.push(i)}}function S(){let e=[!0,!1,!0,!1,!1,!0,!1,!0],t=l*(a-1);for(let n=0;n<8;n++){let r=b*n;for(let t=0;t<a-1;t++){let i=t*l,o=(t+1)*l;for(let t=0;t<a;t++){let a=t+1,s=r+i+t,c=r+i+a,l=r+o+t,u=r+o+a;e[n]?(v.push(s),v.push(l),v.push(c),v.push(c),v.push(l),v.push(u)):(v.push(s),v.push(c),v.push(l),v.push(c),v.push(u),v.push(l))}}for(let i=0;i<a;i++){let a=r+t+i,o=r+t+i+1,s=r+y;e[n]?(v.push(a),v.push(s),v.push(o)):(v.push(a),v.push(o),v.push(s))}}}function C(){let e=y,t=y+b,n=y+b*2,r=y+b*3;v.push(e),v.push(t),v.push(n),v.push(e),v.push(n),v.push(r),e=y+b*4,t=y+b*5,n=y+b*6,r=y+b*7,v.push(e),v.push(n),v.push(t),v.push(e),v.push(r),v.push(n),e=0,t=b,n=b*4,r=b*5,v.push(e),v.push(n),v.push(t),v.push(t),v.push(n),v.push(r),e=b*2,t=b*3,n=b*6,r=b*7,v.push(e),v.push(n),v.push(t),v.push(t),v.push(n),v.push(r),e=a,t=a+b*3,n=a+b*4,r=a+b*7,v.push(e),v.push(t),v.push(n),v.push(t),v.push(r),v.push(n),e=a+b,t=a+b*2,n=a+b*5,r=a+b*6,v.push(e),v.push(n),v.push(t),v.push(t),v.push(n),v.push(r)}function w(){for(let e=0;e<4;e++){let t=e*b,n=4*b+t,r=(e&1)==1;for(let e=0;e<a;e++){let i=e+1,a=t+e,o=t+i,s=n+e,c=n+i;r?(v.push(a),v.push(s),v.push(o),v.push(o),v.push(s),v.push(c)):(v.push(a),v.push(o),v.push(s),v.push(o),v.push(c),v.push(s))}}}function T(){let e=[0,2,4,6],t=[1,3,5,7];for(let n=0;n<4;n++){let r=b*e[n],i=b*t[n],o=1>=n;for(let e=0;e<a;e++){let t=e*l,n=(e+1)*l,a=r+t,s=r+n,c=i+t,u=i+n;o?(v.push(a),v.push(c),v.push(s),v.push(s),v.push(c),v.push(u)):(v.push(a),v.push(s),v.push(c),v.push(s),v.push(u),v.push(c))}}}function E(){let e=a-1,t=[0,1,4,5],n=[3,2,7,6],r=[0,1,1,0];for(let i=0;i<4;i++){let o=t[i]*b,s=n[i]*b;for(let t=0;t<=e;t++){let n=o+a+t*l,c=o+(t==e?b-1:a+(t+1)*l),u=s+a+t*l,d=s+(t==e?b-1:a+(t+1)*l);r[i]?(v.push(n),v.push(u),v.push(c),v.push(c),v.push(u),v.push(d)):(v.push(n),v.push(c),v.push(u),v.push(c),v.push(d),v.push(u))}}}let D=0;for(let e=0;e<g.length;e++)d.setXYZ(D,g[e].x,g[e].y,g[e].z),f.setXYZ(D,_[e].x,_[e].y,_[e].z),D++;this.setIndex(new n.BufferAttribute(new Uint16Array(v),1)),this.setAttribute(`position`,d),this.setAttribute(`normal`,f)}};function I(e,t){return typeof e!=`number`||typeof t!=`number`?!1:Math.abs(e-t)<.001}function L(e,t,n,r=e=>e){let i=r(n);return e*(1-i)+t*i}var R=Number((Math.PI/2).toFixed(5));function ce(e,t,r){let i=new n.Shape;return i.moveTo(r,0),i.lineTo(e-r,0),i.absarc(e-r,r,r,-R,0,!1),i.lineTo(e,t-r),i.absarc(e-r,t-r,r,0,R,!1),i.lineTo(r,t),i.absarc(r,t-r,r,R,Math.PI,!1),i.lineTo(0,r),i.absarc(r,r,r,Math.PI,Math.PI*1.5,!1),i}var z=e=>{let t=document.createElement(`div`);t.innerText=e;let n=new M(t);return n.name=e,n.scale.set(.3,.3,.3),t.style.pointerEvents=`none`,t.style.backfaceVisibility=`hidden`,n},B=e=>{let t=new n.PlaneGeometry(5,5),r=new n.MeshBasicMaterial({transparent:!0,opacity:0}),i=new n.Mesh(t,r),a=document.createElement(`div`);a.innerText=e;let o=new M(a);return o.name=e,o.scale.set(.3,.3,.3),a.style.color=`#ffffff`,a.style.opacity=`0.5`,a.style.pointerEvents=`none`,a.style.backfaceVisibility=`hidden`,i.rotateX(-R),i.add(o),i},le=class extends p.Controller{get config(){return Object.assign({},this._config)}updateState(e,t){let n=this.state;this.state=Object.assign(Object.assign({},this.state),e),typeof e.arrowsVisible==`boolean`&&this.handleArrowsVisible(e.arrowsVisible),this.hooks.emit(`stateChange`,{state:this.state,prevState:n,userAction:t})}constructor(e,r){super(e),this.camera=new t.Camera(90),this.scene=new n.Scene,this.renderer=new n.WebGLRenderer({antialias:!0,alpha:!0}),this.css3drenderer=new se,this.ambientLight=new n.AmbientLight(16777215,.7),this.wrapper=document.createElement(`div`),this.arrows=document.createElement(`div`),this.arrowLeft=document.createElement(`div`),this.arrowRight=document.createElement(`div`),this.arrowFront=document.createElement(`div`),this.arrowBack=document.createElement(`div`),this.arrowTop=document.createElement(`div`),this.arrowBottom=document.createElement(`div`),this.spherical=null,this.dragging=!1,this.style=document.createElement(`style`),this.directionalLight=new n.DirectionalLight(16777215,.2),this.box=new n.Mesh(new F(8,8,8,.5,20),new n.MeshPhongMaterial({color:16777215})),this.faces=new n.Group,this.orient=({longitude:e,latitude:t})=>{this.dragging=!1,this.spherical=null,this.controls.enableDamping=!1,this.five.setState(Object.assign({latitude:t},e===void 0?{}:{longitude:e+this.config.fixedLongitude})),this.five.ready().then(()=>{this.controls.enableDamping=!0,this.setState({arrowsVisible:!0})})},this.onRenderFrame=()=>{var e,t,n,r,i;if(this.renderer.render(this.scene,this.camera),this.css3drenderer.render(this.scene,this.camera),this.directionalLight.position.copy(this.camera.position),(e=this.controls)==null||e.update(),this.dragging){this.camera.computePose(),this.updateByCamera();let{longitude:e,latitude:t}=this.camera.pose;this.five.setState({longitude:e,latitude:t},!0),this.updateArrows({longitude:e,latitude:t})}else if(this.spherical&&(!I(this.spherical.pi,(t=this.controls)==null?void 0:t.getPolarAngle())||!I(this.spherical.theta,(n=this.controls)==null?void 0:n.getAzimuthalAngle()))){this.spherical={pi:(r=this.controls)==null?void 0:r.getPolarAngle(),theta:(i=this.controls)==null?void 0:i.getAzimuthalAngle()},this.camera.computePose(),this.updateByCamera();let{longitude:e,latitude:t}=this.camera.pose;this.five.setState({longitude:e,latitude:t},!0),this.updateArrows({longitude:e,latitude:t})}else this.spherical=null},this.onTapGesture=e=>{let t=e.pointers[0].clientX,r=e.pointers[0].clientY,i=P({x:t,y:r},this.wrapper),a=new n.Raycaster;a.setFromCamera(i,this.camera);let[o]=a.intersectObjects(this.faces.children,!1);if(o){let{longitude:e,latitude:t}=o.object.userData;this.orient({longitude:e,latitude:t})}},this.onFiveWantsGesture=()=>{if(this.spherical)return!1},this.onFiveModeChange=e=>{this.controls&&(this.controls.maxPolarAngle=e===`Topview`?0:R)},this.onCameraUpdate=({state:e})=>{if(this.dragging||this.spherical)return;let{longitude:t,latitude:r}=e;this.camera.pose.longitude===t&&this.camera.pose.latitude===r||(this.camera.setFromPose({longitude:t,latitude:r,distance:20,offset:new n.Vector3(0,0,0)}),this.updateByCamera(),this.updateArrows({longitude:t,latitude:r}))},this.onPanStart=e=>{this.dragging=!0,this.spherical={}},this.onMouseMove=e=>{if(this.dragging)return;let t=P({x:e.clientX,y:e.clientY},this.wrapper),r=new n.Raycaster;r.setFromCamera(t,this.camera);let[i]=r.intersectObjects(this.faces.children,!1);this.faces.children.forEach(e=>{e.material.opacity=0,e.children[0].element.style.color=``}),i&&(i.object.material.opacity=.3,i.object.children[0].element.style.color=`#336dff`)},this.onPanEnd=e=>{this.dragging=!1,this.spherical={pi:this.controls.getPolarAngle(),theta:this.controls.getAzimuthalAngle()}},this.dispose=()=>{this.disable()},this.five=e,this.state=Object.assign({enabled:!1,visible:!0,arrowsVisible:!1},r==null?void 0:r.initialState),this._config=Object.assign({fixedLongitude:0,orthoView:!0},r==null?void 0:r.config),this.state.enabled&&this._enable({userAction:!1}),this.mc=new ee.Manager(this.wrapper),this.mc.add(new ee.Tap({interval:410})),this.mc.add(new ee.Pan({threshold:10,pointers:0})),this.camera.setFromPose({distance:20,offset:new n.Vector3(0,0,0),longitude:e.camera.pose.latitude,latitude:e.camera.pose.latitude}),this.cylinder=new n.Mesh(new n.CylinderGeometry(13.2,14,.01,50,1,!0),new n.ShaderMaterial({uniforms:{radiusTop:{value:13.2},radiusBottom:{value:14},opacity:{value:1}},vertexShader:`
352
+ `;return function(){var n=Error(`get-stack-trace`),r=n&&n.stack?n.stack.replace(/^[^\(]+?[\n$]/gm,``).replace(/^\s+at\s+/gm,``).replace(/^Object.<anonymous>\s*\(/gm,`{anonymous}()@`):`Unknown Stack Trace`,a=e.console&&(e.console.warn||e.console.log);return a&&a.call(e.console,i,r),t.apply(this,arguments)}}var m=typeof Object.assign==`function`?Object.assign:function(e){if(e===r||e===null)throw TypeError(`Cannot convert undefined or null to object`);for(var t=Object(e),n=1;n<arguments.length;n++){var i=arguments[n];if(i!==r&&i!==null)for(var a in i)i.hasOwnProperty(a)&&(t[a]=i[a])}return t},h=p(function(e,t,n){for(var i=Object.keys(t),a=0;a<i.length;)(!n||n&&e[i[a]]===r)&&(e[i[a]]=t[i[a]]),a++;return e},`extend`,"Use `assign`."),g=p(function(e,t){return h(e,t,!0)},`merge`,"Use `assign`.");function _(e,t,n){var r=t.prototype,i=e.prototype=Object.create(r);i.constructor=e,i._super=r,n&&m(i,n)}function v(e,t){return function(){return e.apply(t,arguments)}}function y(e,t){return typeof e==o?e.apply(t&&t[0]||r,t):e}function b(e,t){return e===r?t:e}function x(e,t,n){f(T(t),function(t){e.addEventListener(t,n,!1)})}function S(e,t,n){f(T(t),function(t){e.removeEventListener(t,n,!1)})}function C(e,t){for(;e;){if(e==t)return!0;e=e.parentNode}return!1}function w(e,t){return e.indexOf(t)>-1}function T(e){return e.trim().split(/\s+/g)}function E(e,t,n){if(e.indexOf&&!n)return e.indexOf(t);for(var r=0;r<e.length;){if(n&&e[r][n]==t||!n&&e[r]===t)return r;r++}return-1}function D(e){return Array.prototype.slice.call(e,0)}function O(e,t,n){for(var r=[],i=[],a=0;a<e.length;){var o=t?e[a][t]:e[a];E(i,o)<0&&r.push(e[a]),i[a]=o,a++}return n&&(r=t?r.sort(function(e,n){return e[t]>n[t]}):r.sort()),r}function k(e,t){for(var n,a,o=t[0].toUpperCase()+t.slice(1),s=0;s<i.length;){if(n=i[s],a=n?n+o:t,a in e)return a;s++}return r}var A=1;function ee(){return A++}function j(t){var n=t.ownerDocument||t;return n.defaultView||n.parentWindow||e}var te=/mobile|tablet|ip(ad|hone|od)|android/i,ne=`ontouchstart`in e,re=k(e,`PointerEvent`)!==r,ie=ne&&te.test(navigator.userAgent),M=`touch`,ae=`pen`,N=`mouse`,oe=`kinect`,se=25,P=1,F=2,I=4,L=8,R=1,ce=2,z=4,B=8,le=16,V=ce|z,H=B|le,ue=V|H,de=[`x`,`y`],fe=[`clientX`,`clientY`];function U(e,t){var n=this;this.manager=e,this.callback=t,this.element=e.element,this.target=e.options.inputTarget,this.domHandler=function(t){y(e.options.enable,[e])&&n.handler(t)},this.init()}U.prototype={handler:function(){},init:function(){this.evEl&&x(this.element,this.evEl,this.domHandler),this.evTarget&&x(this.target,this.evTarget,this.domHandler),this.evWin&&x(j(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&S(this.element,this.evEl,this.domHandler),this.evTarget&&S(this.target,this.evTarget,this.domHandler),this.evWin&&S(j(this.element),this.evWin,this.domHandler)}};function pe(e){var t;return t=e.options.inputClass||(re?Pe:ie?He:ne?Ke:ke),new t(e,me)}function me(e,t,n){var r=n.pointers.length,i=n.changedPointers.length,a=t&P&&r-i===0,o=t&(I|L)&&r-i===0;n.isFirst=!!a,n.isFinal=!!o,a&&(e.session={}),n.eventType=t,he(e,n),e.emit(`hammer.input`,n),e.recognize(n),e.session.prevInput=n}function he(e,t){var n=e.session,r=t.pointers,i=r.length;n.firstInput||(n.firstInput=ve(t)),i>1&&!n.firstMultiple?n.firstMultiple=ve(t):i===1&&(n.firstMultiple=!1);var a=n.firstInput,o=n.firstMultiple,s=o?o.center:a.center,u=t.center=ye(r);t.timeStamp=l(),t.deltaTime=t.timeStamp-a.timeStamp,t.angle=Ce(s,u),t.distance=Se(s,u),ge(n,t),t.offsetDirection=xe(t.deltaX,t.deltaY);var d=be(t.deltaTime,t.deltaX,t.deltaY);t.overallVelocityX=d.x,t.overallVelocityY=d.y,t.overallVelocity=c(d.x)>c(d.y)?d.x:d.y,t.scale=o?Te(o.pointers,r):1,t.rotation=o?we(o.pointers,r):0,t.maxPointers=n.prevInput?t.pointers.length>n.prevInput.maxPointers?t.pointers.length:n.prevInput.maxPointers:t.pointers.length,_e(n,t);var f=e.element;C(t.srcEvent.target,f)&&(f=t.srcEvent.target),t.target=f}function ge(e,t){var n=t.center,r=e.offsetDelta||{},i=e.prevDelta||{},a=e.prevInput||{};(t.eventType===P||a.eventType===I)&&(i=e.prevDelta={x:a.deltaX||0,y:a.deltaY||0},r=e.offsetDelta={x:n.x,y:n.y}),t.deltaX=i.x+(n.x-r.x),t.deltaY=i.y+(n.y-r.y)}function _e(e,t){var n=e.lastInterval||t,i=t.timeStamp-n.timeStamp,a,o,s,l;if(t.eventType!=L&&(i>se||n.velocity===r)){var u=t.deltaX-n.deltaX,d=t.deltaY-n.deltaY,f=be(i,u,d);o=f.x,s=f.y,a=c(f.x)>c(f.y)?f.x:f.y,l=xe(u,d),e.lastInterval=t}else a=n.velocity,o=n.velocityX,s=n.velocityY,l=n.direction;t.velocity=a,t.velocityX=o,t.velocityY=s,t.direction=l}function ve(e){for(var t=[],n=0;n<e.pointers.length;)t[n]={clientX:s(e.pointers[n].clientX),clientY:s(e.pointers[n].clientY)},n++;return{timeStamp:l(),pointers:t,center:ye(t),deltaX:e.deltaX,deltaY:e.deltaY}}function ye(e){var t=e.length;if(t===1)return{x:s(e[0].clientX),y:s(e[0].clientY)};for(var n=0,r=0,i=0;i<t;)n+=e[i].clientX,r+=e[i].clientY,i++;return{x:s(n/t),y:s(r/t)}}function be(e,t,n){return{x:t/e||0,y:n/e||0}}function xe(e,t){return e===t?R:c(e)>=c(t)?e<0?ce:z:t<0?B:le}function Se(e,t,n){n||(n=de);var r=t[n[0]]-e[n[0]],i=t[n[1]]-e[n[1]];return Math.sqrt(r*r+i*i)}function Ce(e,t,n){n||(n=de);var r=t[n[0]]-e[n[0]],i=t[n[1]]-e[n[1]];return Math.atan2(i,r)*180/Math.PI}function we(e,t){return Ce(t[1],t[0],fe)+Ce(e[1],e[0],fe)}function Te(e,t){return Se(t[0],t[1],fe)/Se(e[0],e[1],fe)}var Ee={mousedown:P,mousemove:F,mouseup:I},De=`mousedown`,Oe=`mousemove mouseup`;function ke(){this.evEl=De,this.evWin=Oe,this.pressed=!1,U.apply(this,arguments)}_(ke,U,{handler:function(e){var t=Ee[e.type];t&P&&(e.button===0||e.button===2)&&(this.pressed=!0),t&F&&e.which!==1&&(t=I),this.pressed&&(t&I&&(this.pressed=!1),this.callback(this.manager,t,{pointers:[e],changedPointers:[e],pointerType:N,srcEvent:e}))}});var Ae={pointerdown:P,pointermove:F,pointerup:I,pointercancel:L,pointerout:L},je={2:M,3:ae,4:N,5:oe},Me=`pointerdown`,Ne=`pointermove pointerup pointercancel`;e.MSPointerEvent&&!e.PointerEvent&&(Me=`MSPointerDown`,Ne=`MSPointerMove MSPointerUp MSPointerCancel`);function Pe(){this.evEl=Me,this.evWin=Ne,U.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}_(Pe,U,{handler:function(e){var t=this.store,n=!1,r=!1,i=Ae[e.type.toLowerCase().replace(`ms`,``)],a=je[e.pointerType]||e.pointerType,o=a==M,s=E(t,e.pointerId,`pointerId`);i&P&&(e.button===0||e.button===2||o)?s<0&&(t.push(e),s=t.length-1):i&(I|L)?n=!0:!o&&e.buttons===0&&(n=!0,r=!0,i=Ae.pointerup),!(s<0)&&(r||(t[s]=e),this.callback(this.manager,i,{pointers:t,changedPointers:[e],pointerType:a,srcEvent:t[s]}),n&&t.splice(s,1))}});var Fe={touchstart:P,touchmove:F,touchend:I,touchcancel:L},Ie=`touchstart`,Le=`touchstart touchmove touchend touchcancel`;function Re(){this.evTarget=Ie,this.evWin=Le,this.started=!1,U.apply(this,arguments)}_(Re,U,{handler:function(e){var t=Fe[e.type];if(t===P&&(this.started=!0),this.started){var n=ze.call(this,e,t);t&(I|L)&&n[0].length-n[1].length===0&&(this.started=!1),this.callback(this.manager,t,{pointers:n[0],changedPointers:n[1],pointerType:M,srcEvent:e})}}});function ze(e,t){var n=D(e.touches),r=D(e.changedTouches);return t&(I|L)&&(n=O(n.concat(r),`identifier`,!0)),[n,r]}var Be={touchstart:P,touchmove:F,touchend:I,touchcancel:L},Ve=`touchstart touchmove touchend touchcancel`;function He(){this.evTarget=Ve,this.targetIds={},U.apply(this,arguments)}_(He,U,{handler:function(e){var t=Be[e.type],n=Ue.call(this,e,t);n&&this.callback(this.manager,t,{pointers:n[0],changedPointers:n[1],pointerType:M,srcEvent:e})}});function Ue(e,t){var n=D(e.touches),r=this.targetIds;if(t&(P|F)&&n.length===1)return r[n[0].identifier]=!0,[n,n];var i,a,o=D(e.changedTouches),s=[],c=this.target;if(a=n.filter(function(e){return C(e.target,c)}),t===P)for(i=0;i<a.length;)r[a[i].identifier]=!0,i++;for(i=0;i<o.length;)r[o[i].identifier]&&s.push(o[i]),t&(I|L)&&delete r[o[i].identifier],i++;if(s.length)return[O(a.concat(s),`identifier`,!0),s]}var We=2500,Ge=25;function Ke(){U.apply(this,arguments);var e=v(this.handler,this);this.touch=new He(this.manager,e),this.mouse=new ke(this.manager,e),this.primaryTouch=null,this.lastTouches=[]}_(Ke,U,{handler:function(e,t,n){var r=n.pointerType==M,i=n.pointerType==N;if(!(i&&n.sourceCapabilities&&n.sourceCapabilities.firesTouchEvents)){if(r)qe.call(this,t,n);else if(i&&Ye.call(this,n))return;this.callback(e,t,n)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});function qe(e,t){e&P?(this.primaryTouch=t.changedPointers[0].identifier,Je.call(this,t)):e&(I|L)&&Je.call(this,t)}function Je(e){var t=e.changedPointers[0];if(t.identifier===this.primaryTouch){var n={x:t.clientX,y:t.clientY};this.lastTouches.push(n);var r=this.lastTouches;setTimeout(function(){var e=r.indexOf(n);e>-1&&r.splice(e,1)},We)}}function Ye(e){for(var t=e.srcEvent.clientX,n=e.srcEvent.clientY,r=0;r<this.lastTouches.length;r++){var i=this.lastTouches[r],a=Math.abs(t-i.x),o=Math.abs(n-i.y);if(a<=Ge&&o<=Ge)return!0}return!1}var Xe=a?k(a.style,`touchAction`):r,Ze=Xe!==r,Qe=`compute`,$e=`auto`,W=`manipulation`,G=`none`,K=`pan-x`,et=`pan-y`,tt=it();function nt(e,t){this.manager=e,this.set(t)}nt.prototype={set:function(e){e==Qe&&(e=this.compute()),Ze&&this.manager.element.style&&tt[e]&&(this.manager.element.style[Xe]=e),this.actions=e.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var e=[];return f(this.manager.recognizers,function(t){y(t.options.enable,[t])&&(e=e.concat(t.getTouchAction()))}),rt(e.join(` `))},preventDefaults:function(e){var t=e.srcEvent,n=e.offsetDirection;if(this.manager.session.prevented){t.preventDefault();return}var r=this.actions,i=w(r,G)&&!tt[G],a=w(r,et)&&!tt[et],o=w(r,K)&&!tt[K];if(i){var s=e.pointers.length===1,c=e.distance<2,l=e.deltaTime<250;if(s&&c&&l)return}if(!(o&&a)&&(i||a&&n&V||o&&n&H))return this.preventSrc(t)},preventSrc:function(e){this.manager.session.prevented=!0,e.preventDefault()}};function rt(e){if(w(e,G))return G;var t=w(e,K),n=w(e,et);return t&&n?G:t||n?t?K:et:w(e,W)?W:$e}function it(){if(!Ze)return!1;var t={},n=e.CSS&&e.CSS.supports;return[`auto`,`manipulation`,`pan-y`,`pan-x`,`pan-x pan-y`,`none`].forEach(function(r){t[r]=n?e.CSS.supports(`touch-action`,r):!0}),t}var at=1,q=2,ot=4,J=8,Y=J,st=16,X=32;function Z(e){this.options=m({},this.defaults,e||{}),this.id=ee(),this.manager=null,this.options.enable=b(this.options.enable,!0),this.state=at,this.simultaneous={},this.requireFail=[]}Z.prototype={defaults:{},set:function(e){return m(this.options,e),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(e){if(d(e,`recognizeWith`,this))return this;var t=this.simultaneous;return e=ut(e,this),t[e.id]||(t[e.id]=e,e.recognizeWith(this)),this},dropRecognizeWith:function(e){return d(e,`dropRecognizeWith`,this)?this:(e=ut(e,this),delete this.simultaneous[e.id],this)},requireFailure:function(e){if(d(e,`requireFailure`,this))return this;var t=this.requireFail;return e=ut(e,this),E(t,e)===-1&&(t.push(e),e.requireFailure(this)),this},dropRequireFailure:function(e){if(d(e,`dropRequireFailure`,this))return this;e=ut(e,this);var t=E(this.requireFail,e);return t>-1&&this.requireFail.splice(t,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(e){return!!this.simultaneous[e.id]},emit:function(e){var t=this,n=this.state;function r(n){t.manager.emit(n,e)}n<J&&r(t.options.event+ct(n)),r(t.options.event),e.additionalEvent&&r(e.additionalEvent),n>=J&&r(t.options.event+ct(n))},tryEmit:function(e){if(this.canEmit())return this.emit(e);this.state=X},canEmit:function(){for(var e=0;e<this.requireFail.length;){if(!(this.requireFail[e].state&(X|at)))return!1;e++}return!0},recognize:function(e){var t=m({},e);if(!y(this.options.enable,[this,t])){this.reset(),this.state=X;return}this.state&(Y|st|X)&&(this.state=at),this.state=this.process(t),this.state&(q|ot|J|st)&&this.tryEmit(t)},process:function(e){},getTouchAction:function(){},reset:function(){}};function ct(e){return e&st?`cancel`:e&J?`end`:e&ot?`move`:e&q?`start`:``}function lt(e){return e==le?`down`:e==B?`up`:e==ce?`left`:e==z?`right`:``}function ut(e,t){var n=t.manager;return n?n.get(e):e}function Q(){Z.apply(this,arguments)}_(Q,Z,{defaults:{pointers:1},attrTest:function(e){var t=this.options.pointers;return t===0||e.pointers.length===t},process:function(e){var t=this.state,n=e.eventType,r=t&(q|ot),i=this.attrTest(e);return r&&(n&L||!i)?t|st:r||i?n&I?t|J:t&q?t|ot:q:X}});function dt(){Q.apply(this,arguments),this.pX=null,this.pY=null}_(dt,Q,{defaults:{event:`pan`,threshold:10,pointers:1,direction:ue},getTouchAction:function(){var e=this.options.direction,t=[];return e&V&&t.push(et),e&H&&t.push(K),t},directionTest:function(e){var t=this.options,n=!0,r=e.distance,i=e.direction,a=e.deltaX,o=e.deltaY;return i&t.direction||(t.direction&V?(i=a===0?R:a<0?ce:z,n=a!=this.pX,r=Math.abs(e.deltaX)):(i=o===0?R:o<0?B:le,n=o!=this.pY,r=Math.abs(e.deltaY))),e.direction=i,n&&r>t.threshold&&i&t.direction},attrTest:function(e){return Q.prototype.attrTest.call(this,e)&&(this.state&q||!(this.state&q)&&this.directionTest(e))},emit:function(e){this.pX=e.deltaX,this.pY=e.deltaY;var t=lt(e.direction);t&&(e.additionalEvent=this.options.event+t),this._super.emit.call(this,e)}});function ft(){Q.apply(this,arguments)}_(ft,Q,{defaults:{event:`pinch`,threshold:0,pointers:2},getTouchAction:function(){return[G]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.scale-1)>this.options.threshold||this.state&q)},emit:function(e){if(e.scale!==1){var t=e.scale<1?`in`:`out`;e.additionalEvent=this.options.event+t}this._super.emit.call(this,e)}});function pt(){Z.apply(this,arguments),this._timer=null,this._input=null}_(pt,Z,{defaults:{event:`press`,pointers:1,time:251,threshold:9},getTouchAction:function(){return[$e]},process:function(e){var t=this.options,n=e.pointers.length===t.pointers,r=e.distance<t.threshold,i=e.deltaTime>t.time;if(this._input=e,!r||!n||e.eventType&(I|L)&&!i)this.reset();else if(e.eventType&P)this.reset(),this._timer=u(function(){this.state=Y,this.tryEmit()},t.time,this);else if(e.eventType&I)return Y;return X},reset:function(){clearTimeout(this._timer)},emit:function(e){this.state===Y&&(e&&e.eventType&I?this.manager.emit(this.options.event+`up`,e):(this._input.timeStamp=l(),this.manager.emit(this.options.event,this._input)))}});function mt(){Q.apply(this,arguments)}_(mt,Q,{defaults:{event:`rotate`,threshold:0,pointers:2},getTouchAction:function(){return[G]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.rotation)>this.options.threshold||this.state&q)}});function ht(){Q.apply(this,arguments)}_(ht,Q,{defaults:{event:`swipe`,threshold:10,velocity:.3,direction:V|H,pointers:1},getTouchAction:function(){return dt.prototype.getTouchAction.call(this)},attrTest:function(e){var t=this.options.direction,n;return t&(V|H)?n=e.overallVelocity:t&V?n=e.overallVelocityX:t&H&&(n=e.overallVelocityY),this._super.attrTest.call(this,e)&&t&e.offsetDirection&&e.distance>this.options.threshold&&e.maxPointers==this.options.pointers&&c(n)>this.options.velocity&&e.eventType&I},emit:function(e){var t=lt(e.offsetDirection);t&&this.manager.emit(this.options.event+t,e),this.manager.emit(this.options.event,e)}});function gt(){Z.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}_(gt,Z,{defaults:{event:`tap`,pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[W]},process:function(e){var t=this.options,n=e.pointers.length===t.pointers,r=e.distance<t.threshold,i=e.deltaTime<t.time;if(this.reset(),e.eventType&P&&this.count===0)return this.failTimeout();if(r&&i&&n){if(e.eventType!=I)return this.failTimeout();var a=this.pTime?e.timeStamp-this.pTime<t.interval:!0,o=!this.pCenter||Se(this.pCenter,e.center)<t.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,!o||!a?this.count=1:this.count+=1,this._input=e,this.count%t.taps===0)return this.hasRequireFailures()?(this._timer=u(function(){this.state=Y,this.tryEmit()},t.interval,this),q):Y}return X},failTimeout:function(){return this._timer=u(function(){this.state=X},this.options.interval,this),X},reset:function(){clearTimeout(this._timer)},emit:function(){this.state==Y&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}});function _t(e,t){return t=t||{},t.recognizers=b(t.recognizers,_t.defaults.preset),new bt(e,t)}_t.VERSION=`2.0.7`,_t.defaults={domEvents:!1,touchAction:Qe,enable:!0,inputTarget:null,inputClass:null,preset:[[mt,{enable:!1}],[ft,{enable:!1},[`rotate`]],[ht,{direction:V}],[dt,{direction:V},[`swipe`]],[gt],[gt,{event:`doubletap`,taps:2},[`tap`]],[pt]],cssProps:{userSelect:`none`,touchSelect:`none`,touchCallout:`none`,contentZooming:`none`,userDrag:`none`,tapHighlightColor:`rgba(0,0,0,0)`}};var vt=1,yt=2;function bt(e,t){this.options=m({},_t.defaults,t||{}),this.options.inputTarget=this.options.inputTarget||e,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=pe(this),this.touchAction=new nt(this,this.options.touchAction),xt(this,!0),f(this.options.recognizers,function(e){var t=this.add(new e[0](e[1]));e[2]&&t.recognizeWith(e[2]),e[3]&&t.requireFailure(e[3])},this)}bt.prototype={set:function(e){return m(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this},stop:function(e){this.session.stopped=e?yt:vt},recognize:function(e){var t=this.session;if(!t.stopped){this.touchAction.preventDefaults(e);var n,r=this.recognizers,i=t.curRecognizer;(!i||i&&i.state&Y)&&(i=t.curRecognizer=null);for(var a=0;a<r.length;)n=r[a],t.stopped!==yt&&(!i||n==i||n.canRecognizeWith(i))?n.recognize(e):n.reset(),!i&&n.state&(q|ot|J)&&(i=t.curRecognizer=n),a++}},get:function(e){if(e instanceof Z)return e;for(var t=this.recognizers,n=0;n<t.length;n++)if(t[n].options.event==e)return t[n];return null},add:function(e){if(d(e,`add`,this))return this;var t=this.get(e.options.event);return t&&this.remove(t),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e},remove:function(e){if(d(e,`remove`,this))return this;if(e=this.get(e),e){var t=this.recognizers,n=E(t,e);n!==-1&&(t.splice(n,1),this.touchAction.update())}return this},on:function(e,t){if(e!==r&&t!==r){var n=this.handlers;return f(T(e),function(e){n[e]=n[e]||[],n[e].push(t)}),this}},off:function(e,t){if(e!==r){var n=this.handlers;return f(T(e),function(e){t?n[e]&&n[e].splice(E(n[e],t),1):delete n[e]}),this}},emit:function(e,t){this.options.domEvents&&St(e,t);var n=this.handlers[e]&&this.handlers[e].slice();if(!(!n||!n.length)){t.type=e,t.preventDefault=function(){t.srcEvent.preventDefault()};for(var r=0;r<n.length;)n[r](t),r++}},destroy:function(){this.element&&xt(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}};function xt(e,t){var n=e.element;if(n.style){var r;f(e.options.cssProps,function(i,a){r=k(n.style,a),t?(e.oldCssProps[r]=n.style[r],n.style[r]=i):n.style[r]=e.oldCssProps[r]||``}),t||(e.oldCssProps={})}}function St(e,n){var r=t.createEvent(`Event`);r.initEvent(e,!0,!0),r.gesture=n,n.target.dispatchEvent(r)}return m(_t,{INPUT_START:P,INPUT_MOVE:F,INPUT_END:I,INPUT_CANCEL:L,STATE_POSSIBLE:at,STATE_BEGAN:q,STATE_CHANGED:ot,STATE_ENDED:J,STATE_RECOGNIZED:Y,STATE_CANCELLED:st,STATE_FAILED:X,DIRECTION_NONE:R,DIRECTION_LEFT:ce,DIRECTION_RIGHT:z,DIRECTION_UP:B,DIRECTION_DOWN:le,DIRECTION_HORIZONTAL:V,DIRECTION_VERTICAL:H,DIRECTION_ALL:ue,Manager:bt,Input:U,TouchAction:nt,TouchInput:He,MouseInput:ke,PointerEventInput:Pe,TouchMouseInput:Ke,SingleTouchInput:Re,Recognizer:Z,AttrRecognizer:Q,Tap:gt,Pan:dt,Swipe:ht,Pinch:ft,Rotate:mt,Press:pt,on:x,off:S,each:f,merge:g,extend:h,assign:m,inherit:_,bindFn:v,prefixed:k}),_t})(typeof window<`u`?window:{},typeof document<`u`?document:{},`Hammer`),j=function(e,t){t===void 0&&console.warn(`THREE.OrbitControls: The second parameter "domElement" is now mandatory.`),t===document&&console.error(`THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.`),this.object=e,this.domElement=t,this.enabled=!0,this.target=new n.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={LEFT:n.MOUSE.ROTATE,MIDDLE:n.MOUSE.DOLLY,RIGHT:n.MOUSE.PAN},this.touches={ONE:n.TOUCH.ROTATE,TWO:n.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return u.phi},this.getAzimuthalAngle=function(){return u.theta},this.saveState=function(){r.target0.copy(r.target),r.position0.copy(r.object.position),r.zoom0=r.object.zoom},this.reset=function(){r.target.copy(r.target0),r.object.position.copy(r.position0),r.object.zoom=r.zoom0,r.object.updateProjectionMatrix(),r.dispatchEvent(i),r.update(),c=s.NONE},this.update=function(){var t=new n.Vector3,a=new n.Quaternion().setFromUnitVectors(e.up,new n.Vector3(0,1,0)),o=a.clone().inverse(),h=new n.Vector3,g=new n.Quaternion;return function(){var e=r.object.position;return t.copy(e).sub(r.target),t.applyQuaternion(a),u.setFromVector3(t),r.autoRotate&&c===s.NONE&&E(w()),r.enableDamping?(u.theta+=d.theta*r.dampingFactor,u.phi+=d.phi*r.dampingFactor):(u.theta+=d.theta,u.phi+=d.phi),u.theta=Math.max(r.minAzimuthAngle,Math.min(r.maxAzimuthAngle,u.theta)),u.phi=Math.max(r.minPolarAngle,Math.min(r.maxPolarAngle,u.phi)),u.makeSafe(),u.radius*=f,u.radius=Math.max(r.minDistance,Math.min(r.maxDistance,u.radius)),r.enableDamping===!0?r.target.addScaledVector(p,r.dampingFactor):r.target.add(p),t.setFromSpherical(u),t.applyQuaternion(o),e.copy(r.target).add(t),r.object.lookAt(r.target),r.enableDamping===!0?(d.theta*=1-r.dampingFactor,d.phi*=1-r.dampingFactor,p.multiplyScalar(1-r.dampingFactor)):(d.set(0,0,0),p.set(0,0,0)),f=1,m||h.distanceToSquared(r.object.position)>l||8*(1-g.dot(r.object.quaternion))>l?(r.dispatchEvent(i),h.copy(r.object.position),g.copy(r.object.quaternion),m=!1,!0):!1}}(),this.dispose=function(){r.domElement.removeEventListener(`contextmenu`,he,!1),r.domElement.removeEventListener(`mousedown`,V,!1),r.domElement.removeEventListener(`wheel`,de,!1),r.domElement.removeEventListener(`touchstart`,U,!1),r.domElement.removeEventListener(`touchend`,me,!1),r.domElement.removeEventListener(`touchmove`,pe,!1),document.removeEventListener(`mousemove`,H,!1),document.removeEventListener(`mouseup`,ue,!1),r.domElement.removeEventListener(`keydown`,fe,!1)};var r=this,i={type:`change`},a={type:`start`},o={type:`end`},s={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},c=s.NONE,l=1e-6,u=new n.Spherical,d=new n.Spherical,f=1,p=new n.Vector3,m=!1,h=new n.Vector2,g=new n.Vector2,_=new n.Vector2,v=new n.Vector2,y=new n.Vector2,b=new n.Vector2,x=new n.Vector2,S=new n.Vector2,C=new n.Vector2;function w(){return 2*Math.PI/60/60*r.autoRotateSpeed}function T(){return Math.pow(.95,r.zoomSpeed)}function E(e){d.theta-=e}function D(e){d.phi-=e}var O=function(){var e=new n.Vector3;return function(t,n){e.setFromMatrixColumn(n,0),e.multiplyScalar(-t),p.add(e)}}(),k=function(){var e=new n.Vector3;return function(t,n){r.screenSpacePanning===!0?e.setFromMatrixColumn(n,1):(e.setFromMatrixColumn(n,0),e.crossVectors(r.object.up,e)),e.multiplyScalar(t),p.add(e)}}(),A=function(){var e=new n.Vector3;return function(t,n){var i=r.domElement;if(r.object.isPerspectiveCamera){var a=r.object.position;e.copy(a).sub(r.target);var o=e.length();o*=Math.tan(r.object.fov/2*Math.PI/180),O(2*t*o/i.clientHeight,r.object.matrix),k(2*n*o/i.clientHeight,r.object.matrix)}else r.object.isOrthographicCamera?(O(t*(r.object.right-r.object.left)/r.object.zoom/i.clientWidth,r.object.matrix),k(n*(r.object.top-r.object.bottom)/r.object.zoom/i.clientHeight,r.object.matrix)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),r.enablePan=!1)}}();function ee(e){r.object.isPerspectiveCamera?f/=e:r.object.isOrthographicCamera?(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom*e)),r.object.updateProjectionMatrix(),m=!0):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),r.enableZoom=!1)}function j(e){r.object.isPerspectiveCamera?f*=e:r.object.isOrthographicCamera?(r.object.zoom=Math.max(r.minZoom,Math.min(r.maxZoom,r.object.zoom/e)),r.object.updateProjectionMatrix(),m=!0):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),r.enableZoom=!1)}function te(e){h.set(e.clientX,e.clientY)}function ne(e){x.set(e.clientX,e.clientY)}function re(e){v.set(e.clientX,e.clientY)}function ie(e){g.set(e.clientX,e.clientY),_.subVectors(g,h).multiplyScalar(r.rotateSpeed);var t=r.domElement;E(2*Math.PI*_.x/t.clientHeight),D(2*Math.PI*_.y/t.clientHeight),h.copy(g),r.update()}function M(e){S.set(e.clientX,e.clientY),C.subVectors(S,x),C.y>0?ee(T()):C.y<0&&j(T()),x.copy(S),r.update()}function ae(e){y.set(e.clientX,e.clientY),b.subVectors(y,v).multiplyScalar(r.panSpeed),A(b.x,b.y),v.copy(y),r.update()}function N(e){e.deltaY<0?j(T()):e.deltaY>0&&ee(T()),r.update()}function oe(e){var t=!1;switch(e.keyCode){case r.keys.UP:A(0,r.keyPanSpeed),t=!0;break;case r.keys.BOTTOM:A(0,-r.keyPanSpeed),t=!0;break;case r.keys.LEFT:A(r.keyPanSpeed,0),t=!0;break;case r.keys.RIGHT:A(-r.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),r.update())}function se(e){if(e.touches.length==1)h.set(e.touches[0].pageX,e.touches[0].pageY);else{var t=.5*(e.touches[0].pageX+e.touches[1].pageX),n=.5*(e.touches[0].pageY+e.touches[1].pageY);h.set(t,n)}}function P(e){if(e.touches.length==1)v.set(e.touches[0].pageX,e.touches[0].pageY);else{var t=.5*(e.touches[0].pageX+e.touches[1].pageX),n=.5*(e.touches[0].pageY+e.touches[1].pageY);v.set(t,n)}}function F(e){var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY,r=Math.sqrt(t*t+n*n);x.set(0,r)}function I(e){r.enableZoom&&F(e),r.enablePan&&P(e)}function L(e){r.enableZoom&&F(e),r.enableRotate&&se(e)}function R(e){if(e.touches.length==1)g.set(e.touches[0].pageX,e.touches[0].pageY);else{var t=.5*(e.touches[0].pageX+e.touches[1].pageX),n=.5*(e.touches[0].pageY+e.touches[1].pageY);g.set(t,n)}_.subVectors(g,h).multiplyScalar(r.rotateSpeed);var i=r.domElement;E(2*Math.PI*_.x/i.clientHeight),D(2*Math.PI*_.y/i.clientHeight),h.copy(g)}function ce(e){if(e.touches.length==1)y.set(e.touches[0].pageX,e.touches[0].pageY);else{var t=.5*(e.touches[0].pageX+e.touches[1].pageX),n=.5*(e.touches[0].pageY+e.touches[1].pageY);y.set(t,n)}b.subVectors(y,v).multiplyScalar(r.panSpeed),A(b.x,b.y),v.copy(y)}function z(e){var t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+n*n);S.set(0,i),C.set(0,Math.pow(S.y/x.y,r.zoomSpeed)),ee(C.y),x.copy(S)}function B(e){r.enableZoom&&z(e),r.enablePan&&ce(e)}function le(e){r.enableZoom&&z(e),r.enableRotate&&R(e)}function V(e){if(r.enabled!==!1){e.preventDefault(),r.domElement.focus?r.domElement.focus():window.focus();var t;switch(e.button){case 0:t=r.mouseButtons.LEFT;break;case 1:t=r.mouseButtons.MIDDLE;break;case 2:t=r.mouseButtons.RIGHT;break;default:t=-1}switch(t){case n.MOUSE.DOLLY:if(r.enableZoom===!1)return;ne(e),c=s.DOLLY;break;case n.MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(r.enablePan===!1)return;re(e),c=s.PAN}else{if(r.enableRotate===!1)return;te(e),c=s.ROTATE}break;case n.MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(r.enableRotate===!1)return;te(e),c=s.ROTATE}else{if(r.enablePan===!1)return;re(e),c=s.PAN}break;default:c=s.NONE}c!==s.NONE&&(document.addEventListener(`mousemove`,H,!1),document.addEventListener(`mouseup`,ue,!1),r.dispatchEvent(a))}}function H(e){if(r.enabled!==!1)switch(e.preventDefault(),c){case s.ROTATE:if(r.enableRotate===!1)return;ie(e);break;case s.DOLLY:if(r.enableZoom===!1)return;M(e);break;case s.PAN:if(r.enablePan===!1)return;ae(e);break}}function ue(e){r.enabled!==!1&&(document.removeEventListener(`mousemove`,H,!1),document.removeEventListener(`mouseup`,ue,!1),r.dispatchEvent(o),c=s.NONE)}function de(e){r.enabled===!1||r.enableZoom===!1||c!==s.NONE&&c!==s.ROTATE||(e.preventDefault(),e.stopPropagation(),r.dispatchEvent(a),N(e),r.dispatchEvent(o))}function fe(e){r.enabled===!1||r.enableKeys===!1||r.enablePan===!1||oe(e)}function U(e){if(r.enabled!==!1){switch(e.preventDefault(),e.touches.length){case 1:switch(r.touches.ONE){case n.TOUCH.ROTATE:if(r.enableRotate===!1)return;se(e),c=s.TOUCH_ROTATE;break;case n.TOUCH.PAN:if(r.enablePan===!1)return;P(e),c=s.TOUCH_PAN;break;default:c=s.NONE}break;case 2:switch(r.touches.TWO){case n.TOUCH.DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;I(e),c=s.TOUCH_DOLLY_PAN;break;case n.TOUCH.DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;L(e),c=s.TOUCH_DOLLY_ROTATE;break;default:c=s.NONE}break;default:c=s.NONE}c!==s.NONE&&r.dispatchEvent(a)}}function pe(e){if(r.enabled!==!1)switch(e.preventDefault(),e.stopPropagation(),c){case s.TOUCH_ROTATE:if(r.enableRotate===!1)return;R(e),r.update();break;case s.TOUCH_PAN:if(r.enablePan===!1)return;ce(e),r.update();break;case s.TOUCH_DOLLY_PAN:if(r.enableZoom===!1&&r.enablePan===!1)return;B(e),r.update();break;case s.TOUCH_DOLLY_ROTATE:if(r.enableZoom===!1&&r.enableRotate===!1)return;le(e),r.update();break;default:c=s.NONE}}function me(e){r.enabled!==!1&&(r.dispatchEvent(o),c=s.NONE)}function he(e){r.enabled!==!1&&e.preventDefault()}r.domElement.addEventListener(`contextmenu`,he,!1),r.domElement.addEventListener(`mousedown`,V,!1),r.domElement.addEventListener(`wheel`,de,!1),r.domElement.addEventListener(`touchstart`,U,!1),r.domElement.addEventListener(`touchend`,me,!1),r.domElement.addEventListener(`touchmove`,pe,!1),r.domElement.addEventListener(`keydown`,fe,!1),r.domElement.tabIndex===-1&&(r.domElement.tabIndex=0),this.update()};j.prototype=Object.create(n.EventDispatcher.prototype),j.prototype.constructor=j;var te=function(e,t){j.call(this,e,t),this.mouseButtons.LEFT=n.MOUSE.PAN,this.mouseButtons.RIGHT=n.MOUSE.ROTATE,this.touches.ONE=n.TOUCH.PAN,this.touches.TWO=n.TOUCH.DOLLY_ROTATE};te.prototype=Object.create(n.EventDispatcher.prototype),te.prototype.constructor=te;var ne=new n.Vector3,re=new n.Quaternion,ie=new n.Vector3,M=class extends n.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}},ae=class extends M{constructor(e){super(e),this.isCSS3DSprite=!0,this.rotation2D=0}copy(e,t){return super.copy(e,t),this.rotation2D=e.rotation2D,this}},N=new n.Matrix4,oe=new n.Matrix4,se=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),N.copy(r.matrixWorldInverse),N.transpose(),e.rotation2D!==0&&N.multiply(oe.makeRotationZ(e.rotation2D)),e.matrixWorld.decompose(ne,re,ie),N.setPosition(ne),N.scale(ie),N.elements[3]=0,N.elements[7]=0,N.elements[11]=0,N.elements[15]=1;let i=h(N),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.autoUpdate===!0&&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?(N.copy(r.matrixWorldInverse),N.transpose(),e.rotation2D!==0&&N.multiply(oe.makeRotationZ(e.rotation2D)),e.matrixWorld.decompose(ne,re,ie),N.setPosition(ne),N.scale(ie),N.elements[3]=0,N.elements[7]=0,N.elements[11]=0,N.elements[15]=1,i=h(N)):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)}}};function P(e,t,r){let{top:i,left:a,width:o,height:s}=t.getBoundingClientRect();return r&&(a+=o*r.left,i+=s*(1-r.bottom-r.height),o*=r.width,s*=r.height),new n.Vector2((e.x-a)/o*2-1,-(e.y-i)/s*2+1)}var F=class extends n.BufferGeometry{constructor(e,t,r,i,a){super(),this.type=`RoundedBoxGeometry`,a=isNaN(a)?1:Math.max(1,Math.floor(a)),e=isNaN(e)?1:e,t=isNaN(t)?1:t,r=isNaN(r)?1:r,i=isNaN(i)?.15:i,i=Math.min(i,Math.min(e,Math.min(t,Math.min(r)))/2);let o=e/2-i,s=t/2-i,c=r/2-i;this.parameters={width:e,height:t,depth:r,radius:i,radiusSegments:a};let l=a+1,u=l*a+1<<3,d=new n.BufferAttribute(new Float32Array(u*3),3),f=new n.BufferAttribute(new Float32Array(u*3),3),p=[],m=[];new n.Vector3;let h=new n.Vector3,g=[],_=[],v=[],y=l*a,b=l*a+1;x(),C(),S(),w(),E(),T();function x(){let e=[new n.Vector3(1,1,1),new n.Vector3(1,1,-1),new n.Vector3(-1,1,-1),new n.Vector3(-1,1,1),new n.Vector3(1,-1,1),new n.Vector3(1,-1,-1),new n.Vector3(-1,-1,-1),new n.Vector3(-1,-1,1)];for(let e=0;e<8;e++)p.push([]),m.push([]);let t=Math.PI/2,r=new n.Vector3(o,s,c);for(let e=0;e<=a;e++){let n=e/a*t,o=Math.cos(n),s=Math.sin(n);if(e==a){h.set(0,1,0);let e=h.clone().multiplyScalar(i).add(r);p[0].push(e),g.push(e);let t=h.clone();m[0].push(t),_.push(t);continue}for(let e=0;e<=a;e++){let n=e/a*t;h.x=o*Math.cos(n),h.y=s,h.z=o*Math.sin(n);let c=h.clone().multiplyScalar(i).add(r);p[0].push(c),g.push(c);let l=h.clone().normalize();m[0].push(l),_.push(l)}}for(let t=1;t<8;t++)for(let n=0;n<p[0].length;n++){let r=p[0][n].clone().multiply(e[t]);p[t].push(r),g.push(r);let i=m[0][n].clone().multiply(e[t]);m[t].push(i),_.push(i)}}function S(){let e=[!0,!1,!0,!1,!1,!0,!1,!0],t=l*(a-1);for(let n=0;n<8;n++){let r=b*n;for(let t=0;t<a-1;t++){let i=t*l,o=(t+1)*l;for(let t=0;t<a;t++){let a=t+1,s=r+i+t,c=r+i+a,l=r+o+t,u=r+o+a;e[n]?(v.push(s),v.push(l),v.push(c),v.push(c),v.push(l),v.push(u)):(v.push(s),v.push(c),v.push(l),v.push(c),v.push(u),v.push(l))}}for(let i=0;i<a;i++){let a=r+t+i,o=r+t+i+1,s=r+y;e[n]?(v.push(a),v.push(s),v.push(o)):(v.push(a),v.push(o),v.push(s))}}}function C(){let e=y,t=y+b,n=y+b*2,r=y+b*3;v.push(e),v.push(t),v.push(n),v.push(e),v.push(n),v.push(r),e=y+b*4,t=y+b*5,n=y+b*6,r=y+b*7,v.push(e),v.push(n),v.push(t),v.push(e),v.push(r),v.push(n),e=0,t=b,n=b*4,r=b*5,v.push(e),v.push(n),v.push(t),v.push(t),v.push(n),v.push(r),e=b*2,t=b*3,n=b*6,r=b*7,v.push(e),v.push(n),v.push(t),v.push(t),v.push(n),v.push(r),e=a,t=a+b*3,n=a+b*4,r=a+b*7,v.push(e),v.push(t),v.push(n),v.push(t),v.push(r),v.push(n),e=a+b,t=a+b*2,n=a+b*5,r=a+b*6,v.push(e),v.push(n),v.push(t),v.push(t),v.push(n),v.push(r)}function w(){for(let e=0;e<4;e++){let t=e*b,n=4*b+t,r=(e&1)==1;for(let e=0;e<a;e++){let i=e+1,a=t+e,o=t+i,s=n+e,c=n+i;r?(v.push(a),v.push(s),v.push(o),v.push(o),v.push(s),v.push(c)):(v.push(a),v.push(o),v.push(s),v.push(o),v.push(c),v.push(s))}}}function T(){let e=[0,2,4,6],t=[1,3,5,7];for(let n=0;n<4;n++){let r=b*e[n],i=b*t[n],o=1>=n;for(let e=0;e<a;e++){let t=e*l,n=(e+1)*l,a=r+t,s=r+n,c=i+t,u=i+n;o?(v.push(a),v.push(c),v.push(s),v.push(s),v.push(c),v.push(u)):(v.push(a),v.push(s),v.push(c),v.push(s),v.push(u),v.push(c))}}}function E(){let e=a-1,t=[0,1,4,5],n=[3,2,7,6],r=[0,1,1,0];for(let i=0;i<4;i++){let o=t[i]*b,s=n[i]*b;for(let t=0;t<=e;t++){let n=o+a+t*l,c=o+(t==e?b-1:a+(t+1)*l),u=s+a+t*l,d=s+(t==e?b-1:a+(t+1)*l);r[i]?(v.push(n),v.push(u),v.push(c),v.push(c),v.push(u),v.push(d)):(v.push(n),v.push(c),v.push(u),v.push(c),v.push(d),v.push(u))}}}let D=0;for(let e=0;e<g.length;e++)d.setXYZ(D,g[e].x,g[e].y,g[e].z),f.setXYZ(D,_[e].x,_[e].y,_[e].z),D++;this.setIndex(new n.BufferAttribute(new Uint16Array(v),1)),this.setAttribute(`position`,d),this.setAttribute(`normal`,f)}};function I(e,t){return typeof e!=`number`||typeof t!=`number`?!1:Math.abs(e-t)<.001}function L(e,t,n,r=e=>e){let i=r(n);return e*(1-i)+t*i}var R=Number((Math.PI/2).toFixed(5));function ce(e,t,r){let i=new n.Shape;return i.moveTo(r,0),i.lineTo(e-r,0),i.absarc(e-r,r,r,-R,0,!1),i.lineTo(e,t-r),i.absarc(e-r,t-r,r,0,R,!1),i.lineTo(r,t),i.absarc(r,t-r,r,R,Math.PI,!1),i.lineTo(0,r),i.absarc(r,r,r,Math.PI,Math.PI*1.5,!1),i}var z=e=>{let t=document.createElement(`div`);t.innerText=e;let n=new M(t);return n.name=e,n.scale.set(.3,.3,.3),t.style.pointerEvents=`none`,t.style.backfaceVisibility=`hidden`,n},B=e=>{let t=new n.PlaneGeometry(5,5),r=new n.MeshBasicMaterial({transparent:!0,opacity:0}),i=new n.Mesh(t,r),a=document.createElement(`div`);a.innerText=e;let o=new M(a);return o.name=e,o.scale.set(.3,.3,.3),a.style.color=`#ffffff`,a.style.opacity=`0.5`,a.style.pointerEvents=`none`,a.style.backfaceVisibility=`hidden`,i.rotateX(-R),i.add(o),i},le=class extends p.Controller{get config(){return Object.assign({},this._config)}updateState(e,t){let n=this.state;this.state=Object.assign(Object.assign({},this.state),e),typeof e.arrowsVisible==`boolean`&&this.handleArrowsVisible(e.arrowsVisible),this.hooks.emit(`stateChange`,{state:this.state,prevState:n,userAction:t})}constructor(e,r){super(e),this.camera=new t.Camera(90),this.scene=new n.Scene,this.renderer=new n.WebGLRenderer({antialias:!0,alpha:!0}),this.css3drenderer=new se,this.ambientLight=new n.AmbientLight(16777215,.7),this.wrapper=document.createElement(`div`),this.arrows=document.createElement(`div`),this.arrowLeft=document.createElement(`div`),this.arrowRight=document.createElement(`div`),this.arrowFront=document.createElement(`div`),this.arrowBack=document.createElement(`div`),this.arrowTop=document.createElement(`div`),this.arrowBottom=document.createElement(`div`),this.spherical=null,this.dragging=!1,this.style=document.createElement(`style`),this.directionalLight=new n.DirectionalLight(16777215,.2),this.box=new n.Mesh(new F(8,8,8,.5,20),new n.MeshPhongMaterial({color:16777215})),this.faces=new n.Group,this.orient=({longitude:e,latitude:t})=>{this.dragging=!1,this.spherical=null,this.controls.enableDamping=!1,this.five.setState(Object.assign({latitude:t},e===void 0?{}:{longitude:e+this.config.fixedLongitude})),this.five.ready().then(()=>{this.controls.enableDamping=!0,this.setState({arrowsVisible:!0})})},this.onRenderFrame=()=>{var e,t,n,r,i;if(this.renderer.render(this.scene,this.camera),this.css3drenderer.render(this.scene,this.camera),this.directionalLight.position.copy(this.camera.position),(e=this.controls)==null||e.update(),this.dragging){this.camera.computePose(),this.updateByCamera();let{longitude:e,latitude:t}=this.camera.pose;this.five.setState({longitude:e,latitude:t},!0),this.updateArrows({longitude:e,latitude:t})}else if(this.spherical&&(!I(this.spherical.pi,(t=this.controls)==null?void 0:t.getPolarAngle())||!I(this.spherical.theta,(n=this.controls)==null?void 0:n.getAzimuthalAngle()))){this.spherical={pi:(r=this.controls)==null?void 0:r.getPolarAngle(),theta:(i=this.controls)==null?void 0:i.getAzimuthalAngle()},this.camera.computePose(),this.updateByCamera();let{longitude:e,latitude:t}=this.camera.pose;this.five.setState({longitude:e,latitude:t},!0),this.updateArrows({longitude:e,latitude:t})}else this.spherical=null},this.onTapGesture=e=>{let t=e.pointers[0].clientX,r=e.pointers[0].clientY,i=P({x:t,y:r},this.wrapper),a=new n.Raycaster;a.setFromCamera(i,this.camera);let[o]=a.intersectObjects(this.faces.children,!1);if(o){let{longitude:e,latitude:t}=o.object.userData;this.orient({longitude:e,latitude:t})}},this.onFiveWantsGesture=()=>{if(this.spherical)return!1},this.onFiveModeChange=e=>{this.controls&&(this.controls.maxPolarAngle=e===`Topview`?0:R)},this.onCameraUpdate=({state:e})=>{if(this.dragging||this.spherical)return;let{longitude:t,latitude:r}=e;this.camera.pose.longitude===t&&this.camera.pose.latitude===r||(this.camera.setFromPose({longitude:t,latitude:r,distance:20,offset:new n.Vector3(0,0,0)}),this.updateByCamera(),this.updateArrows({longitude:t,latitude:r}))},this.onPanStart=e=>{this.dragging=!0,this.spherical={}},this.onMouseMove=e=>{if(this.dragging)return;let t=P({x:e.clientX,y:e.clientY},this.wrapper),r=new n.Raycaster;r.setFromCamera(t,this.camera);let[i]=r.intersectObjects(this.faces.children,!1);this.faces.children.forEach(e=>{e.material.opacity=0,e.children[0].element.style.color=``}),i&&(i.object.material.opacity=.3,i.object.children[0].element.style.color=`#336dff`)},this.onPanEnd=e=>{this.dragging=!1,this.spherical={pi:this.controls.getPolarAngle(),theta:this.controls.getAzimuthalAngle()}},this.dispose=()=>{this.disable()},this.five=e,this.state=Object.assign({enabled:!1,visible:!0,arrowsVisible:!1},r==null?void 0:r.initialState),this._config=Object.assign({fixedLongitude:0,orthoView:!0},r==null?void 0:r.config),this.state.enabled&&this._enable({userAction:!1}),this.mc=new ee.Manager(this.wrapper),this.mc.add(new ee.Tap({interval:410})),this.mc.add(new ee.Pan({threshold:10,pointers:0})),this.camera.setFromPose({distance:20,offset:new n.Vector3(0,0,0),longitude:e.camera.pose.latitude,latitude:e.camera.pose.latitude}),this.cylinder=new n.Mesh(new n.CylinderGeometry(13.2,14,.01,50,1,!0),new n.ShaderMaterial({uniforms:{radiusTop:{value:13.2},radiusBottom:{value:14},opacity:{value:1}},vertexShader:`
353
353
  varying vec3 pos;
354
354
  varying mat4 vViewMatrix;
355
355
  void main() {
@@ -826,4 +826,24 @@ void main() {
826
826
 
827
827
  #five-CSS3DPlugin .five-CSS3DPlugin-hidden * {
828
828
  pointer-events: none;
829
- }`;function je(){return((1+Math.random())*parseInt(`10000`,36)|0).toString(36).substring(1)}function Me(){let e=je()+je().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 Ne=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){super(e),this.scene=new n.Scene,this.styleSheet=new CSSStyleSheet,this.camera=new n.PerspectiveCamera,this.cacheMap=new WeakMap,this.createCSS3DObject=({id:e=Me(),name:t,innerHTML:r,sprite:i,normal:a,position:o,scalar:s=.00216,visible:c=!0,timeout:l})=>{let u=document.createElement(`div`);u.className=`five-CSS3DPlugin-X`,c||u.classList.add(`five-CSS3DPlugin-hidden`),l&&u.style.setProperty(`--timeout`,l+`ms`),u.innerHTML=r;let d=i?new ae(u):new M(u);if(d.userData={id:e,_visible:c,_timeout:l,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}},a){let e=new n.Vector3(0,0,1),t=new n.Quaternion().setFromUnitVectors(e,a.clone().normalize());d.quaternion.copy(t)}return o&&d.position.copy(o),s&&d.scale.setScalar(s),t&&(d.name=t),d},this.render=()=>{this.camera.fov=this.five.camera.fov,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 se,this.renderer.domElement.id=`five-CSS3DPlugin`,this.styleSheet.replaceSync(Ae),/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),this.state=Object.assign({enabled:!0,visible:!0},t==null?void 0:t.initialState),this.state.enabled?this._enable({userAction:!1}):this.styleSheet.disabled=!0}load(e){return m(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:r,y:i}=this.five.renderer.getSize(new n.Vector2);t.parentElement.appendChild(this.renderer.domElement),this.renderer.setSize(r*2,i*2),this.renderer.domElement.style.width=r*2+`px`,this.renderer.domElement.style.height=i*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 M&&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)}},Pe=(e,t)=>new Ne(e,t);function Fe(e,t,r){if(r){let i=new n.Vector3().subVectors(e.position,r).applyQuaternion(e.quaternion.clone().inverse()).applyQuaternion(t).add(r);e.position.copy(i)}e.quaternion.copy(t)}function Ie(e){return e==null}var Le=class extends n.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 n.Box3().expandByObject(this.originObject3D).getCenter(new n.Vector3)):this.positionFrom instanceof n.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,r=e.yAxis instanceof Function?e.yAxis():e.yAxis,i=e.zAxis instanceof Function?e.zAxis():e.zAxis,a=t==null?void 0:t.clone(),o=r==null?void 0:r.clone(),s=i==null?void 0:i.clone();if(a&&!o&&!o){let e=new n.Quaternion().setFromUnitVectors(new n.Vector3(1,0,0),a.normalize());this.applyQuaternion(e)}if(o&&!a&&!s){let e=new n.Quaternion().setFromUnitVectors(new n.Vector3(0,1,0),o.normalize());this.applyQuaternion(e)}if(s&&!a&&!o){let e=new n.Quaternion().setFromUnitVectors(new n.Vector3(0,0,1),s.normalize());this.applyQuaternion(e)}if([a,o,s].filter(e=>!Ie(e)).length>=2){a||(a=new n.Vector3().crossVectors(o,s).normalize()),o||(o=new n.Vector3().crossVectors(a,s).normalize()),s||(s=new n.Vector3().crossVectors(a,o).normalize()),a.applyQuaternion(this.quaternion),o.applyQuaternion(this.quaternion),s.applyQuaternion(this.quaternion);let e=new n.Matrix4().makeBasis(a,o,s),t=new n.Quaternion().setFromRotationMatrix(e);this.quaternion.copy(t)}}}applyHelperScaleMatrix4(e,t){this.scale.applyMatrix4(e)}setHelperQuaternion(e,t){this.initQuaternion(),t?Fe(this,this.quaternion.clone().premultiply(e),t):this.quaternion.premultiply(e)}applyHelperQuaternion(e,t){if(t){let r=new n.Vector3().subVectors(this.position,t).applyQuaternion(e).add(t);this.position.copy(r)}this.applyQuaternion(e)}dispose(){this.removeFromParent()}},Re=class extends Le{},ze=class extends Le{},Be=class extends Le{},Ve=class extends n.Group{constructor(e){super(),this.direction=e||`x`}};n.Line;var He=class extends n.Mesh{constructor(e,t,n){super(e,t),this.direction=n||`x`}},Ue={X:16730698,Y:54927,Z:3368703},W=class{static get X(){return new n.Color(Ue.X).convertSRGBToLinear().clone()}static get Y(){return new n.Color(Ue.Y).convertSRGBToLinear().clone()}static get Z(){return new n.Color(Ue.Z).convertSRGBToLinear().clone()}},G={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},We=class extends Ve{constructor(e){var t;super(e.direction),this.lineHeight=.5,this.arrowHeight=.1,this.name=`ArrowGroup`;let r=new n.Color((t=e.color)==null?16214315:t),i=()=>new n.MeshBasicMaterial({color:r,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1});this.arrow=new He(new n.ConeGeometry(.04,this.arrowHeight,32),i(),e.direction),this.arrow.name=`arrow-${e.direction}`,this.arrow.renderOrder=G.MOVE_HELPER_ARROW,this.arrowNeg=new He(new n.ConeGeometry(.04,this.arrowHeight,32),i(),e.direction),this.arrowNeg.name=`arrow-neg-${e.direction}`,this.arrowNeg.renderOrder=G.MOVE_HELPER_ARROW;let a=.004;this.line=new He(new n.CylinderGeometry(a,a,this.lineHeight,32),i(),e.direction),this.line.name=`line-${e.direction}`,this.line.renderOrder=G.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))}},Ge=class extends Ve{constructor(e){var t,r;super(`plane`),this.name=`CenterHandle`,this.faceNormals=[new n.Vector3(1,0,0),new n.Vector3(-1,0,0),new n.Vector3(0,1,0),new n.Vector3(0,-1,0),new n.Vector3(0,0,1),new n.Vector3(0,0,-1)],this.baseColor=new n.Color((t=e==null?void 0:e.color)==null?16419862:t);let i=(r=e==null?void 0:e.size)==null?.05:r,a=new n.Color(16755008).convertSRGBToLinear();this.faceMaterials=Array.from({length:6},()=>new n.MeshBasicMaterial({color:a,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1,side:n.FrontSide}));let o=new n.BoxGeometry(i,i,i),s=new n.Mesh(o,this.faceMaterials);s.direction=`plane`,s.renderOrder=G.MOVE_HELPER_CENTER,s.name=`center-plane-handle`,this.cube=s,this.add(this.cube)}update(e){let t=new n.Vector3().subVectors(e.position,this.cube.getWorldPosition(new n.Vector3)).normalize(),r=this.cube.getWorldQuaternion(new n.Quaternion),i=this.faceNormals.map((e,n)=>{let i=e.clone().applyQuaternion(r).dot(t);return{index:n,angle:Math.acos(Math.abs(i))}});i.sort((e,t)=>e.angle-t.angle);let a=[new n.Color(16755008).convertSRGBToLinear(),new n.Color(16419862).convertSRGBToLinear(),new n.Color(13921032).convertSRGBToLinear()];i.forEach((e,t)=>{let n=Math.floor(t/2);this.faceMaterials[e.index].color.copy(a[n])})}},Ke=class extends Ve{constructor(e){var t,r,i;super(e.direction),this.name=`PlaneHandle`;let a=(t=e.size)==null?.12:t,o=(r=e.offset)==null?.12:r,s=new n.Color((i=e.color)==null?16776960:i),c=new n.BoxGeometry(a,a,.005),l=new n.MeshBasicMaterial({color:s,transparent:!0,opacity:.4,depthTest:!1,depthWrite:!1,side:n.DoubleSide});switch(this.handle=new n.Mesh(c,l),this.handle.direction=e.direction,this.handle.renderOrder=G.MOVE_HELPER_ARROW,this.handle.name=`plane-handle-${e.direction}`,e.direction){case`xy`:this.handle.position.set(o,o,0);break;case`xz`:this.handle.position.set(o,0,o),this.handle.rotation.x=-Math.PI/2;break;case`yz`:this.handle.position.set(0,o,o),this.handle.rotation.y=Math.PI/2;break}this.add(this.handle)}};function qe(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 Je(e){let{latitude:t,longitude:r}=e,i=new n.Vector3;return Ye-t<.03?i.set(0,1,0):Xe(0,r)?i.set(0,0,1):Xe(Math.PI,r)?i.set(0,0,-1):Xe(Ye,r)?i.set(1,0,0):i.set(-1,0,0),i}var Ye=Number((Math.PI/2).toFixed(5));function Xe(e,t){return typeof e!=`number`||typeof t!=`number`?!1:Math.abs(e-t)<.001}function Ze(e,t){return Qe(document.createElement(t==null?`div`:t),e)}function Qe(e,t){if(!t)return e;for(let n in t)n&&t[n]&&(e.style[n]=t[n]);return e}function K(e){let t=Ze(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 $e=class extends Re{constructor(e,t){super(e,t),this.name=`MoveHelper`,(t==null?void 0:t.xArrowEnable)!==!1&&(this.xArrow=new We({direction:`x`,color:W.X})),(t==null?void 0:t.yArrowEnable)!==!1&&(this.yArrow=new We({direction:`y`,color:W.Y})),(t==null?void 0:t.zArrowEnable)!==!1&&(this.zArrow=new We({direction:`z`,color:W.Z})),(t==null?void 0:t.centerHandleEnable)!==!1&&(this.centerHandle=new Ge),(t==null?void 0:t.xyPlaneEnable)!==!1&&(this.xyPlane=new Ke({direction:`xy`,color:W.Z})),(t==null?void 0:t.xzPlaneEnable)!==!1&&(this.xzPlane=new Ke({direction:`xz`,color:W.Y})),(t==null?void 0:t.yzPlaneEnable)!==!1&&(this.yzPlane=new Ke({direction:`yz`,color:W.X})),t!=null&&t.container&&(t==null?void 0:t.moveTipsEnable)!==!1&&(this.container=t.container,this.moveTips=K({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 n.Vector3(1,0,0).applyQuaternion(this.quaternion),r=new n.Vector3(0,1,0).applyQuaternion(this.quaternion),i=new n.Vector3(0,0,1).applyQuaternion(this.quaternion),a=e.pose,o=Je(a),s=.0872665;Math.abs(t.angleTo(o)-0)<s||Math.abs(t.angleTo(o)-Math.PI)<s?this.xArrow&&(this.xArrow.visible=!1):Math.abs(r.angleTo(o)-0)<s||Math.abs(r.angleTo(o)-Math.PI)<s?this.yArrow&&(this.yArrow.visible=!1):(Math.abs(i.angleTo(o)-0)<s||Math.abs(i.angleTo(o)-Math.PI)<s)&&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(qe(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()}},et=class extends Be{constructor(e,t){super(e,t),this.name=`RotateHelper`,this.children=[],(t==null?void 0:t.yzCircleEnable)!==!1&&(this.xCircle=new tt({direction:`x`,color:W.X})),(t==null?void 0:t.xzCircleEnable)!==!1&&(this.yCircle=new tt({direction:`y`,color:W.Y})),(t==null?void 0:t.xyCircleEnable)!==!1&&(this.zCircle=new tt({direction:`z`,color:W.Z})),t!=null&&t.container&&(t==null?void 0:t.angleTipsEnable)!==!1&&(this.container=t==null?void 0:t.container,this.angleTips=K({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(qe(e,this.position))}update(e){if(e.type===`OrthographicCamera`)return;let t=this.helperObject.position.clone().sub(e.position).normalize(),r=new n.Vector3(1,0,0).applyQuaternion(this.quaternion),i=new n.Vector3(0,1,0).applyQuaternion(this.quaternion),a=new n.Vector3(0,0,1).applyQuaternion(this.quaternion),o=t.angleTo(r),s=t.angleTo(i),c=t.angleTo(a),l=Math.PI/2,u=s>=l,d=c>=l,f=o>=l;if(this.xCircle){let e=this.xCircle.circle.gapAngle;u&&d?this.xCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,e,Math.PI/2-e*2):u&&!d?this.xCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,Math.PI/2+e,Math.PI/2-e*2):!u&&d?this.xCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,Math.PI/2*3+e,Math.PI/2-e*2):!u&&!d&&(this.xCircle.circle.geometry=new n.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 n.Vector3(0,0,1):!u&&d?(this.xCircle.angleSector.baseAxes=new n.Vector3(0,-1,0),this.xCircle.angleSector.offsetAngle=e=>e-Math.PI/2):!u&&!d&&(this.xCircle.angleSector.baseAxes=new n.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 n.RingGeometry(.3,.35,20,8,e,Math.PI/2-e*2):f&&!d?this.yCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,Math.PI/2*3+e,Math.PI/2-e*2):!f&&d?this.yCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,Math.PI/2+e,Math.PI/2-e*2):!f&&!d&&(this.yCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,Math.PI+e,Math.PI/2-e*2)),f&&d?this.yCircle.angleSector.baseAxes=new n.Vector3(1,0,0):f&&!d?(this.yCircle.angleSector.baseAxes=new n.Vector3(0,0,-1),this.yCircle.angleSector.offsetAngle=e=>e-Math.PI/2):!f&&d?(this.yCircle.angleSector.baseAxes=new n.Vector3(0,0,1),this.yCircle.angleSector.offsetAngle=e=>e+Math.PI/2):!f&&!d&&(this.yCircle.angleSector.baseAxes=new n.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 n.RingGeometry(.3,.35,20,8,e,Math.PI/2-e*2):f&&!u?this.zCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,Math.PI/2*3+e,Math.PI/2-e*2):!f&&u?this.zCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,Math.PI/2+e,Math.PI/2-e*2):!f&&!u&&(this.zCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,Math.PI+e,Math.PI/2-e*2)),this.zCircle.angleSector&&(f&&u?this.zCircle.angleSector.baseAxes=new n.Vector3(1,0,0):f&&!u?(this.zCircle.angleSector.baseAxes=new n.Vector3(0,-1,0),this.zCircle.angleSector.offsetAngle=e=>e-Math.PI/2):!f&&u?(this.zCircle.angleSector.baseAxes=new n.Vector3(0,1,0),this.zCircle.angleSector.offsetAngle=e=>e+Math.PI/2):!f&&!u&&(this.zCircle.angleSector.baseAxes=new n.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()}},tt=class extends n.Group{constructor(e){super(),this.direction=e.direction,this.circle=new nt(e),this.ring=new rt(e),this.angleSector=new it(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)}},nt=class extends n.Mesh{constructor(e){var t;super(),this.gapAngle=.02,this.geometry=new n.RingGeometry(.3,.35,20,8,this.gapAngle,Math.PI/2-this.gapAngle*2),this.material=new n.MeshBasicMaterial({opacity:.6,transparent:!0,color:(t=e.color)==null?16777215:t,side:n.DoubleSide,depthTest:!1}),this.direction=e.direction,this.renderOrder=G.ROTATE_HELPER,this.geometry.name=`RotateHelperCircleGeometry-${this.direction}`}},rt=class extends n.Group{constructor(e){super(),this.direction=e.direction;let t=.015,r=Array(8).fill(null).map((e,r)=>{let i=new n.RingGeometry(.3,.35,20,8,Math.PI/4*r+t,Math.PI/4-t*2),a=new n.MeshBasicMaterial({opacity:1,color:16777215,depthTest:!1,depthWrite:!1,transparent:!0,side:n.DoubleSide}),o=new n.Mesh(i,a);return o.name=`AxesDashedRing-${this.direction}-${r}`,o});this.add(...r)}},it=class extends n.Mesh{constructor(e){var t;switch(super(),this.offsetAngle=e=>e,e.direction){case`x`:this.baseAxes=new n.Vector3(0,0,1);break;case`y`:this.baseAxes=new n.Vector3(1,0,0);break;case`z`:this.baseAxes=new n.Vector3(1,0,0);break}this.geometry=new n.CircleGeometry(.3505,48,0,1e-4),this.material=new n.MeshBasicMaterial({opacity:.4,color:(t=e.color)==null?16777215:t,depthTest:!1,depthWrite:!1,transparent:!0,side:n.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`}},at=class extends ze{constructor(e){super(e),this.name=`BoundingBoxHelper`,this.positionAttribute=new n.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){Fe(this,e,t)}raycasterIntersectObject(e,t){return e.intersectObject(this,!1,t)}raycast(e,t){this.box.raycast(e,t)}update(){let e=new n.Box3,t=new n.Matrix4().getInverse(this.originObject3D.matrixWorld),r=new n.Vector3;if(this.originObject3D.updateMatrixWorld(!0),this.originObject3D.traverse(i=>{let a=i.geometry;if(!a)return;i.updateMatrixWorld(!0);let o=new n.Matrix4().multiplyMatrices(t,i.matrixWorld);if(a.isBufferGeometry){let t=a,n=t.attributes.position;if(n)for(let t=0,i=n.count;t<i;t++)r.fromBufferAttribute(n,t).applyMatrix4(o),e.expandByPoint(r);let i=t.attributes.instanceStart,s=t.attributes.instanceEnd;if(i)for(let t=0,n=i.count;t<n;t++)r.fromBufferAttribute(i,t).applyMatrix4(o),e.expandByPoint(r);if(s)for(let t=0,n=s.count;t<n;t++)r.fromBufferAttribute(s,t).applyMatrix4(o),e.expandByPoint(r)}else if(a.vertices){let t=a.vertices;for(let n of t)r.copy(n).applyMatrix4(o),e.expandByPoint(r)}}),e.isEmpty())return;let{min:i,max:a}=e;this.positionAttribute.setXYZ(0,a.x,a.y,a.z),this.positionAttribute.setXYZ(1,i.x,a.y,a.z),this.positionAttribute.setXYZ(2,i.x,i.y,a.z),this.positionAttribute.setXYZ(3,a.x,i.y,a.z),this.positionAttribute.setXYZ(4,a.x,a.y,i.z),this.positionAttribute.setXYZ(5,i.x,a.y,i.z),this.positionAttribute.setXYZ(6,i.x,i.y,i.z),this.positionAttribute.setXYZ(7,a.x,i.y,i.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 n.BufferGeometry;t.setIndex(new n.BufferAttribute(e,1)),t.setAttribute(`position`,this.positionAttribute);let r=new n.LineBasicMaterial({color:64767,linewidth:1,opacity:1,toneMapped:!1}),i=new n.LineSegments(t,r);return i.matrixAutoUpdate=!1,i}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 n.BufferGeometry;t.setIndex(new n.BufferAttribute(e,1)),t.setAttribute(`position`,this.positionAttribute);let r=new n.MeshBasicMaterial({color:64767,opacity:.1,depthTest:!1,transparent:!0});return new n.Mesh(t,r)}},q=new Map;function ot(e){if(q.has(e))return q.get(e).hooks;let n=new t.Subscribe,r=null,i,a=()=>{r=requestAnimationFrame(a);let t=e.projectionMatrix.toArray().join(`,`)+e.matrixWorld.toArray().join(`,`);t!==i&&(i=t,n.emit(`cameraUpdate`))};return a(),q.set(e,{hooks:n,dispose:()=>{q.delete(e),cancelAnimationFrame(r)}}),n}function J(e){return arguments.length===0?[]:Array.isArray(e)?e:[e]}var Y=class{updateOtherControllers(e){this.otherControllers=e}getIsDragging(){return this.isDragging}constructor(e,r){var i,a,o;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 n.Box3().expandByObject(this.originObject3D)),this.boundingBox),this.hooks=(i=e.sharedHooks)==null?new t.Subscribe:i,this.internalHooks=(a=e.sharedInternalHooks)==null?new t.Subscribe:a,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=(o=e.onRender)==null?(()=>{}):o,this.config=r==null?{}:r,this.otherControllers=e.otherControllers,this.initialHelperPosition(),this.initialHelperQuaternion(),this.updateHelperScale(),this.cameraHooks=ot(this.camera),this.enable();let s=this.onSetOriginObjectScale.bind(this),c=this.onSetOriginObjectRotate.bind(this),l=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`,s),this.internalHooks.on(`setObjectRotate`,c),this.internalHooks.on(`setObjectPosition`,l),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`,s),this.internalHooks.off(`setObjectRotate`,c),this.internalHooks.off(`setObjectPosition`,l),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 r=new n.Vector3().subVectors(this.helperObject3D.position,t).applyQuaternion(e.quaternion).add(t);this.helperObject3D.position.copy(r)}}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,r=new n.Vector3().subVectors(this.boundingBox.max,t).multiply(e).add(t),i=new n.Vector3().subVectors(this.boundingBox.min,t).multiply(e).add(t),a=this.calculateOffset(this.config.offset,{min:i,max:r});this.helperObject3D.initialPosition(a)}}hoverListener(e,t=16777215,r=1){let i=J(e).filter(e=>!Ie(e)),a=[];for(let e of i)if(e.material||e instanceof n.Group){let i=e instanceof n.Group?e.children.filter(e=>e instanceof n.Mesh):[e];i.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 o=()=>{i.forEach(e=>{if(e.name===`ScaleHelperTransparentGroup`){if(e.children[0]){let n=e.children[0].material;n.color.set(t),n.opacity=r}}else{let n=e.material;Array.isArray(n)?n.forEach(e=>{e.color.set(t),e.opacity=r}):(n.color.set(t),n.opacity=r)}}),this.render()},s=()=>{i.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()},c=e=>{this.isDragging||o()},l=e=>{this.isDragging||s()};for(let e of i)this.domEvents.addEventListener(e,`mouseover`,c),this.domEvents.addEventListener(e,`mouseout`,l),this.hooks.on(`moveStart`,o),this.hooks.on(`moveEnd`,s),this.hooks.on(`rotateEnd`,s),this.hooks.on(`scaleEnd`,s),a.push(()=>{this.domEvents.removeEventListener(e,`mouseover`,c),this.domEvents.removeEventListener(e,`mouseout`,l),this.hooks.off(`moveStart`,o),this.hooks.off(`moveEnd`,s),this.hooks.off(`rotateEnd`,s),this.hooks.off(`scaleEnd`,s)})}return()=>a.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 r=new n.Vector3(0,0,0);if(!e)return r;let i=()=>t||this.getBox();if(typeof e.x==`number`)r.setX(e.x);else if(typeof e.x==`object`){let t=i();r.setX((t.max.x-t.min.x)*e.x.percents)}if(typeof e.y==`number`)r.setY(e.y);else if(typeof e.y==`object`){let t=i();r.setY((t.max.y-t.min.y)*e.y.percents)}if(typeof e.z==`number`)r.setZ(e.z);else if(typeof e.z==`object`){let t=i();r.setZ((t.max.z-t.min.z)*e.z.percents)}return r}};function st(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 X=class{constructor(e,t,n){this.camera=e,this.container=t,this.defaults=Object.assign({},n||{})}createSolidLine(e,t,r){let i=Object.assign(Object.assign({color:16777215,renderOrder:G.DRAG_GUIDE_LINE},this.defaults),r||{}),a=t.clone().normalize(),o=this.computeInfiniteLineLength(e),s=e.clone().add(a.clone().multiplyScalar(-o)),c=e.clone().add(a.clone().multiplyScalar(o)),l=new Float32Array([s.x,s.y,s.z,c.x,c.y,c.z]),u=new n.BufferGeometry;u.setAttribute(`position`,new n.BufferAttribute(l,3));let d=new n.LineBasicMaterial({color:i.color,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.65}),f=new n.Line(u,d);return f.renderOrder=i.renderOrder,f}updateSolidLine(e,t,r,i){let a=r.clone().normalize(),o=this.computeInfiniteLineLength(t),s=t.clone().add(a.clone().multiplyScalar(-o)),c=t.clone().add(a.clone().multiplyScalar(o)),l=new Float32Array([s.x,s.y,s.z,c.x,c.y,c.z]),u=e.geometry,d=u.getAttribute(`position`);d&&d.itemSize===3&&d.array.length===l.length?(d.array.set(l),d.needsUpdate=!0):u.setAttribute(`position`,new n.BufferAttribute(l,3)),(i==null?void 0:i.color)!==void 0&&e.material.color.setHex(i.color)}computeInfiniteLineLength(e){return st(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 Z(e,t,r){if(!t||!r||!e)return;let i=P(t,r);if(Math.abs(i.x)===1||Math.abs(i.y)===1)return;let a=new n.Raycaster;return a.setFromCamera(i,e),a.params.Points&&(a.params.Points.threshold=.1),a}function ct(e){let{raycaster:t,line:r,clampToLine:i=!0}=e,a=new n.Plane().setFromNormalAndCoplanarPoint(t.ray.direction.clone().normalize(),new n.Vector3),o=a.projectPoint(r.start,new n.Vector3),s=a.projectPoint(r.end,new n.Vector3),c=new n.Line3(o,s),l=c.closestPointToPoint(t.ray.origin,i,new n.Vector3),u=l.distanceTo(s),d=l.distanceTo(o),f=c.distance();if(u>d&&u>f){let e=-l.distanceTo(o)/f,t=r.start.clone().sub(r.end).normalize();return r.start.clone().sub(t.clone().multiplyScalar(e*r.distance()))}else{let e=l.distanceTo(o)/f;return new n.Vector3().lerpVectors(r.start,r.end,e)}}var lt=class extends Y{get moveByMouseEnable(){return this._moveByMouse.enabled}constructor(...e){var t,r,i,a,o;super(...e),this.name=`MoveController`,this.solidGuide=new X(this.camera,this.container,(r=(t=this.config)==null?void 0:t.solidGuide)==null?{}:r),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 r=(t==null?void 0:t.object).direction;if(!r)return this.dragEnd();let i=new n.Vector3(1,0,0),a=new n.Vector3(0,1,0),o=new n.Vector3(0,0,1),s=(()=>{switch(r){case`x`:return i;case`y`:return a;case`z`:return o;case`xy`:case`xz`:case`yz`:case`plane`:return}})(),c=t.point.clone();if(r===`xy`||r===`xz`||r===`yz`){let e=(()=>{switch(r){case`xy`:return o;case`xz`:return a;case`yz`:return i}})(),t=new n.Plane().setFromNormalAndCoplanarPoint(e,c),s=c.clone();this.startInfo={draggingDirection:r,startVectorProject:s,line:new n.Line3(s.clone(),s.clone()),plane:t}}else if(r===`plane`){let e=this.camera.position.clone(),t=c.clone(),i=t.clone().sub(e).normalize(),a=new n.Plane().setFromNormalAndCoplanarPoint(i,t),o=t.clone();this.startInfo={draggingDirection:r,startVectorProject:o,line:new n.Line3(o.clone(),o.clone()),plane:a}}else{if(!s)return this.dragEnd();this.startInfo={draggingDirection:r,startVectorProject:c,line:new n.Line3(c.clone().sub(s.normalize()),c.clone().add(s.normalize()))};try{let e=s.clone().normalize(),t=this.helperObject3D.getWorldPosition(new n.Vector3),r=this.solidGuide.createSolidLine(t,e,{color:16777215,renderOrder:G.DRAG_GUIDE_LINE});this.scene.add(r),this.dragGuideLine=r}catch(e){}}let l=(()=>{switch(r){case`plane`:return[];case`xy`:return[`x`,`y`,`xy`];case`xz`:return[`x`,`z`,`xz`];case`yz`:return[`y`,`z`,`yz`];default:return[r]}})();this.helperObject3D.showDraggingHelper(l),this.hooks.emit(`moveStart`,r),this.isDragging=!0,this.setTipsText(this.originObject3D.position),this.setTipsPosition(c)},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=Z(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 s=this.helperObject3D;if(this.hoverListener([s.xArrow,s.yArrow,s.zArrow,(i=s.xyPlane)==null?void 0:i.handle,(a=s.xzPlane)==null?void 0:a.handle,(o=s.yzPlane)==null?void 0:o.handle]),s.centerHandle&&s.centerHandle instanceof Ge){let e=s.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 c=this.show.bind(this),l=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`,l),this.hooks.on(`rotateEnd`,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`,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`,l),this.hooks.off(`rotateEnd`,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)}),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,r,i;if(!this.moveByMouseEnable)return;let{point:a,face:o}=e;if(!this.hooks.emit(`wantToMove`,a)){if(this.originObject3D.position.copy(a),(this._moveByMouse.useFaceNormal===!0||typeof this._moveByMouse.useFaceNormal==`object`&&this._moveByMouse.useFaceNormal.enable!==!1)&&o!=null&&o.normal){let e=typeof this._moveByMouse.useFaceNormal==`object`&&this._moveByMouse.useFaceNormal.alignmentVector?this._moveByMouse.useFaceNormal.alignmentVector:{x:0,y:1,z:0},a=new n.Vector3((t=e.x)==null?0:t,(r=e.y)==null?0:r,(i=e.z)==null?0:i),s=typeof this._moveByMouse.useFaceNormal==`object`&&this._moveByMouse.useFaceNormal.fixedFaceNormal?this._moveByMouse.useFaceNormal.fixedFaceNormal(o.normal):o.normal;this.originObject3D.quaternion.setFromUnitVectors(a,s),this.internalHooks.emit(`setObjectRotate`,this.originObject3D.quaternion.clone(),new n.Vector3)}this.internalHooks.emit(`setObjectPosition`,a),this.hooks.emit(`move`,a)}}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 r=this.helperObject3D.getWorldPosition(new n.Vector3);this.solidGuide.updateSolidLine(this.dragGuideLine,r,t)}move(e){if(!this.startInfo)return this.dragEnd();let{line:t,startVectorProject:r}=this.startInfo,i=this.originObject3D,a=this.startInfo.draggingDirection===`plane`||this.startInfo.draggingDirection===`xy`||this.startInfo.draggingDirection===`xz`||this.startInfo.draggingDirection===`yz`,o;if(a){let t=this.startInfo.plane;if(!t)return;let r=new n.Vector3,i=t.normal.dot(e.ray.direction);if(Math.abs(i)<1e-6)return;let a=-(t.normal.dot(e.ray.origin)+t.constant)/i;if(a<0)return;r.copy(e.ray.origin.clone().add(e.ray.direction.clone().multiplyScalar(a))),o=r}else o=ct({raycaster:e,line:t,clampToLine:!1});let s=i.position.clone(),c=o.clone().sub(r),l=new n.Matrix4;l.setPosition(c);let u=i.position.clone().applyMatrix4(l);if(this.hooks.emit(`wantToMove`,u))return;let d=u.clone();this.hooks.emit(`moveBefore`,d);let f=new n.Matrix4;f.setPosition(d.clone().sub(s)),i.position.copy(d),this.setTipsText(d),this.setTipsPosition(d),r.copy(o),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:r,y:i,z:a}=this.helperObject3D.getWorldPosition(new n.Vector3).clone().project(this.camera);if(a>1){t.hide();return}let o=this.container.getBoundingClientRect(),s=(r+1)/2*o.width,c=(-i+1)/2*o.height;t.setLeftTop(s+`px`,c+`px`)}},ut=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();this.five=e,!(!l||!u||!f||!d)&&(this.helperController=new n({camera:l,model:u,domEvents:t,originObject3D:r,helperObject3D:i,container:f,scene:c==null?d:c,onRender:()=>{e.needsRender=!0},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()}},Q=new n.Quaternion,dt=class extends Y{get rotateCenter(){return this.helperObject3D.position.clone()}constructor(...e){var t,n,r;super(...e),this.name=`RotateController`,this.solidGuide=new X(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:r=0,z:i=0}=e,a=new n.Euler(n.MathUtils.degToRad(t),n.MathUtils.degToRad(r),n.MathUtils.degToRad(i)),o=new n.Quaternion().setFromEuler(a);if(this.hooks.emit(`wantToRotate`,o))return;let{originObject3D:s,rotateCenter:c}=this;Fe(s,o,c),this.internalHooks.emit(`setObjectRotate`,o,c),this.hooks.emit(`rotate`,o),this.render()}getEulerAngle(e,t){let{originObject3D:r}=this,i=new n.Euler().setFromQuaternion(r.quaternion),a={x:n.MathUtils.radToDeg(i.x),y:n.MathUtils.radToDeg(i.y),z:n.MathUtils.radToDeg(i.z)},o={x:e===`x`?t:a.x,y:e===`y`?t:a.y,z:e===`z`?t:a.z},s=new n.Euler(n.MathUtils.degToRad(o.x),n.MathUtils.degToRad(o.y),n.MathUtils.degToRad(o.z));return new n.Quaternion().setFromEuler(s)}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 r=(t==null?void 0:t.object).direction;if(!r)return this.dragEnd();let i=t.point;this.setTipsAngle(0);let a=i.clone();a.y+=.2,this.setTipsPosition(a);let o=new n.Quaternion,s=r===`x`?new n.Vector3(1,0,0):r===`y`?new n.Vector3(0,1,0):r===`z`?new n.Vector3(0,0,1):new n.Vector3(0,1,0),c=new n.Plane().setFromNormalAndCoplanarPoint(s,i),l=c.projectPoint(i.clone(),new n.Vector3).clone().sub(this.rotateCenter),u=this.getAngleHelper(r);if(!u)return this.dragEnd();let d=l.angleTo(u.baseAxes.clone().applyQuaternion(o)),f=u.offsetAngle(d);this.setAngleHelperStart(r,f),this.setAngleHelperLength(r,0),this.startInfo={direction:r,startVector:l,directionVector:s,plane:c,angleHelper:u,angle:0,helperQuaternion:o.clone(),startQuaternion:this.originObject3D.quaternion.clone()},Q=new n.Quaternion,this.helperObject3D.showDraggingHelper([r]),this.hooks.emit(`rotateStart`,r),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 r;if(e&&e.isMatrix4){r=new n.Quaternion,e.decompose(new n.Vector3,r,new n.Vector3);let i=new n.Euler().setFromQuaternion(r);if(t===`x`)return Math.round(n.MathUtils.radToDeg(i.z));if(t===`y`)return Math.round(n.MathUtils.radToDeg(i.y));if(t===`z`)return Math.round(n.MathUtils.radToDeg(i.x))}}parseAngleByDirection(e){var t,r;let i=(r=(t=this.originObject3D)==null?void 0:t.ext)==null?void 0:r.matrix,a;if(i&&i.isMatrix4){a=new n.Quaternion,i.decompose(new n.Vector3,a,new n.Vector3);let t=new n.Euler().setFromQuaternion(a);if(e===`x`)return Math.round(n.MathUtils.radToDeg(t.z));if(e===`y`)return Math.round(n.MathUtils.radToDeg(t.y));if(e===`z`)return Math.round(n.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=Z(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:r,angleHelper:i,direction:a,helperQuaternion:o}=this.startInfo,{originObject3D:s}=this,c=e.ray.intersectPlane(r,new n.Vector3);if(!c)return;let l=this.rotateCenter.clone(),u=r.projectPoint(c.clone(),new n.Vector3).clone().sub(l),d=this.startInfo.directionVector.clone().normalize();u=u.clone().projectOnPlane(d).normalize().multiplyScalar(u.length());let f=new n.Quaternion().setFromUnitVectors(t.clone().normalize(),u.clone().normalize()),p=s.quaternion.clone().premultiply(f);if(t.angleTo(u)===0||this.hooks.emit(`wantToRotate`,p))return;let m=new n.Euler().setFromQuaternion(new n.Quaternion().setFromUnitVectors(t.clone().normalize().applyQuaternion(o.clone().inverse()),u.clone().normalize().applyQuaternion(o.clone().inverse())),`${a.toUpperCase()}${`XZY`.replace(a.toUpperCase(),``)}`)[a]*i.angleDirection,h=this.startInfo.angle,g=h+m,_=Math.PI/2,v=n.MathUtils.degToRad(5),y=n.MathUtils.degToRad(10),b=new n.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(a,l):!E&&D&&this.removeSnapGuideLines(),this.setAngleHelperLength(a,this.startInfo.angle),this.setTipsAngle(n.MathUtils.radToDeg(this.startInfo.angle));let O=new n.Quaternion().setFromAxisAngle(d,T);if(l){let e=new n.Vector3().subVectors(s.position,l).applyQuaternion(O).add(l);s.position.copy(e)}s.applyQuaternion(O),Q.premultiply(O),this.internalHooks.emit(`applyObjectRotate`,{quaternion:O,origin:l}),this.hooks.emit(`rotate`,s.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 n.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 r=this.getAngleHelper(e);if(!r){console.warn(`angleHelper is undefined`);return}if(r instanceof n.Mesh&&r.geometry instanceof n.CircleGeometry){let{radius:e,segments:i,thetaLength:a}=r.geometry.parameters;r.geometry=new n.CircleGeometry(e,i,t,a)}else console.warn(`only support THREE.CircleGeometry`)}setAngleHelperLength(e,t){let r=.001,i=e===`x`||e===`y`?-t:t,a=i>=0?Math.max(i,r):Math.min(i,-r),o=this.getAngleHelper(e);if(o instanceof n.Mesh&&o.geometry instanceof n.CircleGeometry){let{radius:e,thetaStart:t}=o.geometry.parameters,r=Math.ceil(Math.abs(a)*(40/(2*Math.PI)));o.geometry=new n.CircleGeometry(e,r,t,a)}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:r,y:i,z:a}=this.helperObject3D.getWorldPosition(new n.Vector3).clone().project(this.camera);if(a>1){t.hide();return}let o=this.container.getBoundingClientRect(),s=(r+1)/2*o.width,c=(-i+1)/2*o.height;t.setLeftTop(s+`px`,c+`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 r=(()=>{switch(e){case`x`:return[new n.Vector3(0,1,0),new n.Vector3(0,0,1)];case`y`:return[new n.Vector3(1,0,0),new n.Vector3(0,0,1)];case`z`:return[new n.Vector3(1,0,0),new n.Vector3(0,1,0)];default:return[]}})();for(let e of r){let n=this.solidGuide.createSolidLine(t,e,{color:16777215,renderOrder:G.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=[]}},ft=class extends Y{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 $(e,t){this._camera=e||null,this._domElement=t||document,this._raycaster=new n.Raycaster,this._selected=null,this._boundObjs={};var r=this;this._$onClick=function(){r._onClick.apply(r,arguments)},this._$onDblClick=function(){r._onDblClick.apply(r,arguments)},this._$onMouseMove=function(){r._onMouseMove.apply(r,arguments)},this._$onMouseDown=function(){r._onMouseDown.apply(r,arguments)},this._$onMouseUp=function(){r._onMouseUp.apply(r,arguments)},this._$onTouchMove=function(){r._onTouchMove.apply(r,arguments)},this._$onTouchStart=function(){r._onTouchStart.apply(r,arguments)},this._$onTouchEnd=function(){r._onTouchEnd.apply(r,arguments)},this._$onContextmenu=function(){r._onContextmenu.apply(r,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)}$.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)},$.eventNames=[`click`,`dblclick`,`mouseover`,`mouseout`,`mousemove`,`mousedown`,`mouseup`,`contextmenu`,`touchstart`,`touchend`],$.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}},$.prototype._objectCtxInit=function(e){e._3xDomEvent={}},$.prototype._objectCtxDeinit=function(e){delete e._3xDomEvent},$.prototype._objectCtxIsInit=function(e){return!!e._3xDomEvent},$.prototype._objectCtxGet=function(e){return e._3xDomEvent},$.prototype.camera=function(e){return e&&(this._camera=e),this._camera},$.prototype.bind=function(e,t,n,r){console.assert($.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)},$.prototype.addEventListener=$.prototype.bind,$.prototype.unbind=function(e,t,n,r){console.assert($.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)},$.prototype.removeEventListener=$.prototype.unbind,$.prototype._bound=function(e,t){var n=this._objectCtxGet(t);return n?!!n[e+`Handlers`]:!1},$.prototype._isObjectVisible=function(e){for(var t=e;t;){if(t.visible===!1)return!1;t=t.parent}return!0},$.prototype._filterVisibleObjects=function(e){var t=this;return e.filter(function(e){return t._isObjectVisible(e)})},$.prototype._onMove=function(e,t,r,i){var a=this._boundObjs[e];if(!(a===void 0||a.length===0)){var o=this._filterVisibleObjects(a);if(o.length!==0){var s=new n.Vector2;s.set(t,r),this._raycaster.setFromCamera(s,this._camera);var c=this._raycaster.intersectObjects(o),l=this;c=c.filter(function(e){return l._isObjectVisible(e.object)}),c.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(c.length>0){var d,f,p,m=c[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,i,m),d&&this._notify(`mouseover`,h,i,m),f&&this._notify(`mouseout`,u,i,m)}}},$.prototype._onEvent=function(e,t,r,i){var a=this._boundObjs[e];if(!(a===void 0||a.length===0)){var o=this._filterVisibleObjects(a);if(o.length!==0){var s=new n.Vector2;s.set(t,r),this._raycaster.setFromCamera(s,this._camera);var c=this._raycaster.intersectObjects(o,!0),l=this;if(c=c.filter(function(e){return l._isObjectVisible(e.object)}),c.sort(function(e,t){var n=e.object.renderOrder||0,r=t.object.renderOrder||0;return n===r?e.distance-t.distance:r-n}),c.length!==0){for(var u=c[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,i,u)}}}},$.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)}},$.prototype._onMouseDown=function(e){return this._onMouseEvent(`mousedown`,e)},$.prototype._onMouseUp=function(e){return this._onMouseEvent(`mouseup`,e)},$.prototype._onMouseEvent=function(e,t){var n=this._getRelativeMouseXY(t);this._onEvent(e,n.x,n.y,t)},$.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)},$.prototype._onClick=function(e){this._onMouseEvent(`click`,e)},$.prototype._onDblClick=function(e){this._onMouseEvent(`dblclick`,e)},$.prototype._onContextmenu=function(e){this._onMouseEvent(`contextmenu`,e)},$.prototype._onTouchStart=function(e){return this._onTouchEvent(`touchstart`,e)},$.prototype._onTouchEnd=function(e){return this._onTouchEvent(`touchend`,e)},$.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)}},$.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 pt=`Object3DHelperPlugin`,mt=pt,ht=()=>{console.error(`${mt} is disposed`)},gt=()=>{console.warn(`${mt} is disabled`)},_t=()=>{console.error(`${mt} is disabled`)},vt=class{constructor(e){this.controllers={},this.state={visible:!0,enabled:!0,disposed:!1},this.hooks=new t.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)})}},yt=class extends p.Controller{constructor(e){super(e),this.name=pt,this.state={visible:!0,enabled:!0,disposed:!1},this.objectHelperMap=new Map,this.five=e}show(e){return m(this,void 0,void 0,function*(){this.setState({visible:!0},e)})}hide(e){return m(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 m(this,void 0,void 0,function*(){})}setState(e,t){var n;if(this.state.disposed)return ht();if(!this.state.enabled&&e.enabled!==!0&&e.disposed!==!0)return _t();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,r={}){var i,a;if(!e){console.error(`Object3D is undefined`);return}if(this.objectHelperMap.has(e)){console.warn(`Object3DHelperPlugin: object3D ${e.name} already has helper`);return}let o=new vt,s=[],c=(i=this.five.getElement())==null?void 0:i.parentElement;this.five.camera;let l=Object.assign(Object.assign({},{moveHelper:!0,rotateHelper:!0,boundingBoxHelper:!1,moveHelperTips:!1,positionFrom:`objectPosition`}),r),{moveHelper:u,rotateHelper:d,boundingBoxHelper:f}=l,p=new n.Group;l.helperOffset&&p.position.copy(l.helperOffset),this.five.scene.add(p);let m=o.hooks,h=new t.Subscribe,g=new $(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(l.moveHelper)),l),n=new $e(e,Object.assign({container:c==null?void 0:c,moveTipsEnable:(a=l.moveHelperTips)==null?!1:a},t)),r=new ut(this.five,g,lt,e,n,t,m,h,p);v.moveController=r.helperController,s.push(()=>r.dispose())}if(_(d)){let t=Object.assign(Object.assign({},this.getConfig(l.rotateHelper)),l),n=new et(e,Object.assign({container:c==null?void 0:c},t)),r=new ut(this.five,g,dt,e,n,t,m,h,p);v.rotateController=r.helperController,s.push(()=>r.dispose())}if(_(f)){let t=new at(e),n=new ut(this.five,g,ft,e,t,void 0,m,h,p);v.boundingBoxController=n.helperController,s.push(()=>n.dispose())}return Object.values(v).forEach(e=>{e&&typeof e.updateOtherControllers==`function`&&e.updateOtherControllers(v)}),o.addControllers(v),this.objectHelperMap.set(e,{helper:o,disposers:s,helperGroup:p}),o.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&&gt()}getConfig(e){if(e&&typeof e!=`boolean`&&e.enable)return e}},bt=e=>new yt(e),xt=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}},St=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?6e3:n,this.curveHeight=(r=t==null?void 0:t.curveHeight)==null?1.5:r,this.pointDuration=(i=t==null?void 0:t.pointDuration)==null?4e3:i}load(){return m(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();if(e){let t=e.material.uniforms;t.u_aggregationEnabled.value=!1,t.u_aggregationProgress.value=1}}catch(e){}}extractKeyframes(e){let t=[];if(!e.content.data)throw Error(`轨迹数据未加载`);let r=e.content.data.positionArray,i=r.length/3,a=.01,o=.1,s=new xt(a,o,1,0,1),c=new xt(a,o,1,0,1),l=new xt(a,o,1,0,1),u=new Float32Array(i);for(let e=0;e<i;e++)if(e===0)u[e]=0;else{let t=new n.Vector3(r[(e-1)*3],r[(e-1)*3+1],r[(e-1)*3+2]);u[e]=new n.Vector3(r[e*3],r[e*3+1],r[e*3+2]).distanceTo(t)+u[e-1]}for(let a=0;a<i;a++){let o=new n.Vector3(0,0,0),d=0;for(let e=a-5;e<a+6;e++)e>=0&&e<i&&(o.add(new n.Vector3(r[e*3],r[e*3+1],r[e*3+2])),d++);o.divideScalar(d).applyMatrix4(e.transform);let f=s.filter(o.x),p=c.filter(o.y),m=l.filter(o.z);t.push({position:new n.Vector3(f,p,m),location:u[a]})}return t}computeAABB2D(e){let t=1/0,r=-1/0,i=1/0,a=-1/0;for(let n of e)n.position.x<t&&(t=n.position.x),n.position.x>r&&(r=n.position.x),n.position.z<i&&(i=n.position.z),n.position.z>a&&(a=n.position.z);return{min:new n.Vector2(t,i),max:new n.Vector2(r,a)}}findClosestKeyframeToRay(e,t){let r=1/0,i=t[0].position.clone(),a=new n.Vector3;for(let n of t){e.closestPointToPoint(n.position,a);let t=a.distanceTo(n.position);t<r&&(r=t,i=n.position.clone())}return i}getCameraCurve(){return m(this,void 0,void 0,function*(){var e,r,i;let a=(i=(r=(e=this.five.model.viewLayers[0])==null?void 0:e.scene)==null?void 0:r.trajectories)==null?void 0:i[0];if(!a)throw Error(`未找到轨迹数据`);a.visible=!0,yield new Promise(e=>{let n=t.AnimationFrameLoop.shared.add(()=>{a.content.loadState===`READY`&&(n(),e(),a.visible=!1)})});let o=this.extractKeyframes(a);if(o.length<2)throw Error(`轨迹关键帧不足,至少需要2个关键帧`);this.keyframes=o;let s=this.computeAABB2D(o);this.boundingAABB=s;let c=this.curveHeight,l=new n.Vector3((s.min.x+s.max.x)/2,c,(s.min.y+s.max.y)/2),u=(s.max.x-s.min.x)/2,d=(s.max.y-s.min.y)/2,f=Math.sqrt(u*u+d*d),p=e=>{let t=new n.Vector3().subVectors(e,l);return t.length()<.001&&t.set(1,0,0),l.clone().add(t.normalize().multiplyScalar(f))},m=new n.Vector3(o[0].position.x,c,o[0].position.z),h=p(m),g=new n.Vector3().subVectors(l,m).normalize(),_=new n.Ray(m,g),v=new n.Vector3(-g.z,0,g.x).normalize(),y=new n.Ray(l,v),b=this.findClosestKeyframeToRay(y,o),x=p(new n.Vector3(b.x,c,b.z)),S=this.findClosestKeyframeToRay(_,o),C=p(new n.Vector3(S.x,c,S.z));return new n.CatmullRomCurve3([h,x,C],!1,`centripetal`,.5)})}findRenderMesh(){let e=null;if(this.five.scene.traverse(t=>{e||t instanceof n.Mesh&&t.material&&t.material.uniforms&&t.material.uniforms.u_aggregationEnabled&&(e=t)}),!e)throw Error(`未找到 GaussianSplatting 渲染网格`);return e}setBounding(e,t,n){let r=this.findRenderMesh();r.material.uniforms.u_aggregationBoundsMin.value.copy(e),r.material.uniforms.u_aggregationBoundsMax.value.copy(t),this.boundsSet=!0}setBounds(){if(!this.boundingAABB)throw Error(`请先调用 getCameraCurve 计算轨迹边界`);let e=this.boundingAABB,t=this.findRenderMesh(),r=new n.Vector3(e.min.x,0,e.min.y),i=new n.Vector3(e.max.x,3,e.max.y);t.material.uniforms.u_aggregationBoundsMin.value.copy(r),t.material.uniforms.u_aggregationBoundsMax.value.copy(i),this.boundsSet=!0}startAggregation(){if(!this.boundsSet)throw Error(`请先调用 setBounds 设置聚合边界`);let e=this.findRenderMesh().material.uniforms;e.u_aggregationEnabled.value=!0,e.u_aggregationProgress.value=0,e.u_aggregationPointDuration.value=Math.min(this.pointDuration/this.duration,1),this.five.needsRender=!0;let n=performance.now(),r=this.duration;this.cancelAnimation=t.AnimationFrameLoop.shared.add(()=>{let t=performance.now()-n,i=Math.min(t/r,1),a=i*i*(3-2*i);e.u_aggregationProgress.value=a,this.five.needsRender=!0,this.five.modelSceneNeedsRender=!0,i>=1&&(e.u_aggregationEnabled.value=!1,this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null))})}playEntrance(){return m(this,void 0,void 0,function*(){let e=yield this.getCameraCurve(),r=this.boundingAABB,i=new n.Vector3((r.min.x+r.max.x)/2,this.curveHeight,(r.min.y+r.max.y)/2),a=e.getPointAt(0),o=new t.Camera(90).copy(this.five.camera);o.position.copy(a),o.lookAt(i),o.computePose(0),this.five.setState(Object.assign({},o.pose)),this.setBounds();let s=this.findRenderMesh().material.uniforms;s.u_aggregationEnabled.value=!0,s.u_aggregationProgress.value=0,s.u_aggregationPointDuration.value=Math.min(this.pointDuration/this.duration,1),this.five.needsRender=!0;let c=this.duration,l=performance.now();return new Promise(n=>{this.cancelAnimation=t.AnimationFrameLoop.shared.add(()=>{let t=performance.now()-l,r=Math.min(t/c,1),a=r*r*(3-2*r);s.u_aggregationProgress.value=a,this.five.modelSceneNeedsRender=!0;let u=e.getPointAt(a);o.position.copy(u),o.lookAt(i),o.computePose(0),this.five.setState(Object.assign({},o.pose)),this.five.needsRender=!0,r>=1&&(s.u_aggregationEnabled.value=!1,s.u_aggregationProgress.value=1,this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null),n())})})})}};e.BackgroundPlugin=ue,Object.defineProperty(e,`BasePlugin`,{enumerable:!0,get:function(){return p}}),e.CSS3DObject=M,e.CSS3DPlugin=Pe,e.CSS3DRenderer=se,e.CSS3DSprite=ae,e.DynamicPathLinePlugin=ke,e.GaussianSplattingEntranceAnimationPlugin=(e,t)=>new St(e,t),e.ItemMaskPlugin=A,e.Object3DHelperController=yt,e.Object3DHelperPlugin=bt,e.OrbitControls=j,e.OrientationPlugin=V,e.PanoAnimePlugin=xe,e.RoundedBoxGeometry=F,e.TrajectoryPlugin=U});
829
+ }`;function je(){return((1+Math.random())*parseInt(`10000`,36)|0).toString(36).substring(1)}function Me(){let e=je()+je().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 Ne=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){super(e),this.scene=new n.Scene,this.styleSheet=new CSSStyleSheet,this.camera=new n.PerspectiveCamera,this.cacheMap=new WeakMap,this.createCSS3DObject=({id:e=Me(),name:t,innerHTML:r,sprite:i,normal:a,position:o,scalar:s=.00216,visible:c=!0,timeout:l})=>{let u=document.createElement(`div`);u.className=`five-CSS3DPlugin-X`,c||u.classList.add(`five-CSS3DPlugin-hidden`),l&&u.style.setProperty(`--timeout`,l+`ms`),u.innerHTML=r;let d=i?new ae(u):new M(u);if(d.userData={id:e,_visible:c,_timeout:l,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}},a){let e=new n.Vector3(0,0,1),t=new n.Quaternion().setFromUnitVectors(e,a.clone().normalize());d.quaternion.copy(t)}return o&&d.position.copy(o),s&&d.scale.setScalar(s),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 se,this.renderer.domElement.id=`five-CSS3DPlugin`,this.styleSheet.replaceSync(Ae),/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),this.state=Object.assign({enabled:!0,visible:!0},t==null?void 0:t.initialState),this.state.enabled?this._enable({userAction:!1}):this.styleSheet.disabled=!0}load(e){return m(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:r,y:i}=this.five.renderer.getSize(new n.Vector2);t.parentElement.appendChild(this.renderer.domElement),this.renderer.setSize(r*2,i*2),this.renderer.domElement.style.width=r*2+`px`,this.renderer.domElement.style.height=i*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 M&&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)}},Pe=(e,t)=>new Ne(e,t),Fe=class extends n.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 n.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}},Ie=new n.Vector3,Le=new n.Matrix4,Re=new n.Matrix4,ze=new n.Vector3,Be=new n.Vector3,Ve=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.autoUpdate===!0&&e.updateMatrixWorld(),n.parent===null&&n.updateMatrixWorld(),Le.copy(n.matrixWorldInverse),Re.multiplyMatrices(n.projectionMatrix,Le),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){Ie.setFromMatrixPosition(e.matrixWorld),Ie.applyMatrix4(Re);let c=Ie.z>=-1&&Ie.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(`+(Ie.x*i+i)+`px,`+(-Ie.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 ze.setFromMatrixPosition(e.matrixWorld),Be.setFromMatrixPosition(t.matrixWorld),ze.distanceToSquared(Be)}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}}},He=`#five-CSS2DPlugin {
830
+ position: absolute;
831
+ pointer-events: none;
832
+ user-select: none;
833
+ top: 0;
834
+ left: 0;
835
+ }
836
+
837
+ .five-CSS2DPlugin-X {
838
+ --timeout: 300ms;
839
+ transition: opacity ease-in-out var(--timeout);
840
+ }
841
+
842
+ .five-CSS2DPlugin-hidden {
843
+ opacity: 0;
844
+ }
845
+
846
+ #five-CSS2DPlugin .five-CSS2DPlugin-hidden * {
847
+ pointer-events: none;
848
+ }
849
+ `,Ue=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){super(e),this.scene=new n.Scene,this.styleSheet=new CSSStyleSheet,this.camera=new n.PerspectiveCamera,this.createCSS2DObject=({id:e=Me(),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 Fe(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 Ve,this.renderer.domElement.id=`five-CSS2DPlugin`,this.styleSheet.replaceSync(He),document&&document.adoptedStyleSheets.push(this.styleSheet),this.state=Object.assign({enabled:!0,visible:!0},t==null?void 0:t.initialState),this.state.enabled?this._enable({userAction:!1}):this.styleSheet.disabled=!0}load(e){return m(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:r,y:i}=this.five.renderer.getSize(new n.Vector2);t.parentElement.appendChild(this.renderer.domElement),this.renderer.setSize(r,i),(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 Fe&&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)}},We=(e,t)=>new Ue(e,t);function Ge(e,t,r){if(r){let i=new n.Vector3().subVectors(e.position,r).applyQuaternion(e.quaternion.clone().inverse()).applyQuaternion(t).add(r);e.position.copy(i)}e.quaternion.copy(t)}function Ke(e){return e==null}var qe=class extends n.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 n.Box3().expandByObject(this.originObject3D).getCenter(new n.Vector3)):this.positionFrom instanceof n.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,r=e.yAxis instanceof Function?e.yAxis():e.yAxis,i=e.zAxis instanceof Function?e.zAxis():e.zAxis,a=t==null?void 0:t.clone(),o=r==null?void 0:r.clone(),s=i==null?void 0:i.clone();if(a&&!o&&!o){let e=new n.Quaternion().setFromUnitVectors(new n.Vector3(1,0,0),a.normalize());this.applyQuaternion(e)}if(o&&!a&&!s){let e=new n.Quaternion().setFromUnitVectors(new n.Vector3(0,1,0),o.normalize());this.applyQuaternion(e)}if(s&&!a&&!o){let e=new n.Quaternion().setFromUnitVectors(new n.Vector3(0,0,1),s.normalize());this.applyQuaternion(e)}if([a,o,s].filter(e=>!Ke(e)).length>=2){a||(a=new n.Vector3().crossVectors(o,s).normalize()),o||(o=new n.Vector3().crossVectors(a,s).normalize()),s||(s=new n.Vector3().crossVectors(a,o).normalize()),a.applyQuaternion(this.quaternion),o.applyQuaternion(this.quaternion),s.applyQuaternion(this.quaternion);let e=new n.Matrix4().makeBasis(a,o,s),t=new n.Quaternion().setFromRotationMatrix(e);this.quaternion.copy(t)}}}applyHelperScaleMatrix4(e,t){this.scale.applyMatrix4(e)}setHelperQuaternion(e,t){this.initQuaternion(),t?Ge(this,this.quaternion.clone().premultiply(e),t):this.quaternion.premultiply(e)}applyHelperQuaternion(e,t){if(t){let r=new n.Vector3().subVectors(this.position,t).applyQuaternion(e).add(t);this.position.copy(r)}this.applyQuaternion(e)}dispose(){this.removeFromParent()}},Je=class extends qe{},Ye=class extends qe{},Xe=class extends qe{},Ze=class extends n.Group{constructor(e){super(),this.direction=e||`x`}};n.Line;var Qe=class extends n.Mesh{constructor(e,t,n){super(e,t),this.direction=n||`x`}},$e={X:16730698,Y:54927,Z:3368703},W=class{static get X(){return new n.Color($e.X).convertSRGBToLinear().clone()}static get Y(){return new n.Color($e.Y).convertSRGBToLinear().clone()}static get Z(){return new n.Color($e.Z).convertSRGBToLinear().clone()}},G={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 Ze{constructor(e){var t;super(e.direction),this.lineHeight=.5,this.arrowHeight=.1,this.name=`ArrowGroup`;let r=new n.Color((t=e.color)==null?16214315:t),i=()=>new n.MeshBasicMaterial({color:r,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1});this.arrow=new Qe(new n.ConeGeometry(.04,this.arrowHeight,32),i(),e.direction),this.arrow.name=`arrow-${e.direction}`,this.arrow.renderOrder=G.MOVE_HELPER_ARROW,this.arrowNeg=new Qe(new n.ConeGeometry(.04,this.arrowHeight,32),i(),e.direction),this.arrowNeg.name=`arrow-neg-${e.direction}`,this.arrowNeg.renderOrder=G.MOVE_HELPER_ARROW;let a=.004;this.line=new Qe(new n.CylinderGeometry(a,a,this.lineHeight,32),i(),e.direction),this.line.name=`line-${e.direction}`,this.line.renderOrder=G.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))}},et=class extends Ze{constructor(e){var t,r;super(`plane`),this.name=`CenterHandle`,this.faceNormals=[new n.Vector3(1,0,0),new n.Vector3(-1,0,0),new n.Vector3(0,1,0),new n.Vector3(0,-1,0),new n.Vector3(0,0,1),new n.Vector3(0,0,-1)],this.baseColor=new n.Color((t=e==null?void 0:e.color)==null?16419862:t);let i=(r=e==null?void 0:e.size)==null?.05:r,a=new n.Color(16755008).convertSRGBToLinear();this.faceMaterials=Array.from({length:6},()=>new n.MeshBasicMaterial({color:a,transparent:!0,opacity:1,depthTest:!1,depthWrite:!1,side:n.FrontSide}));let o=new n.BoxGeometry(i,i,i),s=new n.Mesh(o,this.faceMaterials);s.direction=`plane`,s.renderOrder=G.MOVE_HELPER_CENTER,s.name=`center-plane-handle`,this.cube=s,this.add(this.cube)}update(e){let t=new n.Vector3().subVectors(e.position,this.cube.getWorldPosition(new n.Vector3)).normalize(),r=this.cube.getWorldQuaternion(new n.Quaternion),i=this.faceNormals.map((e,n)=>{let i=e.clone().applyQuaternion(r).dot(t);return{index:n,angle:Math.acos(Math.abs(i))}});i.sort((e,t)=>e.angle-t.angle);let a=[new n.Color(16755008).convertSRGBToLinear(),new n.Color(16419862).convertSRGBToLinear(),new n.Color(13921032).convertSRGBToLinear()];i.forEach((e,t)=>{let n=Math.floor(t/2);this.faceMaterials[e.index].color.copy(a[n])})}},tt=class extends Ze{constructor(e){var t,r,i;super(e.direction),this.name=`PlaneHandle`;let a=(t=e.size)==null?.12:t,o=(r=e.offset)==null?.12:r,s=new n.Color((i=e.color)==null?16776960:i),c=new n.BoxGeometry(a,a,.005),l=new n.MeshBasicMaterial({color:s,transparent:!0,opacity:.4,depthTest:!1,depthWrite:!1,side:n.DoubleSide});switch(this.handle=new n.Mesh(c,l),this.handle.direction=e.direction,this.handle.renderOrder=G.MOVE_HELPER_ARROW,this.handle.name=`plane-handle-${e.direction}`,e.direction){case`xy`:this.handle.position.set(o,o,0);break;case`xz`:this.handle.position.set(o,0,o),this.handle.rotation.x=-Math.PI/2;break;case`yz`:this.handle.position.set(0,o,o),this.handle.rotation.y=Math.PI/2;break}this.add(this.handle)}};function nt(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 rt(e){let{latitude:t,longitude:r}=e,i=new n.Vector3;return it-t<.03?i.set(0,1,0):at(0,r)?i.set(0,0,1):at(Math.PI,r)?i.set(0,0,-1):at(it,r)?i.set(1,0,0):i.set(-1,0,0),i}var it=Number((Math.PI/2).toFixed(5));function at(e,t){return typeof e!=`number`||typeof t!=`number`?!1:Math.abs(e-t)<.001}function q(e,t){return ot(document.createElement(t==null?`div`:t),e)}function ot(e,t){if(!t)return e;for(let n in t)n&&t[n]&&(e.style[n]=t[n]);return e}function J(e){let t=q(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 Y=class extends Je{constructor(e,t){super(e,t),this.name=`MoveHelper`,(t==null?void 0:t.xArrowEnable)!==!1&&(this.xArrow=new K({direction:`x`,color:W.X})),(t==null?void 0:t.yArrowEnable)!==!1&&(this.yArrow=new K({direction:`y`,color:W.Y})),(t==null?void 0:t.zArrowEnable)!==!1&&(this.zArrow=new K({direction:`z`,color:W.Z})),(t==null?void 0:t.centerHandleEnable)!==!1&&(this.centerHandle=new et),(t==null?void 0:t.xyPlaneEnable)!==!1&&(this.xyPlane=new tt({direction:`xy`,color:W.Z})),(t==null?void 0:t.xzPlaneEnable)!==!1&&(this.xzPlane=new tt({direction:`xz`,color:W.Y})),(t==null?void 0:t.yzPlaneEnable)!==!1&&(this.yzPlane=new tt({direction:`yz`,color:W.X})),t!=null&&t.container&&(t==null?void 0:t.moveTipsEnable)!==!1&&(this.container=t.container,this.moveTips=J({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 n.Vector3(1,0,0).applyQuaternion(this.quaternion),r=new n.Vector3(0,1,0).applyQuaternion(this.quaternion),i=new n.Vector3(0,0,1).applyQuaternion(this.quaternion),a=e.pose,o=rt(a),s=.0872665;Math.abs(t.angleTo(o)-0)<s||Math.abs(t.angleTo(o)-Math.PI)<s?this.xArrow&&(this.xArrow.visible=!1):Math.abs(r.angleTo(o)-0)<s||Math.abs(r.angleTo(o)-Math.PI)<s?this.yArrow&&(this.yArrow.visible=!1):(Math.abs(i.angleTo(o)-0)<s||Math.abs(i.angleTo(o)-Math.PI)<s)&&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(nt(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()}},st=class extends Xe{constructor(e,t){super(e,t),this.name=`RotateHelper`,this.children=[],(t==null?void 0:t.yzCircleEnable)!==!1&&(this.xCircle=new X({direction:`x`,color:W.X})),(t==null?void 0:t.xzCircleEnable)!==!1&&(this.yCircle=new X({direction:`y`,color:W.Y})),(t==null?void 0:t.xyCircleEnable)!==!1&&(this.zCircle=new X({direction:`z`,color:W.Z})),t!=null&&t.container&&(t==null?void 0:t.angleTipsEnable)!==!1&&(this.container=t==null?void 0:t.container,this.angleTips=J({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(nt(e,this.position))}update(e){if(e.type===`OrthographicCamera`)return;let t=this.helperObject.position.clone().sub(e.position).normalize(),r=new n.Vector3(1,0,0).applyQuaternion(this.quaternion),i=new n.Vector3(0,1,0).applyQuaternion(this.quaternion),a=new n.Vector3(0,0,1).applyQuaternion(this.quaternion),o=t.angleTo(r),s=t.angleTo(i),c=t.angleTo(a),l=Math.PI/2,u=s>=l,d=c>=l,f=o>=l;if(this.xCircle){let e=this.xCircle.circle.gapAngle;u&&d?this.xCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,e,Math.PI/2-e*2):u&&!d?this.xCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,Math.PI/2+e,Math.PI/2-e*2):!u&&d?this.xCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,Math.PI/2*3+e,Math.PI/2-e*2):!u&&!d&&(this.xCircle.circle.geometry=new n.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 n.Vector3(0,0,1):!u&&d?(this.xCircle.angleSector.baseAxes=new n.Vector3(0,-1,0),this.xCircle.angleSector.offsetAngle=e=>e-Math.PI/2):!u&&!d&&(this.xCircle.angleSector.baseAxes=new n.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 n.RingGeometry(.3,.35,20,8,e,Math.PI/2-e*2):f&&!d?this.yCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,Math.PI/2*3+e,Math.PI/2-e*2):!f&&d?this.yCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,Math.PI/2+e,Math.PI/2-e*2):!f&&!d&&(this.yCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,Math.PI+e,Math.PI/2-e*2)),f&&d?this.yCircle.angleSector.baseAxes=new n.Vector3(1,0,0):f&&!d?(this.yCircle.angleSector.baseAxes=new n.Vector3(0,0,-1),this.yCircle.angleSector.offsetAngle=e=>e-Math.PI/2):!f&&d?(this.yCircle.angleSector.baseAxes=new n.Vector3(0,0,1),this.yCircle.angleSector.offsetAngle=e=>e+Math.PI/2):!f&&!d&&(this.yCircle.angleSector.baseAxes=new n.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 n.RingGeometry(.3,.35,20,8,e,Math.PI/2-e*2):f&&!u?this.zCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,Math.PI/2*3+e,Math.PI/2-e*2):!f&&u?this.zCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,Math.PI/2+e,Math.PI/2-e*2):!f&&!u&&(this.zCircle.circle.geometry=new n.RingGeometry(.3,.35,20,8,Math.PI+e,Math.PI/2-e*2)),this.zCircle.angleSector&&(f&&u?this.zCircle.angleSector.baseAxes=new n.Vector3(1,0,0):f&&!u?(this.zCircle.angleSector.baseAxes=new n.Vector3(0,-1,0),this.zCircle.angleSector.offsetAngle=e=>e-Math.PI/2):!f&&u?(this.zCircle.angleSector.baseAxes=new n.Vector3(0,1,0),this.zCircle.angleSector.offsetAngle=e=>e+Math.PI/2):!f&&!u&&(this.zCircle.angleSector.baseAxes=new n.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()}},X=class extends n.Group{constructor(e){super(),this.direction=e.direction,this.circle=new Z(e),this.ring=new ct(e),this.angleSector=new lt(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)}},Z=class extends n.Mesh{constructor(e){var t;super(),this.gapAngle=.02,this.geometry=new n.RingGeometry(.3,.35,20,8,this.gapAngle,Math.PI/2-this.gapAngle*2),this.material=new n.MeshBasicMaterial({opacity:.6,transparent:!0,color:(t=e.color)==null?16777215:t,side:n.DoubleSide,depthTest:!1}),this.direction=e.direction,this.renderOrder=G.ROTATE_HELPER,this.geometry.name=`RotateHelperCircleGeometry-${this.direction}`}},ct=class extends n.Group{constructor(e){super(),this.direction=e.direction;let t=.015,r=Array(8).fill(null).map((e,r)=>{let i=new n.RingGeometry(.3,.35,20,8,Math.PI/4*r+t,Math.PI/4-t*2),a=new n.MeshBasicMaterial({opacity:1,color:16777215,depthTest:!1,depthWrite:!1,transparent:!0,side:n.DoubleSide}),o=new n.Mesh(i,a);return o.name=`AxesDashedRing-${this.direction}-${r}`,o});this.add(...r)}},lt=class extends n.Mesh{constructor(e){var t;switch(super(),this.offsetAngle=e=>e,e.direction){case`x`:this.baseAxes=new n.Vector3(0,0,1);break;case`y`:this.baseAxes=new n.Vector3(1,0,0);break;case`z`:this.baseAxes=new n.Vector3(1,0,0);break}this.geometry=new n.CircleGeometry(.3505,48,0,1e-4),this.material=new n.MeshBasicMaterial({opacity:.4,color:(t=e.color)==null?16777215:t,depthTest:!1,depthWrite:!1,transparent:!0,side:n.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`}},ut=class extends Ye{constructor(e){super(e),this.name=`BoundingBoxHelper`,this.positionAttribute=new n.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){Ge(this,e,t)}raycasterIntersectObject(e,t){return e.intersectObject(this,!1,t)}raycast(e,t){this.box.raycast(e,t)}update(){let e=new n.Box3,t=new n.Matrix4().getInverse(this.originObject3D.matrixWorld),r=new n.Vector3;if(this.originObject3D.updateMatrixWorld(!0),this.originObject3D.traverse(i=>{let a=i.geometry;if(!a)return;i.updateMatrixWorld(!0);let o=new n.Matrix4().multiplyMatrices(t,i.matrixWorld);if(a.isBufferGeometry){let t=a,n=t.attributes.position;if(n)for(let t=0,i=n.count;t<i;t++)r.fromBufferAttribute(n,t).applyMatrix4(o),e.expandByPoint(r);let i=t.attributes.instanceStart,s=t.attributes.instanceEnd;if(i)for(let t=0,n=i.count;t<n;t++)r.fromBufferAttribute(i,t).applyMatrix4(o),e.expandByPoint(r);if(s)for(let t=0,n=s.count;t<n;t++)r.fromBufferAttribute(s,t).applyMatrix4(o),e.expandByPoint(r)}else if(a.vertices){let t=a.vertices;for(let n of t)r.copy(n).applyMatrix4(o),e.expandByPoint(r)}}),e.isEmpty())return;let{min:i,max:a}=e;this.positionAttribute.setXYZ(0,a.x,a.y,a.z),this.positionAttribute.setXYZ(1,i.x,a.y,a.z),this.positionAttribute.setXYZ(2,i.x,i.y,a.z),this.positionAttribute.setXYZ(3,a.x,i.y,a.z),this.positionAttribute.setXYZ(4,a.x,a.y,i.z),this.positionAttribute.setXYZ(5,i.x,a.y,i.z),this.positionAttribute.setXYZ(6,i.x,i.y,i.z),this.positionAttribute.setXYZ(7,a.x,i.y,i.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 n.BufferGeometry;t.setIndex(new n.BufferAttribute(e,1)),t.setAttribute(`position`,this.positionAttribute);let r=new n.LineBasicMaterial({color:64767,linewidth:1,opacity:1,toneMapped:!1}),i=new n.LineSegments(t,r);return i.matrixAutoUpdate=!1,i}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 n.BufferGeometry;t.setIndex(new n.BufferAttribute(e,1)),t.setAttribute(`position`,this.positionAttribute);let r=new n.MeshBasicMaterial({color:64767,opacity:.1,depthTest:!1,transparent:!0});return new n.Mesh(t,r)}},Q=new Map;function dt(e){if(Q.has(e))return Q.get(e).hooks;let n=new t.Subscribe,r=null,i,a=()=>{r=requestAnimationFrame(a);let t=e.projectionMatrix.toArray().join(`,`)+e.matrixWorld.toArray().join(`,`);t!==i&&(i=t,n.emit(`cameraUpdate`))};return a(),Q.set(e,{hooks:n,dispose:()=>{Q.delete(e),cancelAnimationFrame(r)}}),n}function ft(e){return arguments.length===0?[]:Array.isArray(e)?e:[e]}var pt=class{updateOtherControllers(e){this.otherControllers=e}getIsDragging(){return this.isDragging}constructor(e,r){var i,a,o;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 n.Box3().expandByObject(this.originObject3D)),this.boundingBox),this.hooks=(i=e.sharedHooks)==null?new t.Subscribe:i,this.internalHooks=(a=e.sharedInternalHooks)==null?new t.Subscribe:a,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=(o=e.onRender)==null?(()=>{}):o,this.config=r==null?{}:r,this.otherControllers=e.otherControllers,this.initialHelperPosition(),this.initialHelperQuaternion(),this.updateHelperScale(),this.cameraHooks=dt(this.camera),this.enable();let s=this.onSetOriginObjectScale.bind(this),c=this.onSetOriginObjectRotate.bind(this),l=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`,s),this.internalHooks.on(`setObjectRotate`,c),this.internalHooks.on(`setObjectPosition`,l),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`,s),this.internalHooks.off(`setObjectRotate`,c),this.internalHooks.off(`setObjectPosition`,l),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 r=new n.Vector3().subVectors(this.helperObject3D.position,t).applyQuaternion(e.quaternion).add(t);this.helperObject3D.position.copy(r)}}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,r=new n.Vector3().subVectors(this.boundingBox.max,t).multiply(e).add(t),i=new n.Vector3().subVectors(this.boundingBox.min,t).multiply(e).add(t),a=this.calculateOffset(this.config.offset,{min:i,max:r});this.helperObject3D.initialPosition(a)}}hoverListener(e,t=16777215,r=1){let i=ft(e).filter(e=>!Ke(e)),a=[];for(let e of i)if(e.material||e instanceof n.Group){let i=e instanceof n.Group?e.children.filter(e=>e instanceof n.Mesh):[e];i.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 o=()=>{i.forEach(e=>{if(e.name===`ScaleHelperTransparentGroup`){if(e.children[0]){let n=e.children[0].material;n.color.set(t),n.opacity=r}}else{let n=e.material;Array.isArray(n)?n.forEach(e=>{e.color.set(t),e.opacity=r}):(n.color.set(t),n.opacity=r)}}),this.render()},s=()=>{i.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()},c=e=>{this.isDragging||o()},l=e=>{this.isDragging||s()};for(let e of i)this.domEvents.addEventListener(e,`mouseover`,c),this.domEvents.addEventListener(e,`mouseout`,l),this.hooks.on(`moveStart`,o),this.hooks.on(`moveEnd`,s),this.hooks.on(`rotateEnd`,s),this.hooks.on(`scaleEnd`,s),a.push(()=>{this.domEvents.removeEventListener(e,`mouseover`,c),this.domEvents.removeEventListener(e,`mouseout`,l),this.hooks.off(`moveStart`,o),this.hooks.off(`moveEnd`,s),this.hooks.off(`rotateEnd`,s),this.hooks.off(`scaleEnd`,s)})}return()=>a.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 r=new n.Vector3(0,0,0);if(!e)return r;let i=()=>t||this.getBox();if(typeof e.x==`number`)r.setX(e.x);else if(typeof e.x==`object`){let t=i();r.setX((t.max.x-t.min.x)*e.x.percents)}if(typeof e.y==`number`)r.setY(e.y);else if(typeof e.y==`object`){let t=i();r.setY((t.max.y-t.min.y)*e.y.percents)}if(typeof e.z==`number`)r.setZ(e.z);else if(typeof e.z==`object`){let t=i();r.setZ((t.max.z-t.min.z)*e.z.percents)}return r}};function mt(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 ht=class{constructor(e,t,n){this.camera=e,this.container=t,this.defaults=Object.assign({},n||{})}createSolidLine(e,t,r){let i=Object.assign(Object.assign({color:16777215,renderOrder:G.DRAG_GUIDE_LINE},this.defaults),r||{}),a=t.clone().normalize(),o=this.computeInfiniteLineLength(e),s=e.clone().add(a.clone().multiplyScalar(-o)),c=e.clone().add(a.clone().multiplyScalar(o)),l=new Float32Array([s.x,s.y,s.z,c.x,c.y,c.z]),u=new n.BufferGeometry;u.setAttribute(`position`,new n.BufferAttribute(l,3));let d=new n.LineBasicMaterial({color:i.color,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.65}),f=new n.Line(u,d);return f.renderOrder=i.renderOrder,f}updateSolidLine(e,t,r,i){let a=r.clone().normalize(),o=this.computeInfiniteLineLength(t),s=t.clone().add(a.clone().multiplyScalar(-o)),c=t.clone().add(a.clone().multiplyScalar(o)),l=new Float32Array([s.x,s.y,s.z,c.x,c.y,c.z]),u=e.geometry,d=u.getAttribute(`position`);d&&d.itemSize===3&&d.array.length===l.length?(d.array.set(l),d.needsUpdate=!0):u.setAttribute(`position`,new n.BufferAttribute(l,3)),(i==null?void 0:i.color)!==void 0&&e.material.color.setHex(i.color)}computeInfiniteLineLength(e){return mt(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 gt(e,t,r){if(!t||!r||!e)return;let i=P(t,r);if(Math.abs(i.x)===1||Math.abs(i.y)===1)return;let a=new n.Raycaster;return a.setFromCamera(i,e),a.params.Points&&(a.params.Points.threshold=.1),a}function _t(e){let{raycaster:t,line:r,clampToLine:i=!0}=e,a=new n.Plane().setFromNormalAndCoplanarPoint(t.ray.direction.clone().normalize(),new n.Vector3),o=a.projectPoint(r.start,new n.Vector3),s=a.projectPoint(r.end,new n.Vector3),c=new n.Line3(o,s),l=c.closestPointToPoint(t.ray.origin,i,new n.Vector3),u=l.distanceTo(s),d=l.distanceTo(o),f=c.distance();if(u>d&&u>f){let e=-l.distanceTo(o)/f,t=r.start.clone().sub(r.end).normalize();return r.start.clone().sub(t.clone().multiplyScalar(e*r.distance()))}else{let e=l.distanceTo(o)/f;return new n.Vector3().lerpVectors(r.start,r.end,e)}}var vt=class extends pt{get moveByMouseEnable(){return this._moveByMouse.enabled}constructor(...e){var t,r,i,a,o;super(...e),this.name=`MoveController`,this.solidGuide=new ht(this.camera,this.container,(r=(t=this.config)==null?void 0:t.solidGuide)==null?{}:r),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 r=(t==null?void 0:t.object).direction;if(!r)return this.dragEnd();let i=new n.Vector3(1,0,0),a=new n.Vector3(0,1,0),o=new n.Vector3(0,0,1),s=(()=>{switch(r){case`x`:return i;case`y`:return a;case`z`:return o;case`xy`:case`xz`:case`yz`:case`plane`:return}})(),c=t.point.clone();if(r===`xy`||r===`xz`||r===`yz`){let e=(()=>{switch(r){case`xy`:return o;case`xz`:return a;case`yz`:return i}})(),t=new n.Plane().setFromNormalAndCoplanarPoint(e,c),s=c.clone();this.startInfo={draggingDirection:r,startVectorProject:s,line:new n.Line3(s.clone(),s.clone()),plane:t}}else if(r===`plane`){let e=this.camera.position.clone(),t=c.clone(),i=t.clone().sub(e).normalize(),a=new n.Plane().setFromNormalAndCoplanarPoint(i,t),o=t.clone();this.startInfo={draggingDirection:r,startVectorProject:o,line:new n.Line3(o.clone(),o.clone()),plane:a}}else{if(!s)return this.dragEnd();this.startInfo={draggingDirection:r,startVectorProject:c,line:new n.Line3(c.clone().sub(s.normalize()),c.clone().add(s.normalize()))};try{let e=s.clone().normalize(),t=this.helperObject3D.getWorldPosition(new n.Vector3),r=this.solidGuide.createSolidLine(t,e,{color:16777215,renderOrder:G.DRAG_GUIDE_LINE});this.scene.add(r),this.dragGuideLine=r}catch(e){}}let l=(()=>{switch(r){case`plane`:return[];case`xy`:return[`x`,`y`,`xy`];case`xz`:return[`x`,`z`,`xz`];case`yz`:return[`y`,`z`,`yz`];default:return[r]}})();this.helperObject3D.showDraggingHelper(l),this.hooks.emit(`moveStart`,r),this.isDragging=!0,this.setTipsText(this.originObject3D.position),this.setTipsPosition(c)},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=gt(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 s=this.helperObject3D;if(this.hoverListener([s.xArrow,s.yArrow,s.zArrow,(i=s.xyPlane)==null?void 0:i.handle,(a=s.xzPlane)==null?void 0:a.handle,(o=s.yzPlane)==null?void 0:o.handle]),s.centerHandle&&s.centerHandle instanceof et){let e=s.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 c=this.show.bind(this),l=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`,l),this.hooks.on(`rotateEnd`,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`,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`,l),this.hooks.off(`rotateEnd`,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)}),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,r,i;if(!this.moveByMouseEnable)return;let{point:a,face:o}=e;if(!this.hooks.emit(`wantToMove`,a)){if(this.originObject3D.position.copy(a),(this._moveByMouse.useFaceNormal===!0||typeof this._moveByMouse.useFaceNormal==`object`&&this._moveByMouse.useFaceNormal.enable!==!1)&&o!=null&&o.normal){let e=typeof this._moveByMouse.useFaceNormal==`object`&&this._moveByMouse.useFaceNormal.alignmentVector?this._moveByMouse.useFaceNormal.alignmentVector:{x:0,y:1,z:0},a=new n.Vector3((t=e.x)==null?0:t,(r=e.y)==null?0:r,(i=e.z)==null?0:i),s=typeof this._moveByMouse.useFaceNormal==`object`&&this._moveByMouse.useFaceNormal.fixedFaceNormal?this._moveByMouse.useFaceNormal.fixedFaceNormal(o.normal):o.normal;this.originObject3D.quaternion.setFromUnitVectors(a,s),this.internalHooks.emit(`setObjectRotate`,this.originObject3D.quaternion.clone(),new n.Vector3)}this.internalHooks.emit(`setObjectPosition`,a),this.hooks.emit(`move`,a)}}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 r=this.helperObject3D.getWorldPosition(new n.Vector3);this.solidGuide.updateSolidLine(this.dragGuideLine,r,t)}move(e){if(!this.startInfo)return this.dragEnd();let{line:t,startVectorProject:r}=this.startInfo,i=this.originObject3D,a=this.startInfo.draggingDirection===`plane`||this.startInfo.draggingDirection===`xy`||this.startInfo.draggingDirection===`xz`||this.startInfo.draggingDirection===`yz`,o;if(a){let t=this.startInfo.plane;if(!t)return;let r=new n.Vector3,i=t.normal.dot(e.ray.direction);if(Math.abs(i)<1e-6)return;let a=-(t.normal.dot(e.ray.origin)+t.constant)/i;if(a<0)return;r.copy(e.ray.origin.clone().add(e.ray.direction.clone().multiplyScalar(a))),o=r}else o=_t({raycaster:e,line:t,clampToLine:!1});let s=i.position.clone(),c=o.clone().sub(r),l=new n.Matrix4;l.setPosition(c);let u=i.position.clone().applyMatrix4(l);if(this.hooks.emit(`wantToMove`,u))return;let d=u.clone();this.hooks.emit(`moveBefore`,d);let f=new n.Matrix4;f.setPosition(d.clone().sub(s)),i.position.copy(d),this.setTipsText(d),this.setTipsPosition(d),r.copy(o),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:r,y:i,z:a}=this.helperObject3D.getWorldPosition(new n.Vector3).clone().project(this.camera);if(a>1){t.hide();return}let o=this.container.getBoundingClientRect(),s=(r+1)/2*o.width,c=(-i+1)/2*o.height;t.setLeftTop(s+`px`,c+`px`)}},yt=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();this.five=e,!(!l||!u||!f||!d)&&(this.helperController=new n({camera:l,model:u,domEvents:t,originObject3D:r,helperObject3D:i,container:f,scene:c==null?d:c,onRender:()=>{e.needsRender=!0},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()}},bt=new n.Quaternion,xt=class extends pt{get rotateCenter(){return this.helperObject3D.position.clone()}constructor(...e){var t,n,r;super(...e),this.name=`RotateController`,this.solidGuide=new ht(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:r=0,z:i=0}=e,a=new n.Euler(n.MathUtils.degToRad(t),n.MathUtils.degToRad(r),n.MathUtils.degToRad(i)),o=new n.Quaternion().setFromEuler(a);if(this.hooks.emit(`wantToRotate`,o))return;let{originObject3D:s,rotateCenter:c}=this;Ge(s,o,c),this.internalHooks.emit(`setObjectRotate`,o,c),this.hooks.emit(`rotate`,o),this.render()}getEulerAngle(e,t){let{originObject3D:r}=this,i=new n.Euler().setFromQuaternion(r.quaternion),a={x:n.MathUtils.radToDeg(i.x),y:n.MathUtils.radToDeg(i.y),z:n.MathUtils.radToDeg(i.z)},o={x:e===`x`?t:a.x,y:e===`y`?t:a.y,z:e===`z`?t:a.z},s=new n.Euler(n.MathUtils.degToRad(o.x),n.MathUtils.degToRad(o.y),n.MathUtils.degToRad(o.z));return new n.Quaternion().setFromEuler(s)}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 r=(t==null?void 0:t.object).direction;if(!r)return this.dragEnd();let i=t.point;this.setTipsAngle(0);let a=i.clone();a.y+=.2,this.setTipsPosition(a);let o=new n.Quaternion,s=r===`x`?new n.Vector3(1,0,0):r===`y`?new n.Vector3(0,1,0):r===`z`?new n.Vector3(0,0,1):new n.Vector3(0,1,0),c=new n.Plane().setFromNormalAndCoplanarPoint(s,i),l=c.projectPoint(i.clone(),new n.Vector3).clone().sub(this.rotateCenter),u=this.getAngleHelper(r);if(!u)return this.dragEnd();let d=l.angleTo(u.baseAxes.clone().applyQuaternion(o)),f=u.offsetAngle(d);this.setAngleHelperStart(r,f),this.setAngleHelperLength(r,0),this.startInfo={direction:r,startVector:l,directionVector:s,plane:c,angleHelper:u,angle:0,helperQuaternion:o.clone(),startQuaternion:this.originObject3D.quaternion.clone()},bt=new n.Quaternion,this.helperObject3D.showDraggingHelper([r]),this.hooks.emit(`rotateStart`,r),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 r;if(e&&e.isMatrix4){r=new n.Quaternion,e.decompose(new n.Vector3,r,new n.Vector3);let i=new n.Euler().setFromQuaternion(r);if(t===`x`)return Math.round(n.MathUtils.radToDeg(i.z));if(t===`y`)return Math.round(n.MathUtils.radToDeg(i.y));if(t===`z`)return Math.round(n.MathUtils.radToDeg(i.x))}}parseAngleByDirection(e){var t,r;let i=(r=(t=this.originObject3D)==null?void 0:t.ext)==null?void 0:r.matrix,a;if(i&&i.isMatrix4){a=new n.Quaternion,i.decompose(new n.Vector3,a,new n.Vector3);let t=new n.Euler().setFromQuaternion(a);if(e===`x`)return Math.round(n.MathUtils.radToDeg(t.z));if(e===`y`)return Math.round(n.MathUtils.radToDeg(t.y));if(e===`z`)return Math.round(n.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=gt(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:r,angleHelper:i,direction:a,helperQuaternion:o}=this.startInfo,{originObject3D:s}=this,c=e.ray.intersectPlane(r,new n.Vector3);if(!c)return;let l=this.rotateCenter.clone(),u=r.projectPoint(c.clone(),new n.Vector3).clone().sub(l),d=this.startInfo.directionVector.clone().normalize();u=u.clone().projectOnPlane(d).normalize().multiplyScalar(u.length());let f=new n.Quaternion().setFromUnitVectors(t.clone().normalize(),u.clone().normalize()),p=s.quaternion.clone().premultiply(f);if(t.angleTo(u)===0||this.hooks.emit(`wantToRotate`,p))return;let m=new n.Euler().setFromQuaternion(new n.Quaternion().setFromUnitVectors(t.clone().normalize().applyQuaternion(o.clone().inverse()),u.clone().normalize().applyQuaternion(o.clone().inverse())),`${a.toUpperCase()}${`XZY`.replace(a.toUpperCase(),``)}`)[a]*i.angleDirection,h=this.startInfo.angle,g=h+m,_=Math.PI/2,v=n.MathUtils.degToRad(5),y=n.MathUtils.degToRad(10),b=new n.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(a,l):!E&&D&&this.removeSnapGuideLines(),this.setAngleHelperLength(a,this.startInfo.angle),this.setTipsAngle(n.MathUtils.radToDeg(this.startInfo.angle));let O=new n.Quaternion().setFromAxisAngle(d,T);if(l){let e=new n.Vector3().subVectors(s.position,l).applyQuaternion(O).add(l);s.position.copy(e)}s.applyQuaternion(O),bt.premultiply(O),this.internalHooks.emit(`applyObjectRotate`,{quaternion:O,origin:l}),this.hooks.emit(`rotate`,s.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 n.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 r=this.getAngleHelper(e);if(!r){console.warn(`angleHelper is undefined`);return}if(r instanceof n.Mesh&&r.geometry instanceof n.CircleGeometry){let{radius:e,segments:i,thetaLength:a}=r.geometry.parameters;r.geometry=new n.CircleGeometry(e,i,t,a)}else console.warn(`only support THREE.CircleGeometry`)}setAngleHelperLength(e,t){let r=.001,i=e===`x`||e===`y`?-t:t,a=i>=0?Math.max(i,r):Math.min(i,-r),o=this.getAngleHelper(e);if(o instanceof n.Mesh&&o.geometry instanceof n.CircleGeometry){let{radius:e,thetaStart:t}=o.geometry.parameters,r=Math.ceil(Math.abs(a)*(40/(2*Math.PI)));o.geometry=new n.CircleGeometry(e,r,t,a)}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:r,y:i,z:a}=this.helperObject3D.getWorldPosition(new n.Vector3).clone().project(this.camera);if(a>1){t.hide();return}let o=this.container.getBoundingClientRect(),s=(r+1)/2*o.width,c=(-i+1)/2*o.height;t.setLeftTop(s+`px`,c+`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 r=(()=>{switch(e){case`x`:return[new n.Vector3(0,1,0),new n.Vector3(0,0,1)];case`y`:return[new n.Vector3(1,0,0),new n.Vector3(0,0,1)];case`z`:return[new n.Vector3(1,0,0),new n.Vector3(0,1,0)];default:return[]}})();for(let e of r){let n=this.solidGuide.createSolidLine(t,e,{color:16777215,renderOrder:G.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=[]}},St=class extends pt{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 $(e,t){this._camera=e||null,this._domElement=t||document,this._raycaster=new n.Raycaster,this._selected=null,this._boundObjs={};var r=this;this._$onClick=function(){r._onClick.apply(r,arguments)},this._$onDblClick=function(){r._onDblClick.apply(r,arguments)},this._$onMouseMove=function(){r._onMouseMove.apply(r,arguments)},this._$onMouseDown=function(){r._onMouseDown.apply(r,arguments)},this._$onMouseUp=function(){r._onMouseUp.apply(r,arguments)},this._$onTouchMove=function(){r._onTouchMove.apply(r,arguments)},this._$onTouchStart=function(){r._onTouchStart.apply(r,arguments)},this._$onTouchEnd=function(){r._onTouchEnd.apply(r,arguments)},this._$onContextmenu=function(){r._onContextmenu.apply(r,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)}$.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)},$.eventNames=[`click`,`dblclick`,`mouseover`,`mouseout`,`mousemove`,`mousedown`,`mouseup`,`contextmenu`,`touchstart`,`touchend`],$.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}},$.prototype._objectCtxInit=function(e){e._3xDomEvent={}},$.prototype._objectCtxDeinit=function(e){delete e._3xDomEvent},$.prototype._objectCtxIsInit=function(e){return!!e._3xDomEvent},$.prototype._objectCtxGet=function(e){return e._3xDomEvent},$.prototype.camera=function(e){return e&&(this._camera=e),this._camera},$.prototype.bind=function(e,t,n,r){console.assert($.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)},$.prototype.addEventListener=$.prototype.bind,$.prototype.unbind=function(e,t,n,r){console.assert($.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)},$.prototype.removeEventListener=$.prototype.unbind,$.prototype._bound=function(e,t){var n=this._objectCtxGet(t);return n?!!n[e+`Handlers`]:!1},$.prototype._isObjectVisible=function(e){for(var t=e;t;){if(t.visible===!1)return!1;t=t.parent}return!0},$.prototype._filterVisibleObjects=function(e){var t=this;return e.filter(function(e){return t._isObjectVisible(e)})},$.prototype._onMove=function(e,t,r,i){var a=this._boundObjs[e];if(!(a===void 0||a.length===0)){var o=this._filterVisibleObjects(a);if(o.length!==0){var s=new n.Vector2;s.set(t,r),this._raycaster.setFromCamera(s,this._camera);var c=this._raycaster.intersectObjects(o),l=this;c=c.filter(function(e){return l._isObjectVisible(e.object)}),c.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(c.length>0){var d,f,p,m=c[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,i,m),d&&this._notify(`mouseover`,h,i,m),f&&this._notify(`mouseout`,u,i,m)}}},$.prototype._onEvent=function(e,t,r,i){var a=this._boundObjs[e];if(!(a===void 0||a.length===0)){var o=this._filterVisibleObjects(a);if(o.length!==0){var s=new n.Vector2;s.set(t,r),this._raycaster.setFromCamera(s,this._camera);var c=this._raycaster.intersectObjects(o,!0),l=this;if(c=c.filter(function(e){return l._isObjectVisible(e.object)}),c.sort(function(e,t){var n=e.object.renderOrder||0,r=t.object.renderOrder||0;return n===r?e.distance-t.distance:r-n}),c.length!==0){for(var u=c[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,i,u)}}}},$.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)}},$.prototype._onMouseDown=function(e){return this._onMouseEvent(`mousedown`,e)},$.prototype._onMouseUp=function(e){return this._onMouseEvent(`mouseup`,e)},$.prototype._onMouseEvent=function(e,t){var n=this._getRelativeMouseXY(t);this._onEvent(e,n.x,n.y,t)},$.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)},$.prototype._onClick=function(e){this._onMouseEvent(`click`,e)},$.prototype._onDblClick=function(e){this._onMouseEvent(`dblclick`,e)},$.prototype._onContextmenu=function(e){this._onMouseEvent(`contextmenu`,e)},$.prototype._onTouchStart=function(e){return this._onTouchEvent(`touchstart`,e)},$.prototype._onTouchEnd=function(e){return this._onTouchEvent(`touchend`,e)},$.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)}},$.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 Ct=`Object3DHelperPlugin`,wt=Ct,Tt=()=>{console.error(`${wt} is disposed`)},Et=()=>{console.warn(`${wt} is disabled`)},Dt=()=>{console.error(`${wt} is disabled`)},Ot=class{constructor(e){this.controllers={},this.state={visible:!0,enabled:!0,disposed:!1},this.hooks=new t.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)})}},kt=class extends p.Controller{constructor(e){super(e),this.name=Ct,this.state={visible:!0,enabled:!0,disposed:!1},this.objectHelperMap=new Map,this.five=e}show(e){return m(this,void 0,void 0,function*(){this.setState({visible:!0},e)})}hide(e){return m(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 m(this,void 0,void 0,function*(){})}setState(e,t){var n;if(this.state.disposed)return Tt();if(!this.state.enabled&&e.enabled!==!0&&e.disposed!==!0)return Dt();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,r={}){var i,a;if(!e){console.error(`Object3D is undefined`);return}if(this.objectHelperMap.has(e)){console.warn(`Object3DHelperPlugin: object3D ${e.name} already has helper`);return}let o=new Ot,s=[],c=(i=this.five.getElement())==null?void 0:i.parentElement;this.five.camera;let l=Object.assign(Object.assign({},{moveHelper:!0,rotateHelper:!0,boundingBoxHelper:!1,moveHelperTips:!1,positionFrom:`objectPosition`}),r),{moveHelper:u,rotateHelper:d,boundingBoxHelper:f}=l,p=new n.Group;l.helperOffset&&p.position.copy(l.helperOffset),this.five.scene.add(p);let m=o.hooks,h=new t.Subscribe,g=new $(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(l.moveHelper)),l),n=new Y(e,Object.assign({container:c==null?void 0:c,moveTipsEnable:(a=l.moveHelperTips)==null?!1:a},t)),r=new yt(this.five,g,vt,e,n,t,m,h,p);v.moveController=r.helperController,s.push(()=>r.dispose())}if(_(d)){let t=Object.assign(Object.assign({},this.getConfig(l.rotateHelper)),l),n=new st(e,Object.assign({container:c==null?void 0:c},t)),r=new yt(this.five,g,xt,e,n,t,m,h,p);v.rotateController=r.helperController,s.push(()=>r.dispose())}if(_(f)){let t=new ut(e),n=new yt(this.five,g,St,e,t,void 0,m,h,p);v.boundingBoxController=n.helperController,s.push(()=>n.dispose())}return Object.values(v).forEach(e=>{e&&typeof e.updateOtherControllers==`function`&&e.updateOtherControllers(v)}),o.addControllers(v),this.objectHelperMap.set(e,{helper:o,disposers:s,helperGroup:p}),o.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&&Et()}getConfig(e){if(e&&typeof e!=`boolean`&&e.enable)return e}},At=e=>new kt(e),jt=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}},Mt=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?6e3:n,this.curveHeight=(r=t==null?void 0:t.curveHeight)==null?1.5:r,this.pointDuration=(i=t==null?void 0:t.pointDuration)==null?4e3:i}load(){return m(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();if(e){let t=e.material.uniforms;t.u_aggregationEnabled.value=!1,t.u_aggregationProgress.value=1}}catch(e){}}extractKeyframes(e){let t=[];if(!e.content.data)throw Error(`轨迹数据未加载`);let r=e.content.data.positionArray,i=r.length/3,a=.01,o=.1,s=new jt(a,o,1,0,1),c=new jt(a,o,1,0,1),l=new jt(a,o,1,0,1),u=new Float32Array(i);for(let e=0;e<i;e++)if(e===0)u[e]=0;else{let t=new n.Vector3(r[(e-1)*3],r[(e-1)*3+1],r[(e-1)*3+2]);u[e]=new n.Vector3(r[e*3],r[e*3+1],r[e*3+2]).distanceTo(t)+u[e-1]}for(let a=0;a<i;a++){let o=new n.Vector3(0,0,0),d=0;for(let e=a-5;e<a+6;e++)e>=0&&e<i&&(o.add(new n.Vector3(r[e*3],r[e*3+1],r[e*3+2])),d++);o.divideScalar(d).applyMatrix4(e.transform);let f=s.filter(o.x),p=c.filter(o.y),m=l.filter(o.z);t.push({position:new n.Vector3(f,p,m),location:u[a]})}return t}computeAABB2D(e){let t=1/0,r=-1/0,i=1/0,a=-1/0;for(let n of e)n.position.x<t&&(t=n.position.x),n.position.x>r&&(r=n.position.x),n.position.z<i&&(i=n.position.z),n.position.z>a&&(a=n.position.z);return{min:new n.Vector2(t,i),max:new n.Vector2(r,a)}}findClosestKeyframeToRay(e,t){let r=1/0,i=t[0].position.clone(),a=new n.Vector3;for(let n of t){e.closestPointToPoint(n.position,a);let t=a.distanceTo(n.position);t<r&&(r=t,i=n.position.clone())}return i}getCameraCurve(){return m(this,void 0,void 0,function*(){var e,r,i;let a=(i=(r=(e=this.five.model.viewLayers[0])==null?void 0:e.scene)==null?void 0:r.trajectories)==null?void 0:i[0];if(!a)throw Error(`未找到轨迹数据`);a.visible=!0,yield new Promise(e=>{let n=t.AnimationFrameLoop.shared.add(()=>{a.content.loadState===`READY`&&(n(),e(),a.visible=!1)})});let o=this.extractKeyframes(a);if(o.length<2)throw Error(`轨迹关键帧不足,至少需要2个关键帧`);this.keyframes=o;let s=this.computeAABB2D(o);this.boundingAABB=s;let c=this.curveHeight,l=new n.Vector3((s.min.x+s.max.x)/2,c,(s.min.y+s.max.y)/2),u=(s.max.x-s.min.x)/2,d=(s.max.y-s.min.y)/2,f=Math.sqrt(u*u+d*d),p=e=>{let t=new n.Vector3().subVectors(e,l);return t.length()<.001&&t.set(1,0,0),l.clone().add(t.normalize().multiplyScalar(f))},m=new n.Vector3(o[0].position.x,c,o[0].position.z),h=p(m),g=new n.Vector3().subVectors(l,m).normalize(),_=new n.Ray(m,g),v=new n.Vector3(-g.z,0,g.x).normalize(),y=new n.Ray(l,v),b=this.findClosestKeyframeToRay(y,o),x=p(new n.Vector3(b.x,c,b.z)),S=this.findClosestKeyframeToRay(_,o),C=p(new n.Vector3(S.x,c,S.z));return new n.CatmullRomCurve3([h,x,C],!1,`centripetal`,.5)})}findRenderMesh(){let e=null;if(this.five.scene.traverse(t=>{e||t instanceof n.Mesh&&t.material&&t.material.uniforms&&t.material.uniforms.u_aggregationEnabled&&(e=t)}),!e)throw Error(`未找到 GaussianSplatting 渲染网格`);return e}setBounding(e,t,n){let r=this.findRenderMesh();r.material.uniforms.u_aggregationBoundsMin.value.copy(e),r.material.uniforms.u_aggregationBoundsMax.value.copy(t),this.boundsSet=!0}setBounds(){if(!this.boundingAABB)throw Error(`请先调用 getCameraCurve 计算轨迹边界`);let e=this.boundingAABB,t=this.findRenderMesh(),r=new n.Vector3(e.min.x,0,e.min.y),i=new n.Vector3(e.max.x,3,e.max.y);t.material.uniforms.u_aggregationBoundsMin.value.copy(r),t.material.uniforms.u_aggregationBoundsMax.value.copy(i),this.boundsSet=!0}startAggregation(){if(!this.boundsSet)throw Error(`请先调用 setBounds 设置聚合边界`);let e=this.findRenderMesh().material.uniforms;e.u_aggregationEnabled.value=!0,e.u_aggregationProgress.value=0,e.u_aggregationPointDuration.value=Math.min(this.pointDuration/this.duration,1),this.five.needsRender=!0;let n=performance.now(),r=this.duration;this.cancelAnimation=t.AnimationFrameLoop.shared.add(()=>{let t=performance.now()-n,i=Math.min(t/r,1),a=i*i*(3-2*i);e.u_aggregationProgress.value=a,this.five.needsRender=!0,this.five.modelSceneNeedsRender=!0,i>=1&&(e.u_aggregationEnabled.value=!1,this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null))})}playEntrance(){return m(this,void 0,void 0,function*(){let e=yield this.getCameraCurve(),r=this.boundingAABB,i=new n.Vector3((r.min.x+r.max.x)/2,this.curveHeight,(r.min.y+r.max.y)/2),a=e.getPointAt(0),o=new t.Camera(90).copy(this.five.camera);o.position.copy(a),o.lookAt(i),o.computePose(0),this.five.setState(Object.assign({},o.pose)),this.setBounds();let s=this.findRenderMesh().material.uniforms;s.u_aggregationEnabled.value=!0,s.u_aggregationProgress.value=0,s.u_aggregationPointDuration.value=Math.min(this.pointDuration/this.duration,1),this.five.needsRender=!0;let c=this.duration,l=performance.now();return new Promise(n=>{this.cancelAnimation=t.AnimationFrameLoop.shared.add(()=>{let t=performance.now()-l,r=Math.min(t/c,1),a=r*r*(3-2*r);s.u_aggregationProgress.value=a,this.five.modelSceneNeedsRender=!0;let u=e.getPointAt(a);o.position.copy(u),o.lookAt(i),o.computePose(0),this.five.setState(Object.assign({},o.pose)),this.five.needsRender=!0,r>=1&&(s.u_aggregationEnabled.value=!1,s.u_aggregationProgress.value=1,this.cancelAnimation&&(this.cancelAnimation(),this.cancelAnimation=null),n())})})})}};e.BackgroundPlugin=ue,Object.defineProperty(e,`BasePlugin`,{enumerable:!0,get:function(){return p}}),e.CSS2DObject=Fe,e.CSS2DPlugin=We,e.CSS2DRenderer=Ve,e.CSS3DObject=M,e.CSS3DPlugin=Pe,e.CSS3DRenderer=se,e.CSS3DSprite=ae,e.DynamicPathLinePlugin=ke,e.GaussianSplattingEntranceAnimationPlugin=(e,t)=>new Mt(e,t),e.ItemMaskPlugin=A,e.Object3DHelperController=kt,e.Object3DHelperPlugin=At,e.OrbitControls=j,e.OrientationPlugin=V,e.PanoAnimePlugin=xe,e.RoundedBoxGeometry=F,e.TrajectoryPlugin=U});