x_ite 5.0.3 → 6.1.0

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 (385) hide show
  1. package/.vscode/settings.json +12 -5
  2. package/.vscode/tasks.json +25 -1
  3. package/Makefile +36 -28
  4. package/README.md +6 -11
  5. package/build/bin/dist.pl +0 -6
  6. package/build/bin/examples-and-tests.pl +75 -0
  7. package/build/bin/tests-menu.pl +57 -0
  8. package/build/bin/version.pl +7 -4
  9. package/build/parts/default.start.frag.js +3 -2
  10. package/dist/assets/components/annotation.js +3 -2
  11. package/dist/assets/components/annotation.min.js +1 -1
  12. package/dist/assets/components/cad-geometry.js +3 -2
  13. package/dist/assets/components/cad-geometry.min.js +1 -1
  14. package/dist/assets/components/cube-map-texturing.js +8 -20
  15. package/dist/assets/components/cube-map-texturing.min.js +1 -1
  16. package/dist/assets/components/dis.js +3 -2
  17. package/dist/assets/components/dis.min.js +1 -1
  18. package/dist/assets/components/event-utilities.js +4 -3
  19. package/dist/assets/components/event-utilities.min.js +1 -1
  20. package/dist/assets/components/geometry2d.js +38 -52
  21. package/dist/assets/components/geometry2d.min.js +1 -1
  22. package/dist/assets/components/geospatial.js +34 -1686
  23. package/dist/assets/components/geospatial.min.js +1 -1
  24. package/dist/assets/components/h-anim.js +71 -77
  25. package/dist/assets/components/h-anim.min.js +1 -1
  26. package/dist/assets/components/key-device-sensor.js +4 -3
  27. package/dist/assets/components/key-device-sensor.min.js +1 -1
  28. package/dist/assets/components/layout.js +101 -173
  29. package/dist/assets/components/layout.min.js +1 -1
  30. package/dist/assets/components/nurbs.js +3 -2
  31. package/dist/assets/components/nurbs.min.js +1 -1
  32. package/dist/assets/components/particle-systems.js +1926 -1669
  33. package/dist/assets/components/particle-systems.min.js +1 -1
  34. package/dist/assets/components/picking.js +34 -41
  35. package/dist/assets/components/picking.min.js +1 -1
  36. package/dist/assets/components/projective-texture-mapping.js +73 -86
  37. package/dist/assets/components/projective-texture-mapping.min.js +1 -1
  38. package/dist/assets/components/rigid-body-physics.js +37 -57
  39. package/dist/assets/components/rigid-body-physics.min.js +1 -1
  40. package/dist/assets/components/scripting.js +3 -2
  41. package/dist/assets/components/scripting.min.js +1 -1
  42. package/dist/assets/components/texturing-3d.js +27 -33
  43. package/dist/assets/components/texturing-3d.min.js +3 -3
  44. package/dist/assets/components/volume-rendering.js +12 -11
  45. package/dist/assets/components/volume-rendering.min.js +1 -1
  46. package/dist/assets/components/x_ite.js +3 -2
  47. package/dist/assets/components/x_ite.min.js +1 -1
  48. package/dist/assets/images/Shading.png +0 -0
  49. package/dist/assets/linetype/1.png +0 -0
  50. package/dist/assets/linetype/10.png +0 -0
  51. package/dist/assets/linetype/11.png +0 -0
  52. package/dist/assets/linetype/12.png +0 -0
  53. package/dist/assets/linetype/13.png +0 -0
  54. package/dist/assets/linetype/14.png +0 -0
  55. package/dist/assets/linetype/15.png +0 -0
  56. package/dist/assets/linetype/16.png +0 -0
  57. package/dist/assets/linetype/2.png +0 -0
  58. package/dist/assets/linetype/3.png +0 -0
  59. package/dist/assets/linetype/4.png +0 -0
  60. package/dist/assets/linetype/5.png +0 -0
  61. package/dist/assets/linetype/6.png +0 -0
  62. package/dist/assets/linetype/7.png +0 -0
  63. package/dist/assets/linetype/8.png +0 -0
  64. package/dist/assets/linetype/9.png +0 -0
  65. package/dist/assets/shaders/webgl1/Gouraud.vs +1 -1
  66. package/dist/assets/shaders/webgl1/Line.fs +0 -21
  67. package/dist/assets/shaders/webgl1/Line.vs +0 -10
  68. package/dist/assets/shaders/webgl1/PBR.fs +1 -1
  69. package/dist/assets/shaders/webgl1/PBR.vs +1 -1
  70. package/dist/assets/shaders/webgl1/Phong.fs +1 -1
  71. package/dist/assets/shaders/webgl1/Point.vs +1 -1
  72. package/dist/assets/shaders/webgl2/Depth.vs +29 -1
  73. package/dist/assets/shaders/webgl2/Gouraud.vs +32 -4
  74. package/dist/assets/shaders/webgl2/Line.fs +24 -12
  75. package/dist/assets/shaders/webgl2/Line.vs +36 -11
  76. package/dist/assets/shaders/webgl2/LineTransform.fs +4 -0
  77. package/dist/assets/shaders/webgl2/LineTransform.vs +57 -0
  78. package/dist/assets/shaders/webgl2/PBR.fs +1 -1
  79. package/dist/assets/shaders/webgl2/PBR.vs +35 -7
  80. package/dist/assets/shaders/webgl2/Phong.fs +1 -1
  81. package/dist/assets/shaders/webgl2/Phong.vs +31 -3
  82. package/dist/assets/shaders/webgl2/Point.vs +30 -2
  83. package/dist/assets/shaders/webgl2/Unlit.vs +31 -3
  84. package/dist/example.html +6 -6
  85. package/dist/x_ite.css +199 -224
  86. package/dist/x_ite.js +16335 -15917
  87. package/dist/x_ite.min.js +17 -17
  88. package/dist/x_ite.zip +0 -0
  89. package/docs/404.md +6 -0
  90. package/docs/Accessing-the-External-Browser.md +21 -15
  91. package/docs/Browser-Support.md +6 -0
  92. package/docs/Custom-Shaders.md +18 -25
  93. package/docs/Features.md +11 -5
  94. package/docs/Gemfile +44 -0
  95. package/docs/Gemfile.lock +122 -0
  96. package/docs/Glossary.md +6 -0
  97. package/docs/How-To-Configure-Your-Web-Server.md +6 -0
  98. package/docs/Supported-Nodes.md +9 -1
  99. package/docs/What's-New.md +93 -39
  100. package/docs/XHTML-DOM-Integration.md +6 -0
  101. package/docs/_config.yml +2 -2
  102. package/docs/assets/css/main.scss +26 -0
  103. package/docs/index.md +42 -50
  104. package/docs/reference/Browser-Services.md +9 -3
  105. package/docs/reference/Constants-Services.md +6 -0
  106. package/docs/reference/ECMAScript-Object-and-Function-Definitions.md +12 -6
  107. package/docs/reference/Field-Services-and-Objects.md +105 -1
  108. package/docs/reference/Prototype-Services.md +11 -0
  109. package/docs/reference/Route-Services.md +9 -0
  110. package/docs/reference/Scene-Services.md +17 -2
  111. package/docs/reference/Script-Node-Authoring-Interface.md +7 -1
  112. package/docs/tutorials/Adding-backgrounds.md +6 -0
  113. package/docs/tutorials/Adding-fog.md +6 -0
  114. package/docs/tutorials/Adding-sound.md +6 -0
  115. package/docs/tutorials/Animating-transforms.md +6 -0
  116. package/docs/tutorials/Basic-Nodes.md +6 -0
  117. package/docs/tutorials/Building-a-X3D-world.md +6 -0
  118. package/docs/tutorials/Building-elevation-grids.md +6 -0
  119. package/docs/tutorials/Building-extruded-shapes.md +6 -0
  120. package/docs/tutorials/Building-primitive-shapes.md +6 -0
  121. package/docs/tutorials/Building-shapes-out-of-points,-lines,-and-faces.md +6 -0
  122. package/docs/tutorials/Controlling-appearance-with-materials.md +6 -0
  123. package/docs/tutorials/Controlling-color-on-coordinate-based-geometry.md +6 -0
  124. package/docs/tutorials/Controlling-detail.md +6 -0
  125. package/docs/tutorials/Controlling-how-textures-are-mapped.md +6 -0
  126. package/docs/tutorials/Controlling-navigation.md +6 -0
  127. package/docs/tutorials/Controlling-shading-on-coordinate-based-geometry.md +6 -0
  128. package/docs/tutorials/Controlling-the-viewpoint.md +6 -0
  129. package/docs/tutorials/Creating-new-node-types.md +6 -0
  130. package/docs/tutorials/Grouping-nodes.md +6 -0
  131. package/docs/tutorials/Hello,-World!.md +6 -0
  132. package/docs/tutorials/Improving-Performance.md +6 -0
  133. package/docs/tutorials/Increasing-Rendering-Speed.md +6 -0
  134. package/docs/tutorials/Introducing-X3D.md +6 -0
  135. package/docs/tutorials/Introducing-animation.md +6 -0
  136. package/docs/tutorials/Introducing-script-use.md +6 -0
  137. package/docs/tutorials/Lighting-your-world.md +6 -0
  138. package/docs/tutorials/Mapping-textures.md +6 -0
  139. package/docs/tutorials/Naming-nodes.md +6 -0
  140. package/docs/tutorials/Providing-information-about-your-world.md +6 -0
  141. package/docs/tutorials/Sensing-the-viewer.md +6 -0
  142. package/docs/tutorials/Sensing-viewer-actions.md +6 -0
  143. package/docs/tutorials/Transforming-Shapes.md +6 -0
  144. package/docs/tutorials/Writing-program-scripts-with-ECMAScript.md +6 -0
  145. package/docs/tutorials/index.md +42 -36
  146. package/package.json +6 -7
  147. package/src/assets/components/geometry2d.js +1 -1
  148. package/src/assets/components/key-device-sensor.js +1 -1
  149. package/src/assets/components/layout.js +1 -1
  150. package/src/assets/components/particle-systems.js +1 -1
  151. package/src/assets/components/volume-rendering.js +1 -1
  152. package/src/assets/images/Shading.png +0 -0
  153. package/src/assets/linetype/1.png +0 -0
  154. package/src/assets/linetype/10.png +0 -0
  155. package/src/assets/linetype/11.png +0 -0
  156. package/src/assets/linetype/12.png +0 -0
  157. package/src/assets/linetype/13.png +0 -0
  158. package/src/assets/linetype/14.png +0 -0
  159. package/src/assets/linetype/15.png +0 -0
  160. package/src/assets/linetype/16.png +0 -0
  161. package/src/assets/linetype/2.png +0 -0
  162. package/src/assets/linetype/3.png +0 -0
  163. package/src/assets/linetype/4.png +0 -0
  164. package/src/assets/linetype/5.png +0 -0
  165. package/src/assets/linetype/6.png +0 -0
  166. package/src/assets/linetype/7.png +0 -0
  167. package/src/assets/linetype/8.png +0 -0
  168. package/src/assets/linetype/9.png +0 -0
  169. package/src/assets/shaders/Types.glsl +1 -9
  170. package/src/assets/shaders/webgl1/Gouraud.fs +1 -1
  171. package/src/assets/shaders/webgl1/Gouraud.vs +2 -3
  172. package/src/assets/shaders/webgl1/Line.fs +3 -28
  173. package/src/assets/shaders/webgl1/Line.vs +6 -20
  174. package/src/assets/shaders/webgl1/PBR.fs +6 -6
  175. package/src/assets/shaders/webgl1/PBR.vs +1 -1
  176. package/src/assets/shaders/webgl1/Phong.fs +10 -10
  177. package/src/assets/shaders/webgl1/Point.vs +2 -2
  178. package/src/assets/shaders/webgl1/Unlit.fs +4 -4
  179. package/src/assets/shaders/webgl1/include/Normal.glsl +1 -1
  180. package/src/assets/shaders/webgl1/include/Texture.glsl +3 -8
  181. package/src/assets/shaders/webgl2/Depth.vs +4 -1
  182. package/src/assets/shaders/webgl2/Gouraud.fs +1 -1
  183. package/src/assets/shaders/webgl2/Gouraud.vs +8 -6
  184. package/src/assets/shaders/webgl2/Line.fs +11 -17
  185. package/src/assets/shaders/webgl2/Line.vs +17 -21
  186. package/src/assets/shaders/webgl2/LineTransform.fs +6 -0
  187. package/src/assets/shaders/webgl2/LineTransform.vs +77 -0
  188. package/src/assets/shaders/webgl2/PBR.fs +6 -6
  189. package/src/assets/shaders/webgl2/PBR.vs +10 -7
  190. package/src/assets/shaders/webgl2/Phong.fs +11 -11
  191. package/src/assets/shaders/webgl2/Phong.vs +6 -3
  192. package/src/assets/shaders/webgl2/Point.vs +5 -4
  193. package/src/assets/shaders/webgl2/Unlit.fs +5 -5
  194. package/src/assets/shaders/webgl2/Unlit.vs +6 -3
  195. package/src/assets/shaders/webgl2/include/Line2.glsl +20 -0
  196. package/src/assets/shaders/webgl2/include/Normal.glsl +1 -1
  197. package/src/assets/shaders/webgl2/include/Particle.glsl +36 -0
  198. package/src/assets/shaders/webgl2/include/Texture.glsl +3 -3
  199. package/src/example.html +6 -6
  200. package/src/examples.js +5 -4
  201. package/src/standard/Math/Algorithm.js +12 -28
  202. package/src/standard/Math/Geometry/Line2.js +163 -0
  203. package/src/standard/Math/Geometry/Line3.js +3 -5
  204. package/src/standard/Math/Geometry/Plane3.js +0 -2
  205. package/src/standard/Math/Geometry/Triangle3.js +1 -1
  206. package/src/standard/Math/Geometry/ViewVolume.js +121 -103
  207. package/src/standard/Math/Numbers/Color3.js +6 -0
  208. package/src/standard/Math/Numbers/Color4.js +7 -0
  209. package/src/standard/Math/Numbers/Complex.js +48 -34
  210. package/src/standard/Math/Numbers/Matrix2.js +62 -2
  211. package/src/standard/Math/Numbers/Matrix3.js +129 -110
  212. package/src/standard/Math/Numbers/Matrix4.js +138 -119
  213. package/src/standard/Math/Numbers/Quaternion.js +12 -5
  214. package/src/standard/Math/Numbers/Rotation4.js +8 -1
  215. package/src/standard/Math/Numbers/Vector2.js +42 -9
  216. package/src/standard/Math/Numbers/Vector3.js +50 -14
  217. package/src/standard/Math/Numbers/Vector4.js +48 -11
  218. package/src/standard/Math/Utility/BVH.js +45 -17
  219. package/src/tests.js +68 -66
  220. package/src/x_ite/Base/X3DBaseNode.js +22 -11
  221. package/src/x_ite/Base/X3DField.js +1 -1
  222. package/src/x_ite/Browser/Core/BrowserOptions.js +24 -143
  223. package/src/x_ite/Browser/Core/BrowserTimings.js +6 -4
  224. package/src/x_ite/Browser/Core/Context.js +185 -0
  225. package/src/x_ite/Browser/Core/ContextMenu.js +398 -211
  226. package/src/x_ite/Browser/Core/Notification.js +1 -0
  227. package/src/x_ite/Browser/Core/X3DCoreContext.js +35 -146
  228. package/src/x_ite/Browser/Followers/X3DArrayFollowerTemplate.js +1 -1
  229. package/src/x_ite/Browser/Geometry2D/Disk2DOptions.js +1 -0
  230. package/src/x_ite/Browser/Geometry2D/X3DGeometry2DContext.js +2 -2
  231. package/src/x_ite/Browser/Geometry3D/X3DGeometry3DContext.js +41 -2
  232. package/src/x_ite/Browser/Geospatial/Geocentric.js +2 -2
  233. package/src/x_ite/Browser/Interpolation/CatmullRomSplineInterpolatorTemplate.js +1 -1
  234. package/src/x_ite/Browser/Layout/ScreenText.js +18 -65
  235. package/src/x_ite/Browser/Layout/X3DLayoutContext.js +59 -16
  236. package/src/x_ite/Browser/Navigation/ExamineViewer.js +13 -20
  237. package/src/x_ite/Browser/Navigation/LookAtViewer.js +1 -4
  238. package/src/x_ite/Browser/Navigation/PlaneViewer.js +0 -3
  239. package/src/x_ite/Browser/Navigation/X3DFlyViewer.js +15 -8
  240. package/src/x_ite/Browser/Navigation/X3DViewer.js +12 -20
  241. package/src/x_ite/Browser/Networking/X3DNetworkingContext.js +11 -7
  242. package/src/x_ite/Browser/ParticleSystems/BVH.glsl +183 -0
  243. package/src/x_ite/Browser/ParticleSystems/Box3.glsl +47 -0
  244. package/src/x_ite/Browser/ParticleSystems/GeometryTypes.js +66 -0
  245. package/src/x_ite/Browser/ParticleSystems/Line3.glsl +55 -0
  246. package/src/x_ite/Browser/ParticleSystems/Plane3.glsl +160 -0
  247. package/src/x_ite/Browser/PointingDeviceSensor/PointingDevice.js +27 -3
  248. package/src/x_ite/Browser/PointingDeviceSensor/X3DPointingDeviceSensorContext.js +41 -37
  249. package/src/x_ite/Browser/Rendering/X3DRenderingContext.js +21 -13
  250. package/src/x_ite/Browser/Shaders/Shader.js +33 -12
  251. package/src/x_ite/Browser/Shaders/ShaderSource.js +6 -0
  252. package/src/x_ite/Browser/Shaders/ShaderTest.js +16 -10
  253. package/src/x_ite/Browser/Shape/X3DShapeContext.js +50 -9
  254. package/src/x_ite/Browser/Text/X3DTextContext.js +4 -13
  255. package/src/x_ite/Browser/Text/X3DTextGeometry.js +2 -1
  256. package/src/x_ite/Browser/Texturing/X3DTexturingContext.js +71 -34
  257. package/src/x_ite/Browser/Texturing3D/DICOMParser.js +2 -2
  258. package/src/x_ite/Browser/Time/X3DTimeContext.js +4 -2
  259. package/src/x_ite/Browser/VERSION.js +1 -1
  260. package/src/x_ite/Browser/X3DBrowser.js +7 -6
  261. package/src/x_ite/Browser/X3DBrowserContext.js +43 -10
  262. package/src/x_ite/Components/Core/X3DNode.js +4 -0
  263. package/src/x_ite/Components/Core/X3DPrototypeInstance.js +0 -2
  264. package/src/x_ite/Components/CubeMapTexturing/ComposedCubeMapTexture.js +3 -4
  265. package/src/x_ite/Components/CubeMapTexturing/GeneratedCubeMapTexture.js +1 -12
  266. package/src/x_ite/Components/CubeMapTexturing/ImageCubeMapTexture.js +1 -2
  267. package/src/x_ite/Components/EnvironmentalEffects/TextureBackground.js +1 -1
  268. package/src/x_ite/Components/EnvironmentalEffects/X3DBackgroundNode.js +76 -77
  269. package/src/x_ite/Components/EnvironmentalEffects/X3DFogObject.js +2 -9
  270. package/src/x_ite/Components/EnvironmentalSensor/ProximitySensor.js +51 -65
  271. package/src/x_ite/Components/EventUtilities/X3DSequencerNode.js +1 -1
  272. package/src/x_ite/Components/Followers/ColorDamper.js +1 -1
  273. package/src/x_ite/Components/Followers/X3DChaserNode.js +18 -32
  274. package/src/x_ite/Components/Followers/X3DDamperNode.js +1 -6
  275. package/src/x_ite/Components/Followers/X3DFollowerNode.js +1 -1
  276. package/src/x_ite/Components/Geometry2D/Disk2D.js +30 -46
  277. package/src/x_ite/Components/Geometry2D/TriangleSet2D.js +1 -1
  278. package/src/x_ite/Components/Geometry3D/ElevationGrid.js +12 -4
  279. package/src/x_ite/Components/Geometry3D/IndexedFaceSet.js +4 -4
  280. package/src/x_ite/Components/Geospatial/GeoCoordinate.js +10 -27
  281. package/src/x_ite/Components/Geospatial/GeoLOD.js +1 -1
  282. package/src/x_ite/Components/Geospatial/GeoPositionInterpolator.js +5 -10
  283. package/src/x_ite/Components/Geospatial/GeoTouchSensor.js +9 -16
  284. package/src/x_ite/Components/Geospatial/GeoTransform.js +6 -18
  285. package/src/x_ite/Components/Geospatial/GeoViewpoint.js +26 -30
  286. package/src/x_ite/Components/Geospatial/X3DGeospatialObject.js +20 -27
  287. package/src/x_ite/Components/Grouping/X3DGroupingNode.js +8 -8
  288. package/src/x_ite/Components/Grouping/X3DTransformNode.js +0 -4
  289. package/src/x_ite/Components/HAnim/HAnimHumanoid.js +68 -75
  290. package/src/x_ite/Components/Interpolation/OrientationInterpolator.js +4 -11
  291. package/src/x_ite/Components/Interpolation/X3DInterpolatorNode.js +1 -1
  292. package/src/x_ite/Components/Layout/LayoutGroup.js +4 -9
  293. package/src/x_ite/Components/Layout/ScreenFontStyle.js +1 -1
  294. package/src/x_ite/Components/Layout/ScreenGroup.js +16 -80
  295. package/src/x_ite/Components/Lighting/DirectionalLight.js +28 -36
  296. package/src/x_ite/Components/Lighting/PointLight.js +32 -47
  297. package/src/x_ite/Components/Lighting/SpotLight.js +33 -48
  298. package/src/x_ite/Components/Navigation/Billboard.js +49 -56
  299. package/src/x_ite/Components/Navigation/LOD.js +2 -2
  300. package/src/x_ite/Components/Navigation/OrthoViewpoint.js +29 -30
  301. package/src/x_ite/Components/Navigation/Viewpoint.js +16 -20
  302. package/src/x_ite/Components/Navigation/X3DViewpointNode.js +82 -111
  303. package/src/x_ite/Components/Networking/Anchor.js +18 -7
  304. package/src/x_ite/Components/ParticleSystems/BoundedPhysicsModel.js +6 -6
  305. package/src/x_ite/Components/ParticleSystems/ConeEmitter.js +44 -36
  306. package/src/x_ite/Components/ParticleSystems/ExplosionEmitter.js +26 -17
  307. package/src/x_ite/Components/ParticleSystems/ForcePhysicsModel.js +20 -7
  308. package/src/x_ite/Components/ParticleSystems/ParticleSystem.js +463 -882
  309. package/src/x_ite/Components/ParticleSystems/PointEmitter.js +39 -35
  310. package/src/x_ite/Components/ParticleSystems/PolylineEmitter.js +112 -128
  311. package/src/x_ite/Components/ParticleSystems/SurfaceEmitter.js +105 -112
  312. package/src/x_ite/Components/ParticleSystems/VolumeEmitter.js +138 -176
  313. package/src/x_ite/Components/ParticleSystems/WindPhysicsModel.js +16 -11
  314. package/src/x_ite/Components/ParticleSystems/X3DParticleEmitterNode.js +807 -217
  315. package/src/x_ite/Components/Picking/LinePickSensor.js +31 -39
  316. package/src/x_ite/Components/PointingDeviceSensor/CylinderSensor.js +91 -108
  317. package/src/x_ite/Components/PointingDeviceSensor/PlaneSensor.js +56 -59
  318. package/src/x_ite/Components/PointingDeviceSensor/SphereSensor.js +54 -71
  319. package/src/x_ite/Components/PointingDeviceSensor/TouchSensor.js +8 -15
  320. package/src/x_ite/Components/ProjectiveTextureMapping/TextureProjectorParallel.js +43 -50
  321. package/src/x_ite/Components/ProjectiveTextureMapping/TextureProjectorPerspective.js +32 -39
  322. package/src/x_ite/Components/Rendering/ClipPlane.js +3 -11
  323. package/src/x_ite/Components/Rendering/Color.js +12 -24
  324. package/src/x_ite/Components/Rendering/ColorRGBA.js +13 -25
  325. package/src/x_ite/Components/Rendering/IndexedLineSet.js +26 -4
  326. package/src/x_ite/Components/Rendering/LineSet.js +35 -13
  327. package/src/x_ite/Components/Rendering/PointSet.js +35 -13
  328. package/src/x_ite/Components/Rendering/X3DComposedGeometryNode.js +13 -5
  329. package/src/x_ite/Components/Rendering/X3DGeometryNode.js +331 -387
  330. package/src/x_ite/Components/Rendering/X3DLineGeometryNode.js +350 -140
  331. package/src/x_ite/Components/Rendering/X3DPointGeometryNode.js +116 -126
  332. package/src/x_ite/Components/RigidBodyPhysics/DoubleAxisHingeJoint.js +24 -38
  333. package/src/x_ite/Components/RigidBodyPhysics/SingleAxisHingeJoint.js +10 -17
  334. package/src/x_ite/Components/Shaders/ComposedShader.js +35 -75
  335. package/src/x_ite/Components/Shaders/FloatVertexAttribute.js +8 -11
  336. package/src/x_ite/Components/Shaders/Matrix3VertexAttribute.js +10 -14
  337. package/src/x_ite/Components/Shaders/Matrix4VertexAttribute.js +10 -14
  338. package/src/x_ite/Components/Shaders/ShaderPart.js +1 -10
  339. package/src/x_ite/Components/Shaders/X3DProgrammableShaderObject.js +220 -210
  340. package/src/x_ite/Components/Shaders/X3DShaderNode.js +28 -10
  341. package/src/x_ite/Components/Shaders/X3DVertexAttributeNode.js +15 -1
  342. package/src/x_ite/Components/Shape/Appearance.js +37 -4
  343. package/src/x_ite/Components/Shape/FillProperties.js +12 -1
  344. package/src/x_ite/Components/Shape/LineProperties.js +33 -1
  345. package/src/x_ite/Components/Shape/PointProperties.js +24 -3
  346. package/src/x_ite/Components/Shape/Shape.js +30 -39
  347. package/src/x_ite/Components/Shape/TwoSidedMaterial.js +3 -1
  348. package/src/x_ite/Components/Sound/Sound.js +31 -41
  349. package/src/x_ite/Components/Text/Text.js +6 -20
  350. package/src/x_ite/Components/Texturing/ImageTexture.js +1 -1
  351. package/src/x_ite/Components/Texturing/MovieTexture.js +1 -1
  352. package/src/x_ite/Components/Texturing/PixelTexture.js +2 -2
  353. package/src/x_ite/Components/Texturing/TextureCoordinate.js +5 -5
  354. package/src/x_ite/Components/Texturing/TextureProperties.js +4 -4
  355. package/src/x_ite/Components/Texturing/X3DSingleTextureNode.js +5 -4
  356. package/src/x_ite/Components/Texturing/X3DTexture2DNode.js +24 -33
  357. package/src/x_ite/Components/Texturing3D/TextureCoordinate3D.js +5 -5
  358. package/src/x_ite/Components/Texturing3D/TextureCoordinate4D.js +5 -5
  359. package/src/x_ite/Components/Texturing3D/X3DTexture3DNode.js +12 -19
  360. package/src/x_ite/Components/VolumeRendering/X3DVolumeDataNode.js +8 -8
  361. package/src/x_ite/Components.js +2 -2
  362. package/src/x_ite/Fallback.js +9 -3
  363. package/src/x_ite/Fields/SFColor.js +4 -0
  364. package/src/x_ite/Fields/SFColorRGBA.js +4 -0
  365. package/src/x_ite/Fields/SFImage.js +2 -11
  366. package/src/x_ite/Fields/SFMatrixPrototypeTemplate.js +4 -0
  367. package/src/x_ite/Fields/SFRotation.js +4 -0
  368. package/src/x_ite/Fields/SFString.js +4 -0
  369. package/src/x_ite/Fields/SFVecPrototypeTemplate.js +22 -2
  370. package/src/x_ite/Parser/XMLParser.js +1 -1
  371. package/src/x_ite/Rendering/TextureBuffer.js +43 -36
  372. package/src/x_ite/Rendering/VertexArray.js +103 -0
  373. package/src/x_ite/Rendering/X3DRenderObject.js +127 -148
  374. package/src/x_ite/X3D.js +32 -26
  375. package/src/x_ite.config.js +0 -5
  376. package/src/x_ite.css +216 -175
  377. package/src/x_ite.html +15 -10
  378. package/src/x_ite.js +49 -1
  379. package/x_ite.min.html +15 -10
  380. package/dist/assets/hatching/0.png +0 -0
  381. package/dist/assets/linetype/0.png +0 -0
  382. package/src/assets/hatching/0.png +0 -0
  383. package/src/assets/linetype/0.png +0 -0
  384. package/src/spinner.css +0 -67
  385. package/src/x_ite/Browser/Shape/LineStipples.xcf +0 -0
@@ -1 +1 @@
1
- !function(){const e=window[Symbol.for("X_ITE.X3D-5.0.3")].define,t=window[Symbol.for("X_ITE.X3D-5.0.3")].require;e("x_ite/Components/ParticleSystems/X3DParticleEmitterNode",["x_ite/Components/Core/X3DNode","x_ite/Base/X3DConstants","standard/Math/Numbers/Vector3","standard/Math/Numbers/Rotation4","standard/Math/Geometry/Line3","standard/Math/Geometry/Plane3","standard/Math/Algorithm","standard/Math/Algorithms/QuickSort"],(function(e,t,i,s,r,n,o,a){"use strict";var l=new i(0,0,0),h=new i(0,0,0),d=new r(i.Zero,i.zAxis),c=new n(i.Zero,i.zAxis);function u(e,t){return c.getDistanceToPoint(e)<c.getDistanceToPoint(t)}function m(e,t){return e<c.getDistanceToPoint(t)}function f(i){e.call(this,i),this.addType(t.X3DParticleEmitterNode),this._speed.setUnit("speed"),this._mass.setUnit("mass"),this._surfaceArea.setUnit("area"),this.rotations=[],this.intersections=[],this.intersectionNormals=[],this.sorter=new a(this.intersections,u)}return f.prototype=Object.assign(Object.create(e.prototype),{constructor:f,initialize:function(){e.prototype.initialize.call(this),this._speed.addInterest("set_speed__",this),this._variation.addInterest("set_variation__",this),this._mass.addInterest("set_mass__",this),this.set_speed__(),this.set_variation__(),this.set_mass__()},set_speed__:function(){this.speed=this._speed.getValue()},set_variation__:function(){this.variation=this._variation.getValue()},set_mass__:function(){this.mass=this._mass.getValue()},isExplosive:function(){return!1},getMass:function(){return this.mass},getRandomLifetime:function(e,t){var i=e*t,s=Math.max(0,e-i),r=e+i;return Math.random()*(r-s)+s},getRandomSpeed:function(){var e=this.speed,t=e*this.variation,i=Math.max(0,e-t),s=e+t;return Math.random()*(s-i)+i},getSphericalRandomVelocity:function(e){return this.getRandomNormal(e).multiply(this.getRandomSpeed())},getRandomValue:function(e,t){return Math.random()*(t-e)+e},getRandomNormal:function(e){var t=this.getRandomValue(-1,1)*Math.PI,i=this.getRandomValue(-1,1),s=Math.acos(i),r=Math.sin(s);return e.set(Math.sin(t)*r,Math.cos(t)*r,i)},getRandomNormalWithAngle:function(e,t){var i=(2*Math.random()-1)*Math.PI,s=this.getRandomValue(Math.cos(e),1),r=Math.acos(s),n=Math.sin(r);return t.set(Math.sin(i)*n,Math.cos(i)*n,s)},getRandomNormalWithDirectionAndAngle:function(e,t,s){return rotation.setFromToVec(i.zAxis,e),rotation.multVecRot(this.getRandomNormalWithAngle(t,s))},getRandomSurfaceNormal:function(e){var t=this.getRandomValue(-1,1)*Math.PI,i=Math.pow(Math.random(),1/3),s=Math.acos(i),r=Math.sin(s);return e.set(Math.sin(t)*r,Math.cos(t)*r,i)},animate:function(e,t){for(var r=e.particles,n=e.numParticles,o=e.createParticles,a=e.particleLifetime,d=e.lifetimeVariation,c=e.speeds,u=e.velocities,m=e.turbulences,f=this.rotations,p=e.numForces,_=e.boundedVertices.length,y=e.boundedVolume,g=f.length;g<p;++g)f[g]=new s(0,0,1,0);for(g=0;g<p;++g)f[g].setFromToVec(i.zAxis,u[g]);for(g=0;g<n;++g){var x=r[g],A=x.elapsedTime+t;if(A>x.lifetime)x.lifetime=this.getRandomLifetime(a,d),x.elapsedTime=0,o?(++x.life,this.getRandomPosition(x.position),this.getRandomVelocity(x.velocity)):x.position.set(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);else{for(var F=x.position,w=x.velocity,R=0;R<p;++R)w.add(f[R].multVecRot(this.getRandomNormalWithAngle(m[R],l)).multiply(c[R]));_?(h.x=F.x,h.y=F.y,h.z=F.z,F.x+=w.x*t,F.y+=w.y*t,F.z+=w.z*t,this.bounce(y,h,F,w)):(F.x+=w.x*t,F.y+=w.y*t,F.z+=w.z*t),x.elapsedTime=A}}e.geometryContext.colorMaterial&&this.getColors(r,e.colorKeys,e.colorRamp,n)},bounce:function(e,t,i,s){l.assign(s).normalize(),d.set(t,l);var r=this.intersections,n=this.intersectionNormals,a=e.intersectsLine(d,r,n);if(a){for(var h=0;h<a;++h)r[h].index=h;c.set(t,l),this.sorter.sort(0,a);var u=o.upperBound(r,0,a,0,m);if(u<a){var f=r[u],p=n[f.index];if(c.set(f,p),c.getDistanceToPoint(t)*c.getDistanceToPoint(i)<0){var _=2*p.dot(s);s.x-=p.x*_,s.y-=p.y*_,s.z-=p.z*_,l.assign(s).normalize();var y=f.distance(t);i.x=f.x+l.x*y,i.y=f.y+l.y*y,i.z=f.z+l.z*y}}}},getColors:function(e,t,i,s){for(var r=t.length,n=0,a=0,l=0,h=0;h<s;++h){var d=e[h],c=d.elapsedTime/d.lifetime,u=d.color;if(1==r||c<=t[0])n=0,a=0,l=0;else if(c>=t[r-1])n=r-2,a=r-1,l=1;else{var m=o.upperBound(t,0,r,c,o.less);if(m<r){a=m;var f=t[n=m-1],p=t[a];l=o.clamp((c-f)/(p-f),0,1)}else n=0,a=0,l=0}var _=i[n],y=i[a];u.x=_.x+l*(y.x-_.x),u.y=_.y+l*(y.y-_.y),u.z=_.z+l*(y.z-_.z),u.w=_.w+l*(y.w-_.w)}}}),f})),e("x_ite/Components/ParticleSystems/PointEmitter",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticleEmitterNode","x_ite/Base/X3DConstants","standard/Math/Numbers/Vector3"],(function(e,t,i,s,r,n){"use strict";function o(e){s.call(this,e),this.addType(r.PointEmitter),this._position.setUnit("length"),this._speed.setUnit("speed"),this._mass.setUnit("mass"),this._surfaceArea.setUnit("area"),this.direction=new n(0,0,0)}return o.prototype=Object.assign(Object.create(s.prototype),{constructor:o,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(r.inputOutput,"metadata",new e.SFNode),new t(r.inputOutput,"position",new e.SFVec3f),new t(r.inputOutput,"direction",new e.SFVec3f(0,1,0)),new t(r.inputOutput,"speed",new e.SFFloat),new t(r.inputOutput,"variation",new e.SFFloat(.25)),new t(r.initializeOnly,"mass",new e.SFFloat),new t(r.initializeOnly,"surfaceArea",new e.SFFloat)]),getTypeName:function(){return"PointEmitter"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"emitter"},initialize:function(){s.prototype.initialize.call(this),this._position.addInterest("set_position__",this),this._direction.addInterest("set_direction__",this),this.set_position__(),this.set_direction__()},set_position__:function(){this.position=this._position.getValue()},set_direction__:function(){this.direction.assign(this._direction.getValue()).normalize(),this.direction.equals(n.Zero)?this.getRandomVelocity=this.getSphericalRandomVelocity:delete this.getRandomVelocity},getRandomPosition:function(e){return e.assign(this.position)},getRandomVelocity:function(e){var t=this.direction,i=this.getRandomSpeed();return e.x=t.x*i,e.y=t.y*i,e.z=t.z*i,e}}),o})),e("x_ite/Browser/ParticleSystems/X3DParticleSystemsContext",["x_ite/Components/ParticleSystems/PointEmitter"],(function(e){"use strict";const t=Symbol();function i(){}return i.prototype={getDefaultEmitter:function(){return this[t]=new e(this.getPrivateScene()),this[t].setup(),this.getDefaultEmitter=function(){return this[t]},Object.defineProperty(this,"getDefaultEmitter",{enumerable:!1}),v,this[t]}},i})),e("x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode",["x_ite/Components/Core/X3DNode","x_ite/Base/X3DConstants"],(function(e,t){"use strict";function i(i){e.call(this,i),this.addType(t.X3DParticlePhysicsModelNode)}return i.prototype=Object.assign(Object.create(e.prototype),{constructor:i,addForce:function(){}}),i})),e("x_ite/Components/ParticleSystems/BoundedPhysicsModel",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode","x_ite/Base/X3DConstants","x_ite/Base/X3DCast"],(function(e,t,i,s,r,n){"use strict";function o(e){s.call(this,e),this.addType(r.BoundedPhysicsModel)}return o.prototype=Object.assign(Object.create(s.prototype),{constructor:o,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(r.inputOutput,"metadata",new e.SFNode),new t(r.inputOutput,"enabled",new e.SFBool(!0)),new t(r.inputOutput,"geometry",new e.SFNode)]),getTypeName:function(){return"BoundedPhysicsModel"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"physics"},initialize:function(){s.prototype.initialize.call(this),this._geometry.addInterest("set_geometry__",this),this.set_geometry__()},set_geometry__:function(){this.geometryNode&&this.geometryNode._rebuild.removeInterest("addNodeEvent",this),this.geometryNode=n(r.X3DGeometryNode,this._geometry),this.geometryNode&&this.geometryNode._rebuild.addInterest("addNodeEvent",this)},addGeometry:function(e,t){if(this.geometryNode){for(var i=this.geometryNode.getNormals().getValue(),s=this.geometryNode.getVertices().getValue(),r=0,n=i.length;r<n;++r)e.push(i[r]);for(r=0,n=s.length;r<n;++r)t.push(s[r])}}}),o})),e("x_ite/Components/ParticleSystems/ConeEmitter",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticleEmitterNode","x_ite/Base/X3DConstants","standard/Math/Numbers/Vector3","standard/Math/Numbers/Rotation4"],(function(e,t,i,s,r,n,o){"use strict";function a(e){s.call(this,e),this.addType(r.ConeEmitter),this._position.setUnit("length"),this._angle.setUnit("angle"),this._speed.setUnit("speed"),this._mass.setUnit("mass"),this._surfaceArea.setUnit("area"),this.rotation=new o(0,0,1,0)}return a.prototype=Object.assign(Object.create(s.prototype),{constructor:a,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(r.inputOutput,"metadata",new e.SFNode),new t(r.inputOutput,"position",new e.SFVec3f),new t(r.inputOutput,"direction",new e.SFVec3f(0,1,0)),new t(r.inputOutput,"angle",new e.SFFloat(.7854)),new t(r.inputOutput,"speed",new e.SFFloat),new t(r.inputOutput,"variation",new e.SFFloat(.25)),new t(r.initializeOnly,"mass",new e.SFFloat),new t(r.initializeOnly,"surfaceArea",new e.SFFloat)]),getTypeName:function(){return"ConeEmitter"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"emitter"},initialize:function(){s.prototype.initialize.call(this),this._position.addInterest("set_position__",this),this._direction.addInterest("set_direction__",this),this._angle.addInterest("set_angle__",this),this.set_position__(),this.set_direction__(),this.set_angle__()},set_position__:function(){this.position=this._position.getValue()},set_direction__:function(){var e=this._direction.getValue();this.rotation.setFromToVec(n.zAxis,e),e.equals(n.Zero)?this.getRandomVelocity=this.getSphericalRandomVelocity:delete this.getRandomVelocity},set_angle__:function(){this.angle=this._angle.getValue()},getRandomPosition:function(e){return e.assign(this.position)},getRandomVelocity:function(e){return this.rotation.multVecRot(this.getRandomNormalWithAngle(this.angle,e).multiply(this.getRandomSpeed()))}}),a})),e("x_ite/Components/ParticleSystems/ExplosionEmitter",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticleEmitterNode","x_ite/Base/X3DConstants"],(function(e,t,i,s,r){"use strict";function n(e){s.call(this,e),this.addType(r.ExplosionEmitter),this._position.setUnit("length"),this._speed.setUnit("speed"),this._mass.setUnit("mass"),this._surfaceArea.setUnit("area"),this.getRandomVelocity=this.getSphericalRandomVelocity}return n.prototype=Object.assign(Object.create(s.prototype),{constructor:n,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(r.inputOutput,"metadata",new e.SFNode),new t(r.inputOutput,"position",new e.SFVec3f),new t(r.inputOutput,"speed",new e.SFFloat),new t(r.inputOutput,"variation",new e.SFFloat(.25)),new t(r.initializeOnly,"mass",new e.SFFloat),new t(r.initializeOnly,"surfaceArea",new e.SFFloat)]),getTypeName:function(){return"ExplosionEmitter"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"emitter"},initialize:function(){s.prototype.initialize.call(this),this._position.addInterest("set_position__",this),this.set_position__()},set_position__:function(){this.position=this._position.getValue()},isExplosive:function(){return!0},getRandomPosition:function(e){return e.assign(this.position)}}),n})),e("x_ite/Components/ParticleSystems/ForcePhysicsModel",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode","x_ite/Base/X3DConstants"],(function(e,t,i,s,r){"use strict";function n(e){s.call(this,e),this.addType(r.ForcePhysicsModel),this._force.setUnit("force")}return n.prototype=Object.assign(Object.create(s.prototype),{constructor:n,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(r.inputOutput,"metadata",new e.SFNode),new t(r.inputOutput,"enabled",new e.SFBool(!0)),new t(r.inputOutput,"force",new e.SFVec3f(0,-9.8,0))]),getTypeName:function(){return"ForcePhysicsModel"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"physics"},addForce:function(e,t,i,s){this._enabled.getValue()&&(i[e].assign(this._force.getValue()),s[e]=0)}}),n})),e("standard/Math/Utility/BVH",["standard/Math/Numbers/Vector3","standard/Math/Geometry/Plane3","standard/Math/Algorithms/QuickSort"],(function(e,t,i){"use strict";const s=new e(0,0,0),r=new e(0,0,0),n=new e(0,0,0),o={u:0,v:0,t:0},a=[new e(0,0,1),new e(0,0,-1),new e(0,1,0),new e(0,-1,0),new e(1,0,0)];function l(e,t){this.vertices=e.vertices,this.normals=e.normals,this.i4=12*t,this.i3=9*t}function h(i,o,d,c){this.min=new e(0,0,0),this.max=new e(0,0,0),this.planes=[],this.intersection=new e(0,0,0);const u=i.vertices,m=this.min,f=this.max,p=d+c;let _=12*o[d];m.set(u[_],u[_+1],u[_+2]),f.assign(m);for(let e=d;e<p;++e)_=12*o[e],s.set(u[_],u[_+1],u[_+2]),r.set(u[_+4],u[_+5],u[_+6]),n.set(u[_+8],u[_+9],u[_+10]),m.min(s,r,n),f.max(s,r,n);for(let e=0;e<5;++e)this.planes[e]=new t(e%2?m:f,a[e]);if(c>2){i.sorter.compare.axis=this.getLongestAxis(m,f),i.sorter.sort(d,p);var y=c>>>1}else y=1;const g=c-y;this.left=y>1?new h(i,o,d,y):new l(i,o[d]),this.right=g>1?new h(i,o,d+y,g):new l(i,o[d+y])}function d(e,t){this.vertices=e,this.normals=t;const s=e.length/12;switch(s){case 0:this.root=null;break;case 1:this.root=new l(this,0);break;default:{const t=[];for(let e=0;e<s;++e)t.push(e);this.sorter=new i(t,function(e,t){function i(e,s){const r=i.vertices;return t=i.axis,Math.min(r[e+t],r[e+4+t],r[e+8+t])<Math.min(r[s+t],r[s+4+t],r[s+8+t])}return i.vertices=e,i.axis=t,i}(e,0)),this.root=new h(this,t,0,s);break}}}return l.prototype={intersectsLine:function(t,i,a){const l=this.vertices,h=this.normals,d=this.i4,c=this.i3;if(s.x=l[d],s.y=l[d+1],s.z=l[d+2],r.x=l[d+4],r.y=l[d+5],r.z=l[d+6],n.x=l[d+8],n.y=l[d+9],n.z=l[d+10],t.intersectsTriangle(s,r,n,o)){const t=o.u,s=o.v,r=1-t-s,n=i.size++;n>=i.length&&i.push(new e(0,0,0)),i[n].set(r*l[d]+t*l[d+4]+s*l[d+8],r*l[d+1]+t*l[d+5]+s*l[d+9],r*l[d+2]+t*l[d+6]+s*l[d+10]),a&&(n>=a.length&&a.push(new e(0,0,0)),a[n].set(r*h[c]+t*h[c+3]+s*h[c+6],r*h[c+1]+t*h[c+4]+s*h[c+7],r*h[c+2]+t*h[c+5]+s*h[c+8]))}}},h.prototype={intersectsLine:function(e,t,i){this.intersectsBBox(e)&&(this.left.intersectsLine(e,t,i),this.right.intersectsLine(e,t,i))},intersectsBBox:function(e){const t=this.planes,i=this.min,s=this.max,r=i.x,n=s.x,o=i.y,a=s.y,l=i.z,h=s.z,d=this.intersection;return!!(t[0].intersectsLine(e,d)&&d.x>=r&&d.x<=n&&d.y>=o&&d.y<=a)||(!!(t[1].intersectsLine(e,d)&&d.x>=r&&d.x<=n&&d.y>=o&&d.y<=a)||(!!(t[2].intersectsLine(e,d)&&d.x>=r&&d.x<=n&&d.z>=l&&d.z<=h)||(!!(t[3].intersectsLine(e,d)&&d.x>=r&&d.x<=n&&d.z>=l&&d.z<=h)||!!(t[4].intersectsLine(e,d)&&d.y>=o&&d.y<=a&&d.z>=l&&d.z<=h))))},getLongestAxis:function(e,t){const i=t.x-e.x,s=t.y-e.y,r=t.z-e.z;return i<s?s<r?2:1:i<r?2:0}},d.prototype={constructor:d,intersectsLine:function(e,t,i){return t.size=0,this.root?(this.root.intersectsLine(e,t,i),t.size):0}},d})),e("x_ite/Components/ParticleSystems/ParticleSystem",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/Shape/X3DShapeNode","x_ite/Rendering/TraverseType","x_ite/Base/X3DConstants","x_ite/Base/X3DCast","x_ite/Browser/Shape/AlphaMode","standard/Math/Numbers/Vector3","standard/Math/Numbers/Vector4","standard/Math/Numbers/Matrix4","standard/Math/Numbers/Matrix3","standard/Math/Algorithms/QuickSort","standard/Math/Algorithm","standard/Math/Utility/BVH"],(function(e,t,i,s,r,n,o,a,l,h,d,c,u,m,f){"use strict";var p=0;const _=p++,y=p++,g=p++,x=p++,A=p++,F=p++,w={POINT:_,LINE:y,TRIANGLE:g,QUAD:x,GEOMETRY:A,SPRITE:F},R=new d,b=new l(0,0,0),P=new l(0,0,0),S=new l(0,0,0),v=new l(0,0,0),B=new l(0,0,0),C=new l(0,0,0),N=new l(0,0,0),T=new l(0,0,0),D=new l(0,0,0),V=new l(0,0,0);function I(e,t){return e.distance<t.distance}function M(e){s.call(this,e),this.addType(n.ParticleSystem),this._particleSize.setUnit("length"),this.createParticles=!0,this.particles=[],this.velocities=[],this.speeds=[],this.turbulences=[],this.geometryType=_,this.maxParticles=0,this.numParticles=0,this.particleLifetime=0,this.lifetimeVariation=0,this.emitterNode=null,this.forcePhysicsModelNodes=[],this.boundedPhysicsModelNodes=[],this.boundedNormals=[],this.boundedVertices=[],this.boundedVolume=null,this.creationTime=0,this.pauseTime=0,this.deltaTime=0,this.numForces=0,this.colorKeys=[],this.colorRamppNode=null,this.colorRamp=[],this.texCoordKeys=[],this.texCoordRampNode=null,this.texCoordRamp=[],this.texCoordAnim=!1,this.vertexCount=0,this.shaderNode=null,this.rotation=new c,this.particleSorter=new u(this.particles,I),this.sortParticles=!1,this.geometryContext={}}return M.prototype=Object.assign(Object.create(s.prototype),{constructor:M,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(n.inputOutput,"metadata",new e.SFNode),new t(n.inputOutput,"enabled",new e.SFBool(!0)),new t(n.inputOutput,"createParticles",new e.SFBool(!0)),new t(n.initializeOnly,"geometryType",new e.SFString("QUAD")),new t(n.inputOutput,"maxParticles",new e.SFInt32(200)),new t(n.inputOutput,"particleLifetime",new e.SFFloat(5)),new t(n.inputOutput,"lifetimeVariation",new e.SFFloat(.25)),new t(n.inputOutput,"particleSize",new e.SFVec2f(.02,.02)),new t(n.initializeOnly,"emitter",new e.SFNode),new t(n.initializeOnly,"physics",new e.MFNode),new t(n.initializeOnly,"colorKey",new e.MFFloat),new t(n.initializeOnly,"colorRamp",new e.SFNode),new t(n.initializeOnly,"texCoordKey",new e.MFFloat),new t(n.initializeOnly,"texCoordRamp",new e.SFNode),new t(n.outputOnly,"isActive",new e.SFBool),new t(n.inputOutput,"visible",new e.SFBool(!0)),new t(n.inputOutput,"castShadow",new e.SFBool(!0)),new t(n.inputOutput,"bboxDisplay",new e.SFBool),new t(n.initializeOnly,"bboxSize",new e.SFVec3f(-1,-1,-1)),new t(n.initializeOnly,"bboxCenter",new e.SFVec3f),new t(n.inputOutput,"appearance",new e.SFNode),new t(n.inputOutput,"geometry",new e.SFNode)]),getTypeName:function(){return"ParticleSystem"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"children"},initialize:function(){s.prototype.initialize.call(this);const e=this.getBrowser(),t=e.getContext();this.isLive().addInterest("set_live__",this),e.getBrowserOptions()._Shading.addInterest("set_shader__",this),this._enabled.addInterest("set_enabled__",this),this._createParticles.addInterest("set_createParticles__",this),this._geometryType.addInterest("set_geometryType__",this),this._maxParticles.addInterest("set_enabled__",this),this._particleLifetime.addInterest("set_particleLifetime__",this),this._lifetimeVariation.addInterest("set_lifetimeVariation__",this),this._emitter.addInterest("set_emitter__",this),this._physics.addInterest("set_physics__",this),this._colorKey.addInterest("set_color__",this),this._colorRamp.addInterest("set_colorRamp__",this),this._texCoordKey.addInterest("set_texCoord__",this),this._texCoordRamp.addInterest("set_texCoordRamp__",this),this.idBuffer=t.createBuffer(),this.positionBuffer=t.createBuffer(),this.elapsedTimeBuffer=t.createBuffer(),this.lifeBuffer=t.createBuffer(),this.colorBuffer=t.createBuffer(),this.texCoordBuffers=[t.createBuffer()],this.normalBuffer=t.createBuffer(),this.vertexBuffer=t.createBuffer();for(var i=1,r=this.getBrowser().getMaxTextures();i<r;++i)this.texCoordBuffers.push(this.texCoordBuffers[0]);this.idArray=new Float32Array,this.positionArray=new Float32Array,this.elapsedTimeArray=new Float32Array,this.lifeArray=new Float32Array,this.colorArray=new Float32Array,this.texCoordArray=new Float32Array,this.normalArray=new Float32Array,this.vertexArray=new Float32Array,this.primitiveMode=t.TRIANGLES,this.geometryContext.fogCoords=!1,this.geometryContext.textureCoordinateNode=e.getDefaultTextureCoordinate(),this.geometryContext.textureCoordinateMapping=new Map,this.set_emitter__(),this.set_enabled__(),this.set_createParticles__(),this.set_particleLifetime__(),this.set_lifetimeVariation__(),this.set_physics__(),this.set_colorRamp__(),this.set_texCoordRamp__()},set_bbox__:function(){this._bboxSize.getValue().equals(this.getDefaultBBoxSize())?this.bbox.set():this.bbox.set(this._bboxSize.getValue(),this._bboxCenter.getValue()),this.bboxSize.assign(this.bbox.size),this.bboxCenter.assign(this.bbox.center)},set_transparent__:function(){if(this.getAppearance().getAlphaMode()===a.AUTO)if(this.geometryType===_)this.setTransparent(!0);else this.setTransparent(this.getAppearance().getTransparent()||this.colorRampNode&&this.colorRampNode.getTransparent()||this.geometryType===A&&this.geometryNode&&this.geometryNode.getTransparent());else this.setTransparent(this.getAppearance().getTransparent())},set_live__:function(){this.isLive().getValue()?this._isActive.getValue()&&this._maxParticles.getValue()&&(this.getBrowser().sensorEvents().addInterest("animateParticles",this),this.pauseTime&&(this.creationTime+=performance.now()/1e3-this.pauseTime,this.pauseTime=0)):this._isActive.getValue()&&this._maxParticles.getValue()&&(this.getBrowser().sensorEvents().removeInterest("animateParticles",this),0===this.pauseTime&&(this.pauseTime=performance.now()/1e3))},set_enabled__:function(){this._enabled.getValue()&&this._maxParticles.getValue()?this._isActive.getValue()||(this.isLive().getValue()?(this.getBrowser().sensorEvents().addInterest("animateParticles",this),this.pauseTime=0):this.pauseTime=performance.now()/1e3,this._isActive=!0):this._isActive.getValue()&&(this.isLive().getValue()&&this.getBrowser().sensorEvents().removeInterest("animateParticles",this),this._isActive=!1,this.numParticles=0),this.set_maxParticles__()},set_createParticles__:function(){this.createParticles=this._createParticles.getValue()},set_geometryType__:function(){var e=this.getBrowser().getContext(),t=this.maxParticles;switch(this.geometryType=w[this._geometryType.getValue()],this.geometryType||(this.geometryType=_),this.geometryType){case _:this.idArray=new Float32Array(t),this.positionArray=new Float32Array(3*t),this.elapsedTimeArray=new Float32Array(t),this.lifeArray=new Float32Array(t),this.colorArray=new Float32Array(4*t),this.texCoordArray=new Float32Array,this.normalArray=new Float32Array,this.vertexArray=new Float32Array(4*t);for(var i=0,s=(r=this.idArray).length;i<s;++i)r[i]=i;this.colorArray.fill(1),this.vertexArray.fill(1),this.testWireframe=!1,this.primitiveMode=e.POINTS,this.texCoordCount=0,this.vertexCount=1,this.geometryContext.geometryType=0;break;case y:this.idArray=new Float32Array(2*t),this.positionArray=new Float32Array(6*t),this.elapsedTimeArray=new Float32Array(2*t),this.lifeArray=new Float32Array(2*t),this.colorArray=new Float32Array(8*t),this.texCoordArray=new Float32Array,this.normalArray=new Float32Array,this.vertexArray=new Float32Array(8*t);for(i=0,s=(r=this.idArray).length;i<s;++i)r[i]=Math.floor(i/2);this.colorArray.fill(1),this.vertexArray.fill(1),this.testWireframe=!1,this.primitiveMode=e.LINES,this.texCoordCount=2,this.vertexCount=2,this.geometryContext.geometryType=1;break;case g:case x:case F:this.idArray=new Float32Array(6*t),this.positionArray=new Float32Array(18*t),this.elapsedTimeArray=new Float32Array(6*t),this.lifeArray=new Float32Array(6*t),this.colorArray=new Float32Array(24*t),this.texCoordArray=new Float32Array(24*t),this.normalArray=new Float32Array(18*t),this.vertexArray=new Float32Array(24*t);var r;for(i=0,s=(r=this.idArray).length;i<s;++i)r[i]=Math.floor(i/6);this.colorArray.fill(1),this.vertexArray.fill(1);for(var n=this.texCoordArray,o=this.normalArray,a=(i=0,18*t);i<a;i+=3)o[i]=0,o[i+1]=0,o[i+2]=1;e.bindBuffer(e.ARRAY_BUFFER,this.normalBuffer),e.bufferData(e.ARRAY_BUFFER,this.normalArray,e.STATIC_DRAW);for(i=0;i<t;++i){var l=24*i;n[l]=n[l+12]=0,n[l+1]=n[l+13]=0,n[l+2]=n[l+14]=0,n[l+3]=n[l+15]=1,n[l+4]=1,n[l+5]=0,n[l+6]=0,n[l+7]=1,n[l+8]=n[l+16]=1,n[l+9]=n[l+17]=1,n[l+10]=n[l+18]=0,n[l+11]=n[l+19]=1,n[l+20]=0,n[l+21]=1,n[l+22]=0,n[l+23]=1}e.bindBuffer(e.ARRAY_BUFFER,this.texCoordBuffers[0]),e.bufferData(e.ARRAY_BUFFER,this.texCoordArray,e.STATIC_DRAW),this.testWireframe=!0,this.primitiveMode=e.TRIANGLES,this.texCoordCount=4,this.vertexCount=6,this.geometryContext.geometryType=2;break;case A:this.texCoordCount=0,this.vertexCount=0}e.bindBuffer(e.ARRAY_BUFFER,this.idBuffer),e.bufferData(e.ARRAY_BUFFER,this.idArray,e.STATIC_DRAW),this.set_shader__(),this.set_transparent__()},set_shader__:function(){switch(this.geometryType){case _:this.shaderNode=this.getBrowser().getPointShader();break;case y:this.shaderNode=this.getBrowser().getLineShader();break;case g:case x:case F:case A:this.shaderNode=null}},set_maxParticles__:function(){for(var e=this.particles,t=Math.max(0,this._maxParticles.getValue()),i=this.numParticles,s=Math.min(e.length,t);i<s;++i)e[i].life=1,e[i].lifetime=-1;for(i=e.length,s=t;i<s;++i)e[i]={id:i,life:1,lifetime:-1,elapsedTime:0,position:new l(0,0,0),velocity:new l(0,0,0),color:new h(1,1,1,1),distance:0};this.maxParticles=t,this.numParticles=Math.min(this.numParticles,t),this.emitterNode.isExplosive()||(this.creationTime=performance.now()/1e3),this.set_geometryType__()},set_particleLifetime__:function(){this.particleLifetime=this._particleLifetime.getValue()},set_lifetimeVariation__:function(){this.lifetimeVariation=this._lifetimeVariation.getValue()},set_emitter__:function(){this.emitterNode=o(n.X3DParticleEmitterNode,this._emitter),this.emitterNode||(this.emitterNode=this.getBrowser().getDefaultEmitter()),this.createParticles=this._createParticles.getValue()},set_physics__:function(){for(var e=this._physics.getValue(),t=this.forcePhysicsModelNodes,i=this.boundedPhysicsModelNodes,s=0,r=i.length;s<r;++s)i[s].removeInterest("set_boundedPhysics__",this);t.length=0,i.length=0;for(s=0,r=e.length;s<r;++s)try{for(var o=e[s].getValue().getInnerNode(),a=o.getType(),l=a.length-1;l>=0;--l){switch(a[l]){case n.ForcePhysicsModel:case n.WindPhysicsModel:t.push(o);break;case n.BoundedPhysicsModel:o.addInterest("set_boundedPhysics__",this),i.push(o);break;default:continue}break}}catch(e){}this.set_boundedPhysics__()},set_boundedPhysics__:function(){var e=this.boundedPhysicsModelNodes,t=this.boundedNormals,i=this.boundedVertices;t.length=0,i.length=0;for(var s=0,r=e.length;s<r;++s)e[s].addGeometry(t,i);this.boundedVolume=new f(i,t)},set_colorRamp__:function(){this.colorRampNode&&this.colorRampNode.removeInterest("set_color__",this),this.colorRampNode=o(n.X3DColorNode,this._colorRamp),this.colorRampNode&&this.colorRampNode.addInterest("set_color__",this),this.set_color__(),this.set_transparent__()},set_color__:function(){for(var e=this._colorKey,t=this.colorKeys,i=this.colorRamp,s=0,r=e.length;s<r;++s)t[s]=e[s];t.length=r,this.colorRampNode&&this.colorRampNode.getVectors(this.colorRamp);for(s=i.length,r=e.length;s<r;++s)i[s]=new h(1,1,1,1);i.length=r,this.geometryContext.colorMaterial=!(!t.length||!this.colorRampNode)},set_texCoordRamp__:function(){this.texCoordRampNode&&this.texCoordRampNode.removeInterest("set_texCoord__",this),this.texCoordRampNode=o(n.X3DTextureCoordinateNode,this._texCoordRamp),this.texCoordRampNode&&this.texCoordRampNode.addInterest("set_texCoord__",this),this.set_texCoord__()},set_texCoord__:function(){for(var e=this._texCoordKey,t=this.texCoordKeys,i=this.texCoordRamp,s=0,r=e.length;s<r;++s)t[s]=e[s];t.length=r,this.texCoordRampNode&&this.texCoordRampNode.getTexCoord(i);for(s=i.length,r=e.length*this.texCoordCount;s<r;++s)i[s]=new h(0,0,0,0);i.length=r,this.texCoordAnim=!(!t.length||!this.texCoordRampNode)},intersectsBox:function(e,t){},animateParticles:function(){var e=this.emitterNode,t=1/Math.max(10,this.getBrowser().getCurrentFrameRate()),i=this.deltaTime=(14*this.deltaTime+t)/15;if(e.isExplosive()){var s=performance.now()/1e3,r=this.particleLifetime+this.particleLifetime*this.lifetimeVariation;0===this.numParticles||s-this.creationTime>r?(this.creationTime=s,this.numParticles=this.maxParticles,this.createParticles=this._createParticles.getValue(),i=Number.POSITIVE_INFINITY):this.createParticles=!1}else if(this.numParticles<this.maxParticles){s=performance.now()/1e3;var n=Math.max(0,Math.floor((s-this.creationTime)*this.maxParticles/this.particleLifetime));n&&(this.creationTime=s),this.numParticles=Math.floor(Math.min(this.maxParticles,this.numParticles+n))}if(e.getMass()){for(var o=this.forcePhysicsModelNodes,a=this.velocities,h=this.speeds,d=this.turbulences,c=this.deltaTime/e.getMass(),u=a.length,m=o.length;u<m;++u)a[u]=new l(0,0,0);for(u=0,m=o.length;u<m;++u)o[u].addForce(u,e,a,d);for(u=0,m=a.length;u<m;++u)a[u].multiply(c),h[u]=a[u].abs();this.numForces=m}else this.numForces=0;e.animate(this,i),this.updateGeometry(null),this.getBrowser().addBrowserEvent()},updateGeometry:function(e){switch(this.geometryType){case _:e||this.updatePoint();break;case y:e||this.updateLine();break;case g:case x:case F:this.updateQuad(e)}},updatePoint:function(){var e=this.getBrowser().getContext(),t=this.particles,i=this.numParticles,s=this.positionArray,r=this.elapsedTimeArray,n=this.lifeArray,o=this.colorArray,a=this.vertexArray;if(this.geometryContext.colorMaterial){for(var l=0;l<i;++l){var h=t[l].color;o[m=4*l]=h.x,o[m+1]=h.y,o[m+2]=h.z,o[m+3]=h.w}e.bindBuffer(e.ARRAY_BUFFER,this.colorBuffer),e.bufferData(e.ARRAY_BUFFER,this.colorArray,e.STATIC_DRAW)}for(l=0;l<i;++l){var d=t[l].position,c=t[l].elapsedTime/t[l].lifetime,u=3*l,m=4*l;s[u]=d.x,s[u+1]=d.y,s[u+2]=d.z,r[l]=c,n[l]=t[l].life,a[m]=d.x,a[m+1]=d.y,a[m+2]=d.z}e.bindBuffer(e.ARRAY_BUFFER,this.positionBuffer),e.bufferData(e.ARRAY_BUFFER,this.positionArray,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this.elapsedTimeBuffer),e.bufferData(e.ARRAY_BUFFER,this.elapsedTimeArray,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this.lifeBuffer),e.bufferData(e.ARRAY_BUFFER,this.lifeArray,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertexArray,e.STATIC_DRAW)},updateLine:function(){var e=this.getBrowser().getContext(),t=this.particles,i=this.numParticles,s=this.positionArray,r=this.elapsedTimeArray,n=this.lifeArray,o=this.colorArray,a=this.vertexArray,l=this._particleSize.y/2;if(this.geometryContext.colorMaterial){for(var h=0;h<i;++h){var d=t[h].color;o[A=8*h]=d.x,o[A+1]=d.y,o[A+2]=d.z,o[A+3]=d.w,o[A+4]=d.x,o[A+5]=d.y,o[A+6]=d.z,o[A+7]=d.w}e.bindBuffer(e.ARRAY_BUFFER,this.colorBuffer),e.bufferData(e.ARRAY_BUFFER,this.colorArray,e.STATIC_DRAW)}for(h=0;h<i;++h){var c=t[h],u=c.position,m=t[h].elapsedTime/t[h].lifetime,f=t[h].life,p=u.x,_=u.y,y=u.z,g=2*h,x=6*h,A=8*h;s[x]=p,s[x+1]=_,s[x+2]=y,s[x+3]=p,s[x+4]=_,s[x+5]=y,r[g]=m,r[g+1]=m,n[g]=f,n[g+1]=f,v.assign(c.velocity).normalize().multiply(l),a[A]=p-v.x,a[A+1]=_-v.y,a[A+2]=y-v.z,a[A+4]=p+v.x,a[A+5]=_+v.y,a[A+6]=y+v.z}e.bindBuffer(e.ARRAY_BUFFER,this.positionBuffer),e.bufferData(e.ARRAY_BUFFER,this.positionArray,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this.elapsedTimeBuffer),e.bufferData(e.ARRAY_BUFFER,this.elapsedTimeArray,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this.lifeBuffer),e.bufferData(e.ARRAY_BUFFER,this.lifeArray,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this.vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this.vertexArray,e.STATIC_DRAW)},updateQuad:function(e){try{var t=this.getBrowser().getContext(),i=this.particles,s=this.maxParticles,r=this.numParticles,n=this.positionArray,o=this.elapsedTimeArray,a=this.lifeArray,l=this.colorArray,h=this.texCoordArray,d=this.normalArray,c=this.vertexArray,u=this._particleSize.x/2,f=this._particleSize.y/2;if(!e){if(this.geometryContext.colorMaterial){for(var p=0;p<s;++p){var _=i[p].color;l[G=24*p]=l[G+4]=l[G+8]=l[G+12]=l[G+16]=l[G+20]=_.x,l[G+1]=l[G+5]=l[G+9]=l[G+13]=l[G+17]=l[G+21]=_.y,l[G+2]=l[G+6]=l[G+10]=l[G+14]=l[G+18]=l[G+22]=_.z,l[G+3]=l[G+7]=l[G+11]=l[G+15]=l[G+19]=l[G+23]=_.w}t.bindBuffer(t.ARRAY_BUFFER,this.colorBuffer),t.bufferData(t.ARRAY_BUFFER,this.colorArray,t.STATIC_DRAW)}if(this.texCoordAnim&&this.texCoordArray.length){var y=this.texCoordKeys,g=this.texCoordRamp,x=y.length,A=0;for(p=0;p<s;++p){var w=i[p],R=w.elapsedTime/w.lifetime;if(1==x||R<=y[0])A=0;else if(R>=y.at(-1))A=x-2;else{var b=m.upperBound(y,0,x,R,m.less);A=b<x?b-1:0}var P=g[A*=this.texCoordCount],D=g[A+1],V=g[A+2],I=g[A+3];h[G=24*p]=h[G+12]=P.x,h[G+1]=h[G+13]=P.y,h[G+2]=h[G+14]=P.z,h[G+3]=h[G+15]=P.w,h[G+4]=D.x,h[G+5]=D.y,h[G+6]=D.z,h[G+7]=D.w,h[G+8]=h[G+16]=V.x,h[G+9]=h[G+17]=V.y,h[G+10]=h[G+18]=V.z,h[G+11]=h[G+19]=V.w,h[G+20]=I.x,h[G+21]=I.y,h[G+22]=I.z,h[G+23]=I.w}t.bindBuffer(t.ARRAY_BUFFER,this.texCoordBuffers[0]),t.bufferData(t.ARRAY_BUFFER,this.texCoordArray,t.STATIC_DRAW)}}if(this.geometryType===F){if(e){var M=this.getScreenAlignedRotation(e);v.set(M[0],M[1],M[2]).cross(S.set(M[3],M[4],M[5])).normalize();var z=v.x,E=v.y,O=v.z;for(p=0,x=18*s;p<x;p+=3)d[p]=z,d[p+1]=E,d[p+2]=O;t.bindBuffer(t.ARRAY_BUFFER,this.normalBuffer),t.bufferData(t.ARRAY_BUFFER,this.normalArray,t.STATIC_DRAW),B.set(-u,-f,0),C.set(u,-f,0),N.set(u,f,0),T.set(-u,f,0),M.multVecMatrix(B),M.multVecMatrix(C),M.multVecMatrix(N),M.multVecMatrix(T);for(p=0;p<r;++p){var U=i[p].position,X=i[p].elapsedTime/i[p].lifetime,Y=U.x,L=U.y,W=U.z,j=6*p,G=24*p;n[k=18*p]=n[k+3]=n[k+6]=n[k+9]=n[k+12]=n[k+15]=Y,n[k+1]=n[k+4]=n[k+7]=n[k+10]=n[k+13]=n[k+16]=L,n[k+2]=n[k+5]=n[k+8]=n[k+11]=n[k+14]=n[k+17]=W,o[j]=o[j+1]=o[j+2]=o[j+3]=o[j+4]=o[j+5]=X,a[j]=a[j+1]=a[j+2]=a[j+3]=a[j+4]=a[j+5]=i[p].life,c[G]=c[G+12]=Y+B.x,c[G+1]=c[G+13]=L+B.y,c[G+2]=c[G+14]=W+B.z,c[G+4]=Y+C.x,c[G+5]=L+C.y,c[G+6]=W+C.z,c[G+8]=c[G+16]=Y+N.x,c[G+9]=c[G+17]=L+N.y,c[G+10]=c[G+18]=W+N.z,c[G+20]=Y+T.x,c[G+21]=L+T.y,c[G+22]=W+T.z}t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer),t.bufferData(t.ARRAY_BUFFER,this.positionArray,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this.elapsedTimeBuffer),t.bufferData(t.ARRAY_BUFFER,this.elapsedTimeArray,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this.lifeBuffer),t.bufferData(t.ARRAY_BUFFER,this.lifeArray,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertexArray,t.STATIC_DRAW)}}else if(!e){for(p=0;p<r;++p){var k;U=i[p].position,X=i[p].elapsedTime/i[p].lifetime,Y=U.x,L=U.y,W=U.z,j=6*p,G=24*p;n[k=18*p]=n[k+3]=n[k+6]=n[k+9]=n[k+12]=n[k+15]=Y,n[k+1]=n[k+4]=n[k+7]=n[k+10]=n[k+13]=n[k+16]=L,n[k+2]=n[k+5]=n[k+8]=n[k+11]=n[k+14]=n[k+17]=W,o[j]=o[j+1]=o[j+2]=o[j+3]=o[j+4]=o[j+5]=X,a[j]=a[j+1]=a[j+2]=a[j+3]=a[j+4]=a[j+5]=i[p].life,c[G]=c[G+12]=Y-u,c[G+1]=c[G+13]=L-f,c[G+2]=c[G+14]=W,c[G+4]=Y+u,c[G+5]=L-f,c[G+6]=W,c[G+8]=c[G+16]=Y+u,c[G+9]=c[G+17]=L+f,c[G+10]=c[G+18]=W,c[G+20]=Y-u,c[G+21]=L+f,c[G+22]=W}t.bindBuffer(t.ARRAY_BUFFER,this.positionBuffer),t.bufferData(t.ARRAY_BUFFER,this.positionArray,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this.elapsedTimeBuffer),t.bufferData(t.ARRAY_BUFFER,this.elapsedTimeArray,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this.lifeBuffer),t.bufferData(t.ARRAY_BUFFER,this.lifeArray,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertexArray,t.STATIC_DRAW)}}catch(e){console.error(e)}},traverse:function(e,t){if(this._isActive.getValue()){switch(e){case r.POINTER:case r.PICKING:case r.COLLISION:break;case r.SHADOW:this._castShadow.getValue()&&t.addDepthShape(this);break;case r.DISPLAY:t.addDisplayShape(this)&&this.getAppearance().traverse(e,t)}this.geometryType===A&&this.getGeometry()&&this.getGeometry().traverse(e,t)}},depth:function(e,t,i){if(this.updateGeometry(t.modelViewMatrix),this.geometryType===A){var s=this.getGeometry();s&&s.displayParticlesDepth(e,t,i,this.particles,this.numParticles)}else{if(this.numParticles<=0)return;i.getValid()&&(i.enableFloatAttrib(e,"x3d_ParticleId",this.idBuffer,1),i.enableFloatAttrib(e,"x3d_ParticlePosition",this.positionBuffer,3),i.enableFloatAttrib(e,"x3d_ParticleElapsedTime",this.elapsedTimeBuffer,1),i.enableFloatAttrib(e,"x3d_ParticleLife",this.lifeBuffer,1),i.enableVertexAttribute(e,this.vertexBuffer),e.drawArrays(this.primitiveMode,0,this.numParticles*this.vertexCount),i.disableFloatAttrib(e,"x3d_ParticleId"),i.disableFloatAttrib(e,"x3d_ParticlePosition"),i.disableFloatAttrib(e,"x3d_ParticleElapsedTime"),i.disableFloatAttrib(e,"x3d_ParticleLife"))}},display:function(e,t){try{if(this.numParticles<=0)return;if(this.updateGeometry(t.modelViewMatrix),this.geometryType===A){const i=this.getGeometry();i&&i.displayParticles(e,t,this.particles,this.numParticles)}else{const r=this.getAppearance(),n=r.shaderNode||this.shaderNode||r.materialNode.getShader(t.browser,t.shadow);if(n.getValid()){t.geometryContext=this.geometryContext;const o=r.blendModeNode;if(o&&o.enable(e),n.enable(e),n.setLocalUniforms(e,t),n.enableFloatAttrib(e,"x3d_ParticleId",this.idBuffer,1),n.enableFloatAttrib(e,"x3d_ParticlePosition",this.positionBuffer,3),n.enableFloatAttrib(e,"x3d_ParticleElapsedTime",this.elapsedTimeBuffer,1),n.enableFloatAttrib(e,"x3d_ParticleLife",this.lifeBuffer,1),this.geometryContext.colorMaterial&&n.enableColorAttribute(e,this.colorBuffer),this.texCoordArray.length&&n.enableTexCoordAttribute(e,this.texCoordBuffers),this.normalArray.length&&n.enableNormalAttribute(e,this.normalBuffer),n.enableVertexAttribute(e,this.vertexBuffer),n.wireframe&&this.testWireframe)for(var i=0,s=this.numParticles*this.vertexCount;i<s;i+=3)e.drawArrays(n.primitiveMode,i,3);else{const i=d.prototype.determinant3.call(t.modelViewMatrix)>0;e.frontFace(i?e.CCW:e.CW),e.enable(e.CULL_FACE),e.cullFace(e.BACK),e.drawArrays(this.primitiveMode,0,this.numParticles*this.vertexCount)}n.disableFloatAttrib(e,"x3d_ParticleId"),n.disableFloatAttrib(e,"x3d_ParticlePosition"),n.disableFloatAttrib(e,"x3d_ParticleElapsedTime"),n.disableFloatAttrib(e,"x3d_ParticleLife"),n.disableColorAttribute(e),n.disableTexCoordAttribute(e),n.disableNormalAttribute(e),o&&o.disable(e),t.geometryContext=null}}}catch(e){console.error(e)}},getScreenAlignedRotation:function(e){R.assign(e).inverse(),R.multDirMatrix(b.assign(l.zAxis)),R.multDirMatrix(P.assign(l.yAxis)),D.assign(P).cross(b),V.assign(b).cross(D);var t=b;return D.normalize(),V.normalize(),t.normalize(),this.rotation.set(D.x,D.y,D.z,V.x,V.y,V.z,t.x,t.y,t.z)}}),M})),e("x_ite/Components/ParticleSystems/PolylineEmitter",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticleEmitterNode","x_ite/Components/Rendering/IndexedLineSet","x_ite/Base/X3DConstants","standard/Math/Numbers/Vector3","standard/Math/Algorithm"],(function(e,t,i,s,r,n,o,a){"use strict";function l(e){s.call(this,e),this.addType(n.PolylineEmitter),this._speed.setUnit("speed"),this._mass.setUnit("mass"),this._surfaceArea.setUnit("area"),this.direction=new o(0,0,0),this.polylineNode=new r(e),this.polylines=[],this.lengthSoFarArray=[0]}var h,d;function c(e){return e.set(0,0,0)}return l.prototype=Object.assign(Object.create(s.prototype),{constructor:l,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(n.inputOutput,"metadata",new e.SFNode),new t(n.inputOutput,"direction",new e.SFVec3f(0,1,0)),new t(n.inputOutput,"speed",new e.SFFloat),new t(n.inputOutput,"variation",new e.SFFloat(.25)),new t(n.initializeOnly,"mass",new e.SFFloat),new t(n.initializeOnly,"surfaceArea",new e.SFFloat),new t(n.inputOutput,"coordIndex",new e.MFInt32(-1)),new t(n.inputOutput,"coord",new e.SFNode)]),getTypeName:function(){return"PolylineEmitter"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"emitter"},initialize:function(){s.prototype.initialize.call(this),this._direction.addInterest("set_direction__",this),this._coordIndex.addFieldInterest(this.polylineNode._coordIndex),this._coord.addFieldInterest(this.polylineNode._coord),this.polylineNode._coordIndex=this._coordIndex,this.polylineNode._coord=this._coord,this.polylineNode._rebuild.addInterest("set_polyline",this),this.polylineNode.setPrivate(!0),this.polylineNode.setup(),this.set_direction__(),this.set_polyline()},set_direction__:function(){this.direction.assign(this._direction.getValue()).normalize(),this.direction.equals(o.Zero)?this.getRandomVelocity=this.getSphericalRandomVelocity:delete this.getRandomVelocity},set_polyline:(h=new o(0,0,0),d=new o(0,0,0),function(){var e=this.vertices=this.polylineNode.getVertices().getValue();if(e.length){delete this.getRandomPosition;var t=0,i=this.lengthSoFarArray;i.length=1;for(var s=0,r=e.length;s<r;s+=8)h.set(e[s],e[s+1],e[s+2]),d.set(e[s+4],e[s+5],e[s+6]),t+=d.subtract(h).abs(),i.push(t)}else this.getRandomPosition=c}),getRandomPosition:function(e){var t=this.lengthSoFarArray,i=t.length,s=Math.random()*t.at(-1),r=0,n=0,o=0;if(1==i||s<=t[0])r=0,o=0;else if(s>=t.at(-1))r=i-2,o=1;else{var l=a.upperBound(t,0,i,s,a.less);if(l<i){n=l;var h=t[r=l-1],d=t[n];o=a.clamp((s-h)/(d-h),0,1)}else r=0,o=0}n=(r*=8)+4;var c=this.vertices,u=c[r],m=c[r+1],f=c[r+2],p=c[n],_=c[n+1],y=c[n+2];return e.x=u+o*(p-u),e.y=m+o*(_-m),e.z=f+o*(y-f),e},getRandomVelocity:function(e){var t=this.direction,i=this.getRandomSpeed();return e.x=t.x*i,e.y=t.y*i,e.z=t.z*i,e}}),l})),e("x_ite/Components/ParticleSystems/SurfaceEmitter",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticleEmitterNode","x_ite/Base/X3DConstants","x_ite/Base/X3DCast","standard/Math/Geometry/Triangle3","standard/Math/Numbers/Vector3","standard/Math/Algorithm"],(function(e,t,i,s,r,n,o,a,l){"use strict";function h(e){s.call(this,e),this.addType(r.SurfaceEmitter),this._speed.setUnit("speed"),this._mass.setUnit("mass"),this._surfaceArea.setUnit("area"),this.surfaceNode=null,this.areaSoFarArray=[0],this.direction=new a(0,0,0)}var d,c,u;function m(e){return e.set(0,0,0)}return h.prototype=Object.assign(Object.create(s.prototype),{constructor:h,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(r.inputOutput,"metadata",new e.SFNode),new t(r.inputOutput,"speed",new e.SFFloat),new t(r.inputOutput,"variation",new e.SFFloat(.25)),new t(r.initializeOnly,"mass",new e.SFFloat),new t(r.initializeOnly,"surfaceArea",new e.SFFloat),new t(r.initializeOnly,"surface",new e.SFNode)]),getTypeName:function(){return"SurfaceEmitter"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"emitter"},initialize:function(){s.prototype.initialize.call(this),this._surface.addInterest("set_surface__",this),this.set_surface__()},set_surface__:function(){this.surfaceNode&&this.surfaceNode._rebuild.removeInterest("set_geometry__",this),this.surfaceNode=n(r.X3DGeometryNode,this._surface),this.surfaceNode&&this.surfaceNode._rebuild.addInterest("set_geometry__",this),this.set_geometry__()},set_geometry__:(d=new a(0,0,0),c=new a(0,0,0),u=new a(0,0,0),function(){if(this.surfaceNode){delete this.getRandomPosition,delete this.getRandomVelocity;var e=0,t=this.areaSoFarArray,i=this.surfaceNode.getVertices().getValue();this.normals=this.surfaceNode.getNormals().getValue(),this.vertices=i,t.length=1;for(var s=0,r=i.length;s<r;s+=12)d.set(i[s],i[s+1],i[s+2]),c.set(i[s+4],i[s+5],i[s+6]),u.set(i[s+8],i[s+9],i[s+10]),e+=o.area(d,c,u),t.push(e)}else this.getRandomPosition=m,this.getRandomVelocity=this.getSphericalRandomVelocity}),getRandomPosition:function(e){var t=this.areaSoFarArray,i=t.length,s=Math.random()*t.at(-1),r=0;if(1==i||s<=t[0])r=0;else if(s>=t.at(-1))r=i-2;else{var n=l.upperBound(t,0,i,s,l.less);r=n<i?n-1:0}var o=Math.random(),a=Math.random();o+a>1&&(o=1-o,a=1-a);var h=1-o-a,d=12*r,c=this.vertices;e.x=o*c[d]+a*c[d+4]+h*c[d+8],e.y=o*c[d+1]+a*c[d+5]+h*c[d+9],e.z=o*c[d+2]+a*c[d+6]+h*c[d+10];d=9*r;var u=this.normals,m=this.direction;return m.x=o*u[d]+a*u[d+3]+h*u[d+6],m.y=o*u[d+1]+a*u[d+4]+h*u[d+7],m.z=o*u[d+2]+a*u[d+5]+h*u[d+8],e},getRandomVelocity:function(e){var t=this.getRandomSpeed(),i=this.direction;return e.x=i.x*t,e.y=i.y*t,e.z=i.z*t,e}}),h})),e("x_ite/Components/ParticleSystems/VolumeEmitter",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticleEmitterNode","x_ite/Components/Geometry3D/IndexedFaceSet","x_ite/Base/X3DConstants","standard/Math/Numbers/Vector3","standard/Math/Numbers/Rotation4","standard/Math/Geometry/Line3","standard/Math/Geometry/Plane3","standard/Math/Geometry/Triangle3","standard/Math/Algorithm","standard/Math/Utility/BVH","standard/Math/Algorithms/QuickSort"],(function(e,t,i,s,r,n,o,a,l,h,d,c,u,m){"use strict";function f(e){s.call(this,e),this.addType(n.VolumeEmitter),this._speed.setUnit("speed"),this._mass.setUnit("mass"),this._surfaceArea.setUnit("area"),this.direction=new o(0,0,0),this.volumeNode=new r(e),this.areaSoFarArray=[0]}var p,_,y;return f.prototype=Object.assign(Object.create(s.prototype),{constructor:f,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(n.inputOutput,"metadata",new e.SFNode),new t(n.initializeOnly,"internal",new e.SFBool(!0)),new t(n.inputOutput,"direction",new e.SFVec3f(0,1,0)),new t(n.inputOutput,"speed",new e.SFFloat),new t(n.inputOutput,"variation",new e.SFFloat(.25)),new t(n.initializeOnly,"mass",new e.SFFloat),new t(n.initializeOnly,"surfaceArea",new e.SFFloat),new t(n.inputOutput,"coordIndex",new e.MFInt32(-1)),new t(n.inputOutput,"coord",new e.SFNode)]),getTypeName:function(){return"VolumeEmitter"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"emitter"},initialize:function(){s.prototype.initialize.call(this),this._direction.addInterest("set_direction__",this),this._coordIndex.addFieldInterest(this.volumeNode._coordIndex),this._coord.addFieldInterest(this.volumeNode._coord),this.volumeNode._creaseAngle=Math.PI,this.volumeNode._convex=!1,this.volumeNode._coordIndex=this._coordIndex,this.volumeNode._coord=this._coord,this.volumeNode._rebuild.addInterest("set_geometry__",this),this.volumeNode.setPrivate(!0),this.volumeNode.setup(),this.set_direction__(),this.set_geometry__()},set_direction__:function(){this.direction.assign(this._direction.getValue()).normalize(),this.direction.equals(o.Zero)?this.getRandomVelocity=this.getSphericalRandomVelocity:delete this.getRandomVelocity},set_geometry__:(p=new o(0,0,0),_=new o(0,0,0),y=new o(0,0,0),function(){var e=0,t=this.areaSoFarArray,i=this.volumeNode.getNormals().getValue(),s=this.volumeNode.getVertices().getValue();this.normals=i,this.vertices=s,t.length=1;for(var r=0,n=s.length;r<n;r+=12)p.set(s[r],s[r+1],s[r+2]),_.set(s[r+4],s[r+5],s[r+6]),y.set(s[r+8],s[r+9],s[r+10]),e+=d.area(p,_,y),t.push(e);this.bvh=new u(s,i)}),getRandomPosition:function(){var e=new o(0,0,0),t=new o(0,0,0),i=new a(0,0,1,0),s=new l(o.Zero,o.zAxis),r=new h(o.Zero,o.zAxis),n=[],d=new m(n,(function(e,t){return r.getDistanceToPoint(e)<r.getDistanceToPoint(t)}));return function(a){var l=this.areaSoFarArray,h=l.length,u=Math.random()*l.at(-1),m=0;if(1==h||u<=l[0])m=0;else if(u>=l.at(-1))m=h-2;else{m=(F=c.upperBound(l,0,h,u,c.less))<h?F-1:0}var f=Math.random(),p=Math.random();f+p>1&&(f=1-f,p=1-p);var _=1-f-p,y=12*m,g=this.vertices;e.x=f*g[y]+p*g[y+4]+_*g[y+8],e.y=f*g[y+1]+p*g[y+5]+_*g[y+9],e.z=f*g[y+2]+p*g[y+6]+_*g[y+10];y=9*m;var x=this.normals;t.x=f*x[y]+p*x[y+3]+_*x[y+6],t.y=f*x[y+1]+p*x[y+4]+_*x[y+7],t.z=f*x[y+2]+p*x[y+5]+_*x[y+8],i.setFromToVec(o.zAxis,t),i.multVecRot(this.getRandomSurfaceNormal(t)),s.set(e,t),r.set(e,t);var A=this.bvh.intersectsLine(s,n);if(A-=A%2){d.sort(0,A);var F=2*Math.round(this.getRandomValue(0,A/2-1)),w=n[F],R=n[F+1];_=Math.random();return a.x=w.x+(R.x-w.x)*_,a.y=w.y+(R.y-w.y)*_,a.z=w.z+(R.z-w.z)*_,a}return a.set(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY)}}(),getRandomVelocity:function(e){var t=this.direction,i=this.getRandomSpeed();return e.x=t.x*i,e.y=t.y*i,e.z=t.z*i,e}}),f})),e("x_ite/Components/ParticleSystems/WindPhysicsModel",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode","x_ite/Base/X3DConstants","standard/Math/Numbers/Vector3","standard/Math/Algorithm"],(function(e,t,i,s,r,n,o){"use strict";function a(e){s.call(this,e),this.addType(r.WindPhysicsModel),this._speed.setUnit("speed")}var l;return a.prototype=Object.assign(Object.create(s.prototype),{constructor:a,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(r.inputOutput,"metadata",new e.SFNode),new t(r.inputOutput,"enabled",new e.SFBool(!0)),new t(r.inputOutput,"direction",new e.SFVec3f),new t(r.inputOutput,"speed",new e.SFFloat(.1)),new t(r.inputOutput,"gustiness",new e.SFFloat(.1)),new t(r.inputOutput,"turbulence",new e.SFFloat)]),getTypeName:function(){return"WindPhysicsModel"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"physics"},getRandomSpeed:function(e){var t=Math.max(0,this._speed.getValue()),i=t*Math.max(0,this._gustiness.getValue());return e.getRandomValue(Math.max(0,t-i),t+i)},addForce:(l=new n(0,0,0),function(e,t,i,s){var r=t._surfaceArea.getValue();if(this._enabled.getValue()){var a=this.getRandomSpeed(t),h=.64615*Math.pow(10,2*Math.log(a));this._direction.getValue().equals(n.Zero)?t.getRandomNormal(l):l.assign(this._direction.getValue()).normalize(),i[e].assign(l.multiply(r*h)),s[e]=Math.PI*o.clamp(this._turbulence.getValue(),0,1)}})}),a})),e(t.getComponentUrl("particle-systems"),["x_ite/Components","x_ite/Browser/ParticleSystems/X3DParticleSystemsContext","x_ite/Components/ParticleSystems/BoundedPhysicsModel","x_ite/Components/ParticleSystems/ConeEmitter","x_ite/Components/ParticleSystems/ExplosionEmitter","x_ite/Components/ParticleSystems/ForcePhysicsModel","x_ite/Components/ParticleSystems/ParticleSystem","x_ite/Components/ParticleSystems/PointEmitter","x_ite/Components/ParticleSystems/PolylineEmitter","x_ite/Components/ParticleSystems/SurfaceEmitter","x_ite/Components/ParticleSystems/VolumeEmitter","x_ite/Components/ParticleSystems/WindPhysicsModel","x_ite/Components/ParticleSystems/X3DParticleEmitterNode","x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode"],(function(e,t,i,s,r,n,o,a,l,h,d,c,u,m){"use strict";e.addComponent({name:"ParticleSystems",types:{BoundedPhysicsModel:i,ConeEmitter:s,ExplosionEmitter:r,ForcePhysicsModel:n,ParticleSystem:o,PointEmitter:a,PolylineEmitter:l,SurfaceEmitter:h,VolumeEmitter:d,WindPhysicsModel:c},abstractTypes:{X3DParticleEmitterNode:u,X3DParticlePhysicsModelNode:m},browser:t})}))}();
1
+ !function(){const e=window[Symbol.for("X_ITE.X3D-6.1.0")],t=e.define,n=e.require;t("x_ite/Browser/ParticleSystems/GeometryTypes",[],(function(){"use strict";let e=0;return{POINT:e++,LINE:e++,TRIANGLE:e++,QUAD:e++,SPRITE:e++,GEOMETRY:e++}})),t("text!x_ite/Browser/ParticleSystems/Line3.glsl",[],(function(){return"struct Line3 {\n vec3 point;\n vec3 direction;\n};\n\n// Line3\n// line3 (const in vec3 point1, const in vec3 point2)\n// {\n// return Line3 (point1, normalize (point2 - point1));\n// }\n\n/* Line intersect triangle */\n\nbool\nintersects (const in Line3 line, const in vec3 a, const in vec3 b, const in vec3 c, out vec3 r)\n{\n // find vectors for two edges sharing vert0\n vec3 edge1 = b - a;\n vec3 edge2 = c - a;\n\n // begin calculating determinant - also used to calculate U parameter\n vec3 pvec = cross (line .direction, edge2);\n\n // if determinant is near zero, ray lies in plane of triangle\n float det = dot (edge1, pvec);\n\n // Non culling intersection\n\n if (det == 0.0)\n return false;\n\n float inv_det = 1.0 / det;\n\n // calculate distance from vert0 to ray point\n vec3 tvec = line .point - a;\n\n // calculate U parameter and test bounds\n float u = dot (tvec, pvec) * inv_det;\n\n if (u < 0.0 || u > 1.0)\n return false;\n\n // prepare to test V parameter\n vec3 qvec = cross (tvec, edge1);\n\n // calculate V parameter and test bounds\n float v = dot (line .direction, qvec) * inv_det;\n\n if (v < 0.0 || u + v > 1.0)\n return false;\n\n r = vec3 (u, v, 1.0 - u - v);\n\n return true;\n}\n"})),t("text!x_ite/Browser/ParticleSystems/Plane3.glsl",[],(function(){return"struct Plane3\n{\n vec3 normal;\n float distanceFromOrigin;\n};\n\nPlane3\nplane3 (const in vec3 point, const in vec3 normal)\n{\n return Plane3 (normal, dot (normal, point));\n}\n\nfloat\nplane_distance (const in Plane3 plane, const in vec3 point)\n{\n return dot (point, plane .normal) - plane .distanceFromOrigin;\n}\n\n/* Plane intersect line */\nbool\nintersects (const in Plane3 plane, const in Line3 line, out vec3 point)\n{\n // Check if the line is parallel to the plane.\n float theta = dot (line .direction, plane .normal);\n\n // Plane and line are parallel.\n if (theta == 0.0)\n return false;\n\n // Plane and line are not parallel. The intersection point can be calculated now.\n float t = (plane .distanceFromOrigin - dot (plane .normal, line .point)) / theta;\n\n point = line .point + line .direction * t;\n\n return true;\n}\n\n/* Find find the first point that is farther to the plane than value. */\n// int\n// upper_bound (const in vec4 points [ARRAY_SIZE], in int count, const in float value, const in Plane3 plane)\n// {\n// int first = 0;\n// int step = 0;\n\n// while (count > 0)\n// {\n// int index = first;\n\n// step = count >> 1;\n\n// index += step;\n\n// if (value < plane_distance (plane, points [index] .xyz))\n// {\n// count = step;\n// }\n// else\n// {\n// first = ++ index;\n// count -= step + 1;\n// }\n// }\n\n// return first;\n// }\n\n/* CombSort: sort points in distance to a plane. */\nvoid\nsort (inout vec4 points [ARRAY_SIZE], const in int count, const in Plane3 plane)\n{\n const float shrink = 1.0 / 1.3;\n\n int gap = count;\n bool exchanged = true;\n\n while (exchanged)\n {\n gap = int (float (gap) * shrink);\n\n if (gap <= 1)\n {\n exchanged = false;\n gap = 1;\n }\n\n for (int i = 0, l = count - gap; i < l; ++ i)\n {\n int j = gap + i;\n\n if (plane_distance (plane, points [i] .xyz) > plane_distance (plane, points [j] .xyz))\n {\n vec4 tmp1 = points [i];\n points [i] = points [j];\n points [j] = tmp1;\n\n exchanged = true;\n }\n }\n }\n}\n\n\n// /* CombSort: sort points and normals in distance to a plane. */\n// void\n// sort (inout vec4 points [ARRAY_SIZE], inout vec3 normals [ARRAY_SIZE], const in int count, const in Plane3 plane)\n// {\n// const float shrink = 1.0 / 1.3;\n\n// int gap = count;\n// bool exchanged = true;\n\n// while (exchanged)\n// {\n// gap = int (float (gap) * shrink);\n\n// if (gap <= 1)\n// {\n// exchanged = false;\n// gap = 1;\n// }\n\n// for (int i = 0, l = count - gap; i < l; ++ i)\n// {\n// int j = gap + i;\n\n// if (plane_distance (plane, points [i] .xyz) > plane_distance (plane, points [j] .xyz))\n// {\n// vec4 tmp1 = points [i];\n// points [i] = points [j];\n// points [j] = tmp1;\n\n// vec3 tmp2 = normals [i];\n// normals [i] = normals [j];\n// normals [j] = tmp2;\n\n// exchanged = true;\n// }\n// }\n// }\n// }\n\nint\nmin_index (const in vec4 points [ARRAY_SIZE], const in int count, const in float value, const in Plane3 plane)\n{\n int index = -1;\n float dist = 1000000.0;\n\n for (int i = 0; i < count; ++ i)\n {\n float d = plane_distance (plane, points [i] .xyz);\n\n if (d >= value && d < dist)\n {\n dist = d;\n index = i;\n }\n }\n\n return index;\n}\n"})),t("text!x_ite/Browser/ParticleSystems/Box3.glsl",[],(function(){return"bool\nintersects (const in vec3 min, const in vec3 max, const in Line3 line)\n{\n vec3 intersection;\n\n // front\n\n if (intersects (plane3 (max, vec3 (0.0, 0.0, 1.0)), line, intersection))\n {\n if (all (greaterThanEqual (vec4 (intersection .xy, max .xy), vec4 (min .xy, intersection .xy))))\n return true;\n }\n\n // back\n\n if (intersects (plane3 (min, vec3 (0.0, 0.0, -1.0)), line, intersection))\n {\n if (all (greaterThanEqual (vec4 (intersection .xy, max .xy), vec4 (min .xy, intersection .xy))))\n return true;\n }\n\n // top\n\n if (intersects (plane3 (max, vec3 (0.0, 1.0, 0.0)), line, intersection))\n {\n if (all (greaterThanEqual (vec4 (intersection .xz, max .xz), vec4 (min .xz, intersection .xz))))\n return true;\n }\n\n // bottom\n\n if (intersects (plane3 (min, vec3 (0.0, -1.0, 0.0)), line, intersection))\n {\n if (all (greaterThanEqual (vec4 (intersection .xz, max .xz), vec4 (min .xz, intersection .xz))))\n return true;\n }\n\n // right\n\n if (intersects (plane3 (max, vec3 (1.0, 0.0, 0.0)), line, intersection))\n {\n if (all (greaterThanEqual (vec4 (intersection .yz, max .yz), vec4 (min .yz, intersection .yz))))\n return true;\n }\n\n return false;\n}\n"})),t("text!x_ite/Browser/ParticleSystems/BVH.glsl",[],(function(){return"#define BVH_NODE 0\n#define BVH_TRIANGLE 1\n#define BVH_STACK_SIZE 32\n\nint bvhNodeIndex = 0;\n\nvoid\nsetBVHIndex (const in int index)\n{\n bvhNodeIndex = index;\n}\n\nint\ngetBVHRoot (const in sampler2D volume, const in int hierarchyIndex, const in int rootIndex)\n{\n return int (texelFetch (volume, rootIndex, 0) .x) + hierarchyIndex;\n}\n\nint\ngetBVHType (const in sampler2D volume)\n{\n return int (texelFetch (volume, bvhNodeIndex, 0) .x);\n}\n\nvec3\ngetBVHMin (const in sampler2D volume)\n{\n return texelFetch (volume, bvhNodeIndex + 1, 0) .xyz;\n}\n\nvec3\ngetBVHMax (const in sampler2D volume)\n{\n return texelFetch (volume, bvhNodeIndex + 2, 0) .xyz;\n}\n\nint\ngetBVHLeft (const in sampler2D volume, const in int hierarchyIndex)\n{\n return int (texelFetch (volume, bvhNodeIndex, 0) .y) + hierarchyIndex;\n}\n\nint\ngetBVHRight (const in sampler2D volume, const in int hierarchyIndex)\n{\n return int (texelFetch (volume, bvhNodeIndex, 0) .z) + hierarchyIndex;\n}\n\nint\ngetBVHTriangle (const in sampler2D volume)\n{\n return int (texelFetch (volume, bvhNodeIndex, 0) .y);\n}\n\n/* Ray triangle intersection test */\n\nint\ngetIntersections (const in sampler2D volume, const in int verticesIndex, const in int hierarchyIndex, const in int rootIndex, const in Line3 line, out vec4 points [ARRAY_SIZE])\n{\n int current = getBVHRoot (volume, hierarchyIndex, rootIndex);\n int count = 0;\n int stackIndex = -1;\n int stack [BVH_STACK_SIZE];\n\n while (stackIndex >= 0 || current >= 0)\n {\n if (current >= 0)\n {\n setBVHIndex (current);\n\n if (getBVHType (volume) == BVH_NODE)\n {\n // Node\n\n if (intersects (getBVHMin (volume), getBVHMax (volume), line))\n {\n stack [++ stackIndex] = current;\n\n current = getBVHLeft (volume, hierarchyIndex);\n }\n else\n {\n current = -1;\n }\n }\n else\n {\n // Triangle\n\n int t = getBVHTriangle (volume);\n int v = verticesIndex + t;\n vec3 r = vec3 (0.0);\n\n vec3 a = texelFetch (volume, v, 0) .xyz;\n vec3 b = texelFetch (volume, v + 1, 0) .xyz;\n vec3 c = texelFetch (volume, v + 2, 0) .xyz;\n\n if (intersects (line, a, b, c, r))\n points [count ++] = vec4 (r .z * a + r .x * b + r .y * c, 1.0);\n\n current = -1;\n }\n }\n else\n {\n setBVHIndex (stack [stackIndex --]);\n\n current = getBVHRight (volume, hierarchyIndex);\n }\n }\n\n return count;\n}\n\nint\ngetIntersections (const in sampler2D volume, const in int verticesIndex, const in int normalsIndex, const in int hierarchyIndex, const in int rootIndex, const in Line3 line, out vec4 points [ARRAY_SIZE], out vec3 normals [ARRAY_SIZE])\n{\n int current = getBVHRoot (volume, hierarchyIndex, rootIndex);\n int count = 0;\n int stackIndex = -1;\n int stack [BVH_STACK_SIZE];\n\n while (stackIndex >= 0 || current >= 0)\n {\n if (current >= 0)\n {\n setBVHIndex (current);\n\n if (getBVHType (volume) == BVH_NODE)\n {\n // Node\n\n if (intersects (getBVHMin (volume), getBVHMax (volume), line))\n {\n stack [++ stackIndex] = current;\n\n current = getBVHLeft (volume, hierarchyIndex);\n }\n else\n {\n current = -1;\n }\n }\n else\n {\n // Triangle\n\n int t = getBVHTriangle (volume);\n int v = verticesIndex + t;\n vec3 r = vec3 (0.0);\n\n vec3 a = texelFetch (volume, v, 0) .xyz;\n vec3 b = texelFetch (volume, v + 1, 0) .xyz;\n vec3 c = texelFetch (volume, v + 2, 0) .xyz;\n\n if (intersects (line, a, b, c, r))\n {\n points [count] = vec4 (r .z * a + r .x * b + r .y * c, 1.0);\n\n int n = normalsIndex + t;\n\n vec3 n0 = texelFetch (volume, n, 0) .xyz;\n vec3 n1 = texelFetch (volume, n + 1, 0) .xyz;\n vec3 n2 = texelFetch (volume, n + 2, 0) .xyz;\n\n normals [count] = save_normalize (r .z * n0 + r .x * n1 + r .y * n2);\n\n ++ count;\n }\n\n current = -1;\n }\n }\n else\n {\n setBVHIndex (stack [stackIndex --]);\n\n current = getBVHRight (volume, hierarchyIndex);\n }\n }\n\n return count;\n}\n"})),t("x_ite/Components/ParticleSystems/X3DParticleEmitterNode",["x_ite/Components/Core/X3DNode","x_ite/Browser/ParticleSystems/GeometryTypes","x_ite/Base/X3DConstants","text!x_ite/Browser/ParticleSystems/Line3.glsl","text!x_ite/Browser/ParticleSystems/Plane3.glsl","text!x_ite/Browser/ParticleSystems/Box3.glsl","text!x_ite/Browser/ParticleSystems/BVH.glsl"],(function(e,t,n,i,o,r,s){"use strict";function a(t){e.call(this,t),this.addType(n.X3DParticleEmitterNode),this._speed.setUnit("speed"),this._mass.setUnit("mass"),this._surfaceArea.setUnit("area"),this.samplers=[],this.uniforms={},this.functions=[],this.program=null,this.addSampler("forces"),this.addSampler("boundedVolume"),this.addSampler("colorRamp"),this.addSampler("texCoordRamp"),this.addUniform("speed","uniform float speed;"),this.addUniform("variation","uniform float variation;"),this.addFunction(i),this.addFunction(o),this.addFunction(r),this.addFunction(s)}return a.prototype=Object.assign(Object.create(e.prototype),{constructor:a,initialize:function(){e.prototype.initialize.call(this);const t=this.getBrowser().getContext();t.getVersion()<2||(this.program=this.createProgram(),this.transformFeedback=t.createTransformFeedback(),this._on.addInterest("set_on__",this),this._speed.addInterest("set_speed__",this),this._variation.addInterest("set_variation__",this),this._mass.addInterest("set_mass__",this),this.set_on__(),this.set_speed__(),this.set_variation__(),this.set_mass__())},isExplosive:function(){return!1},getMass:function(){return this.mass},set_on__:function(){this.on=this._on.getValue()},set_speed__:function(){this.setUniform("uniform1f","speed",this._speed.getValue())},set_variation__:function(){this.setUniform("uniform1f","variation",this._variation.getValue())},set_mass__:function(){this.mass=this._mass.getValue()},getRandomValue:function(e,t){return Math.random()*(t-e)+e},getRandomNormal:function(e){const t=this.getRandomValue(-1,1)*Math.PI,n=this.getRandomValue(-1,1),i=Math.acos(n),o=Math.sin(i);return e.set(Math.sin(t)*o,Math.cos(t)*o,n)},animate:function(e,t){const n=this.getBrowser().getContext(),i=e.inputParticles,o=e.particleStride,r=e.particleOffsets,s=this.program;if(n.useProgram(s),n.uniform1i(s.randomSeed,4294967295*Math.random()),n.uniform1i(s.geometryType,e.geometryType),n.uniform1i(s.createParticles,e.createParticles&&this.on),n.uniform1f(s.particleLifetime,e.particleLifetime),n.uniform1f(s.lifetimeVariation,e.lifetimeVariation),n.uniform1f(s.deltaTime,t),n.uniform2f(s.particleSize,e._particleSize.x,e._particleSize.y),n.uniform1i(s.numForces,e.numForces),e.numForces&&(n.activeTexture(n.TEXTURE0+s.forcesTextureUnit),n.bindTexture(n.TEXTURE_2D,e.forcesTexture)),e.boundedHierarchyRoot<0?n.uniform1i(s.boundedHierarchyRoot,-1):(n.uniform1i(s.boundedVerticesIndex,e.boundedVerticesIndex),n.uniform1i(s.boundedNormalsIndex,e.boundedNormalsIndex),n.uniform1i(s.boundedHierarchyIndex,e.boundedHierarchyIndex),n.uniform1i(s.boundedHierarchyRoot,e.boundedHierarchyRoot),n.activeTexture(n.TEXTURE0+s.boundedVolumeTextureUnit),n.bindTexture(n.TEXTURE_2D,e.boundedTexture)),n.uniform1i(s.numColors,e.numColors),e.numColors&&(n.activeTexture(n.TEXTURE0+s.colorRampTextureUnit),n.bindTexture(n.TEXTURE_2D,e.colorRampTexture)),n.uniform1i(s.numTexCoords,e.numTexCoords),e.numTexCoords&&(n.uniform1i(s.texCoordCount,e.texCoordCount),n.activeTexture(n.TEXTURE0+s.texCoordRampTextureUnit),n.bindTexture(n.TEXTURE_2D,e.texCoordRampTexture)),this.activateTextures(n,s),i.emitterArrayObject.enable(n,s)){for(const[e,t]of s.inputs)n.bindBuffer(n.ARRAY_BUFFER,i),n.enableVertexAttribArray(t),n.vertexAttribPointer(t,4,n.FLOAT,!1,o,r[e]);n.bindBuffer(n.ARRAY_BUFFER,null)}n.bindTransformFeedback(n.TRANSFORM_FEEDBACK,this.transformFeedback),n.bindBufferBase(n.TRANSFORM_FEEDBACK_BUFFER,0,e.outputParticles),n.enable(n.RASTERIZER_DISCARD),n.beginTransformFeedback(n.POINTS),n.drawArrays(n.POINTS,0,e.numParticles),n.endTransformFeedback(),n.disable(n.RASTERIZER_DISCARD),n.bindTransformFeedback(n.TRANSFORM_FEEDBACK,null)},addSampler:function(e){this.samplers.push(e)},addUniform:function(e,t){this.uniforms[e]=t},setUniform:function(e,t,n,i,o){const r=this.getBrowser().getContext(),s=this.program;r.useProgram(s),r[e](s[t],n,i,o)},addFunction:function(e){this.functions.push(e)},createProgram:function(){const e=this.getBrowser(),n=e.getContext(),i=`#version 300 es\n\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n\n uniform int randomSeed;\n uniform int geometryType;\n uniform bool createParticles;\n uniform float particleLifetime;\n uniform float lifetimeVariation;\n uniform float deltaTime;\n uniform vec2 particleSize;\n\n uniform int numForces;\n uniform sampler2D forces;\n\n uniform int boundedVerticesIndex;\n uniform int boundedNormalsIndex;\n uniform int boundedHierarchyIndex;\n uniform int boundedHierarchyRoot;\n uniform sampler2D boundedVolume;\n\n uniform int numColors;\n uniform sampler2D colorRamp;\n\n uniform int texCoordCount;\n uniform int numTexCoords;\n uniform sampler2D texCoordRamp;\n\n ${Object.values(this.uniforms).join("\n")}\n\n in vec4 input0;\n in vec4 input2;\n in vec4 input6;\n\n out vec4 output0;\n out vec4 output1;\n out vec4 output2;\n\n out vec4 output3;\n out vec4 output4;\n out vec4 output5;\n out vec4 output6;\n\n // Constants\n\n ${Object.entries(t).map((([e,t])=>`#define ${e} ${t}`)).join("\n")}\n\n const int ARRAY_SIZE = 32;\n const float M_PI = 3.14159265359;\n\n uniform float NaN;\n\n // Texture\n\n vec4\n texelFetch (const in sampler2D sampler, const in int index, const in int lod)\n {\n int x = textureSize (sampler, lod) .x;\n ivec2 p = ivec2 (index % x, index / x);\n vec4 t = texelFetch (sampler, p, lod);\n\n return t;\n }\n\n // Math\n\n // Save normalize, that will not divide by zero.\n vec3\n save_normalize (const in vec3 vector)\n {\n float l = length (vector);\n\n if (l == 0.0)\n return vec3 (0.0);\n\n return vector / l;\n }\n\n // Quaternion\n\n vec4\n Quaternion (const in vec3 fromVector, const in vec3 toVector)\n {\n vec3 from = save_normalize (fromVector);\n vec3 to = save_normalize (toVector);\n\n float cos_angle = dot (from, to);\n vec3 cross_vec = cross (from, to);\n float cross_len = length (cross_vec);\n\n if (cross_len == 0.0)\n {\n if (cos_angle > 0.0)\n {\n return vec4 (0.0, 0.0, 0.0, 1.0);\n }\n else\n {\n vec3 t = cross (from, vec3 (1.0, 0.0, 0.0));\n\n if (dot (t, t) == 0.0)\n t = cross (from, vec3 (0.0, 1.0, 0.0));\n\n t = save_normalize (t);\n\n return vec4 (t, 0.0);\n }\n }\n else\n {\n float s = sqrt (abs (1.0 - cos_angle) * 0.5);\n\n cross_vec = save_normalize (cross_vec);\n\n return vec4 (cross_vec * s, sqrt (abs (1.0 + cos_angle) * 0.5));\n }\n }\n\n vec3\n multVecQuat (const in vec3 v, const in vec4 q)\n {\n float a = q .w * q .w - q .x * q .x - q .y * q .y - q .z * q .z;\n float b = 2.0 * (v .x * q .x + v .y * q .y + v .z * q .z);\n float c = 2.0 * q .w;\n vec3 r = a * v .xyz + b * q .xyz + c * (q .yzx * v .zxy - q .zxy * v .yzx);\n\n return r;\n }\n\n mat3\n Matrix3 (const in vec4 quaternion)\n {\n float x = quaternion .x;\n float y = quaternion .y;\n float z = quaternion .z;\n float w = quaternion .w;\n float A = y * y;\n float B = z * z;\n float C = x * y;\n float D = z * w;\n float E = z * x;\n float F = y * w;\n float G = x * x;\n float H = y * z;\n float I = x * w;\n\n return mat3 (1.0 - 2.0 * (A + B),\n 2.0 * (C + D),\n 2.0 * (E - F),\n 2.0 * (C - D),\n 1.0 - 2.0 * (B + G),\n 2.0 * (H + I),\n 2.0 * (E + F),\n 2.0 * (H - I),\n 1.0 - 2.0 * (A + G));\n }\n\n /* Random number generation */\n\n uint seed = 1u;\n\n void\n srand (const in int value)\n {\n seed = uint (value);\n }\n\n // Return a uniform distributed random floating point number in the interval [0, 1].\n float\n random ()\n {\n seed = seed * 1103515245u + 12345u;\n\n return float (seed) / 4294967295.0;\n }\n\n float\n getRandomValue (const in float min, const in float max)\n {\n return min + random () * (max - min);\n }\n\n float\n getRandomLifetime ()\n {\n float v = particleLifetime * lifetimeVariation;\n float min_ = max (0.0, particleLifetime - v);\n float max_ = particleLifetime + v;\n\n return getRandomValue (min_, max_);\n }\n\n float\n getRandomSpeed ()\n {\n float v = speed * variation;\n float min_ = max (0.0, speed - v);\n float max_ = speed + v;\n\n return getRandomValue (min_, max_);\n }\n\n vec3\n getRandomNormal ()\n {\n float theta = getRandomValue (-M_PI, M_PI);\n float cphi = getRandomValue (-1.0, 1.0);\n float r = sqrt (1.0 - cphi * cphi); // sin (acos (cphi));\n\n return vec3 (sin (theta) * r, cos (theta) * r, cphi);\n }\n\n vec3\n getRandomNormalWithAngle (const in float angle)\n {\n float theta = getRandomValue (-M_PI, M_PI);\n float cphi = getRandomValue (cos (angle), 1.0);\n float r = sqrt (1.0 - cphi * cphi); // sin (acos (cphi));\n\n return vec3 (sin (theta) * r, cos (theta) * r, cphi);\n }\n\n vec3\n getRandomNormalWithDirectionAndAngle (const in vec3 direction, const in float angle)\n {\n vec4 rotation = Quaternion (vec3 (0.0, 0.0, 1.0), direction);\n vec3 normal = getRandomNormalWithAngle (angle);\n\n return multVecQuat (normal, rotation);\n }\n\n vec3\n getRandomSurfaceNormal (const in vec3 direction)\n {\n float theta = getRandomValue (-M_PI, M_PI);\n float cphi = pow (random (), 1.0 / 3.0);\n float r = sqrt (1.0 - cphi * cphi); // sin (acos (cphi));\n vec3 normal = vec3 (sin (theta) * r, cos (theta) * r, cphi);\n vec4 rotation = Quaternion (vec3 (0.0, 0.0, 1.0), direction);\n\n return multVecQuat (normal, rotation);\n }\n\n vec3\n getRandomSphericalVelocity ()\n {\n vec3 normal = getRandomNormal ();\n float speed = getRandomSpeed ();\n\n return normal * speed;\n }\n\n // Algorithms\n\n int\n upperBound (const in sampler2D sampler, in int count, const in float value)\n {\n int first = 0;\n int step = 0;\n\n while (count > 0)\n {\n int index = first;\n\n step = count >> 1;\n\n index += step;\n\n if (value < texelFetch (sampler, index, 0) .x)\n {\n count = step;\n }\n else\n {\n first = ++ index;\n count -= step + 1;\n }\n }\n\n return first;\n }\n\n void\n interpolate (const in sampler2D sampler, const in int count, const in float fraction, out int index0, out int index1, out float weight)\n {\n // Determine index0, index1 and weight.\n\n if (count == 1 || fraction <= texelFetch (sampler, 0, 0) .x)\n {\n index0 = 0;\n index1 = 0;\n weight = 0.0;\n }\n else if (fraction >= texelFetch (sampler, count - 1, 0) .x)\n {\n index0 = count - 2;\n index1 = count - 1;\n weight = 1.0;\n }\n else\n {\n int index = upperBound (sampler, count, fraction);\n\n if (index < count)\n {\n index1 = index;\n index0 = index - 1;\n\n float key0 = texelFetch (sampler, index0, 0) .x;\n float key1 = texelFetch (sampler, index1, 0) .x;\n\n weight = clamp ((fraction - key0) / (key1 - key0), 0.0, 1.0);\n }\n else\n {\n index0 = 0;\n index1 = 0;\n weight = 0.0;\n }\n }\n }\n\n void\n interpolate (const in sampler2D sampler, const in int count, const in float fraction, out int index0)\n {\n // Determine index0.\n\n if (count == 1 || fraction <= texelFetch (sampler, 0, 0) .x)\n {\n index0 = 0;\n }\n else if (fraction >= texelFetch (sampler, count - 1, 0) .x)\n {\n index0 = count - 2;\n }\n else\n {\n int index = upperBound (sampler, count, fraction);\n\n if (index < count)\n index0 = index - 1;\n else\n index0 = 0;\n }\n }\n\n vec3\n getRandomBarycentricCoord ()\n {\n // Random barycentric coordinates.\n\n float u = random ();\n float v = random ();\n\n if (u + v > 1.0)\n {\n u = 1.0 - u;\n v = 1.0 - v;\n }\n\n float t = 1.0 - u - v;\n\n return vec3 (t, u, v);\n }\n\n void\n getRandomPointOnSurface (const in sampler2D surface, const in int verticesIndex, const in int normalsIndex, out vec4 position, out vec3 normal)\n {\n // Determine index0, index1 and weight.\n\n float lastAreaSoFar = texelFetch (surface, verticesIndex - 1, 0) .x;\n float fraction = random () * lastAreaSoFar;\n\n int index0;\n int index1;\n int index2;\n float weight;\n\n interpolate (surface, verticesIndex, fraction, index0, index1, weight);\n\n // Interpolate and return position.\n\n index0 *= 3;\n index1 = index0 + 1;\n index2 = index0 + 2;\n\n vec4 vertex0 = texelFetch (surface, verticesIndex + index0, 0);\n vec4 vertex1 = texelFetch (surface, verticesIndex + index1, 0);\n vec4 vertex2 = texelFetch (surface, verticesIndex + index2, 0);\n\n vec3 normal0 = texelFetch (surface, normalsIndex + index0, 0) .xyz;\n vec3 normal1 = texelFetch (surface, normalsIndex + index1, 0) .xyz;\n vec3 normal2 = texelFetch (surface, normalsIndex + index2, 0) .xyz;\n\n // Random barycentric coordinates.\n\n vec3 r = getRandomBarycentricCoord ();\n\n // Calculate position and direction.\n\n position = r .z * vertex0 + r .x * vertex1 + r .y * vertex2;\n normal = save_normalize (r .z * normal0 + r .x * normal1 + r .y * normal2);\n }\n\n // Functions\n\n ${this.functions.join("\n")}\n\n // Current values\n\n vec4\n getColor (const in float lifetime, const in float elapsedTime)\n {\n if (numColors > 0)\n {\n // Determine index0, index1 and weight.\n\n float fraction = elapsedTime / lifetime;\n\n int index0;\n int index1;\n float weight;\n\n interpolate (colorRamp, numColors, fraction, index0, index1, weight);\n\n // Interpolate and return color.\n\n vec4 color0 = texelFetch (colorRamp, numColors + index0, 0);\n vec4 color1 = texelFetch (colorRamp, numColors + index1, 0);\n\n return mix (color0, color1, weight);\n }\n else\n {\n return vec4 (1.0);\n }\n }\n\n void\n bounce (const in vec4 fromPosition, inout vec4 toPosition, inout vec3 velocity)\n {\n if (boundedHierarchyRoot < 0)\n return;\n\n Line3 line = Line3 (fromPosition .xyz, save_normalize (velocity));\n\n vec4 points [ARRAY_SIZE];\n vec3 normals [ARRAY_SIZE];\n\n int numIntersections = getIntersections (boundedVolume, boundedVerticesIndex, boundedNormalsIndex, boundedHierarchyIndex, boundedHierarchyRoot, line, points, normals);\n\n if (numIntersections == 0)\n return;\n\n Plane3 plane1 = plane3 (line .point, line .direction);\n\n int index = min_index (points, numIntersections, 0.0, plane1);\n\n if (index == -1)\n return;\n\n Plane3 plane2 = plane3 (points [index] .xyz, normals [index]);\n\n if (sign (plane_distance (plane2, fromPosition .xyz)) == sign (plane_distance (plane2, toPosition .xyz)))\n return;\n\n velocity = reflect (velocity, normals [index]);\n toPosition = vec4 (points [index] .xyz + reflect (points [index] .xyz - fromPosition .xyz, normals [index]), 1.0);\n }\n\n int\n getTexCoordIndex0 (const in float lifetime, const in float elapsedTime)\n {\n if (numTexCoords == 0)\n {\n return -1;\n }\n else\n {\n float fraction = elapsedTime / lifetime;\n int index0 = 0;\n\n interpolate (texCoordRamp, numTexCoords, fraction, index0);\n\n return numTexCoords + index0 * texCoordCount;\n }\n }\n\n void\n main ()\n {\n int life = int (input0 [0]);\n float lifetime = input0 [1];\n float elapsedTime = input0 [2] + deltaTime;\n\n srand ((gl_VertexID + randomSeed) * randomSeed);\n\n if (elapsedTime > lifetime)\n {\n // Create new particle or hide particle.\n\n lifetime = getRandomLifetime ();\n elapsedTime = 0.0;\n\n output0 = vec4 (max (life + 1, 1), lifetime, elapsedTime, getTexCoordIndex0 (lifetime, elapsedTime));\n\n if (createParticles)\n {\n output1 = getColor (lifetime, elapsedTime);\n output2 = vec4 (getRandomVelocity (), 0.0);\n output6 = getRandomPosition ();\n }\n else\n {\n output1 = vec4 (0.0);\n output2 = vec4 (0.0);\n output6 = vec4 (NaN);\n }\n }\n else\n {\n // Animate particle.\n\n vec3 velocity = input2 .xyz;\n vec4 position = input6;\n\n for (int i = 0; i < numForces; ++ i)\n {\n vec4 force = texelFetch (forces, i, 0);\n float turbulence = force .w;\n vec3 normal = getRandomNormalWithDirectionAndAngle (force .xyz, turbulence);\n float speed = length (force .xyz);\n\n velocity += normal * speed;\n }\n\n position .xyz += velocity * deltaTime;\n\n bounce (input6, position, velocity);\n\n output0 = vec4 (life, lifetime, elapsedTime, getTexCoordIndex0 (lifetime, elapsedTime));\n output1 = getColor (lifetime, elapsedTime);\n output2 = vec4 (velocity, 0.0);\n output6 = position;\n }\n\n switch (geometryType)\n {\n case POINT:\n case SPRITE:\n case GEOMETRY:\n {\n output3 = vec4 (1.0, 0.0, 0.0, 0.0);\n output4 = vec4 (0.0, 1.0, 0.0, 0.0);\n output5 = vec4 (0.0, 0.0, 1.0, 0.0);\n break;\n }\n case LINE:\n {\n mat3 r = Matrix3 (Quaternion (vec3 (0.0, 0.0, 1.0), output2 .xyz));\n mat3 s = mat3 (1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, particleSize .y);\n mat3 m = r * s;\n\n output3 = vec4 (m [0], 0.0);\n output4 = vec4 (m [1], 0.0);\n output5 = vec4 (m [2], 0.0);\n break;\n }\n default: // QUAD, TRIANGLE\n {\n output3 = vec4 (particleSize .x, 0.0, 0.0, 0.0);\n output4 = vec4 (0.0, particleSize .y, 0.0, 0.0);\n output5 = vec4 (0.0, 0.0, 1.0, 0.0);\n break;\n }\n }\n }\n `,o=n.createShader(n.VERTEX_SHADER);n.shaderSource(o,i),n.compileShader(o);const r=n.createShader(n.FRAGMENT_SHADER);n.shaderSource(r,"#version 300 es\n\n precision highp float;\n\n void\n main () { }\n "),n.compileShader(r);const s=n.createProgram();n.attachShader(s,o),n.attachShader(s,r),n.transformFeedbackVaryings(s,Array.from({length:7},((e,t)=>"output"+t)),n.INTERLEAVED_ATTRIBS),n.linkProgram(s),n.getProgramParameter(s,n.LINK_STATUS)||console.error("Couldn't initialize particle shader: "+n.getProgramInfoLog(s)),s.inputs=[[0,n.getAttribLocation(s,"input0")],[2,n.getAttribLocation(s,"input2")],[6,n.getAttribLocation(s,"input6")]],s.randomSeed=n.getUniformLocation(s,"randomSeed"),s.geometryType=n.getUniformLocation(s,"geometryType"),s.createParticles=n.getUniformLocation(s,"createParticles"),s.particleLifetime=n.getUniformLocation(s,"particleLifetime"),s.lifetimeVariation=n.getUniformLocation(s,"lifetimeVariation"),s.deltaTime=n.getUniformLocation(s,"deltaTime"),s.particleSize=n.getUniformLocation(s,"particleSize"),s.numForces=n.getUniformLocation(s,"numForces"),s.forces=n.getUniformLocation(s,"forces"),s.boundedVerticesIndex=n.getUniformLocation(s,"boundedVerticesIndex"),s.boundedNormalsIndex=n.getUniformLocation(s,"boundedNormalsIndex"),s.boundedHierarchyIndex=n.getUniformLocation(s,"boundedHierarchyIndex"),s.boundedHierarchyRoot=n.getUniformLocation(s,"boundedHierarchyRoot"),s.boundedVolume=n.getUniformLocation(s,"boundedVolume"),s.numColors=n.getUniformLocation(s,"numColors"),s.colorRamp=n.getUniformLocation(s,"colorRamp"),s.texCoordCount=n.getUniformLocation(s,"texCoordCount"),s.numTexCoords=n.getUniformLocation(s,"numTexCoords"),s.texCoordRamp=n.getUniformLocation(s,"texCoordRamp");for(const e of Object.keys(this.uniforms))s[e]=n.getUniformLocation(s,e);s.NaN=n.getUniformLocation(s,"NaN"),n.useProgram(s);for(const t of this.samplers){const i=n.getUniformLocation(s,t);n.uniform1i(i,s[t+"TextureUnit"]=e.getTexture2DUnit())}return n.uniform1f(s.NaN,NaN),e.resetTextureUnits(),s},activateTextures:function(){},createTexture:function(){const e=this.getBrowser().getContext(),t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,1,1,0,e.RGBA,e.FLOAT,new Float32Array(4)),t},getTexture2DUnit:function(e,t,n){const i=t[n];return void 0===i?t[n]=e.getTexture2DUnit():i}}),a})),t("x_ite/Components/ParticleSystems/PointEmitter",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticleEmitterNode","x_ite/Base/X3DConstants","standard/Math/Numbers/Vector3"],(function(e,t,n,i,o,r){"use strict";function s(e){i.call(this,e),this.addType(o.PointEmitter),this._position.setUnit("length"),this.addUniform("position","uniform vec3 position;"),this.addUniform("direction","uniform vec3 direction;"),this.addFunction("vec3 getRandomVelocity ()\n {\n if (direction == vec3 (0.0))\n return getRandomSphericalVelocity ();\n\n else\n return direction * getRandomSpeed ();\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n return vec4 (position, 1.0);\n }")}return s.prototype=Object.assign(Object.create(i.prototype),{constructor:s,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new n([new t(o.inputOutput,"metadata",new e.SFNode),new t(o.inputOutput,"on",new e.SFBool(!0)),new t(o.inputOutput,"position",new e.SFVec3f),new t(o.inputOutput,"direction",new e.SFVec3f(0,1,0)),new t(o.inputOutput,"speed",new e.SFFloat),new t(o.inputOutput,"variation",new e.SFFloat(.25)),new t(o.inputOutput,"mass",new e.SFFloat),new t(o.inputOutput,"surfaceArea",new e.SFFloat)]),getTypeName:function(){return"PointEmitter"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"emitter"},initialize:function(){i.prototype.initialize.call(this),this.getBrowser().getContext().getVersion()<2||(this._position.addInterest("set_position__",this),this._direction.addInterest("set_direction__",this),this.set_position__(),this.set_direction__())},set_position__:function(){const e=this._position.getValue();this.setUniform("uniform3f","position",e.x,e.y,e.z)},set_direction__:function(){const e=new r(0,0,0);return function(){e.assign(this._direction.getValue()).normalize(),this.setUniform("uniform3f","direction",e.x,e.y,e.z)}}()}),s})),t("x_ite/Browser/ParticleSystems/X3DParticleSystemsContext",["x_ite/Components/ParticleSystems/PointEmitter"],(function(e){"use strict";const t=Symbol();function n(){}return n.prototype={getDefaultEmitter:function(){return this[t]=new e(this.getPrivateScene()),this[t].setup(),this.getDefaultEmitter=function(){return this[t]},Object.defineProperty(this,"getDefaultEmitter",{enumerable:!1}),v,this[t]}},n})),t("x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode",["x_ite/Components/Core/X3DNode","x_ite/Base/X3DConstants"],(function(e,t){"use strict";function n(n){e.call(this,n),this.addType(t.X3DParticlePhysicsModelNode)}return n.prototype=Object.assign(Object.create(e.prototype),{constructor:n,addForce:function(){}}),n})),t("x_ite/Components/ParticleSystems/BoundedPhysicsModel",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode","x_ite/Base/X3DConstants","x_ite/Base/X3DCast"],(function(e,t,n,i,o,r){"use strict";function s(e){i.call(this,e),this.addType(o.BoundedPhysicsModel)}return s.prototype=Object.assign(Object.create(i.prototype),{constructor:s,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new n([new t(o.inputOutput,"metadata",new e.SFNode),new t(o.inputOutput,"enabled",new e.SFBool(!0)),new t(o.inputOutput,"geometry",new e.SFNode)]),getTypeName:function(){return"BoundedPhysicsModel"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"physics"},initialize:function(){i.prototype.initialize.call(this),this._geometry.addInterest("set_geometry__",this),this.set_geometry__()},set_geometry__:function(){this.geometryNode&&this.geometryNode._rebuild.removeInterest("addNodeEvent",this),this.geometryNode=r(o.X3DGeometryNode,this._geometry),this.geometryNode&&this.geometryNode._rebuild.addInterest("addNodeEvent",this)},addGeometry:function(e,t){if(this.geometryNode&&this._enabled.getValue()){const n=this.geometryNode.getNormals().getValue(),i=this.geometryNode.getVertices().getValue();for(const t of n)e.push(t);for(const e of i)t.push(e)}}}),s})),t("x_ite/Components/ParticleSystems/ConeEmitter",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticleEmitterNode","x_ite/Base/X3DConstants"],(function(e,t,n,i,o){"use strict";function r(e){i.call(this,e),this.addType(o.ConeEmitter),this._position.setUnit("length"),this._angle.setUnit("angle"),this.addUniform("position","uniform vec3 position;"),this.addUniform("direction","uniform vec3 direction;"),this.addUniform("angle","uniform float angle;"),this.addFunction("vec3 getRandomVelocity ()\n {\n if (direction == vec3 (0.0))\n {\n return getRandomSphericalVelocity ();\n }\n else\n {\n vec3 normal = getRandomNormalWithDirectionAndAngle (direction, angle);\n float speed = getRandomSpeed ();\n\n return normal * speed;\n }\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n return vec4 (position, 1.0);\n }")}return r.prototype=Object.assign(Object.create(i.prototype),{constructor:r,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new n([new t(o.inputOutput,"metadata",new e.SFNode),new t(o.inputOutput,"on",new e.SFBool(!0)),new t(o.inputOutput,"position",new e.SFVec3f),new t(o.inputOutput,"direction",new e.SFVec3f(0,1,0)),new t(o.inputOutput,"angle",new e.SFFloat(.7854)),new t(o.inputOutput,"speed",new e.SFFloat),new t(o.inputOutput,"variation",new e.SFFloat(.25)),new t(o.inputOutput,"mass",new e.SFFloat),new t(o.inputOutput,"surfaceArea",new e.SFFloat)]),getTypeName:function(){return"ConeEmitter"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"emitter"},initialize:function(){i.prototype.initialize.call(this),this.getBrowser().getContext().getVersion()<2||(this._position.addInterest("set_position__",this),this._direction.addInterest("set_direction__",this),this._angle.addInterest("set_angle__",this),this.set_position__(),this.set_direction__(),this.set_angle__())},set_position__:function(){const e=this._position.getValue();this.setUniform("uniform3f","position",e.x,e.y,e.z)},set_direction__:function(){const e=this._direction.getValue();this.setUniform("uniform3f","direction",e.x,e.y,e.z)},set_angle__:function(){this.setUniform("uniform1f","angle",this._angle.getValue())}}),r})),t("x_ite/Components/ParticleSystems/ExplosionEmitter",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticleEmitterNode","x_ite/Base/X3DConstants"],(function(e,t,n,i,o){"use strict";function r(e){i.call(this,e),this.addType(o.ExplosionEmitter),this._position.setUnit("length"),this.addUniform("position","uniform vec3 position;"),this.addFunction("vec3 getRandomVelocity ()\n {\n return getRandomSphericalVelocity ();\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n return vec4 (position, 1.0);\n }")}return r.prototype=Object.assign(Object.create(i.prototype),{constructor:r,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new n([new t(o.inputOutput,"metadata",new e.SFNode),new t(o.inputOutput,"on",new e.SFBool(!0)),new t(o.inputOutput,"position",new e.SFVec3f),new t(o.inputOutput,"speed",new e.SFFloat),new t(o.inputOutput,"variation",new e.SFFloat(.25)),new t(o.inputOutput,"mass",new e.SFFloat),new t(o.inputOutput,"surfaceArea",new e.SFFloat)]),getTypeName:function(){return"ExplosionEmitter"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"emitter"},initialize:function(){i.prototype.initialize.call(this),this.getBrowser().getContext().getVersion()<2||(this._position.addInterest("set_position__",this),this.set_position__())},isExplosive:function(){return!0},set_position__:function(){const e=this._position.getValue();this.setUniform("uniform3f","position",e.x,e.y,e.z)}}),r})),t("x_ite/Components/ParticleSystems/ForcePhysicsModel",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode","x_ite/Base/X3DConstants","standard/Math/Numbers/Vector3"],(function(e,t,n,i,o,r){"use strict";function s(e){i.call(this,e),this.addType(o.ForcePhysicsModel),this._force.setUnit("force")}return s.prototype=Object.assign(Object.create(i.prototype),{constructor:s,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new n([new t(o.inputOutput,"metadata",new e.SFNode),new t(o.inputOutput,"enabled",new e.SFBool(!0)),new t(o.inputOutput,"force",new e.SFVec3f(0,-9.8,0))]),getTypeName:function(){return"ForcePhysicsModel"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"physics"},addForce:function(){const e=new r(0,0,0);return function(t,n,i,o){return!!this._enabled.getValue()&&(o.set(e.assign(this._force.getValue()).multiply(i),4*t),o[4*t+3]=0,!0)}}()}),s})),t("standard/Math/Utility/BVH",["standard/Math/Numbers/Vector3","standard/Math/Geometry/Plane3","standard/Math/Algorithms/QuickSort"],(function(e,t,n){"use strict";const i=new e(0,0,0),o=new e(0,0,0),r=new e(0,0,0),s={u:0,v:0,t:0},a=[new e(0,0,1),new e(0,0,-1),new e(0,1,0),new e(0,-1,0),new e(1,0,0)];function c(e,t){this.vertices=e.vertices,this.normals=e.normals,this.triangle=t,this.i4=12*t,this.i3=9*t}function l(n,s,u,d){this.min=new e(0,0,0),this.max=new e(0,0,0),this.planes=[],this.intersection=new e(0,0,0);const m=n.vertices,h=this.min,p=this.max,f=u+d;let x=12*s[u];h.set(m[x],m[x+1],m[x+2]),p.assign(h);for(let e=u;e<f;++e)x=12*s[e],i.set(m[x],m[x+1],m[x+2]),o.set(m[x+4],m[x+5],m[x+6]),r.set(m[x+8],m[x+9],m[x+10]),h.min(i,o,r),p.max(i,o,r);for(let e=0;e<5;++e)this.planes[e]=new t(e%2?h:p,a[e]);if(d>2){n.sorter.compare.axis=this.getLongestAxis(h,p),n.sorter.sort(u,f);var _=d>>>1}else _=1;const y=d-_;this.left=_>1?new l(n,s,u,_):new c(n,s[u]),this.right=y>1?new l(n,s,u+_,y):new c(n,s[u+_])}function u(e,t){const i=e.length/12;switch(this.vertices=e,this.normals=t,i){case 0:this.root=null;break;case 1:this.root=new c(this,0);break;default:{const t=[];for(let e=0;e<i;++e)t.push(e);this.sorter=new n(t,function(e,t){return function(n,i){return Math.min(e[n+t],e[n+4+t],e[n+8+t])<Math.min(e[i+t],e[i+4+t],e[i+8+t])}}(e,0)),this.root=new l(this,t,0,i);break}}}return c.prototype={intersectsLine:function(t,n,a){const c=this.vertices,l=this.normals,u=this.i4,d=this.i3;if(i.x=c[u],i.y=c[u+1],i.z=c[u+2],o.x=c[u+4],o.y=c[u+5],o.z=c[u+6],r.x=c[u+8],r.y=c[u+9],r.z=c[u+10],t.intersectsTriangle(i,o,r,s)){const t=s.u,i=s.v,o=1-t-i,r=n.size++;r>=n.length&&n.push(new e(0,0,0)),n[r].set(o*c[u]+t*c[u+4]+i*c[u+8],o*c[u+1]+t*c[u+5]+i*c[u+9],o*c[u+2]+t*c[u+6]+i*c[u+10]),a&&(r>=a.length&&a.push(new e(0,0,0)),a[r].set(o*l[d]+t*l[d+3]+i*l[d+6],o*l[d+1]+t*l[d+4]+i*l[d+7],o*l[d+2]+t*l[d+5]+i*l[d+8]))}},toArray:function(e){const t=e.length/4;return e.push(1,3*this.triangle,0,0),t}},l.prototype={intersectsLine:function(e,t,n){this.intersectsBBox(e)&&(this.left.intersectsLine(e,t,n),this.right.intersectsLine(e,t,n))},intersectsBBox:function(e){const t=this.planes,n=this.min,i=this.max,o=n.x,r=i.x,s=n.y,a=i.y,c=n.z,l=i.z,u=this.intersection;return!!(t[0].intersectsLine(e,u)&&u.x>=o&&u.x<=r&&u.y>=s&&u.y<=a)||(!!(t[1].intersectsLine(e,u)&&u.x>=o&&u.x<=r&&u.y>=s&&u.y<=a)||(!!(t[2].intersectsLine(e,u)&&u.x>=o&&u.x<=r&&u.z>=c&&u.z<=l)||(!!(t[3].intersectsLine(e,u)&&u.x>=o&&u.x<=r&&u.z>=c&&u.z<=l)||!!(t[4].intersectsLine(e,u)&&u.y>=s&&u.y<=a&&u.z>=c&&u.z<=l))))},getLongestAxis:function(e,t){const n=t.x-e.x,i=t.y-e.y,o=t.z-e.z;return n<i?i<o?2:1:n<o?2:0},toArray:function(e){const t=this.left.toArray(e),n=this.right.toArray(e),i=this.min,o=this.max,r=e.length/4;return e.push(0,t,n,0,i.x,i.y,i.z,0,o.x,o.y,o.z,0),r}},u.prototype={constructor:u,intersectsLine:function(e,t,n){return t.size=0,this.root?(this.root.intersectsLine(e,t,n),t.size):0},toArray:function(e){if(this.root){const t=this.root.toArray(e);e.push(t,0,0,0)}return e}},u})),t("x_ite/Components/ParticleSystems/ParticleSystem",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/Shape/X3DShapeNode","x_ite/Browser/ParticleSystems/GeometryTypes","x_ite/Rendering/VertexArray","x_ite/Rendering/TraverseType","x_ite/Base/X3DConstants","x_ite/Base/X3DCast","x_ite/Browser/Shape/AlphaMode","standard/Math/Numbers/Vector3","standard/Math/Numbers/Matrix4","standard/Math/Numbers/Matrix3","standard/Math/Utility/BVH"],(function(e,t,n,i,o,r,s,a,c,l,u,d,m,h){"use strict";const p=new Float32Array([0,0,0,1]),f=new Float32Array([0,0,0,1,1,0,0,1,0,0,-.5,1,0,0,.5,1]),x=new Float32Array([0,0,0,1,1,0,0,1,1,1,0,1,0,0,0,1,1,1,0,1,0,1,0,1,0,0,1,-.5,-.5,0,1,.5,-.5,0,1,.5,.5,0,1,-.5,-.5,0,1,.5,.5,0,1,-.5,.5,0,1]);function _(e){i.call(this,e),this.addType(a.ParticleSystem),this._particleSize.setUnit("length"),this.maxParticles=0,this.numParticles=0,this.forcePhysicsModelNodes=[],this.forces=new Float32Array(4),this.boundedPhysicsModelNodes=[],this.boundedNormals=[],this.boundedVertices=[],this.colorRamp=new Float32Array,this.texCoordRamp=new Float32Array,this.geometryContext={},this.creationTime=0,this.pauseTime=0,this.deltaTime=0,this.particleStride=7*Float32Array.BYTES_PER_ELEMENT*4,this.particleOffsets=Array.from({length:7},((e,t)=>4*Float32Array.BYTES_PER_ELEMENT*t)),this.particleOffset=this.particleOffsets[0],this.colorOffset=this.particleOffsets[1],this.matrixOffset=this.particleOffsets[3],this.texCoordOffset=0}return _.prototype=Object.assign(Object.create(i.prototype),{constructor:_,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new n([new t(a.inputOutput,"metadata",new e.SFNode),new t(a.inputOutput,"enabled",new e.SFBool(!0)),new t(a.inputOutput,"createParticles",new e.SFBool(!0)),new t(a.initializeOnly,"geometryType",new e.SFString("QUAD")),new t(a.inputOutput,"maxParticles",new e.SFInt32(200)),new t(a.inputOutput,"particleLifetime",new e.SFFloat(5)),new t(a.inputOutput,"lifetimeVariation",new e.SFFloat(.25)),new t(a.inputOutput,"particleSize",new e.SFVec2f(.02,.02)),new t(a.initializeOnly,"emitter",new e.SFNode),new t(a.initializeOnly,"physics",new e.MFNode),new t(a.initializeOnly,"colorKey",new e.MFFloat),new t(a.initializeOnly,"colorRamp",new e.SFNode),new t(a.initializeOnly,"texCoordKey",new e.MFFloat),new t(a.initializeOnly,"texCoordRamp",new e.SFNode),new t(a.outputOnly,"isActive",new e.SFBool),new t(a.inputOutput,"visible",new e.SFBool(!0)),new t(a.inputOutput,"castShadow",new e.SFBool(!0)),new t(a.inputOutput,"bboxDisplay",new e.SFBool),new t(a.initializeOnly,"bboxSize",new e.SFVec3f(-1,-1,-1)),new t(a.initializeOnly,"bboxCenter",new e.SFVec3f),new t(a.inputOutput,"appearance",new e.SFNode),new t(a.inputOutput,"geometry",new e.SFNode)]),getTypeName:function(){return"ParticleSystem"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"children"},initialize:function(){i.prototype.initialize.call(this);const e=this.getBrowser();e.getContext();e.getContext().getVersion()<2||(this.isLive().addInterest("set_live__",this),e.getBrowserOptions()._Shading.addInterest("set_shader__",this),this._enabled.addInterest("set_enabled__",this),this._createParticles.addInterest("set_createParticles__",this),this._geometryType.addInterest("set_geometryType__",this),this._geometryType.addInterest("set_texCoord__",this),this._maxParticles.addInterest("set_enabled__",this),this._particleLifetime.addInterest("set_particleLifetime__",this),this._lifetimeVariation.addInterest("set_lifetimeVariation__",this),this._emitter.addInterest("set_emitter__",this),this._physics.addInterest("set_physics__",this),this._colorKey.addInterest("set_color__",this),this._colorRamp.addInterest("set_colorRamp__",this),this._texCoordKey.addInterest("set_texCoord__",this),this._texCoordRamp.addInterest("set_texCoordRamp__",this),this.inputParticles=this.createBuffer(),this.outputParticles=this.createBuffer(),this.inputParticles.emitterArrayObject=new r,this.inputParticles.vertexArrayObject=new r,this.inputParticles.shadowArrayObject=new r,this.outputParticles.emitterArrayObject=new r,this.outputParticles.vertexArrayObject=new r,this.outputParticles.shadowArrayObject=new r,this.forcesTexture=this.createTexture(),this.boundedTexture=this.createTexture(),this.colorRampTexture=this.createTexture(),this.texCoordRampTexture=this.createTexture(),this.geometryBuffer=this.createBuffer(),this.texCoordBuffers=new Array(e.getMaxTextures()).fill(this.geometryBuffer),this.geometryContext.fogCoords=!1,this.geometryContext.textureCoordinateNode=e.getDefaultTextureCoordinate(),this.geometryContext.textureCoordinateMapping=new Map,this.set_emitter__(),this.set_enabled__(),this.set_geometryType__(),this.set_createParticles__(),this.set_particleLifetime__(),this.set_lifetimeVariation__(),this.set_physics__(),this.set_colorRamp__(),this.set_texCoordRamp__())},set_bbox__:function(){this._bboxSize.getValue().equals(this.getDefaultBBoxSize())?this.bbox.set():this.bbox.set(this._bboxSize.getValue(),this._bboxCenter.getValue()),this.bboxSize.assign(this.bbox.size),this.bboxCenter.assign(this.bbox.center)},set_transparent__:function(){if(this.getAppearance().getAlphaMode()===l.AUTO)if(this.geometryType===o.POINT)this.setTransparent(!0);else this.setTransparent(this.getAppearance().getTransparent()||this.colorRampNode&&this.colorRampNode.getTransparent()||this.geometryType===o.GEOMETRY&&this.geometryNode&&this.geometryNode.getTransparent());else this.setTransparent(this.getAppearance().getTransparent())},set_live__:function(){this.isLive().getValue()?this._isActive.getValue()&&this._maxParticles.getValue()&&(this.getBrowser().sensorEvents().addInterest("animateParticles",this),this.pauseTime&&(this.creationTime+=performance.now()/1e3-this.pauseTime,this.pauseTime=0)):this._isActive.getValue()&&this._maxParticles.getValue()&&(this.getBrowser().sensorEvents().removeInterest("animateParticles",this),0===this.pauseTime&&(this.pauseTime=performance.now()/1e3))},set_enabled__:function(){this._enabled.getValue()&&this._maxParticles.getValue()?this._isActive.getValue()||(this.isLive().getValue()?(this.getBrowser().sensorEvents().addInterest("animateParticles",this),this.pauseTime=0):this.pauseTime=performance.now()/1e3,this._isActive=!0,delete this.traverse):this._isActive.getValue()&&(this.isLive().getValue()&&this.getBrowser().sensorEvents().removeInterest("animateParticles",this),this._isActive=!1,this.numParticles=0,this.traverse=Function.prototype),this.set_maxParticles__()},set_createParticles__:function(){this.createParticles=this._createParticles.getValue()},set_geometryType__:function(){const e=this.getBrowser().getContext();switch(this.geometryType=o.hasOwnProperty(this._geometryType.getValue())?o[this._geometryType.getValue()]:o.QUAD,this.geometryType){case o.POINT:this.geometryContext.geometryType=0,this.texCoordCount=0,this.vertexCount=1,this.hasNormals=!1,this.primitiveMode=e.POINTS,this.verticesOffset=0,e.bindBuffer(e.ARRAY_BUFFER,this.geometryBuffer),e.bufferData(e.ARRAY_BUFFER,p,e.DYNAMIC_DRAW);break;case o.LINE:this.geometryContext.geometryType=1,this.texCoordCount=2,this.vertexCount=2,this.hasNormals=!1,this.primitiveMode=e.LINES,this.texCoordsOffset=0,this.verticesOffset=8*Float32Array.BYTES_PER_ELEMENT,e.bindBuffer(e.ARRAY_BUFFER,this.geometryBuffer),e.bufferData(e.ARRAY_BUFFER,f,e.DYNAMIC_DRAW);break;case o.TRIANGLE:case o.QUAD:case o.SPRITE:this.geometryContext.geometryType=2,this.texCoordCount=4,this.vertexCount=6,this.hasNormals=!0,this.primitiveMode=e.TRIANGLES,this.texCoordsOffset=0,this.normalOffset=24*Float32Array.BYTES_PER_ELEMENT,this.verticesOffset=27*Float32Array.BYTES_PER_ELEMENT,e.bindBuffer(e.ARRAY_BUFFER,this.geometryBuffer),e.bufferData(e.ARRAY_BUFFER,x,e.DYNAMIC_DRAW);break;case o.GEOMETRY:this.texCoordCount=0,this.vertexCount=0}this.updateVertexArrays(),this.set_shader__(),this.set_transparent__()},set_shader__:function(){switch(this.geometryType){case o.POINT:this.shaderNode=this.getBrowser().getPointShader();break;case o.LINE:this.shaderNode=this.getBrowser().getLineShader();break;default:this.shaderNode=null}},set_maxParticles__:function(){const e=this.numParticles,t=Math.max(0,this._maxParticles.getValue());this.maxParticles=t,this.numParticles=Math.min(e,t),this.emitterNode.isExplosive()||(this.creationTime=performance.now()/1e3),this.resizeBuffers(e),this.updateVertexArrays()},set_particleLifetime__:function(){this.particleLifetime=this._particleLifetime.getValue()},set_lifetimeVariation__:function(){this.lifetimeVariation=this._lifetimeVariation.getValue()},set_emitter__:function(){this.emitterNode=c(a.X3DParticleEmitterNode,this._emitter),this.emitterNode||(this.emitterNode=this.getBrowser().getDefaultEmitter()),this.createParticles=this._createParticles.getValue()},set_physics__:function(){const e=this._physics.getValue(),t=this.forcePhysicsModelNodes,n=this.boundedPhysicsModelNodes;for(let e=0,t=n.length;e<t;++e)n[e].removeInterest("set_boundedPhysics__",this);t.length=0,n.length=0;for(let i=0,o=e.length;i<o;++i)try{const o=e[i].getValue().getInnerNode(),r=o.getType();for(let e=r.length-1;e>=0;--e){switch(r[e]){case a.ForcePhysicsModel:case a.WindPhysicsModel:t.push(o);break;case a.BoundedPhysicsModel:o.addInterest("set_boundedPhysics__",this),n.push(o);break;default:continue}break}}catch(e){}this.set_boundedPhysics__()},set_boundedPhysics__:function(){const e=this.getBrowser().getContext(),t=this.boundedPhysicsModelNodes,n=this.boundedNormals,i=this.boundedVertices;n.length=0,i.length=0;for(let e=0,o=t.length;e<o;++e)t[e].addGeometry(n,i);const o=new h(i,n).toArray([]),r=i.length/4,s=n.length/3,a=o.length/4,c=Math.ceil(Math.sqrt(r+s+a)),l=new Float32Array(c*c*4);this.boundedVerticesIndex=0,this.boundedNormalsIndex=r,this.boundedHierarchyIndex=this.boundedNormalsIndex+s,this.boundedHierarchyRoot=this.boundedHierarchyIndex+a-1,l.set(i);for(let e=4*this.boundedNormalsIndex,t=0,i=n.length;t<i;e+=4,t+=3)l[e+0]=n[t+0],l[e+1]=n[t+1],l[e+2]=n[t+2];l.set(o,4*this.boundedHierarchyIndex),c&&(e.bindTexture(e.TEXTURE_2D,this.boundedTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,c,c,0,e.RGBA,e.FLOAT,l))},set_colorRamp__:function(){this.colorRampNode&&this.colorRampNode.removeInterest("set_color__",this),this.colorRampNode=c(a.X3DColorNode,this._colorRamp),this.colorRampNode&&this.colorRampNode.addInterest("set_color__",this),this.set_color__(),this.set_transparent__()},set_color__:function(){const e=this.getBrowser().getContext(),t=this._colorKey,n=t.length,i=Math.ceil(Math.sqrt(2*n));let o=this.colorRamp;i*i*4>o.length&&(o=this.colorRamp=new Float32Array(i*i*4));for(let e=0;e<n;++e)o[4*e]=t[e];this.colorRampNode?o.set(this.colorRampNode.addColors([],n).slice(0,4*n),4*n):o.fill(1,4*n),i&&(e.bindTexture(e.TEXTURE_2D,this.colorRampTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,i,i,0,e.RGBA,e.FLOAT,o)),this.numColors=n,this.geometryContext.colorMaterial=!(!n||!this.colorRampNode),this.updateVertexArrays()},set_texCoordRamp__:function(){this.texCoordRampNode&&this.texCoordRampNode.removeInterest("set_texCoord__",this),this.texCoordRampNode=c(a.X3DTextureCoordinateNode,this._texCoordRamp),this.texCoordRampNode&&this.texCoordRampNode.addInterest("set_texCoord__",this),this.set_texCoord__()},set_texCoord__:function(){const e=this.getBrowser().getContext(),t=this._texCoordKey,n=t.length,i=Math.ceil(Math.sqrt(n+n*this.texCoordCount));let o=this.texCoordRamp;i*i*4>o.length?o=this.texCoordRamp=new Float32Array(i*i*4):o.fill(0);for(let e=0;e<n;++e)o[4*e]=t[e];this.texCoordRampNode&&o.set(this.texCoordRampNode.getTexCoord([]).slice(0,n*this.texCoordCount*4),4*n),i&&(e.bindTexture(e.TEXTURE_2D,this.texCoordRampTexture),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,i,i,0,e.RGBA,e.FLOAT,o)),this.numTexCoords=this.texCoordRampNode?n:0,this.updateVertexArrays()},updateVertexArrays:function(){this.inputParticles.vertexArrayObject.update(),this.inputParticles.shadowArrayObject.update(),this.inputParticles.emitterArrayObject.update(),this.outputParticles.vertexArrayObject.update(),this.outputParticles.shadowArrayObject.update(),this.outputParticles.emitterArrayObject.update()},createTexture:function(){const e=this.getBrowser().getContext(),t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,1,1,0,e.RGBA,e.FLOAT,new Float32Array(4)),t},createBuffer:function(){const e=this.getBrowser().getContext(),t=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,new Uint32Array,e.DYNAMIC_DRAW),t},resizeBuffers:function(e){const t=this.getBrowser().getContext(),n=this.maxParticles,i=this.particleStride,o=Object.assign(t.createBuffer(),this.outputParticles),r=new Uint8Array(n*i);t.bindBuffer(t.ARRAY_BUFFER,this.inputParticles),t.bufferData(t.ARRAY_BUFFER,r,t.DYNAMIC_DRAW),t.bindBuffer(t.COPY_READ_BUFFER,this.outputParticles),t.bindBuffer(t.ARRAY_BUFFER,o),t.bufferData(t.ARRAY_BUFFER,r,t.DYNAMIC_DRAW),t.copyBufferSubData(t.COPY_READ_BUFFER,t.ARRAY_BUFFER,0,0,Math.min(n*i,e*i)),t.deleteBuffer(this.outputParticles),this.outputParticles=o},animateParticles:function(){const e=this.getBrowser(),t=e.getContext(),n=this.emitterNode,i=1/Math.max(10,this.getBrowser().getCurrentFrameRate());let o=this.deltaTime=(14*this.deltaTime+i)/15;if(n.isExplosive()){const e=performance.now()/1e3,t=this.particleLifetime+this.particleLifetime*this.lifetimeVariation;0===this.numParticles||e-this.creationTime>t?(this.creationTime=e,this.numParticles=this.maxParticles,this.createParticles=this._createParticles.getValue(),o=Number.POSITIVE_INFINITY):this.createParticles=!1}else if(this.numParticles<this.maxParticles){const e=performance.now()/1e3,t=Math.max(0,Math.floor((e-this.creationTime)*this.maxParticles/this.particleLifetime));t&&(this.creationTime=e),this.numParticles=Math.floor(Math.min(this.maxParticles,this.numParticles+t))}if(n.getMass()){const e=this.forcePhysicsModelNodes;let i=e.length,r=this.forces,s=o/n.getMass();4*i>r.length&&(r=this.forces=new Float32Array(4*i));let a=0;for(let t=0;t<i;++t)a+=!e[t].addForce(t-a,n,s,r);this.numForces=i-=a,i&&(t.bindTexture(t.TEXTURE_2D,this.forcesTexture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA32F,i,1,0,t.RGBA,t.FLOAT,r))}else this.numForces=0;const r=this.outputParticles;this.outputParticles=this.inputParticles,this.inputParticles=r,n.animate(this,o),e.addBrowserEvent()},updateSprite:function(){const e=new Float32Array(x),t=[new u(-.5,-.5,0),new u(.5,-.5,0),new u(.5,.5,0),new u(-.5,-.5,0),new u(.5,.5,0),new u(-.5,.5,0)],n=new u(0,0,0),i=new u(0,0,0);return function(o,r){for(let t=0;t<3;++t)e[24+t]=r[6+t];i.set(this._particleSize.x,this._particleSize.y,1);for(let o=0;o<6;++o){const s=27+4*o;r.multVecMatrix(n.assign(t[o]).multVec(i)),e[s+0]=n.x,e[s+1]=n.y,e[s+2]=n.z}o.bindBuffer(o.ARRAY_BUFFER,this.geometryBuffer),o.bufferData(o.ARRAY_BUFFER,e,o.DYNAMIC_DRAW)}}(),intersectsBox:function(e,t){},traverse:function(e,t){if(0!==this.numParticles){switch(e){case s.POINTER:case s.PICKING:case s.COLLISION:break;case s.SHADOW:this._castShadow.getValue()&&t.addDepthShape(this);break;case s.DISPLAY:t.addDisplayShape(this)&&this.getAppearance().traverse(e,t)}this.geometryType===o.GEOMETRY&&this.getGeometry()&&this.getGeometry().traverse(e,t)}},depth:function(e,t,n){switch(this.geometryType){case o.GEOMETRY:{const i=this.getGeometry();i&&i.displayParticlesDepth(e,t,n,this);break}case o.SPRITE:this.updateSprite(e,this.getScreenAlignedRotation(t.modelViewMatrix));default:{const t=this.outputParticles;if(t.shadowArrayObject.enable(e,n)){const i=this.particleStride;n.enableParticleAttribute(e,t,i,this.particleOffset,1),n.enableParticleMatrixAttribute(e,t,i,this.matrixOffset,1),n.enableVertexAttribute(e,this.geometryBuffer,0,this.verticesOffset)}e.drawArraysInstanced(this.primitiveMode,0,this.vertexCount,this.numParticles);break}}},display:function(e,t){switch(this.geometryType){case o.GEOMETRY:{const n=this.getGeometry();n&&n.displayParticles(e,t,this);break}case o.SPRITE:this.updateSprite(e,this.getScreenAlignedRotation(t.modelViewMatrix));case o.QUAD:case o.TRIANGLE:{const n=d.prototype.determinant3.call(t.modelViewMatrix)>0;e.frontFace(n?e.CCW:e.CW),e.enable(e.CULL_FACE),e.cullFace(e.BACK)}default:{const n=this.getAppearance(),i=n.shaderNode||this.shaderNode||n.materialNode.getShader(t.browser,t.shadow),o=i.getPrimitiveMode(this.primitiveMode);if(i.isValid()){t.geometryContext=this.geometryContext;const r=n.blendModeNode;if(r&&r.enable(e),i.enable(e),i.setLocalUniforms(e,t),this.numTexCoords){const n=t.browser.getTexture2DUnit();e.activeTexture(e.TEXTURE0+n),e.bindTexture(e.TEXTURE_2D,this.texCoordRampTexture),e.uniform1i(i.x3d_TexCoordRamp,n)}const s=this.outputParticles;if(s.vertexArrayObject.enable(e,i)){const t=this.particleStride;i.enableParticleAttribute(e,s,t,this.particleOffset,1),i.enableParticleMatrixAttribute(e,s,t,this.matrixOffset,1),this.geometryContext.colorMaterial&&(i.enableColorAttribute(e,s,t,this.colorOffset),i.colorAttributeDivisor(e,1)),this.texCoordCount&&i.enableTexCoordAttribute(e,this.texCoordBuffers,0,this.texCoordOffset),this.hasNormals&&(i.enableNormalAttribute(e,this.geometryBuffer,0,this.normalOffset),i.normalAttributeDivisor(e,this.maxParticles)),i.enableVertexAttribute(e,this.geometryBuffer,0,this.verticesOffset)}e.drawArraysInstanced(o,0,this.vertexCount,this.numParticles),r&&r.disable(e),delete t.geometryContext}break}}},getScreenAlignedRotation:function(){const e=new d,t=new u(0,0,0),n=new u(0,0,0),i=new u(0,0,0),o=new m(9);return function(r){e.assign(r).inverse(),e.multDirMatrix(t.assign(u.zAxis)),e.multDirMatrix(n.assign(u.yAxis));const s=n.cross(t);i.assign(t).cross(s);const a=t;return s.normalize(),i.normalize(),a.normalize(),o.set(s.x,s.y,s.z,i.x,i.y,i.z,a.x,a.y,a.z),o}}()}),_})),t("x_ite/Components/ParticleSystems/PolylineEmitter",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticleEmitterNode","x_ite/Components/Rendering/IndexedLineSet","x_ite/Base/X3DConstants","standard/Math/Numbers/Vector3"],(function(e,t,n,i,o,r,s){"use strict";function a(e){i.call(this,e),this.addType(r.PolylineEmitter),this.polylinesNode=new o(e),this.polylinesArray=new Float32Array,this.addSampler("polylines"),this.addUniform("direction","uniform vec3 direction;"),this.addUniform("verticesIndex","uniform int verticesIndex;"),this.addUniform("polylines","uniform sampler2D polylines;"),this.addFunction("vec3 getRandomVelocity ()\n {\n if (direction == vec3 (0.0))\n return getRandomSphericalVelocity ();\n\n else\n return direction * getRandomSpeed ();\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n if (verticesIndex < 0)\n {\n return vec4 (NaN);\n }\n else\n {\n // Determine index0, index1 and weight.\n\n float lastLengthSoFar = texelFetch (polylines, verticesIndex - 1, 0) .x;\n float fraction = random () * lastLengthSoFar;\n\n int index0 = 0;\n int index1 = 0;\n float weight = 0.0;\n\n interpolate (polylines, verticesIndex, fraction, index0, index1, weight);\n\n // Interpolate and return position.\n\n index0 *= 2;\n index1 = index0 + 1;\n\n vec4 vertex0 = texelFetch (polylines, verticesIndex + index0, 0);\n vec4 vertex1 = texelFetch (polylines, verticesIndex + index1, 0);\n\n return mix (vertex0, vertex1, weight);\n }\n }")}return a.prototype=Object.assign(Object.create(i.prototype),{constructor:a,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new n([new t(r.inputOutput,"metadata",new e.SFNode),new t(r.inputOutput,"on",new e.SFBool(!0)),new t(r.inputOutput,"direction",new e.SFVec3f(0,1,0)),new t(r.inputOutput,"speed",new e.SFFloat),new t(r.inputOutput,"variation",new e.SFFloat(.25)),new t(r.inputOutput,"mass",new e.SFFloat),new t(r.inputOutput,"surfaceArea",new e.SFFloat),new t(r.inputOutput,"coordIndex",new e.MFInt32(-1)),new t(r.inputOutput,"coord",new e.SFNode)]),getTypeName:function(){return"PolylineEmitter"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"emitter"},initialize:function(){i.prototype.initialize.call(this);this.getBrowser().getContext().getVersion()<2||(this.polylinesTexture=this.createTexture(),this._direction.addInterest("set_direction__",this),this._coordIndex.addFieldInterest(this.polylinesNode._coordIndex),this._coord.addFieldInterest(this.polylinesNode._coord),this.polylinesNode._coordIndex=this._coordIndex,this.polylinesNode._coord=this._coord,this.polylinesNode._rebuild.addInterest("set_polyline",this),this.polylinesNode.setPrivate(!0),this.polylinesNode.setup(),this.set_direction__(),this.set_polyline())},set_direction__:function(){const e=new s(0,0,0);return function(){e.assign(this._direction.getValue()).normalize(),this.setUniform("uniform3f","direction",e.x,e.y,e.z)}}(),set_polyline:function(){const e=new s(0,0,0),t=new s(0,0,0);return function(){const n=this.getBrowser().getContext(),i=this.polylinesNode.getVertices().getValue(),o=i.length/4,r=o/2+1,s=Math.ceil(Math.sqrt(r+o)),a=r;let c=this.polylinesArray;c.length<s*s*4&&(c=this.polylinesArray=new Float32Array(s*s*4));let l=0;for(let n=0,o=i.length;n<o;n+=8)e.set(i[n],i[n+1],i[n+2]),t.set(i[n+4],i[n+5],i[n+6]),c[n/2+4]=l+=t.subtract(e).magnitude();c.set(i,4*a),this.setUniform("uniform1i","verticesIndex",o?a:-1),s&&(n.bindTexture(n.TEXTURE_2D,this.polylinesTexture),n.texImage2D(n.TEXTURE_2D,0,n.RGBA32F,s,s,0,n.RGBA,n.FLOAT,c))}}(),activateTextures:function(e,t){e.activeTexture(e.TEXTURE0+t.polylinesTextureUnit),e.bindTexture(e.TEXTURE_2D,this.polylinesTexture)}}),a})),t("x_ite/Components/ParticleSystems/SurfaceEmitter",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticleEmitterNode","x_ite/Base/X3DConstants","x_ite/Base/X3DCast","standard/Math/Geometry/Triangle3","standard/Math/Numbers/Vector3"],(function(e,t,n,i,o,r,s,a){"use strict";function c(e){i.call(this,e),this.addType(o.SurfaceEmitter),this.surfaceNode=null,this.surfaceArray=new Float32Array,this.addSampler("surface"),this.addUniform("solid","uniform bool solid;"),this.addUniform("verticesIndex","uniform int verticesIndex;"),this.addUniform("normalsIndex","uniform int normalsIndex;"),this.addUniform("surface","uniform sampler2D surface;"),this.addFunction("vec4 position; vec3 getRandomVelocity ()\n {\n if (verticesIndex < 0)\n {\n return vec3 (0.0);\n }\n else\n {\n vec3 normal;\n\n getRandomPointOnSurface (surface, verticesIndex, normalsIndex, position, normal);\n\n if (solid == false && random () > 0.5)\n normal = -normal;\n\n return normal * getRandomSpeed ();\n }\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n return verticesIndex < 0 ? vec4 (NaN) : position;\n }")}return c.prototype=Object.assign(Object.create(i.prototype),{constructor:c,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new n([new t(o.inputOutput,"metadata",new e.SFNode),new t(o.inputOutput,"on",new e.SFBool(!0)),new t(o.inputOutput,"speed",new e.SFFloat),new t(o.inputOutput,"variation",new e.SFFloat(.25)),new t(o.inputOutput,"mass",new e.SFFloat),new t(o.inputOutput,"surfaceArea",new e.SFFloat),new t(o.inputOutput,"surface",new e.SFNode)]),getTypeName:function(){return"SurfaceEmitter"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"emitter"},initialize:function(){i.prototype.initialize.call(this);this.getBrowser().getContext().getVersion()<2||(this.surfaceTexture=this.createTexture(),this._surface.addInterest("set_surface__",this),this.set_surface__())},set_surface__:function(){this.surfaceNode&&(this.surfaceNode._solid.removeInterest("set_solid__",this),this.surfaceNode._rebuild.removeInterest("set_geometry__",this)),this.surfaceNode=r(o.X3DGeometryNode,this._surface),this.surfaceNode&&(this.surfaceNode._solid.addInterest("set_solid__",this),this.surfaceNode._rebuild.addInterest("set_geometry__",this)),this.set_solid__(),this.set_geometry__()},set_solid__:function(){this.surfaceNode&&this.setUniform("uniform1i","solid",this.surfaceNode._solid.getValue())},set_geometry__:function(){const e=new a(0,0,0),t=new a(0,0,0),n=new a(0,0,0);return function(){const i=this.getBrowser().getContext();if(this.surfaceNode){const o=this.surfaceNode.getVertices().getValue(),r=this.surfaceNode.getNormals().getValue(),a=o.length/4,c=a/3+1,l=Math.ceil(Math.sqrt(c+a+a)),u=c,d=u+a;let m=this.surfaceArray;m.length<l*l*4&&(m=this.surfaceArray=new Float32Array(l*l*4));let h=0;for(let i=0,r=o.length;i<r;i+=12)e.set(o[i],o[i+1],o[i+2]),t.set(o[i+4],o[i+5],o[i+6]),n.set(o[i+8],o[i+9],o[i+10]),m[i/3+4]=h+=s.area(e,t,n);m.set(o,4*u);for(let e=4*d,t=0,n=r.length;t<n;e+=4,t+=3)m[e+0]=r[t+0],m[e+1]=r[t+1],m[e+2]=r[t+2];this.setUniform("uniform1i","verticesIndex",a?u:-1),this.setUniform("uniform1i","normalsIndex",a?d:-1),l&&(i.bindTexture(i.TEXTURE_2D,this.surfaceTexture),i.texImage2D(i.TEXTURE_2D,0,i.RGBA32F,l,l,0,i.RGBA,i.FLOAT,m))}else this.setUniform("uniform1i","verticesIndex",-1),this.setUniform("uniform1i","normalsIndex",-1)}}(),activateTextures:function(e,t){e.activeTexture(e.TEXTURE0+t.surfaceTextureUnit),e.bindTexture(e.TEXTURE_2D,this.surfaceTexture)}}),c})),t("x_ite/Components/ParticleSystems/VolumeEmitter",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticleEmitterNode","x_ite/Components/Geometry3D/IndexedFaceSet","x_ite/Base/X3DConstants","standard/Math/Numbers/Vector3","standard/Math/Geometry/Triangle3","standard/Math/Utility/BVH"],(function(e,t,n,i,o,r,s,a,c){"use strict";function l(e){i.call(this,e),this.addType(r.VolumeEmitter),this.volumeNode=new o(e),this.volumeArray=new Float32Array,this.addSampler("volume"),this.addUniform("direction","uniform vec3 direction;"),this.addUniform("verticesIndex","uniform int verticesIndex;"),this.addUniform("normalsIndex","uniform int normalsIndex;"),this.addUniform("hierarchyIndex","uniform int hierarchyIndex;"),this.addUniform("hierarchyRoot","uniform int hierarchyRoot;"),this.addUniform("volume","uniform sampler2D volume;"),this.addFunction("vec3 getRandomVelocity ()\n {\n if (hierarchyRoot < 0)\n {\n return vec3 (0.0);\n }\n else\n {\n if (direction == vec3 (0.0))\n return getRandomSphericalVelocity ();\n\n else\n return direction * getRandomSpeed ();\n }\n }"),this.addFunction("vec4 getRandomPosition ()\n {\n if (hierarchyRoot < 0)\n {\n return vec4 (NaN);\n }\n else\n {\n vec4 point;\n vec3 normal;\n\n getRandomPointOnSurface (volume, verticesIndex, normalsIndex, point, normal);\n\n Line3 line = Line3 (point .xyz, getRandomSurfaceNormal (normal));\n\n vec4 points [ARRAY_SIZE];\n\n int numIntersections = getIntersections (volume, verticesIndex, hierarchyIndex, hierarchyRoot, line, points);\n\n numIntersections -= numIntersections % 2; // We need an even count of intersections.\n\n switch (numIntersections)\n {\n case 0:\n return vec4 (0.0);\n case 2:\n break;\n default:\n sort (points, numIntersections, plane3 (line .point, line .direction));\n break;\n }\n\n int index = int (fract (random ()) * float (numIntersections / 2)) * 2; // Select random intersection.\n\n return mix (points [index], points [index + 1], random ());\n }\n }")}return l.prototype=Object.assign(Object.create(i.prototype),{constructor:l,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new n([new t(r.inputOutput,"metadata",new e.SFNode),new t(r.inputOutput,"on",new e.SFBool(!0)),new t(r.inputOutput,"internal",new e.SFBool(!0)),new t(r.inputOutput,"direction",new e.SFVec3f(0,1,0)),new t(r.inputOutput,"speed",new e.SFFloat),new t(r.inputOutput,"variation",new e.SFFloat(.25)),new t(r.inputOutput,"mass",new e.SFFloat),new t(r.inputOutput,"surfaceArea",new e.SFFloat),new t(r.inputOutput,"coordIndex",new e.MFInt32(-1)),new t(r.inputOutput,"coord",new e.SFNode)]),getTypeName:function(){return"VolumeEmitter"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"emitter"},initialize:function(){i.prototype.initialize.call(this);this.getBrowser().getContext().getVersion()<2||(this.volumeTexture=this.createTexture(),this._direction.addInterest("set_direction__",this),this._coordIndex.addFieldInterest(this.volumeNode._coordIndex),this._coord.addFieldInterest(this.volumeNode._coord),this.volumeNode._creaseAngle=Math.PI,this.volumeNode._convex=!1,this.volumeNode._coordIndex=this._coordIndex,this.volumeNode._coord=this._coord,this.volumeNode._rebuild.addInterest("set_geometry__",this),this.volumeNode.setPrivate(!0),this.volumeNode.setup(),this.set_direction__(),this.set_geometry__())},set_direction__:function(){const e=new s(0,0,0);return function(){e.assign(this._direction.getValue()).normalize(),this.setUniform("uniform3f","direction",e.x,e.y,e.z)}}(),set_geometry__:function(){const e=new s(0,0,0),t=new s(0,0,0),n=new s(0,0,0);return function(){const i=this.getBrowser().getContext(),o=this.volumeNode.getVertices().getValue(),r=this.volumeNode.getNormals().getValue(),s=new c(o,r).toArray([]),l=o.length/4,u=r.length/3,d=l/3+1,m=s.length/4,h=Math.ceil(Math.sqrt(d+l+l+m)),p=d,f=p+l,x=f+u;let _=this.volumeArray;_.length<h*h*4&&(_=this.volumeArray=new Float32Array(h*h*4));let y=0;for(let i=0,r=o.length;i<r;i+=12)e.set(o[i],o[i+1],o[i+2]),t.set(o[i+4],o[i+5],o[i+6]),n.set(o[i+8],o[i+9],o[i+10]),_[i/3+4]=y+=a.area(e,t,n);_.set(o,4*p);for(let e=4*f,t=0,n=r.length;t<n;e+=4,t+=3)_[e+0]=r[t+0],_[e+1]=r[t+1],_[e+2]=r[t+2];_.set(s,4*x),this.setUniform("uniform1i","verticesIndex",p),this.setUniform("uniform1i","normalsIndex",f),this.setUniform("uniform1i","hierarchyIndex",x),this.setUniform("uniform1i","hierarchyRoot",x+m-1),h&&(i.bindTexture(i.TEXTURE_2D,this.volumeTexture),i.texImage2D(i.TEXTURE_2D,0,i.RGBA32F,h,h,0,i.RGBA,i.FLOAT,_))}}(),activateTextures:function(e,t){e.activeTexture(e.TEXTURE0+t.volumeTextureUnit),e.bindTexture(e.TEXTURE_2D,this.volumeTexture)}}),l})),t("x_ite/Components/ParticleSystems/WindPhysicsModel",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode","x_ite/Base/X3DConstants","standard/Math/Numbers/Vector3","standard/Math/Algorithm"],(function(e,t,n,i,o,r,s){"use strict";function a(e){i.call(this,e),this.addType(o.WindPhysicsModel),this._speed.setUnit("speed")}return a.prototype=Object.assign(Object.create(i.prototype),{constructor:a,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new n([new t(o.inputOutput,"metadata",new e.SFNode),new t(o.inputOutput,"enabled",new e.SFBool(!0)),new t(o.inputOutput,"direction",new e.SFVec3f),new t(o.inputOutput,"speed",new e.SFFloat(.1)),new t(o.inputOutput,"gustiness",new e.SFFloat(.1)),new t(o.inputOutput,"turbulence",new e.SFFloat)]),getTypeName:function(){return"WindPhysicsModel"},getComponentName:function(){return"ParticleSystems"},getContainerField:function(){return"physics"},getRandomSpeed:function(e){const t=Math.max(0,this._speed.getValue()),n=t*Math.max(0,this._gustiness.getValue());return e.getRandomValue(Math.max(0,t-n),t+n)},addForce:function(){const e=new r(0,0,0);return function(t,n,i,o){if(this._enabled.getValue()){const a=n._surfaceArea.getValue(),c=this.getRandomSpeed(n),l=.64615*Math.pow(10,2*Math.log(c));return this._direction.getValue().equals(r.Zero)?n.getRandomNormal(e):e.assign(this._direction.getValue()).normalize(),o.set(e.multiply(a*l*i),4*t),o[4*t+3]=Math.PI*s.clamp(this._turbulence.getValue(),0,1),!0}return!1}}()}),a})),t(n.getComponentUrl("particle-systems"),["x_ite/Components","x_ite/Browser/ParticleSystems/X3DParticleSystemsContext","x_ite/Components/ParticleSystems/BoundedPhysicsModel","x_ite/Components/ParticleSystems/ConeEmitter","x_ite/Components/ParticleSystems/ExplosionEmitter","x_ite/Components/ParticleSystems/ForcePhysicsModel","x_ite/Components/ParticleSystems/ParticleSystem","x_ite/Components/ParticleSystems/PointEmitter","x_ite/Components/ParticleSystems/PolylineEmitter","x_ite/Components/ParticleSystems/SurfaceEmitter","x_ite/Components/ParticleSystems/VolumeEmitter","x_ite/Components/ParticleSystems/WindPhysicsModel","x_ite/Components/ParticleSystems/X3DParticleEmitterNode","x_ite/Components/ParticleSystems/X3DParticlePhysicsModelNode"],(function(e,t,n,i,o,r,s,a,c,l,u,d,m,h){"use strict";e.addComponent({name:"ParticleSystems",types:{BoundedPhysicsModel:n,ConeEmitter:i,ExplosionEmitter:o,ForcePhysicsModel:r,ParticleSystem:s,PointEmitter:a,PolylineEmitter:c,SurfaceEmitter:l,VolumeEmitter:u,WindPhysicsModel:d},abstractTypes:{X3DParticleEmitterNode:m,X3DParticlePhysicsModelNode:h},context:t})}))}();
@@ -4,8 +4,9 @@
4
4
  var module = { }, exports, process;
5
5
 
6
6
  const
7
- define = window [Symbol .for ("X_ITE.X3D-5.0.3")] .define,
8
- require = window [Symbol .for ("X_ITE.X3D-5.0.3")] .require;
7
+ X3D = window [Symbol .for ("X_ITE.X3D-6.1.0")],
8
+ define = X3D .define,
9
+ require = X3D .require;
9
10
  /* -*- Mode: JavaScript; coding: utf-8; tab-width: 3; indent-tabs-mode: tab; c-basic-offset: 3 -*-
10
11
  *******************************************************************************
11
12
  *
@@ -883,58 +884,50 @@ function (Fields,
883
884
 
884
885
  for (var t = 0, tLength = targets .size; t < tLength; ++ t)
885
886
  {
886
- try
887
- {
888
- var
889
- target = targets [t],
890
- geometryNode = target .geometryNode,
891
- vertices = this .pickingGeometryNode .getVertices ();
887
+ var
888
+ target = targets [t],
889
+ geometryNode = target .geometryNode,
890
+ vertices = this .pickingGeometryNode .getVertices ();
892
891
 
893
- targetBBox .assign (geometryNode .getBBox ()) .multRight (target .modelMatrix);
894
- matrix .assign (target .modelMatrix) .inverse () .multLeft (modelMatrix);
892
+ targetBBox .assign (geometryNode .getBBox ()) .multRight (target .modelMatrix);
893
+ matrix .assign (target .modelMatrix) .inverse () .multLeft (modelMatrix);
895
894
 
896
- for (var v = 0, vLength = vertices .length; v < vLength; v += 8)
897
- {
898
- matrix .multVecMatrix (point1 .set (vertices [v + 0], vertices [v + 1], vertices [v + 2]));
899
- matrix .multVecMatrix (point2 .set (vertices [v + 4], vertices [v + 5], vertices [v + 6]));
900
- line .setPoints (point1, point2);
895
+ for (var v = 0, vLength = vertices .length; v < vLength; v += 8)
896
+ {
897
+ matrix .multVecMatrix (point1 .set (vertices [v + 0], vertices [v + 1], vertices [v + 2]));
898
+ matrix .multVecMatrix (point2 .set (vertices [v + 4], vertices [v + 5], vertices [v + 6]));
899
+ line .setPoints (point1, point2);
901
900
 
902
- intersections .length = 0;
901
+ intersections .length = 0;
903
902
 
904
- if (geometryNode .intersectsLine (line, clipPlanes, target .modelMatrix, intersections))
903
+ if (geometryNode .intersectsLineWithGeometry (line, target .modelMatrix, clipPlanes, intersections))
904
+ {
905
+ for (var i = 0, iLength = intersections .length; i < iLength; ++ i)
905
906
  {
906
- for (var i = 0, iLength = intersections .length; i < iLength; ++ i)
907
- {
908
- // Test if intersection.point is between point1 and point2.
907
+ // Test if intersection.point is between point1 and point2.
909
908
 
910
- var intersection = intersections [i];
909
+ var intersection = intersections [i];
911
910
 
912
- a .assign (intersection .point) .subtract (point1);
913
- b .assign (intersection .point) .subtract (point2);
911
+ a .assign (intersection .point) .subtract (point1);
912
+ b .assign (intersection .point) .subtract (point2);
914
913
 
915
- var
916
- c = a .add (b) .abs (),
917
- s = point1 .distance (point2);
914
+ var
915
+ c = a .add (b) .magnitude (),
916
+ s = point1 .distance (point2);
918
917
 
919
- if (c <= s)
920
- target .intersections .push (intersection);
921
- }
918
+ if (c <= s)
919
+ target .intersections .push (intersection);
922
920
  }
923
921
  }
924
-
925
- if (target .intersections .length)
926
- {
927
- pickingCenter .assign (pickingBBox .center);
928
- targetCenter .assign (targetBBox .center);
929
-
930
- target .intersected = true;
931
- target .distance = pickingCenter .distance (targetCenter);
932
- }
933
922
  }
934
- catch (error)
923
+
924
+ if (target .intersections .length)
935
925
  {
936
- // Catch inverse.
937
- console .error (error);
926
+ pickingCenter .assign (pickingBBox .center);
927
+ targetCenter .assign (targetBBox .center);
928
+
929
+ target .intersected = true;
930
+ target .distance = pickingCenter .distance (targetCenter);
938
931
  }
939
932
  }
940
933
  }
@@ -1 +1 @@
1
- !function(){const e=window[Symbol.for("X_ITE.X3D-5.0.3")].define,t=window[Symbol.for("X_ITE.X3D-5.0.3")].require;e("x_ite/Browser/Picking/MatchCriterion",[],(function(){"use strict";let e=0;return{MATCH_ANY:e++,MATCH_EVERY:e++,MATCH_ONLY_ONE:e++}})),e("x_ite/Browser/Picking/IntersectionType",[],(function(){"use strict";let e=0;return{BOUNDS:e++,GEOMETRY:e++}})),e("x_ite/Browser/Picking/SortOrder",[],(function(){"use strict";let e=0;return{ANY:e++,CLOSEST:e++,ALL:e++,ALL_SORTED:e++}})),e("x_ite/Components/Picking/X3DPickSensorNode",["x_ite/Fields","x_ite/Components/Core/X3DSensorNode","x_ite/Rendering/TraverseType","x_ite/Base/X3DConstants","x_ite/Browser/Picking/MatchCriterion","x_ite/Browser/Picking/IntersectionType","x_ite/Browser/Picking/SortOrder","standard/Math/Numbers/Matrix4","standard/Math/Algorithms/QuickSort","standard/Utility/ObjectCache"],(function(e,t,i,n,o,s,r,c,a,h){"use strict";var p,d,g,l,u=h(c);function m(e,t){return e.distance<t.distance}function _(i){t.call(this,i),this.addType(n.X3DPickSensorNode),this.objectType=new Set,this.intersectionType=s.BOUNDS,this.sortOrder=r.CLOSEST,this.pickTargetNodes=new Set,this.modelMatrices=[],this.targets=[],this.targets.size=0,this.pickedTargets=[],this.pickedTargetsSorter=new a(this.pickedTargets,m),this.pickedGeometries=new e.MFNode}return _.prototype=Object.assign(Object.create(t.prototype),{constructor:_,initialize:function(){this.isLive().addInterest("set_live__",this),this._enabled.addInterest("set_live__",this),this._objectType.addInterest("set_objectType__",this),this._matchCriterion.addInterest("set_matchCriterion__",this),this._intersectionType.addInterest("set_intersectionType__",this),this._sortOrder.addInterest("set_sortOrder__",this),this._pickTarget.addInterest("set_pickTarget__",this),this.set_objectType__(),this.set_matchCriterion__(),this.set_intersectionType__(),this.set_sortOrder__(),this.set_pickTarget__()},getObjectType:function(){return this.objectType},getMatchCriterion:function(){return this.matchCriterion},getIntersectionType:function(){return this.intersectionType},getSortOrder:function(){return this.sortOrder},getModelMatrices:function(){return this.modelMatrices},getTargets:function(){return this.targets},getPickShape:(l=new WeakMap,function(e){var t=l.get(e);if(void 0!==t)return t;var i=this.getExecutionContext().createNode("Shape",!1),n=this.getExecutionContext().createNode("CollidableShape",!1);return i.setPrivate(!0),n.setPrivate(!0),n.setConvex(!0),i._geometry=e,n._shape=i,i.setup(),n.setup(),l.set(e,n),n}),getPickedGeometries:function(){var e=this.targets,t=e.size,i=this.pickedTargets,n=this.pickedGeometries;i.length=0;for(var o=0;o<t;++o){var s=e[o];s.intersected&&i.push(s)}if(0===i.length)return n.length=0,n;switch(this.sortOrder){case r.ANY:i.length=1,n[0]=this.getPickedGeometry(i[0]),n.length=1;break;case r.CLOSEST:this.pickedTargetsSorter.sort(0,i.length),i.length=1,n[0]=this.getPickedGeometry(i[0]),n.length=1;break;case r.ALL:o=0;for(var c=i.length;o<c;++o)n[o]=this.getPickedGeometry(i[o]);n.length=c;break;case r.ALL_SORTED:for(this.pickedTargetsSorter.sort(0,i.length),o=0,c=i.length;o<c;++o)n[o]=this.getPickedGeometry(i[o]);n.length=c}return n},getPickedGeometry:function(e){var t=this.getExecutionContext(),i=e.geometryNode;if(i.getExecutionContext()===t)return i;if(-1!==(r=i.getExecutionContext()).getType().indexOf(n.X3DPrototypeInstance)&&r.getExecutionContext()===t)return r;for(var o=e.pickingHierarchy,s=o.length-1;s>=0;--s){var r,c=o[s];if(c.getExecutionContext()===t)return c;if(-1!==(r=c.getExecutionContext()).getType().indexOf(n.X3DPrototypeInstance)&&r.getExecutionContext()===t)return r}return null},getPickedTargets:function(){return this.pickedTargets},set_live__:function(){this.isLive().getValue()&&this._enabled.getValue()&&!this.objectType.has("NONE")?(this.getBrowser().addPickSensor(this),this.setPickableObject(!0)):(this.getBrowser().removePickSensor(this),this.setPickableObject(!1))},set_objectType__:function(){this.objectType.clear();for(var e=0,t=this._objectType.length;e<t;++e)this.objectType.add(this._objectType[e]);this.set_live__()},set_matchCriterion__:(g=new Map([["MATCH_ANY",o.MATCH_ANY],["MATCH_EVERY",o.MATCH_EVERY],["MATCH_ONLY_ONE",o.MATCH_ONLY_ONE]]),function(){this.matchCriterion=g.get(this._matchCriterion.getValue()),void 0===this.matchCriterion&&(this.matchCriterion=MatchCriterionType.MATCH_ANY)}),set_intersectionType__:(d=new Map([["BOUNDS",s.BOUNDS],["GEOMETRY",s.GEOMETRY]]),function(){this.intersectionType=d.get(this._intersectionType.getValue()),void 0===this.intersectionType&&(this.intersectionType=s.BOUNDS)}),set_sortOrder__:(p=new Map([["ANY",r.ANY],["CLOSEST",r.CLOSEST],["ALL",r.ALL],["ALL_SORTED",r.ALL_SORTED]]),function(){this.sortOrder=p.get(this._sortOrder.getValue()),void 0===this.sortOrder&&(this.sortOrder=r.CLOSEST)}),set_pickTarget__:function(){this.pickTargetNodes.clear();for(var e=0,t=this._pickTarget.length;e<t;++e)try{for(var i=this._pickTarget[e].getValue().getInnerNode(),o=i.getType(),s=o.length-1;s>=0;--s)switch(o[s]){case n.Inline:case n.Shape:case n.X3DGroupingNode:this.pickTargetNodes.add(i);break;default:continue}}catch(e){}},traverse:function(e,t){e===i.PICKING&&this.getPickableObject()&&this.modelMatrices.push(u.pop().assign(t.getModelViewMatrix().get()))},collect:function(e,t,i){var n=this.pickTargetNodes;if(i.some((function(e){return n.has(e)}))){var o=this.targets;if(o.size<o.length)var s=o[o.size];else{s={modelMatrix:new c,pickingHierarchy:[],pickedPoint:[],intersections:[]};o.push(s)}++o.size,s.intersected=!1,s.geometryNode=e,s.pickedPoint.length=0,s.intersections.length=0,s.modelMatrix.assign(t);for(var r=s.pickingHierarchy,a=0,h=i.length;a<h;++a)r[a]=i[a];r.length=h}},process:function(){for(var e=this.modelMatrices,t=0,i=e.length;t<i;++t)u.push(e[t]);this.modelMatrices.length=0,this.targets.size=0}}),_})),e("x_ite/Components/Picking/LinePickSensor",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/Picking/X3DPickSensorNode","x_ite/Base/X3DConstants","x_ite/Browser/Picking/IntersectionType","standard/Math/Numbers/Vector3","standard/Math/Numbers/Matrix4","standard/Math/Geometry/Box3","standard/Math/Geometry/Line3"],(function(e,t,i,n,o,s,r,c,a,h){"use strict";function p(e){n.call(this,e),this.addType(o.LinePickSensor),this.pickingGeometryNode=null}var d,g,l,u,m,_,y,k,f,w,S,C,T,b,N,O;return p.prototype=Object.assign(Object.create(n.prototype),{constructor:p,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(o.inputOutput,"metadata",new e.SFNode),new t(o.inputOutput,"enabled",new e.SFBool(!0)),new t(o.inputOutput,"objectType",new e.MFString("ALL")),new t(o.inputOutput,"matchCriterion",new e.SFString("MATCH_ANY")),new t(o.initializeOnly,"intersectionType",new e.SFString("BOUNDS")),new t(o.initializeOnly,"sortOrder",new e.SFString("CLOSEST")),new t(o.outputOnly,"isActive",new e.SFBool),new t(o.outputOnly,"pickedTextureCoordinate",new e.MFVec3f),new t(o.outputOnly,"pickedNormal",new e.MFVec3f),new t(o.outputOnly,"pickedPoint",new e.MFVec3f),new t(o.inputOutput,"pickingGeometry",new e.SFNode),new t(o.inputOutput,"pickTarget",new e.MFNode),new t(o.outputOnly,"pickedGeometry",new e.MFNode)]),getTypeName:function(){return"LinePickSensor"},getComponentName:function(){return"Picking"},getContainerField:function(){return"children"},initialize:function(){n.prototype.initialize.call(this),this._pickingGeometry.addInterest("set_pickingGeometry__",this),this.set_pickingGeometry__()},set_pickingGeometry__:function(){this.pickingGeometryNode=null;try{for(var e=this._pickingGeometry.getValue().getInnerNode(),t=e.getType(),i=t.length-1;i>=0;--i)switch(t[i]){case o.IndexedLineSet:case o.LineSet:this.pickingGeometryNode=e;break;default:continue}}catch(e){}},process:(d=new a,g=new a,l=new r(0,0,0),u=new r(0,0,0),m=new c,_=new r(0,0,0),y=new r(0,0,0),k=new h(r.Zero,r.zAxis),f=new r(0,0,0),w=new r(0,0,0),S=[],C=[],T=new r(0,0,0),b=new e.MFVec3f,N=new e.MFVec3f,O=new e.MFVec3f,function(){if(this.pickingGeometryNode){var e=this.getModelMatrices(),t=this.getTargets();switch(this.getIntersectionType()){case s.BOUNDS:for(var i=0,o=e.length;i<o;++i){var r=e[i];d.assign(this.pickingGeometryNode.getBBox()).multRight(r);for(var c=0,a=t.size;c<a;++c){var h=t[c];g.assign(h.geometryNode.getBBox()).multRight(h.modelMatrix),d.intersectsBox(g)&&(l.assign(d.center),u.assign(g.center),h.intersected=!0,h.distance=l.distance(u))}}var p=this.getPickedGeometries(),x=Boolean(p.length);p.remove(0,p.length,null),x!==this._isActive.getValue()&&(this._isActive=x),this._pickedGeometry.equals(p)||(this._pickedGeometry=p);break;case s.GEOMETRY:for(i=0,o=e.length;i<o;++i)for(r=e[i],d.assign(this.pickingGeometryNode.getBBox()).multRight(r),c=0,a=t.size;c<a;++c)try{var P=(h=t[c]).geometryNode,v=this.pickingGeometryNode.getVertices();g.assign(P.getBBox()).multRight(h.modelMatrix),m.assign(h.modelMatrix).inverse().multLeft(r);for(var B=0,M=v.length;B<M;B+=8)if(m.multVecMatrix(_.set(v[B+0],v[B+1],v[B+2])),m.multVecMatrix(y.set(v[B+4],v[B+5],v[B+6])),k.setPoints(_,y),C.length=0,P.intersectsLine(k,S,h.modelMatrix,C))for(var G=0,D=C.length;G<D;++G){var F=C[G];f.assign(F.point).subtract(_),w.assign(F.point).subtract(y),f.add(w).abs()<=_.distance(y)&&h.intersections.push(F)}h.intersections.length&&(l.assign(d.center),u.assign(g.center),h.intersected=!0,h.distance=l.distance(u))}catch(e){console.error(e)}p=this.getPickedGeometries(),x=Boolean(p.length),p.remove(0,p.length,null),x!==this._isActive.getValue()&&(this._isActive=x),this._pickedGeometry.equals(p)||(this._pickedGeometry=p);var A=this.getPickedTargets();for(b.length=0,N.length=0,O.length=0,c=0,a=A.length;c<a;++c){var V=A[c].intersections;for(G=0,D=V.length;G<D;++G)c=(F=V[G]).texCoord,T.set(c.x,c.y,c.z),b.push(T),N.push(F.normal),O.push(F.point)}this._pickedTextureCoordinate.equals(b)||(this._pickedTextureCoordinate=b),this._pickedNormal.equals(N)||(this._pickedNormal=N),this._pickedPoint.equals(O)||(this._pickedPoint=O)}}n.prototype.process.call(this)})}),p})),e("x_ite/Components/Picking/X3DPickableObject",["x_ite/Base/X3DConstants"],(function(e){"use strict";function t(t){this.addType(e.X3DPickableObject),this.objectType=new Set}return t.prototype={constructor:t,initialize:function(){this._objectType.addInterest("set_objectType__",this),this.set_objectType__()},getObjectType:function(){return this.objectType},set_objectType__:function(){this.objectType.clear();for(var e=0,t=this._objectType.length;e<t;++e)this.objectType.add(this._objectType[e])}},t})),e("x_ite/Components/Picking/PickableGroup",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/Grouping/X3DGroupingNode","x_ite/Components/Picking/X3DPickableObject","x_ite/Browser/Picking/MatchCriterion","x_ite/Base/X3DConstants","x_ite/Rendering/TraverseType"],(function(e,t,i,n,o,s,r,c){"use strict";function a(e){n.call(this,e),o.call(this,e),this.addType(r.PickableGroup)}return a.prototype=Object.assign(Object.create(n.prototype),o.prototype,{constructor:a,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(r.inputOutput,"metadata",new e.SFNode),new t(r.inputOutput,"pickable",new e.SFBool(!0)),new t(r.inputOutput,"objectType",new e.MFString("ALL")),new t(r.inputOutput,"visible",new e.SFBool(!0)),new t(r.inputOutput,"bboxDisplay",new e.SFBool),new t(r.initializeOnly,"bboxSize",new e.SFVec3f(-1,-1,-1)),new t(r.initializeOnly,"bboxCenter",new e.SFVec3f),new t(r.inputOnly,"addChildren",new e.MFNode),new t(r.inputOnly,"removeChildren",new e.MFNode),new t(r.inputOutput,"children",new e.MFNode)]),getTypeName:function(){return"PickableGroup"},getComponentName:function(){return"Picking"},getContainerField:function(){return"children"},initialize:function(){n.prototype.initialize.call(this),o.prototype.initialize.call(this),this._pickable.addInterest("set_pickable__",this),this.set_pickable__()},set_pickableObjects__:function(){this.set_pickable__()},set_pickable__:function(){this.setPickableObject(Boolean(this._pickable.getValue()||this.getTransformSensors().size))},traverse:function(){const e=new Set;return function(t,i){if(t===c.PICKING){if(this._pickable.getValue()){if(this.getObjectType().has("NONE"))return;const o=i.getBrowser(),r=o.getPickable();if(this.getObjectType().has("ALL"))r.push(!0),n.prototype.traverse.call(this,t,i),r.pop();else{const c=o.getPickSensors();for(const t of c.at(-1)){if(!t.getObjectType().has("ALL")){let e=0;for(const i of this.getObjectType())if(t.getObjectType().has(i)){++e;break}switch(t.getMatchCriterion()){case s.MATCH_ANY:if(0===e)continue;break;case s.MATCH_EVERY:if(e!==pickSensor.getObjectType().size)continue;break;case s.MATCH_ONLY_ONE:if(1!==e)continue}}e.add(t)}r.push(!0),c.push(e),n.prototype.traverse.call(this,t,i),c.pop(),r.pop(),e.clear()}}}else n.prototype.traverse.call(this,t,i)}}()}),a})),e("x_ite/Browser/Picking/VolumePicker",["standard/Math/Numbers/Vector3","standard/Math/Numbers/Rotation4","standard/Math/Numbers/Matrix4",t.getComponentUrl("rigid-body-physics")],(function(e,t,i,n){"use strict";const o=n.Ammo;function s(){this.broadphase=new o.btDbvtBroadphase,this.collisionConfiguration=new o.btDefaultCollisionConfiguration,this.dispatcher=new o.btCollisionDispatcher(this.collisionConfiguration),this.collisionWorld=new o.btCollisionWorld(this.dispatcher,this.broadphase,this.collisionConfiguration),this.compoundShape1=new o.btCompoundShape,this.motionState1=new o.btDefaultMotionState,this.constructionInfo1=new o.btRigidBodyConstructionInfo(0,this.motionState1,this.compoundShape1),this.rigidBody1=new o.btRigidBody(this.constructionInfo1),this.compoundShape2=new o.btCompoundShape,this.motionState2=new o.btDefaultMotionState,this.constructionInfo2=new o.btRigidBodyConstructionInfo(0,this.motionState2,this.compoundShape2),this.rigidBody2=new o.btRigidBody(this.constructionInfo2),this.collisionWorld.addCollisionObject(this.rigidBody1),this.collisionWorld.addCollisionObject(this.rigidBody2)}return s.prototype={constuctor:s,setChildShape1:function(e,t){this.setChildShape(this.compoundShape1,e,t)},setChildShape2:function(e,t){this.setChildShape(this.compoundShape2,e,t)},setChildShape1Components:function(e,t,i){this.setChildShapeComponents(this.compoundShape1,e,t,i)},setChildShape2Components:function(e,t,i){this.setChildShapeComponents(this.compoundShape2,e,t,i)},setChildShape:function(){const i=new e(0,0,0),n=new t(0,0,1,0),s=new e(1,1,1),r=new o.btVector3(0,0,0);return function(e,t,o){try{e.getNumChildShapes()&&e.removeChildShapeByIndex(0),o.getNumChildShapes()&&(t.get(i,n,s),r.setValue(s.x,s.y,s.z),o.setLocalScaling(r),e.addChildShape(this.getTransform(i,n),o))}catch(e){}}}(),setChildShapeComponents:function(e,t,i,n){e.getNumChildShapes()&&e.removeChildShapeByIndex(0),n.getNumChildShapes()&&(n.setLocalScaling(i),e.addChildShape(t,n))},contactTest:function(){this.collisionWorld.performDiscreteCollisionDetection();const e=this.dispatcher.getNumManifolds();for(let t=0;t<e;++t){const e=this.dispatcher.getManifoldByIndexInternal(t),i=e.getNumContacts();for(let t=0;t<i;++t){if(e.getContactPoint(t).getDistance()<=0)return!0}}return!1},getTransform:function(){const e=new o.btTransform,t=new o.btVector3(0,0,0),n=new i;return function(i,o,s){const r=s||e;return n.set(i,o),t.setValue(n[12],n[13],n[14]),r.getBasis().setValue(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),r.setOrigin(t),r}}()},s})),e("x_ite/Components/Picking/PointPickSensor",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/Picking/X3DPickSensorNode","x_ite/Base/X3DCast","x_ite/Base/X3DConstants","x_ite/Browser/Picking/IntersectionType","x_ite/Browser/Picking/VolumePicker","standard/Math/Numbers/Vector3","standard/Math/Numbers/Rotation4","standard/Math/Geometry/Box3",t.getComponentUrl("rigid-body-physics")],(function(e,t,i,n,o,s,r,c,a,h,p,d){"use strict";var g,l,u,m,_,y,k,f,w,S,C,T,b,N=d.Ammo;function O(e){n.call(this,e),this.addType(s.PointPickSensor),this.pickingGeometryNode=null,this.picker=new c,this.compoundShapes=[]}return O.prototype=Object.assign(Object.create(n.prototype),{constructor:O,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(s.inputOutput,"metadata",new e.SFNode),new t(s.inputOutput,"enabled",new e.SFBool(!0)),new t(s.inputOutput,"objectType",new e.MFString("ALL")),new t(s.inputOutput,"matchCriterion",new e.SFString("MATCH_ANY")),new t(s.initializeOnly,"intersectionType",new e.SFString("BOUNDS")),new t(s.initializeOnly,"sortOrder",new e.SFString("CLOSEST")),new t(s.outputOnly,"isActive",new e.SFBool),new t(s.outputOnly,"pickedPoint",new e.MFVec3f),new t(s.inputOutput,"pickingGeometry",new e.SFNode),new t(s.inputOutput,"pickTarget",new e.MFNode),new t(s.outputOnly,"pickedGeometry",new e.MFNode)]),getTypeName:function(){return"PointPickSensor"},getComponentName:function(){return"Picking"},getContainerField:function(){return"children"},initialize:function(){n.prototype.initialize.call(this),this._pickingGeometry.addInterest("set_pickingGeometry__",this),this.set_pickingGeometry__()},set_pickingGeometry__:function(){this.pickingGeometryNode&&this.pickingGeometryNode._rebuild.removeInterest("set_geometry__",this),this.pickingGeometryNode=o(s.PointSet,this._pickingGeometry),this.pickingGeometryNode&&this.pickingGeometryNode._rebuild.addInterest("set_geometry__",this),this.set_geometry__()},set_geometry__:(C=new N.btVector3(1,1,1),T=new N.btVector3,b=new N.btTransform,function(){var e=this.compoundShapes;if(this.pickingGeometryNode){var t=this.pickingGeometryNode.getCoord();if(t){for(var i=0,n=t.getSize();i<n;++i)if(i<e.length){var o=e[i],s=t.get1Point(i,o.point);T.setValue(s.x,s.y,s.z),b.setOrigin(T),o.setLocalScaling(C),o.updateChildTransform(0,b)}else{o=new N.btCompoundShape;var r=new N.btSphereShape(0);s=t.get1Point(i,new a(0,0,0)),o.point=s,T.setValue(s.x,s.y,s.z),b.setOrigin(T),o.addChildShape(b,r),e.push(o)}e.length=n}else e.length=0}else e.length=0}),process:(g=new p,l=new p,u=new a(0,0,0),m=new a(0,0,0),_=new N.btTransform,y=new N.btVector3,k=new a(0,0,0),f=new h(0,0,1,0),w=new a(1,1,1),S=new e.MFVec3f,function(){if(this.pickingGeometryNode){var e=this.getModelMatrices(),t=this.getTargets();switch(this.getIntersectionType()){case r.BOUNDS:for(var i=0,o=e.length;i<o;++i){var s=e[i];g.assign(this.pickingGeometryNode.getBBox()).multRight(s);for(var c=0,a=t.size;c<a;++c){var h=t[c];l.assign(h.geometryNode.getBBox()).multRight(h.modelMatrix),g.intersectsBox(l)&&(u.assign(g.center),m.assign(l.center),h.intersected=!0,h.distance=u.distance(m))}}var p=this.getPickedGeometries(),d=Boolean(p.length);p.remove(0,p.length,null),d!==this._isActive.getValue()&&(this._isActive=d),this._pickedGeometry.equals(p)||(this._pickedGeometry=p);break;case r.GEOMETRY:var C=this.picker,T=this.compoundShapes;for(i=0,o=e.length;i<o;++i){s=e[i],g.assign(this.pickingGeometryNode.getBBox()).multRight(s),s.get(k,f,w),C.getTransform(k,f,_),y.setValue(w.x,w.y,w.z);for(var b=0,N=T.length;b<N;++b){var O=T[b];for(C.setChildShape1Components(_,y,O),c=0,a=t.size;c<a;++c){h=t[c];var x=this.getPickShape(h.geometryNode);l.assign(h.geometryNode.getBBox()).multRight(h.modelMatrix),C.setChildShape2(h.modelMatrix,x.getCompoundShape()),C.contactTest()&&(u.assign(g.center),m.assign(l.center),h.intersected=!0,h.distance=u.distance(m),h.pickedPoint.push(O.point))}}}p=this.getPickedGeometries(),d=Boolean(p.length),p.remove(0,p.length,null),d!==this._isActive.getValue()&&(this._isActive=d),this._pickedGeometry.equals(p)||(this._pickedGeometry=p);var P=this.getPickedTargets();for(S.length=0,c=0,a=P.length;c<a;++c)for(var v=P[c].pickedPoint,B=0,M=v.length;B<M;++B)S.push(v[B]);this._pickedPoint.equals(S)||(this._pickedPoint=S)}}n.prototype.process.call(this)})}),O})),e("x_ite/Components/Picking/PrimitivePickSensor",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/Picking/X3DPickSensorNode","x_ite/Base/X3DConstants","x_ite/Browser/Picking/IntersectionType","x_ite/Browser/Picking/VolumePicker","standard/Math/Numbers/Vector3","standard/Math/Geometry/Box3"],(function(e,t,i,n,o,s,r,c,a){"use strict";function h(e){n.call(this,e),this.addType(o.PrimitivePickSensor),this.pickingGeometryNode=null,this.picker=new r}var p,d,g,l;return h.prototype=Object.assign(Object.create(n.prototype),{constructor:h,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(o.inputOutput,"metadata",new e.SFNode),new t(o.inputOutput,"enabled",new e.SFBool(!0)),new t(o.inputOutput,"objectType",new e.MFString("ALL")),new t(o.inputOutput,"matchCriterion",new e.SFString("MATCH_ANY")),new t(o.initializeOnly,"intersectionType",new e.SFString("BOUNDS")),new t(o.initializeOnly,"sortOrder",new e.SFString("CLOSEST")),new t(o.outputOnly,"isActive",new e.SFBool),new t(o.inputOutput,"pickingGeometry",new e.SFNode),new t(o.inputOutput,"pickTarget",new e.MFNode),new t(o.outputOnly,"pickedGeometry",new e.MFNode)]),getTypeName:function(){return"PrimitivePickSensor"},getComponentName:function(){return"Picking"},getContainerField:function(){return"children"},initialize:function(){n.prototype.initialize.call(this),this._pickingGeometry.addInterest("set_pickingGeometry__",this),this.set_pickingGeometry__()},set_pickingGeometry__:function(){this.pickingGeometryNode=null;try{for(var e=this._pickingGeometry.getValue().getInnerNode(),t=e.getType(),i=t.length-1;i>=0;--i)switch(t[i]){case o.Box:case o.Cone:case o.Cylinder:case o.Sphere:this.pickingGeometryNode=e;break;default:continue}}catch(e){}},process:(p=new a,d=new a,g=new c(0,0,0),l=new c(0,0,0),function(){if(this.pickingGeometryNode){var e=this.getModelMatrices(),t=this.getTargets();switch(this.getIntersectionType()){case s.BOUNDS:for(var i=0,o=e.length;i<o;++i){var r=e[i];p.assign(this.pickingGeometryNode.getBBox()).multRight(r);for(var c=0,a=t.size;c<a;++c){var h=t[c];d.assign(h.geometryNode.getBBox()).multRight(h.modelMatrix),p.intersectsBox(d)&&(g.assign(p.center),l.assign(d.center),h.intersected=!0,h.distance=g.distance(l))}}var u=this.getPickedGeometries(),m=Boolean(u.length);u.remove(0,u.length,null),m!==this._isActive.getValue()&&(this._isActive=m),this._pickedGeometry.equals(u)||(this._pickedGeometry=u);break;case s.GEOMETRY:var _=this.picker;for(i=0,o=e.length;i<o;++i){r=e[i];var y=this.getPickShape(this.pickingGeometryNode);for(p.assign(this.pickingGeometryNode.getBBox()).multRight(r),_.setChildShape1(r,y.getCompoundShape()),c=0,a=t.size;c<a;++c){h=t[c];var k=this.getPickShape(h.geometryNode);d.assign(h.geometryNode.getBBox()).multRight(h.modelMatrix),_.setChildShape2(h.modelMatrix,k.getCompoundShape()),_.contactTest()&&(g.assign(p.center),l.assign(d.center),h.intersected=!0,h.distance=g.distance(l))}}u=this.getPickedGeometries(),m=Boolean(u.length),u.remove(0,u.length,null),m!==this._isActive.getValue()&&(this._isActive=m),this._pickedGeometry.equals(u)||(this._pickedGeometry=u)}}n.prototype.process.call(this)})}),h})),e("x_ite/Components/Picking/VolumePickSensor",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/Picking/X3DPickSensorNode","x_ite/Base/X3DCast","x_ite/Base/X3DConstants","x_ite/Browser/Picking/IntersectionType","x_ite/Browser/Picking/VolumePicker","standard/Math/Numbers/Vector3","standard/Math/Geometry/Box3"],(function(e,t,i,n,o,s,r,c,a,h){"use strict";function p(e){n.call(this,e),this.addType(s.VolumePickSensor),this.pickingGeometryNode=null,this.picker=new c}var d,g,l,u;return p.prototype=Object.assign(Object.create(n.prototype),{constructor:p,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(s.inputOutput,"metadata",new e.SFNode),new t(s.inputOutput,"enabled",new e.SFBool(!0)),new t(s.inputOutput,"objectType",new e.MFString("ALL")),new t(s.inputOutput,"matchCriterion",new e.SFString("MATCH_ANY")),new t(s.initializeOnly,"intersectionType",new e.SFString("BOUNDS")),new t(s.initializeOnly,"sortOrder",new e.SFString("CLOSEST")),new t(s.outputOnly,"isActive",new e.SFBool),new t(s.inputOutput,"pickingGeometry",new e.SFNode),new t(s.inputOutput,"pickTarget",new e.MFNode),new t(s.outputOnly,"pickedGeometry",new e.MFNode)]),getTypeName:function(){return"VolumePickSensor"},getComponentName:function(){return"Picking"},getContainerField:function(){return"children"},initialize:function(){n.prototype.initialize.call(this),this._pickingGeometry.addInterest("set_pickingGeometry__",this),this.set_pickingGeometry__()},set_pickingGeometry__:function(){this.pickingGeometryNode=o(s.X3DGeometryNode,this._pickingGeometry)},process:(d=new h,g=new h,l=new a(0,0,0),u=new a(0,0,0),function(){if(this.pickingGeometryNode){var e=this.getModelMatrices(),t=this.getTargets();switch(this.getIntersectionType()){case r.BOUNDS:for(var i=0,o=e.length;i<o;++i){var s=e[i];d.assign(this.pickingGeometryNode.getBBox()).multRight(s);for(var c=0,a=t.size;c<a;++c){var h=t[c];g.assign(h.geometryNode.getBBox()).multRight(h.modelMatrix),d.intersectsBox(g)&&(l.assign(d.center),u.assign(g.center),h.intersected=!0,h.distance=l.distance(u))}}var p=this.getPickedGeometries(),m=Boolean(p.length);p.remove(0,p.length,null),m!==this._isActive.getValue()&&(this._isActive=m),this._pickedGeometry.equals(p)||(this._pickedGeometry=p);break;case r.GEOMETRY:var _=this.picker;for(i=0,o=e.length;i<o;++i){s=e[i];var y=this.getPickShape(this.pickingGeometryNode);for(d.assign(this.pickingGeometryNode.getBBox()).multRight(s),_.setChildShape1(s,y.getCompoundShape()),c=0,a=t.size;c<a;++c){h=t[c];var k=this.getPickShape(h.geometryNode);g.assign(h.geometryNode.getBBox()).multRight(h.modelMatrix),_.setChildShape2(h.modelMatrix,k.getCompoundShape()),_.contactTest()&&(l.assign(d.center),u.assign(g.center),h.intersected=!0,h.distance=l.distance(u))}}p=this.getPickedGeometries(),m=Boolean(p.length),p.remove(0,p.length,null),m!==this._isActive.getValue()&&(this._isActive=m),this._pickedGeometry.equals(p)||(this._pickedGeometry=p)}}n.prototype.process.call(this)})}),p})),e(t.getComponentUrl("picking"),["x_ite/Components","x_ite/Components/Picking/LinePickSensor","x_ite/Components/Picking/PickableGroup","x_ite/Components/Picking/PointPickSensor","x_ite/Components/Picking/PrimitivePickSensor","x_ite/Components/Picking/VolumePickSensor","x_ite/Components/Picking/X3DPickSensorNode","x_ite/Components/Picking/X3DPickableObject",t.getComponentUrl("rigid-body-physics")],(function(e,t,i,n,o,s,r,c){"use strict";e.addComponent({name:"Picking",types:{LinePickSensor:t,PickableGroup:i,PointPickSensor:n,PrimitivePickSensor:o,VolumePickSensor:s},abstractTypes:{X3DPickSensorNode:r,X3DPickableObject:c}})}))}();
1
+ !function(){const e=window[Symbol.for("X_ITE.X3D-6.1.0")],t=e.define,i=e.require;t("x_ite/Browser/Picking/MatchCriterion",[],(function(){"use strict";let e=0;return{MATCH_ANY:e++,MATCH_EVERY:e++,MATCH_ONLY_ONE:e++}})),t("x_ite/Browser/Picking/IntersectionType",[],(function(){"use strict";let e=0;return{BOUNDS:e++,GEOMETRY:e++}})),t("x_ite/Browser/Picking/SortOrder",[],(function(){"use strict";let e=0;return{ANY:e++,CLOSEST:e++,ALL:e++,ALL_SORTED:e++}})),t("x_ite/Components/Picking/X3DPickSensorNode",["x_ite/Fields","x_ite/Components/Core/X3DSensorNode","x_ite/Rendering/TraverseType","x_ite/Base/X3DConstants","x_ite/Browser/Picking/MatchCriterion","x_ite/Browser/Picking/IntersectionType","x_ite/Browser/Picking/SortOrder","standard/Math/Numbers/Matrix4","standard/Math/Algorithms/QuickSort","standard/Utility/ObjectCache"],(function(e,t,i,n,o,s,r,c,a,h){"use strict";var p,d,g,l,u=h(c);function m(e,t){return e.distance<t.distance}function _(i){t.call(this,i),this.addType(n.X3DPickSensorNode),this.objectType=new Set,this.intersectionType=s.BOUNDS,this.sortOrder=r.CLOSEST,this.pickTargetNodes=new Set,this.modelMatrices=[],this.targets=[],this.targets.size=0,this.pickedTargets=[],this.pickedTargetsSorter=new a(this.pickedTargets,m),this.pickedGeometries=new e.MFNode}return _.prototype=Object.assign(Object.create(t.prototype),{constructor:_,initialize:function(){this.isLive().addInterest("set_live__",this),this._enabled.addInterest("set_live__",this),this._objectType.addInterest("set_objectType__",this),this._matchCriterion.addInterest("set_matchCriterion__",this),this._intersectionType.addInterest("set_intersectionType__",this),this._sortOrder.addInterest("set_sortOrder__",this),this._pickTarget.addInterest("set_pickTarget__",this),this.set_objectType__(),this.set_matchCriterion__(),this.set_intersectionType__(),this.set_sortOrder__(),this.set_pickTarget__()},getObjectType:function(){return this.objectType},getMatchCriterion:function(){return this.matchCriterion},getIntersectionType:function(){return this.intersectionType},getSortOrder:function(){return this.sortOrder},getModelMatrices:function(){return this.modelMatrices},getTargets:function(){return this.targets},getPickShape:(l=new WeakMap,function(e){var t=l.get(e);if(void 0!==t)return t;var i=this.getExecutionContext().createNode("Shape",!1),n=this.getExecutionContext().createNode("CollidableShape",!1);return i.setPrivate(!0),n.setPrivate(!0),n.setConvex(!0),i._geometry=e,n._shape=i,i.setup(),n.setup(),l.set(e,n),n}),getPickedGeometries:function(){var e=this.targets,t=e.size,i=this.pickedTargets,n=this.pickedGeometries;i.length=0;for(var o=0;o<t;++o){var s=e[o];s.intersected&&i.push(s)}if(0===i.length)return n.length=0,n;switch(this.sortOrder){case r.ANY:i.length=1,n[0]=this.getPickedGeometry(i[0]),n.length=1;break;case r.CLOSEST:this.pickedTargetsSorter.sort(0,i.length),i.length=1,n[0]=this.getPickedGeometry(i[0]),n.length=1;break;case r.ALL:o=0;for(var c=i.length;o<c;++o)n[o]=this.getPickedGeometry(i[o]);n.length=c;break;case r.ALL_SORTED:for(this.pickedTargetsSorter.sort(0,i.length),o=0,c=i.length;o<c;++o)n[o]=this.getPickedGeometry(i[o]);n.length=c}return n},getPickedGeometry:function(e){var t=this.getExecutionContext(),i=e.geometryNode;if(i.getExecutionContext()===t)return i;if(-1!==(r=i.getExecutionContext()).getType().indexOf(n.X3DPrototypeInstance)&&r.getExecutionContext()===t)return r;for(var o=e.pickingHierarchy,s=o.length-1;s>=0;--s){var r,c=o[s];if(c.getExecutionContext()===t)return c;if(-1!==(r=c.getExecutionContext()).getType().indexOf(n.X3DPrototypeInstance)&&r.getExecutionContext()===t)return r}return null},getPickedTargets:function(){return this.pickedTargets},set_live__:function(){this.isLive().getValue()&&this._enabled.getValue()&&!this.objectType.has("NONE")?(this.getBrowser().addPickSensor(this),this.setPickableObject(!0)):(this.getBrowser().removePickSensor(this),this.setPickableObject(!1))},set_objectType__:function(){this.objectType.clear();for(var e=0,t=this._objectType.length;e<t;++e)this.objectType.add(this._objectType[e]);this.set_live__()},set_matchCriterion__:(g=new Map([["MATCH_ANY",o.MATCH_ANY],["MATCH_EVERY",o.MATCH_EVERY],["MATCH_ONLY_ONE",o.MATCH_ONLY_ONE]]),function(){this.matchCriterion=g.get(this._matchCriterion.getValue()),void 0===this.matchCriterion&&(this.matchCriterion=MatchCriterionType.MATCH_ANY)}),set_intersectionType__:(d=new Map([["BOUNDS",s.BOUNDS],["GEOMETRY",s.GEOMETRY]]),function(){this.intersectionType=d.get(this._intersectionType.getValue()),void 0===this.intersectionType&&(this.intersectionType=s.BOUNDS)}),set_sortOrder__:(p=new Map([["ANY",r.ANY],["CLOSEST",r.CLOSEST],["ALL",r.ALL],["ALL_SORTED",r.ALL_SORTED]]),function(){this.sortOrder=p.get(this._sortOrder.getValue()),void 0===this.sortOrder&&(this.sortOrder=r.CLOSEST)}),set_pickTarget__:function(){this.pickTargetNodes.clear();for(var e=0,t=this._pickTarget.length;e<t;++e)try{for(var i=this._pickTarget[e].getValue().getInnerNode(),o=i.getType(),s=o.length-1;s>=0;--s)switch(o[s]){case n.Inline:case n.Shape:case n.X3DGroupingNode:this.pickTargetNodes.add(i);break;default:continue}}catch(e){}},traverse:function(e,t){e===i.PICKING&&this.getPickableObject()&&this.modelMatrices.push(u.pop().assign(t.getModelViewMatrix().get()))},collect:function(e,t,i){var n=this.pickTargetNodes;if(i.some((function(e){return n.has(e)}))){var o=this.targets;if(o.size<o.length)var s=o[o.size];else{s={modelMatrix:new c,pickingHierarchy:[],pickedPoint:[],intersections:[]};o.push(s)}++o.size,s.intersected=!1,s.geometryNode=e,s.pickedPoint.length=0,s.intersections.length=0,s.modelMatrix.assign(t);for(var r=s.pickingHierarchy,a=0,h=i.length;a<h;++a)r[a]=i[a];r.length=h}},process:function(){for(var e=this.modelMatrices,t=0,i=e.length;t<i;++t)u.push(e[t]);this.modelMatrices.length=0,this.targets.size=0}}),_})),t("x_ite/Components/Picking/LinePickSensor",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/Picking/X3DPickSensorNode","x_ite/Base/X3DConstants","x_ite/Browser/Picking/IntersectionType","standard/Math/Numbers/Vector3","standard/Math/Numbers/Matrix4","standard/Math/Geometry/Box3","standard/Math/Geometry/Line3"],(function(e,t,i,n,o,s,r,c,a,h){"use strict";function p(e){n.call(this,e),this.addType(o.LinePickSensor),this.pickingGeometryNode=null}var d,g,l,u,m,_,y,k,f,w,S,C,T,N,b,O;return p.prototype=Object.assign(Object.create(n.prototype),{constructor:p,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(o.inputOutput,"metadata",new e.SFNode),new t(o.inputOutput,"enabled",new e.SFBool(!0)),new t(o.inputOutput,"objectType",new e.MFString("ALL")),new t(o.inputOutput,"matchCriterion",new e.SFString("MATCH_ANY")),new t(o.initializeOnly,"intersectionType",new e.SFString("BOUNDS")),new t(o.initializeOnly,"sortOrder",new e.SFString("CLOSEST")),new t(o.outputOnly,"isActive",new e.SFBool),new t(o.outputOnly,"pickedTextureCoordinate",new e.MFVec3f),new t(o.outputOnly,"pickedNormal",new e.MFVec3f),new t(o.outputOnly,"pickedPoint",new e.MFVec3f),new t(o.inputOutput,"pickingGeometry",new e.SFNode),new t(o.inputOutput,"pickTarget",new e.MFNode),new t(o.outputOnly,"pickedGeometry",new e.MFNode)]),getTypeName:function(){return"LinePickSensor"},getComponentName:function(){return"Picking"},getContainerField:function(){return"children"},initialize:function(){n.prototype.initialize.call(this),this._pickingGeometry.addInterest("set_pickingGeometry__",this),this.set_pickingGeometry__()},set_pickingGeometry__:function(){this.pickingGeometryNode=null;try{for(var e=this._pickingGeometry.getValue().getInnerNode(),t=e.getType(),i=t.length-1;i>=0;--i)switch(t[i]){case o.IndexedLineSet:case o.LineSet:this.pickingGeometryNode=e;break;default:continue}}catch(e){}},process:(d=new a,g=new a,l=new r(0,0,0),u=new r(0,0,0),m=new c,_=new r(0,0,0),y=new r(0,0,0),k=new h(r.Zero,r.zAxis),f=new r(0,0,0),w=new r(0,0,0),S=[],C=[],T=new r(0,0,0),N=new e.MFVec3f,b=new e.MFVec3f,O=new e.MFVec3f,function(){if(this.pickingGeometryNode){var e=this.getModelMatrices(),t=this.getTargets();switch(this.getIntersectionType()){case s.BOUNDS:for(var i=0,o=e.length;i<o;++i){var r=e[i];d.assign(this.pickingGeometryNode.getBBox()).multRight(r);for(var c=0,a=t.size;c<a;++c){var h=t[c];g.assign(h.geometryNode.getBBox()).multRight(h.modelMatrix),d.intersectsBox(g)&&(l.assign(d.center),u.assign(g.center),h.intersected=!0,h.distance=l.distance(u))}}var p=this.getPickedGeometries(),x=Boolean(p.length);p.remove(0,p.length,null),x!==this._isActive.getValue()&&(this._isActive=x),this._pickedGeometry.equals(p)||(this._pickedGeometry=p);break;case s.GEOMETRY:for(i=0,o=e.length;i<o;++i)for(r=e[i],d.assign(this.pickingGeometryNode.getBBox()).multRight(r),c=0,a=t.size;c<a;++c){var P=(h=t[c]).geometryNode,v=this.pickingGeometryNode.getVertices();g.assign(P.getBBox()).multRight(h.modelMatrix),m.assign(h.modelMatrix).inverse().multLeft(r);for(var B=0,M=v.length;B<M;B+=8)if(m.multVecMatrix(_.set(v[B+0],v[B+1],v[B+2])),m.multVecMatrix(y.set(v[B+4],v[B+5],v[B+6])),k.setPoints(_,y),C.length=0,P.intersectsLineWithGeometry(k,h.modelMatrix,S,C))for(var G=0,D=C.length;G<D;++G){var F=C[G];f.assign(F.point).subtract(_),w.assign(F.point).subtract(y),f.add(w).magnitude()<=_.distance(y)&&h.intersections.push(F)}h.intersections.length&&(l.assign(d.center),u.assign(g.center),h.intersected=!0,h.distance=l.distance(u))}p=this.getPickedGeometries(),x=Boolean(p.length),p.remove(0,p.length,null),x!==this._isActive.getValue()&&(this._isActive=x),this._pickedGeometry.equals(p)||(this._pickedGeometry=p);var A=this.getPickedTargets();for(N.length=0,b.length=0,O.length=0,c=0,a=A.length;c<a;++c){var V=A[c].intersections;for(G=0,D=V.length;G<D;++G)c=(F=V[G]).texCoord,T.set(c.x,c.y,c.z),N.push(T),b.push(F.normal),O.push(F.point)}this._pickedTextureCoordinate.equals(N)||(this._pickedTextureCoordinate=N),this._pickedNormal.equals(b)||(this._pickedNormal=b),this._pickedPoint.equals(O)||(this._pickedPoint=O)}}n.prototype.process.call(this)})}),p})),t("x_ite/Components/Picking/X3DPickableObject",["x_ite/Base/X3DConstants"],(function(e){"use strict";function t(t){this.addType(e.X3DPickableObject),this.objectType=new Set}return t.prototype={constructor:t,initialize:function(){this._objectType.addInterest("set_objectType__",this),this.set_objectType__()},getObjectType:function(){return this.objectType},set_objectType__:function(){this.objectType.clear();for(var e=0,t=this._objectType.length;e<t;++e)this.objectType.add(this._objectType[e])}},t})),t("x_ite/Components/Picking/PickableGroup",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/Grouping/X3DGroupingNode","x_ite/Components/Picking/X3DPickableObject","x_ite/Browser/Picking/MatchCriterion","x_ite/Base/X3DConstants","x_ite/Rendering/TraverseType"],(function(e,t,i,n,o,s,r,c){"use strict";function a(e){n.call(this,e),o.call(this,e),this.addType(r.PickableGroup)}return a.prototype=Object.assign(Object.create(n.prototype),o.prototype,{constructor:a,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(r.inputOutput,"metadata",new e.SFNode),new t(r.inputOutput,"pickable",new e.SFBool(!0)),new t(r.inputOutput,"objectType",new e.MFString("ALL")),new t(r.inputOutput,"visible",new e.SFBool(!0)),new t(r.inputOutput,"bboxDisplay",new e.SFBool),new t(r.initializeOnly,"bboxSize",new e.SFVec3f(-1,-1,-1)),new t(r.initializeOnly,"bboxCenter",new e.SFVec3f),new t(r.inputOnly,"addChildren",new e.MFNode),new t(r.inputOnly,"removeChildren",new e.MFNode),new t(r.inputOutput,"children",new e.MFNode)]),getTypeName:function(){return"PickableGroup"},getComponentName:function(){return"Picking"},getContainerField:function(){return"children"},initialize:function(){n.prototype.initialize.call(this),o.prototype.initialize.call(this),this._pickable.addInterest("set_pickable__",this),this.set_pickable__()},set_pickableObjects__:function(){this.set_pickable__()},set_pickable__:function(){this.setPickableObject(Boolean(this._pickable.getValue()||this.getTransformSensors().size))},traverse:function(){const e=new Set;return function(t,i){if(t===c.PICKING){if(this._pickable.getValue()){if(this.getObjectType().has("NONE"))return;const o=i.getBrowser(),r=o.getPickable();if(this.getObjectType().has("ALL"))r.push(!0),n.prototype.traverse.call(this,t,i),r.pop();else{const c=o.getPickSensors();for(const t of c.at(-1)){if(!t.getObjectType().has("ALL")){let e=0;for(const i of this.getObjectType())if(t.getObjectType().has(i)){++e;break}switch(t.getMatchCriterion()){case s.MATCH_ANY:if(0===e)continue;break;case s.MATCH_EVERY:if(e!==pickSensor.getObjectType().size)continue;break;case s.MATCH_ONLY_ONE:if(1!==e)continue}}e.add(t)}r.push(!0),c.push(e),n.prototype.traverse.call(this,t,i),c.pop(),r.pop(),e.clear()}}}else n.prototype.traverse.call(this,t,i)}}()}),a})),t("x_ite/Browser/Picking/VolumePicker",["standard/Math/Numbers/Vector3","standard/Math/Numbers/Rotation4","standard/Math/Numbers/Matrix4",i.getComponentUrl("rigid-body-physics")],(function(e,t,i,n){"use strict";const o=n.Ammo;function s(){this.broadphase=new o.btDbvtBroadphase,this.collisionConfiguration=new o.btDefaultCollisionConfiguration,this.dispatcher=new o.btCollisionDispatcher(this.collisionConfiguration),this.collisionWorld=new o.btCollisionWorld(this.dispatcher,this.broadphase,this.collisionConfiguration),this.compoundShape1=new o.btCompoundShape,this.motionState1=new o.btDefaultMotionState,this.constructionInfo1=new o.btRigidBodyConstructionInfo(0,this.motionState1,this.compoundShape1),this.rigidBody1=new o.btRigidBody(this.constructionInfo1),this.compoundShape2=new o.btCompoundShape,this.motionState2=new o.btDefaultMotionState,this.constructionInfo2=new o.btRigidBodyConstructionInfo(0,this.motionState2,this.compoundShape2),this.rigidBody2=new o.btRigidBody(this.constructionInfo2),this.collisionWorld.addCollisionObject(this.rigidBody1),this.collisionWorld.addCollisionObject(this.rigidBody2)}return s.prototype={constuctor:s,setChildShape1:function(e,t){this.setChildShape(this.compoundShape1,e,t)},setChildShape2:function(e,t){this.setChildShape(this.compoundShape2,e,t)},setChildShape1Components:function(e,t,i){this.setChildShapeComponents(this.compoundShape1,e,t,i)},setChildShape2Components:function(e,t,i){this.setChildShapeComponents(this.compoundShape2,e,t,i)},setChildShape:function(){const i=new e(0,0,0),n=new t(0,0,1,0),s=new e(1,1,1),r=new o.btVector3(0,0,0);return function(e,t,o){try{e.getNumChildShapes()&&e.removeChildShapeByIndex(0),o.getNumChildShapes()&&(t.get(i,n,s),r.setValue(s.x,s.y,s.z),o.setLocalScaling(r),e.addChildShape(this.getTransform(i,n),o))}catch(e){}}}(),setChildShapeComponents:function(e,t,i,n){e.getNumChildShapes()&&e.removeChildShapeByIndex(0),n.getNumChildShapes()&&(n.setLocalScaling(i),e.addChildShape(t,n))},contactTest:function(){this.collisionWorld.performDiscreteCollisionDetection();const e=this.dispatcher.getNumManifolds();for(let t=0;t<e;++t){const e=this.dispatcher.getManifoldByIndexInternal(t),i=e.getNumContacts();for(let t=0;t<i;++t){if(e.getContactPoint(t).getDistance()<=0)return!0}}return!1},getTransform:function(){const e=new o.btTransform,t=new o.btVector3(0,0,0),n=new i;return function(i,o,s){const r=s||e;return n.set(i,o),t.setValue(n[12],n[13],n[14]),r.getBasis().setValue(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),r.setOrigin(t),r}}()},s})),t("x_ite/Components/Picking/PointPickSensor",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/Picking/X3DPickSensorNode","x_ite/Base/X3DCast","x_ite/Base/X3DConstants","x_ite/Browser/Picking/IntersectionType","x_ite/Browser/Picking/VolumePicker","standard/Math/Numbers/Vector3","standard/Math/Numbers/Rotation4","standard/Math/Geometry/Box3",i.getComponentUrl("rigid-body-physics")],(function(e,t,i,n,o,s,r,c,a,h,p,d){"use strict";var g,l,u,m,_,y,k,f,w,S,C,T,N,b=d.Ammo;function O(e){n.call(this,e),this.addType(s.PointPickSensor),this.pickingGeometryNode=null,this.picker=new c,this.compoundShapes=[]}return O.prototype=Object.assign(Object.create(n.prototype),{constructor:O,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(s.inputOutput,"metadata",new e.SFNode),new t(s.inputOutput,"enabled",new e.SFBool(!0)),new t(s.inputOutput,"objectType",new e.MFString("ALL")),new t(s.inputOutput,"matchCriterion",new e.SFString("MATCH_ANY")),new t(s.initializeOnly,"intersectionType",new e.SFString("BOUNDS")),new t(s.initializeOnly,"sortOrder",new e.SFString("CLOSEST")),new t(s.outputOnly,"isActive",new e.SFBool),new t(s.outputOnly,"pickedPoint",new e.MFVec3f),new t(s.inputOutput,"pickingGeometry",new e.SFNode),new t(s.inputOutput,"pickTarget",new e.MFNode),new t(s.outputOnly,"pickedGeometry",new e.MFNode)]),getTypeName:function(){return"PointPickSensor"},getComponentName:function(){return"Picking"},getContainerField:function(){return"children"},initialize:function(){n.prototype.initialize.call(this),this._pickingGeometry.addInterest("set_pickingGeometry__",this),this.set_pickingGeometry__()},set_pickingGeometry__:function(){this.pickingGeometryNode&&this.pickingGeometryNode._rebuild.removeInterest("set_geometry__",this),this.pickingGeometryNode=o(s.PointSet,this._pickingGeometry),this.pickingGeometryNode&&this.pickingGeometryNode._rebuild.addInterest("set_geometry__",this),this.set_geometry__()},set_geometry__:(C=new b.btVector3(1,1,1),T=new b.btVector3,N=new b.btTransform,function(){var e=this.compoundShapes;if(this.pickingGeometryNode){var t=this.pickingGeometryNode.getCoord();if(t){for(var i=0,n=t.getSize();i<n;++i)if(i<e.length){var o=e[i],s=t.get1Point(i,o.point);T.setValue(s.x,s.y,s.z),N.setOrigin(T),o.setLocalScaling(C),o.updateChildTransform(0,N)}else{o=new b.btCompoundShape;var r=new b.btSphereShape(0);s=t.get1Point(i,new a(0,0,0)),o.point=s,T.setValue(s.x,s.y,s.z),N.setOrigin(T),o.addChildShape(N,r),e.push(o)}e.length=n}else e.length=0}else e.length=0}),process:(g=new p,l=new p,u=new a(0,0,0),m=new a(0,0,0),_=new b.btTransform,y=new b.btVector3,k=new a(0,0,0),f=new h(0,0,1,0),w=new a(1,1,1),S=new e.MFVec3f,function(){if(this.pickingGeometryNode){var e=this.getModelMatrices(),t=this.getTargets();switch(this.getIntersectionType()){case r.BOUNDS:for(var i=0,o=e.length;i<o;++i){var s=e[i];g.assign(this.pickingGeometryNode.getBBox()).multRight(s);for(var c=0,a=t.size;c<a;++c){var h=t[c];l.assign(h.geometryNode.getBBox()).multRight(h.modelMatrix),g.intersectsBox(l)&&(u.assign(g.center),m.assign(l.center),h.intersected=!0,h.distance=u.distance(m))}}var p=this.getPickedGeometries(),d=Boolean(p.length);p.remove(0,p.length,null),d!==this._isActive.getValue()&&(this._isActive=d),this._pickedGeometry.equals(p)||(this._pickedGeometry=p);break;case r.GEOMETRY:var C=this.picker,T=this.compoundShapes;for(i=0,o=e.length;i<o;++i){s=e[i],g.assign(this.pickingGeometryNode.getBBox()).multRight(s),s.get(k,f,w),C.getTransform(k,f,_),y.setValue(w.x,w.y,w.z);for(var N=0,b=T.length;N<b;++N){var O=T[N];for(C.setChildShape1Components(_,y,O),c=0,a=t.size;c<a;++c){h=t[c];var x=this.getPickShape(h.geometryNode);l.assign(h.geometryNode.getBBox()).multRight(h.modelMatrix),C.setChildShape2(h.modelMatrix,x.getCompoundShape()),C.contactTest()&&(u.assign(g.center),m.assign(l.center),h.intersected=!0,h.distance=u.distance(m),h.pickedPoint.push(O.point))}}}p=this.getPickedGeometries(),d=Boolean(p.length),p.remove(0,p.length,null),d!==this._isActive.getValue()&&(this._isActive=d),this._pickedGeometry.equals(p)||(this._pickedGeometry=p);var P=this.getPickedTargets();for(S.length=0,c=0,a=P.length;c<a;++c)for(var v=P[c].pickedPoint,B=0,M=v.length;B<M;++B)S.push(v[B]);this._pickedPoint.equals(S)||(this._pickedPoint=S)}}n.prototype.process.call(this)})}),O})),t("x_ite/Components/Picking/PrimitivePickSensor",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/Picking/X3DPickSensorNode","x_ite/Base/X3DConstants","x_ite/Browser/Picking/IntersectionType","x_ite/Browser/Picking/VolumePicker","standard/Math/Numbers/Vector3","standard/Math/Geometry/Box3"],(function(e,t,i,n,o,s,r,c,a){"use strict";function h(e){n.call(this,e),this.addType(o.PrimitivePickSensor),this.pickingGeometryNode=null,this.picker=new r}var p,d,g,l;return h.prototype=Object.assign(Object.create(n.prototype),{constructor:h,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(o.inputOutput,"metadata",new e.SFNode),new t(o.inputOutput,"enabled",new e.SFBool(!0)),new t(o.inputOutput,"objectType",new e.MFString("ALL")),new t(o.inputOutput,"matchCriterion",new e.SFString("MATCH_ANY")),new t(o.initializeOnly,"intersectionType",new e.SFString("BOUNDS")),new t(o.initializeOnly,"sortOrder",new e.SFString("CLOSEST")),new t(o.outputOnly,"isActive",new e.SFBool),new t(o.inputOutput,"pickingGeometry",new e.SFNode),new t(o.inputOutput,"pickTarget",new e.MFNode),new t(o.outputOnly,"pickedGeometry",new e.MFNode)]),getTypeName:function(){return"PrimitivePickSensor"},getComponentName:function(){return"Picking"},getContainerField:function(){return"children"},initialize:function(){n.prototype.initialize.call(this),this._pickingGeometry.addInterest("set_pickingGeometry__",this),this.set_pickingGeometry__()},set_pickingGeometry__:function(){this.pickingGeometryNode=null;try{for(var e=this._pickingGeometry.getValue().getInnerNode(),t=e.getType(),i=t.length-1;i>=0;--i)switch(t[i]){case o.Box:case o.Cone:case o.Cylinder:case o.Sphere:this.pickingGeometryNode=e;break;default:continue}}catch(e){}},process:(p=new a,d=new a,g=new c(0,0,0),l=new c(0,0,0),function(){if(this.pickingGeometryNode){var e=this.getModelMatrices(),t=this.getTargets();switch(this.getIntersectionType()){case s.BOUNDS:for(var i=0,o=e.length;i<o;++i){var r=e[i];p.assign(this.pickingGeometryNode.getBBox()).multRight(r);for(var c=0,a=t.size;c<a;++c){var h=t[c];d.assign(h.geometryNode.getBBox()).multRight(h.modelMatrix),p.intersectsBox(d)&&(g.assign(p.center),l.assign(d.center),h.intersected=!0,h.distance=g.distance(l))}}var u=this.getPickedGeometries(),m=Boolean(u.length);u.remove(0,u.length,null),m!==this._isActive.getValue()&&(this._isActive=m),this._pickedGeometry.equals(u)||(this._pickedGeometry=u);break;case s.GEOMETRY:var _=this.picker;for(i=0,o=e.length;i<o;++i){r=e[i];var y=this.getPickShape(this.pickingGeometryNode);for(p.assign(this.pickingGeometryNode.getBBox()).multRight(r),_.setChildShape1(r,y.getCompoundShape()),c=0,a=t.size;c<a;++c){h=t[c];var k=this.getPickShape(h.geometryNode);d.assign(h.geometryNode.getBBox()).multRight(h.modelMatrix),_.setChildShape2(h.modelMatrix,k.getCompoundShape()),_.contactTest()&&(g.assign(p.center),l.assign(d.center),h.intersected=!0,h.distance=g.distance(l))}}u=this.getPickedGeometries(),m=Boolean(u.length),u.remove(0,u.length,null),m!==this._isActive.getValue()&&(this._isActive=m),this._pickedGeometry.equals(u)||(this._pickedGeometry=u)}}n.prototype.process.call(this)})}),h})),t("x_ite/Components/Picking/VolumePickSensor",["x_ite/Fields","x_ite/Base/X3DFieldDefinition","x_ite/Base/FieldDefinitionArray","x_ite/Components/Picking/X3DPickSensorNode","x_ite/Base/X3DCast","x_ite/Base/X3DConstants","x_ite/Browser/Picking/IntersectionType","x_ite/Browser/Picking/VolumePicker","standard/Math/Numbers/Vector3","standard/Math/Geometry/Box3"],(function(e,t,i,n,o,s,r,c,a,h){"use strict";function p(e){n.call(this,e),this.addType(s.VolumePickSensor),this.pickingGeometryNode=null,this.picker=new c}var d,g,l,u;return p.prototype=Object.assign(Object.create(n.prototype),{constructor:p,[Symbol.for("X_ITE.X3DBaseNode.fieldDefinitions")]:new i([new t(s.inputOutput,"metadata",new e.SFNode),new t(s.inputOutput,"enabled",new e.SFBool(!0)),new t(s.inputOutput,"objectType",new e.MFString("ALL")),new t(s.inputOutput,"matchCriterion",new e.SFString("MATCH_ANY")),new t(s.initializeOnly,"intersectionType",new e.SFString("BOUNDS")),new t(s.initializeOnly,"sortOrder",new e.SFString("CLOSEST")),new t(s.outputOnly,"isActive",new e.SFBool),new t(s.inputOutput,"pickingGeometry",new e.SFNode),new t(s.inputOutput,"pickTarget",new e.MFNode),new t(s.outputOnly,"pickedGeometry",new e.MFNode)]),getTypeName:function(){return"VolumePickSensor"},getComponentName:function(){return"Picking"},getContainerField:function(){return"children"},initialize:function(){n.prototype.initialize.call(this),this._pickingGeometry.addInterest("set_pickingGeometry__",this),this.set_pickingGeometry__()},set_pickingGeometry__:function(){this.pickingGeometryNode=o(s.X3DGeometryNode,this._pickingGeometry)},process:(d=new h,g=new h,l=new a(0,0,0),u=new a(0,0,0),function(){if(this.pickingGeometryNode){var e=this.getModelMatrices(),t=this.getTargets();switch(this.getIntersectionType()){case r.BOUNDS:for(var i=0,o=e.length;i<o;++i){var s=e[i];d.assign(this.pickingGeometryNode.getBBox()).multRight(s);for(var c=0,a=t.size;c<a;++c){var h=t[c];g.assign(h.geometryNode.getBBox()).multRight(h.modelMatrix),d.intersectsBox(g)&&(l.assign(d.center),u.assign(g.center),h.intersected=!0,h.distance=l.distance(u))}}var p=this.getPickedGeometries(),m=Boolean(p.length);p.remove(0,p.length,null),m!==this._isActive.getValue()&&(this._isActive=m),this._pickedGeometry.equals(p)||(this._pickedGeometry=p);break;case r.GEOMETRY:var _=this.picker;for(i=0,o=e.length;i<o;++i){s=e[i];var y=this.getPickShape(this.pickingGeometryNode);for(d.assign(this.pickingGeometryNode.getBBox()).multRight(s),_.setChildShape1(s,y.getCompoundShape()),c=0,a=t.size;c<a;++c){h=t[c];var k=this.getPickShape(h.geometryNode);g.assign(h.geometryNode.getBBox()).multRight(h.modelMatrix),_.setChildShape2(h.modelMatrix,k.getCompoundShape()),_.contactTest()&&(l.assign(d.center),u.assign(g.center),h.intersected=!0,h.distance=l.distance(u))}}p=this.getPickedGeometries(),m=Boolean(p.length),p.remove(0,p.length,null),m!==this._isActive.getValue()&&(this._isActive=m),this._pickedGeometry.equals(p)||(this._pickedGeometry=p)}}n.prototype.process.call(this)})}),p})),t(i.getComponentUrl("picking"),["x_ite/Components","x_ite/Components/Picking/LinePickSensor","x_ite/Components/Picking/PickableGroup","x_ite/Components/Picking/PointPickSensor","x_ite/Components/Picking/PrimitivePickSensor","x_ite/Components/Picking/VolumePickSensor","x_ite/Components/Picking/X3DPickSensorNode","x_ite/Components/Picking/X3DPickableObject",i.getComponentUrl("rigid-body-physics")],(function(e,t,i,n,o,s,r,c){"use strict";e.addComponent({name:"Picking",types:{LinePickSensor:t,PickableGroup:i,PointPickSensor:n,PrimitivePickSensor:o,VolumePickSensor:s},abstractTypes:{X3DPickSensorNode:r,X3DPickableObject:c}})}))}();