@woosh/meep-engine 2.106.1 → 2.107.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 (587) hide show
  1. package/build/meep.cjs +1990 -2364
  2. package/build/meep.min.js +1 -1
  3. package/build/meep.module.js +1990 -2364
  4. package/editor/Editor.js +55 -60
  5. package/editor/SelectionVisualizer.js +111 -109
  6. package/editor/actions/concrete/ComponentAddAction.js +0 -3
  7. package/editor/actions/concrete/ComponentRemoveAction.js +0 -4
  8. package/editor/actions/concrete/EntityCreateAction.js +0 -3
  9. package/editor/actions/concrete/EntityRemoveAction.js +0 -4
  10. package/editor/actions/concrete/SelectionAddAction.js +0 -3
  11. package/editor/actions/concrete/SelectionClearAction.js +0 -3
  12. package/editor/actions/concrete/SelectionRemoveAction.js +0 -3
  13. package/editor/ecs/EditorEntity.js +8 -6
  14. package/editor/tools/SelectionTool.js +0 -5
  15. package/editor/tools/TopDownCameraControlTool.js +2 -5
  16. package/editor/tools/TransformTool.js +137 -136
  17. package/editor/tools/engine/Tool.js +1 -6
  18. package/editor/tools/engine/ToolEngine.js +145 -148
  19. package/editor/tools/v2/TransformControls.js +25 -24
  20. package/editor/view/EditorView.js +0 -5
  21. package/editor/view/ecs/ComponentControlFactory.js +37 -40
  22. package/editor/view/ecs/EntityEditor.js +0 -3
  23. package/editor/view/ecs/EntityList.js +6 -11
  24. package/editor/view/ecs/components/MeshController.js +4 -7
  25. package/editor/view/ecs/components/TransformController.js +3 -9
  26. package/editor/view/tools/ToolView.js +2 -8
  27. package/package.json +1 -1
  28. package/src/core/IdPool.d.ts.map +1 -1
  29. package/src/core/IdPool.js +0 -5
  30. package/src/core/UUID.d.ts.map +1 -1
  31. package/src/core/UUID.js +0 -4
  32. package/src/core/binary/BitSet.d.ts +17 -14
  33. package/src/core/binary/BitSet.d.ts.map +1 -1
  34. package/src/core/binary/BitSet.js +411 -412
  35. package/src/core/binary/type/Field.d.ts +0 -8
  36. package/src/core/binary/type/Field.d.ts.map +1 -1
  37. package/src/core/binary/type/Field.js +16 -19
  38. package/src/core/binary/type/MultiplicityType.js +0 -4
  39. package/src/core/binary/type/PrimitiveTypes.d.ts.map +1 -1
  40. package/src/core/binary/type/PrimitiveTypes.js +0 -4
  41. package/src/core/binary/type/Type.d.ts +0 -6
  42. package/src/core/binary/type/Type.d.ts.map +1 -1
  43. package/src/core/binary/type/Type.js +63 -64
  44. package/src/core/binary/type/TypeBuilder.d.ts +0 -1
  45. package/src/core/binary/type/TypeBuilder.d.ts.map +1 -1
  46. package/src/core/binary/type/TypeBuilder.js +15 -18
  47. package/src/core/binary/type/TypeRegistry.d.ts +6 -4
  48. package/src/core/binary/type/TypeRegistry.d.ts.map +1 -1
  49. package/src/core/binary/type/TypeRegistry.js +38 -42
  50. package/src/core/bvh2/visual/BVHGeometry.d.ts.map +1 -1
  51. package/src/core/bvh2/visual/BVHGeometry.js +0 -3
  52. package/src/core/codegen/LineBuilder.d.ts.map +1 -1
  53. package/src/core/codegen/LineBuilder.js +0 -5
  54. package/src/core/collection/set/ArraySet.d.ts.map +1 -1
  55. package/src/core/collection/set/ArraySet.js +1 -5
  56. package/src/core/collection/table/RowFirstTable.d.ts.map +1 -1
  57. package/src/core/collection/table/RowFirstTable.js +0 -5
  58. package/src/core/color/parse_color.d.ts.map +1 -1
  59. package/src/core/color/parse_color.js +1 -5
  60. package/src/core/geom/2d/Rectangle.d.ts.map +1 -1
  61. package/src/core/geom/2d/Rectangle.js +0 -4
  62. package/src/core/geom/2d/aabb/AABB2.d.ts.map +1 -1
  63. package/src/core/geom/2d/aabb/AABB2.js +0 -6
  64. package/src/core/geom/3d/aabb/AABB3.d.ts.map +1 -1
  65. package/src/core/geom/3d/aabb/AABB3.js +0 -5
  66. package/src/core/geom/3d/morton/Morton.d.ts.map +1 -1
  67. package/src/core/geom/3d/morton/Morton.js +0 -3
  68. package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +11 -11
  69. package/src/core/geom/Quaternion.d.ts.map +1 -1
  70. package/src/core/geom/Quaternion.js +0 -5
  71. package/src/core/geom/Vector4.d.ts.map +1 -1
  72. package/src/core/geom/Vector4.js +0 -4
  73. package/src/core/graph/Edge.d.ts.map +1 -1
  74. package/src/core/graph/Edge.js +0 -5
  75. package/src/core/graph/WeightedEdge.d.ts.map +1 -1
  76. package/src/core/json/JsonUtils.d.ts.map +1 -1
  77. package/src/core/json/JsonUtils.js +0 -4
  78. package/src/core/math/random/MersenneTwister.d.ts +1 -2
  79. package/src/core/math/random/MersenneTwister.d.ts.map +1 -1
  80. package/src/core/math/random/MersenneTwister.js +134 -133
  81. package/src/core/model/BooleanVector3.d.ts.map +1 -1
  82. package/src/core/model/BooleanVector3.js +108 -108
  83. package/src/core/model/BoundedValue.d.ts +116 -0
  84. package/src/core/model/BoundedValue.d.ts.map +1 -0
  85. package/src/core/model/BoundedValue.js +214 -217
  86. package/src/core/model/LinearValue.d.ts +84 -0
  87. package/src/core/model/LinearValue.d.ts.map +1 -0
  88. package/src/core/model/LinearValue.js +116 -117
  89. package/src/core/model/ObservedEnum.d.ts.map +1 -1
  90. package/src/core/model/ObservedEnum.js +82 -80
  91. package/src/core/model/ObservedValue.d.ts +10 -17
  92. package/src/core/model/ObservedValue.d.ts.map +1 -1
  93. package/src/core/model/ObservedValue.js +85 -88
  94. package/src/core/model/object/ObjectPoolFactory.d.ts +1 -9
  95. package/src/core/model/object/ObjectPoolFactory.d.ts.map +1 -1
  96. package/src/core/model/object/ObjectPoolFactory.js +73 -73
  97. package/src/core/model/scheme/Schema.d.ts +0 -6
  98. package/src/core/model/scheme/Schema.d.ts.map +1 -1
  99. package/src/core/model/scheme/Schema.js +50 -48
  100. package/src/core/model/scheme/SchemeRegistry.d.ts +6 -1
  101. package/src/core/model/scheme/SchemeRegistry.d.ts.map +1 -1
  102. package/src/core/model/scheme/SchemeRegistry.js +46 -44
  103. package/src/core/process/Future.d.ts +14 -9
  104. package/src/core/process/Future.d.ts.map +1 -1
  105. package/src/core/process/Future.js +96 -98
  106. package/src/core/process/executor/ConcurrentExecutor.d.ts.map +1 -1
  107. package/src/core/process/executor/ConcurrentExecutor.js +0 -3
  108. package/src/core/process/task/Task.d.ts.map +1 -1
  109. package/src/core/process/task/Task.js +0 -5
  110. package/src/core/process/task/TaskGroup.d.ts.map +1 -1
  111. package/src/core/process/task/TaskGroup.js +178 -180
  112. package/src/core/process/task/TaskSignal.d.ts.map +1 -1
  113. package/src/core/process/task/TaskSignal.js +0 -5
  114. package/src/core/process/task/TaskState.d.ts.map +1 -1
  115. package/src/core/process/task/TaskState.js +0 -4
  116. package/src/core/process/worker/WorkerBuilder.d.ts.map +1 -1
  117. package/src/core/process/worker/WorkerBuilder.js +0 -5
  118. package/src/core/process/worker/WorkerProxy.d.ts.map +1 -1
  119. package/src/core/process/worker/WorkerProxy.js +0 -5
  120. package/src/engine/Clock.d.ts.map +1 -1
  121. package/src/engine/Clock.js +0 -5
  122. package/src/engine/Engine.js +4 -4
  123. package/src/engine/EntityCreator.d.ts.map +1 -1
  124. package/src/engine/EntityCreator.js +7 -10
  125. package/src/engine/animation/AnimatedActions.d.ts.map +1 -1
  126. package/src/engine/animation/AnimatedActions.js +0 -5
  127. package/src/engine/animation/Animations.d.ts.map +1 -1
  128. package/src/engine/animation/Animations.js +1 -6
  129. package/src/engine/animation/EntityAnimation.js +1 -4
  130. package/src/engine/animation/Tween.js +1 -4
  131. package/src/engine/animation/keyed2/AnimationTrack.d.ts +0 -6
  132. package/src/engine/animation/keyed2/AnimationTrack.d.ts.map +1 -1
  133. package/src/engine/animation/keyed2/AnimationTrack.js +154 -152
  134. package/src/engine/animation/keyed2/AnimationTrackPlayback.d.ts +0 -10
  135. package/src/engine/animation/keyed2/AnimationTrackPlayback.d.ts.map +1 -1
  136. package/src/engine/animation/keyed2/AnimationTrackPlayback.js +173 -171
  137. package/src/engine/asset/AssetManager.d.ts.map +1 -1
  138. package/src/engine/asset/AssetManager.js +0 -5
  139. package/src/engine/asset/preloader/AssetLevel.js +0 -3
  140. package/src/engine/ecs/EntityManager.d.ts.map +1 -1
  141. package/src/engine/ecs/EntityManager.js +0 -4
  142. package/src/engine/ecs/System.d.ts.map +1 -1
  143. package/src/engine/ecs/System.js +0 -5
  144. package/src/engine/ecs/animation/Animation.d.ts.map +1 -1
  145. package/src/engine/ecs/animation/Animation.js +1 -19
  146. package/src/engine/ecs/components/Motion.d.ts.map +1 -1
  147. package/src/engine/ecs/components/Motion.js +0 -5
  148. package/src/engine/ecs/components/PropertySet.d.ts +8 -1
  149. package/src/engine/ecs/components/PropertySet.d.ts.map +1 -1
  150. package/src/engine/ecs/components/PropertySet.js +87 -83
  151. package/src/engine/ecs/components/Script.d.ts +0 -16
  152. package/src/engine/ecs/components/Script.d.ts.map +1 -1
  153. package/src/engine/ecs/components/Script.js +14 -18
  154. package/src/engine/ecs/components/Tag.d.ts.map +1 -1
  155. package/src/engine/ecs/components/Tag.js +4 -5
  156. package/src/engine/ecs/components/Timer.d.ts +0 -5
  157. package/src/engine/ecs/components/Timer.d.ts.map +1 -1
  158. package/src/engine/ecs/components/Timer.js +0 -5
  159. package/src/engine/ecs/grid/HeightMap2NormalMap.d.ts.map +1 -1
  160. package/src/engine/ecs/grid/HeightMap2NormalMap.js +2 -6
  161. package/src/engine/ecs/grid/HeightSampler2NormalSamplerSoft.d.ts.map +1 -1
  162. package/src/engine/ecs/grid/HeightSampler2NormalSamplerSoft.js +0 -3
  163. package/src/engine/ecs/grid/NormalMap2AOMap.d.ts.map +1 -1
  164. package/src/engine/ecs/grid/NormalMap2AOMap.js +3 -8
  165. package/src/engine/ecs/gui/GUIElement.d.ts.map +1 -1
  166. package/src/engine/ecs/gui/GUIElement.js +0 -3
  167. package/src/engine/ecs/gui/GUIElementSystem.d.ts.map +1 -1
  168. package/src/engine/ecs/gui/GUIElementSystem.js +0 -4
  169. package/src/engine/ecs/gui/hud/HeadsUpDisplay.d.ts.map +1 -1
  170. package/src/engine/ecs/gui/hud/HeadsUpDisplay.js +0 -7
  171. package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.d.ts.map +1 -1
  172. package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +0 -5
  173. package/src/engine/ecs/gui/menu/radial/RadialContextMenu.d.ts.map +1 -1
  174. package/src/engine/ecs/gui/menu/radial/RadialContextMenu.js +5 -8
  175. package/src/engine/ecs/gui/position/ViewportPosition.d.ts.map +1 -1
  176. package/src/engine/ecs/gui/position/ViewportPosition.js +0 -4
  177. package/src/engine/ecs/gui/position/ViewportPositionSystem.d.ts +1 -2
  178. package/src/engine/ecs/gui/position/ViewportPositionSystem.d.ts.map +1 -1
  179. package/src/engine/ecs/gui/position/ViewportPositionSystem.js +6 -10
  180. package/src/engine/ecs/ik/IKProblem.d.ts +1 -2
  181. package/src/engine/ecs/ik/IKProblem.d.ts.map +1 -1
  182. package/src/engine/ecs/renderable/RenderSystem.d.ts.map +1 -1
  183. package/src/engine/ecs/renderable/RenderSystem.js +0 -3
  184. package/src/engine/ecs/renderable/Renderable.d.ts.map +1 -1
  185. package/src/engine/ecs/renderable/Renderable.js +0 -5
  186. package/src/engine/ecs/systems/AnimationSystem.d.ts.map +1 -1
  187. package/src/engine/ecs/systems/AnimationSystem.js +9 -17
  188. package/src/engine/ecs/systems/MotionSystem.d.ts.map +1 -1
  189. package/src/engine/ecs/systems/MotionSystem.js +1 -6
  190. package/src/engine/ecs/systems/ScriptSystem.d.ts.map +1 -1
  191. package/src/engine/ecs/systems/ScriptSystem.js +1 -6
  192. package/src/engine/ecs/systems/TimerSystem.d.ts.map +1 -1
  193. package/src/engine/ecs/systems/TimerSystem.js +1 -6
  194. package/src/engine/ecs/team/Team.d.ts.map +1 -1
  195. package/src/engine/ecs/team/Team.js +0 -3
  196. package/src/engine/ecs/terrain/BufferedGeometryArraysBuilder.d.ts.map +1 -1
  197. package/src/engine/ecs/terrain/BufferedGeometryArraysBuilder.js +0 -5
  198. package/src/engine/ecs/terrain/TerrainClouds.d.ts.map +1 -1
  199. package/src/engine/ecs/terrain/TerrainClouds.js +0 -5
  200. package/src/engine/ecs/terrain/ecs/Terrain.d.ts.map +1 -1
  201. package/src/engine/ecs/terrain/ecs/Terrain.js +0 -5
  202. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrain.d.ts.map +1 -1
  203. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrain.js +0 -3
  204. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.d.ts.map +1 -1
  205. package/src/engine/ecs/terrain/ecs/cling/ClingToTerrainSystem.js +11 -14
  206. package/src/engine/ecs/terrain/overlay/TerrainOverlay.d.ts.map +1 -1
  207. package/src/engine/ecs/terrain/overlay/TerrainOverlay.js +0 -5
  208. package/src/engine/ecs/terrain/tiles/TerrainTile.d.ts.map +1 -1
  209. package/src/engine/ecs/terrain/tiles/TerrainTile.js +0 -5
  210. package/src/engine/ecs/terrain/tiles/TerrainTileManager.d.ts +1 -1
  211. package/src/engine/ecs/terrain/tiles/TerrainTileManager.d.ts.map +1 -1
  212. package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +0 -3
  213. package/src/engine/ecs/terrain/tiles/TileBuildWorker.js +0 -4
  214. package/src/engine/ecs/transform/Transform.d.ts.map +1 -1
  215. package/src/engine/ecs/transform/Transform.js +0 -4
  216. package/src/engine/google/gapi.js +0 -4
  217. package/src/engine/graphics/FrameThrottle.d.ts +0 -4
  218. package/src/engine/graphics/FrameThrottle.d.ts.map +1 -1
  219. package/src/engine/graphics/FrameThrottle.js +0 -5
  220. package/src/engine/graphics/GraphicsEngine.d.ts.map +1 -1
  221. package/src/engine/graphics/GraphicsEngine.js +1 -6
  222. package/src/engine/graphics/composit/LayerCompositer.d.ts.map +1 -1
  223. package/src/engine/graphics/composit/LayerCompositer.js +2 -5
  224. package/src/engine/graphics/ecs/animation/AnimationController.d.ts.map +1 -1
  225. package/src/engine/graphics/ecs/animation/AnimationController.js +0 -5
  226. package/src/engine/graphics/ecs/animation/AnimationControllerSystem.d.ts.map +1 -1
  227. package/src/engine/graphics/ecs/animation/AnimationControllerSystem.js +2 -7
  228. package/src/engine/graphics/ecs/animation/AnimationRule.d.ts +0 -1
  229. package/src/engine/graphics/ecs/animation/AnimationRule.d.ts.map +1 -1
  230. package/src/engine/graphics/ecs/animation/AnimationRule.js +70 -66
  231. package/src/engine/graphics/ecs/camera/Camera.d.ts.map +1 -1
  232. package/src/engine/graphics/ecs/camera/Camera.js +0 -5
  233. package/src/engine/graphics/ecs/camera/CameraSystem.d.ts.map +1 -1
  234. package/src/engine/graphics/ecs/camera/CameraSystem.js +0 -5
  235. package/src/engine/graphics/ecs/camera/FrustumProjector.d.ts.map +1 -1
  236. package/src/engine/graphics/ecs/camera/FrustumProjector.js +0 -5
  237. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.d.ts.map +1 -1
  238. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraController.js +4 -9
  239. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.d.ts.map +1 -1
  240. package/src/engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js +3 -8
  241. package/src/engine/graphics/ecs/highlight/Highlight.d.ts.map +1 -1
  242. package/src/engine/graphics/ecs/highlight/Highlight.js +0 -3
  243. package/src/engine/graphics/ecs/highlight/system/MeshHighlightSystem.d.ts.map +1 -1
  244. package/src/engine/graphics/ecs/highlight/system/MeshHighlightSystem.js +3 -8
  245. package/src/engine/graphics/ecs/light/Light.d.ts.map +1 -1
  246. package/src/engine/graphics/ecs/light/Light.js +2 -6
  247. package/src/engine/graphics/ecs/light/LightSystem.d.ts.map +1 -1
  248. package/src/engine/graphics/ecs/light/LightSystem.js +0 -5
  249. package/src/engine/graphics/ecs/mesh/Mesh.d.ts.map +1 -1
  250. package/src/engine/graphics/ecs/mesh/Mesh.js +0 -3
  251. package/src/engine/graphics/ecs/mesh/MeshSystem.d.ts.map +1 -1
  252. package/src/engine/graphics/ecs/mesh/MeshSystem.js +0 -5
  253. package/src/engine/graphics/ecs/trail2d/Trail2D.d.ts.map +1 -1
  254. package/src/engine/graphics/ecs/trail2d/Trail2D.js +0 -5
  255. package/src/engine/graphics/ecs/trail2d/Trail2DSystem.d.ts.map +1 -1
  256. package/src/engine/graphics/ecs/trail2d/Trail2DSystem.js +0 -5
  257. package/src/engine/graphics/ecs/water/Water.d.ts.map +1 -1
  258. package/src/engine/graphics/ecs/water/Water.js +0 -5
  259. package/src/engine/graphics/ecs/water/WaterSystem.d.ts.map +1 -1
  260. package/src/engine/graphics/ecs/water/WaterSystem.js +0 -3
  261. package/src/engine/graphics/filter/ImageFilter.d.ts.map +1 -1
  262. package/src/engine/graphics/filter/ImageFilter.js +0 -5
  263. package/src/engine/graphics/geometry/BufferGeometryWrap.js +1 -3
  264. package/src/engine/graphics/geometry/buffered/ComputeNormals.d.ts.map +1 -1
  265. package/src/engine/graphics/geometry/buffered/ComputeNormals.js +0 -5
  266. package/src/engine/graphics/geometry/ribbon/Ribbon.d.ts.map +1 -1
  267. package/src/engine/graphics/geometry/ribbon/Ribbon.js +1 -4
  268. package/src/engine/graphics/material/SplatMaterial.d.ts.map +1 -1
  269. package/src/engine/graphics/material/SplatMaterial.js +0 -3
  270. package/src/engine/graphics/material/WaterMaterial.d.ts.map +1 -1
  271. package/src/engine/graphics/material/WaterMaterial.js +0 -3
  272. package/src/engine/graphics/particles/particular/engine/MovingBoundingBox.d.ts +0 -5
  273. package/src/engine/graphics/particles/particular/engine/MovingBoundingBox.d.ts.map +1 -1
  274. package/src/engine/graphics/particles/particular/engine/MovingBoundingBox.js +114 -114
  275. package/src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.d.ts +0 -1
  276. package/src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.d.ts.map +1 -1
  277. package/src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +347 -348
  278. package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.d.ts +1 -3
  279. package/src/engine/graphics/particles/particular/engine/emitter/ParticlePool.d.ts.map +1 -1
  280. package/src/engine/graphics/particles/particular/engine/parameter/ParameterSet.d.ts +0 -1
  281. package/src/engine/graphics/particles/particular/engine/parameter/ParameterSet.d.ts.map +1 -1
  282. package/src/engine/graphics/particles/particular/engine/parameter/ParameterSet.js +110 -111
  283. package/src/engine/graphics/particles/particular/engine/parameter/ParameterSheet.d.ts +0 -9
  284. package/src/engine/graphics/particles/particular/engine/parameter/ParameterSheet.d.ts.map +1 -1
  285. package/src/engine/graphics/particles/particular/engine/parameter/ParameterSheet.js +70 -66
  286. package/src/engine/graphics/particles/particular/engine/parameter/ParameterTrackSet.d.ts +0 -5
  287. package/src/engine/graphics/particles/particular/engine/parameter/ParameterTrackSet.d.ts.map +1 -1
  288. package/src/engine/graphics/particles/particular/engine/parameter/ParameterTrackSet.js +82 -82
  289. package/src/engine/graphics/particles/particular/group/Operation.d.ts +0 -7
  290. package/src/engine/graphics/particles/particular/group/Operation.d.ts.map +1 -1
  291. package/src/engine/graphics/particles/particular/group/Operation.js +16 -14
  292. package/src/engine/graphics/particles/particular/group/ParticleAttribute.d.ts +0 -9
  293. package/src/engine/graphics/particles/particular/group/ParticleAttribute.d.ts.map +1 -1
  294. package/src/engine/graphics/particles/particular/group/ParticleAttribute.js +23 -21
  295. package/src/engine/graphics/particles/particular/group/ParticleGroup.d.ts +2 -10
  296. package/src/engine/graphics/particles/particular/group/ParticleGroup.d.ts.map +1 -1
  297. package/src/engine/graphics/particles/particular/group/ParticleGroup.js +463 -464
  298. package/src/engine/graphics/particles/particular/group/ParticleSpecification.d.ts +0 -2
  299. package/src/engine/graphics/particles/particular/group/ParticleSpecification.d.ts.map +1 -1
  300. package/src/engine/graphics/particles/particular/group/ParticleSpecification.js +39 -33
  301. package/src/engine/graphics/render/buffer/FrameBufferManager.d.ts +6 -1
  302. package/src/engine/graphics/render/buffer/FrameBufferManager.d.ts.map +1 -1
  303. package/src/engine/graphics/render/buffer/FrameBufferManager.js +166 -163
  304. package/src/engine/graphics/render/layers/RenderLayer.d.ts.map +1 -1
  305. package/src/engine/graphics/render/layers/RenderLayer.js +0 -5
  306. package/src/engine/graphics/shaders/AlphaBlendShader.js +1 -3
  307. package/src/engine/graphics/shaders/AmbientOcclusionShader.d.ts.map +1 -1
  308. package/src/engine/graphics/shaders/AmbientOcclusionShader.js +0 -3
  309. package/src/engine/graphics/shaders/ClearShader.js +1 -3
  310. package/src/engine/graphics/shaders/CopyShader.d.ts +0 -3
  311. package/src/engine/graphics/shaders/CopyShader.d.ts.map +1 -1
  312. package/src/engine/graphics/shaders/CopyShader.js +1 -3
  313. package/src/engine/graphics/shaders/NormalMapShader2.d.ts.map +1 -1
  314. package/src/engine/graphics/shaders/NormalMapShader2.js +0 -5
  315. package/src/engine/graphics/shaders/TerrainShader.js +0 -4
  316. package/src/engine/graphics/shaders/WaterShader.js +0 -3
  317. package/src/engine/graphics/shaders/lib/ShaderChunks.js +1 -3
  318. package/src/engine/graphics/texture/Canvas2Sampler2D.d.ts.map +1 -1
  319. package/src/engine/graphics/texture/Canvas2Sampler2D.js +1 -4
  320. package/src/engine/graphics/texture/CheckersTexture.d.ts.map +1 -1
  321. package/src/engine/graphics/texture/CheckersTexture.js +0 -3
  322. package/src/engine/graphics/texture/CheckersTextureURI.js +1 -3
  323. package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
  324. package/src/engine/graphics/texture/sampler/Sampler2D.js +0 -5
  325. package/src/engine/graphics/texture/sampler/Sampler2D2Canvas.d.ts.map +1 -1
  326. package/src/engine/graphics/texture/sampler/Sampler2D2Canvas.js +0 -5
  327. package/src/engine/graphics/texture/sampler/Sampler2D2Texture.d.ts.map +1 -1
  328. package/src/engine/graphics/texture/sampler/Sampler2D2Texture.js +0 -3
  329. package/src/engine/graphics/three/ThreeFactory.d.ts.map +1 -1
  330. package/src/engine/graphics/three/ThreeFactory.js +0 -5
  331. package/src/engine/grid/grid2transform/GridPosition2Transform.d.ts.map +1 -1
  332. package/src/engine/grid/grid2transform/GridPosition2Transform.js +0 -4
  333. package/src/engine/grid/grid2transform/GridPosition2TransformSystem.d.ts.map +1 -1
  334. package/src/engine/grid/grid2transform/GridPosition2TransformSystem.js +4 -7
  335. package/src/engine/grid/obstacle/GridObstacle.d.ts.map +1 -1
  336. package/src/engine/grid/obstacle/GridObstacle.js +0 -5
  337. package/src/engine/grid/position/GridPosition.d.ts.map +1 -1
  338. package/src/engine/grid/position/GridPosition.js +0 -4
  339. package/src/engine/grid/position/GridPositionSystem.d.ts.map +1 -1
  340. package/src/engine/grid/position/GridPositionSystem.js +1 -4
  341. package/src/engine/input/devices/KeyCodes.d.ts.map +1 -1
  342. package/src/engine/input/devices/KeyCodes.js +3 -4
  343. package/src/engine/input/devices/KeyboardDevice.d.ts.map +1 -1
  344. package/src/engine/input/devices/KeyboardDevice.js +0 -4
  345. package/src/engine/input/devices/PointerDevice.d.ts.map +1 -1
  346. package/src/engine/input/devices/PointerDevice.js +0 -3
  347. package/src/engine/input/ecs/components/InputController.d.ts.map +1 -1
  348. package/src/engine/input/ecs/components/InputController.js +1 -5
  349. package/src/engine/input/ecs/controllers/KeyboardCameraController.d.ts.map +1 -1
  350. package/src/engine/input/ecs/controllers/KeyboardCameraController.js +5 -10
  351. package/src/engine/input/ecs/systems/InputControllerSystem.d.ts.map +1 -1
  352. package/src/engine/input/ecs/systems/InputControllerSystem.js +78 -78
  353. package/src/engine/input/ecs/util/TopDownCameraControllerHelper.d.ts.map +1 -1
  354. package/src/engine/input/ecs/util/TopDownCameraControllerHelper.js +3 -6
  355. package/src/engine/intelligence/mcts/MonteCarlo.spec.js +78 -76
  356. package/src/engine/navigation/ecs/components/Path.d.ts.map +1 -1
  357. package/src/engine/navigation/ecs/components/Path.js +0 -5
  358. package/src/engine/navigation/ecs/path_following/PathFollower.d.ts.map +1 -1
  359. package/src/engine/navigation/ecs/path_following/PathFollower.js +1 -6
  360. package/src/engine/navigation/ecs/path_following/PathFollowingSystem.d.ts.map +1 -1
  361. package/src/engine/navigation/ecs/path_following/PathFollowingSystem.js +5 -12
  362. package/src/engine/network/DataChannel.js +284 -284
  363. package/src/engine/network/xhr.d.ts +0 -3
  364. package/src/engine/network/xhr.d.ts.map +1 -1
  365. package/src/engine/network/xhr.js +0 -3
  366. package/src/engine/notify/Notification.d.ts +1 -1
  367. package/src/engine/notify/Notification.d.ts.map +1 -1
  368. package/src/engine/notify/Notification.js +1 -6
  369. package/src/engine/notify/NotificationLog.d.ts.map +1 -1
  370. package/src/engine/notify/NotificationLog.js +0 -5
  371. package/src/engine/options/OptionsView.d.ts.map +1 -1
  372. package/src/engine/options/OptionsView.js +1 -6
  373. package/src/engine/physics/ammo/Body.js +0 -3
  374. package/src/engine/physics/ammo/PhysicsWorker.d.ts.map +1 -1
  375. package/src/engine/physics/ammo/PhysicsWorker.js +1 -3
  376. package/src/engine/physics/ammo/World.d.ts +68 -0
  377. package/src/engine/physics/ammo/World.d.ts.map +1 -0
  378. package/src/engine/physics/ammo/World.js +277 -278
  379. package/src/engine/physics/ammo/shapes/BoxShape.js +0 -3
  380. package/src/engine/physics/ammo/shapes/CapsuleShape.js +0 -3
  381. package/src/engine/physics/ammo/shapes/MeshShape.js +0 -3
  382. package/src/engine/physics/ammo/shapes/PlaneShape.js +0 -3
  383. package/src/engine/physics/ammo/shapes/Shape.js +1 -3
  384. package/src/engine/physics/ammo/shapes/SphereShape.js +0 -3
  385. package/src/engine/physics/cannon/CannonJSPhysicsSystem.d.ts.map +1 -1
  386. package/src/engine/physics/cannon/CannonJSPhysicsSystem.js +3 -6
  387. package/src/engine/save/GameStateLoader.d.ts.map +1 -1
  388. package/src/engine/save/GameStateLoader.js +1 -5
  389. package/src/engine/save/Storage.d.ts.map +1 -1
  390. package/src/engine/save/Storage.js +0 -7
  391. package/src/engine/scene/Scene.d.ts.map +1 -1
  392. package/src/engine/scene/Scene.js +2 -7
  393. package/src/engine/scene/SceneManager.d.ts.map +1 -1
  394. package/src/engine/scene/SceneManager.js +1 -4
  395. package/src/engine/simulation/DormandPrince.d.ts +0 -1
  396. package/src/engine/simulation/DormandPrince.d.ts.map +1 -1
  397. package/src/engine/simulation/DormandPrince.js +5 -5
  398. package/src/engine/simulation/Ticker.d.ts.map +1 -1
  399. package/src/engine/simulation/Ticker.js +0 -3
  400. package/src/engine/sound/ecs/SoundController.d.ts +0 -7
  401. package/src/engine/sound/ecs/SoundController.d.ts.map +1 -1
  402. package/src/engine/sound/ecs/SoundController.js +118 -119
  403. package/src/engine/sound/ecs/SoundControllerSystem.d.ts.map +1 -1
  404. package/src/engine/sound/ecs/SoundControllerSystem.js +3 -8
  405. package/src/engine/sound/ecs/SoundListener.d.ts +0 -1
  406. package/src/engine/sound/ecs/SoundListener.d.ts.map +1 -1
  407. package/src/engine/sound/ecs/SoundListener.js +26 -29
  408. package/src/engine/sound/ecs/SoundListenerSystem.d.ts.map +1 -1
  409. package/src/engine/sound/ecs/SoundListenerSystem.js +0 -5
  410. package/src/engine/sound/ecs/emitter/SoundEmitter.d.ts.map +1 -1
  411. package/src/engine/sound/ecs/emitter/SoundEmitter.js +0 -5
  412. package/src/engine/sound/ecs/emitter/SoundEmitterSystem.d.ts.map +1 -1
  413. package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +0 -7
  414. package/src/engine/ui/GUIEngine.d.ts.map +1 -1
  415. package/src/engine/ui/GUIEngine.js +0 -5
  416. package/src/engine/ui/tiles2d/TileGrid.d.ts.map +1 -1
  417. package/src/engine/ui/tiles2d/TileGrid.js +1 -4
  418. package/src/generation/markers/debug/visualizeMarkers.js +10 -10
  419. package/src/view/DOM.js +1 -3
  420. package/src/view/SVG.d.ts +0 -3
  421. package/src/view/SVG.d.ts.map +1 -1
  422. package/src/view/SVG.js +0 -4
  423. package/src/view/asset/PreloaderView.d.ts.map +1 -1
  424. package/src/view/asset/PreloaderView.js +0 -3
  425. package/src/view/common/LabelView.d.ts +1 -6
  426. package/src/view/common/LabelView.d.ts.map +1 -1
  427. package/src/view/common/LabelView.js +24 -33
  428. package/src/view/common/ListView.d.ts.map +1 -1
  429. package/src/view/common/ListView.js +0 -6
  430. package/src/view/common/MeshView.js +3 -6
  431. package/src/view/common/VirtualListView.d.ts.map +1 -1
  432. package/src/view/common/VirtualListView.js +0 -5
  433. package/src/view/common/dnd/DragAndDropContext.d.ts +1 -2
  434. package/src/view/common/dnd/DragAndDropContext.d.ts.map +1 -1
  435. package/src/view/common/dnd/DragAndDropContext.js +107 -110
  436. package/src/view/controller/GuiController.d.ts.map +1 -1
  437. package/src/view/controller/GuiController.js +1 -6
  438. package/src/view/controller/controls/BooleanVector3Control.d.ts +1 -1
  439. package/src/view/controller/controls/BooleanVector3Control.d.ts.map +1 -1
  440. package/src/view/controller/controls/GuiControl.js +2 -7
  441. package/src/view/controller/controls/Vector1Control.d.ts +1 -1
  442. package/src/view/controller/controls/Vector1Control.d.ts.map +1 -1
  443. package/src/view/controller/controls/Vector1Control.js +2 -7
  444. package/src/view/controller/controls/Vector2Control.d.ts.map +1 -1
  445. package/src/view/controller/controls/Vector2Control.js +0 -4
  446. package/src/view/controller/controls/Vector3Control.d.ts.map +1 -1
  447. package/src/view/controller/controls/Vector3Control.js +0 -3
  448. package/src/view/elements/ConfirmationDialogView.d.ts.map +1 -1
  449. package/src/view/elements/ConfirmationDialogView.js +1 -6
  450. package/src/view/elements/DropDownSelectionView.d.ts.map +1 -1
  451. package/src/view/elements/DropDownSelectionView.js +0 -5
  452. package/src/view/elements/EmptyView.d.ts.map +1 -1
  453. package/src/view/elements/EmptyView.js +0 -4
  454. package/src/view/elements/Group.d.ts.map +1 -1
  455. package/src/view/elements/Group.js +0 -3
  456. package/src/view/elements/MeshPreview.d.ts.map +1 -1
  457. package/src/view/elements/MeshPreview.js +5 -8
  458. package/src/view/elements/SimpleWindow.d.ts +1 -1
  459. package/src/view/elements/SimpleWindow.d.ts.map +1 -1
  460. package/src/view/elements/SimpleWindow.js +5 -11
  461. package/src/view/elements/button/ButtonView.d.ts.map +1 -1
  462. package/src/view/elements/button/ButtonView.js +1 -5
  463. package/src/view/elements/image/ImageView.d.ts.map +1 -1
  464. package/src/view/elements/image/ImageView.js +0 -4
  465. package/src/view/elements/image/SvgImageView.d.ts.map +1 -1
  466. package/src/view/elements/image/SvgImageView.js +2 -7
  467. package/src/view/elements/label/LabeledValueView.d.ts.map +1 -1
  468. package/src/view/elements/label/LabeledValueView.js +3 -8
  469. package/src/view/elements/navigation/ViewStack.d.ts +0 -7
  470. package/src/view/elements/navigation/ViewStack.d.ts.map +1 -1
  471. package/src/view/elements/navigation/ViewStack.js +17 -19
  472. package/src/view/elements/notify/NotificationView.js +1 -4
  473. package/src/view/elements/notify/ToastLogView.d.ts.map +1 -1
  474. package/src/view/elements/notify/ToastLogView.js +0 -3
  475. package/src/view/elements/progress/SmoothProgressBar.d.ts +72 -0
  476. package/src/view/elements/progress/SmoothProgressBar.d.ts.map +1 -0
  477. package/src/view/elements/radial/RadialMenu.d.ts.map +1 -1
  478. package/src/view/elements/radial/RadialMenu.js +1 -6
  479. package/src/view/elements/radial/RadialMenuElement.d.ts.map +1 -1
  480. package/src/view/elements/radial/RadialMenuElement.js +1 -4
  481. package/src/view/elements/radial/RadialProgressView.d.ts +1 -1
  482. package/src/view/elements/radial/RadialProgressView.d.ts.map +1 -1
  483. package/src/view/elements/radial/RadialProgressView.js +4 -9
  484. package/src/view/elements/tiles2d/Tile.d.ts.map +1 -1
  485. package/src/view/elements/tiles2d/Tile.js +3 -6
  486. package/src/view/elements/tiles2d/TileGrid.d.ts.map +1 -1
  487. package/src/view/elements/tiles2d/TileGrid.js +0 -5
  488. package/src/view/minimap/Minimap.d.ts.map +1 -1
  489. package/src/view/minimap/Minimap.js +11 -16
  490. package/src/view/minimap/dom/MinimapCameraView.d.ts +1 -2
  491. package/src/view/minimap/dom/MinimapCameraView.d.ts.map +1 -1
  492. package/src/view/minimap/dom/MinimapTerrainView.d.ts +1 -1
  493. package/src/view/minimap/dom/MinimapTerrainView.d.ts.map +1 -1
  494. package/src/view/minimap/gl/MarkerGL.d.ts +2 -12
  495. package/src/view/minimap/gl/MarkerGL.d.ts.map +1 -1
  496. package/src/view/minimap/gl/MarkerGL.js +60 -56
  497. package/src/view/minimap/gl/MinimapMarkersGL.d.ts +1 -1
  498. package/src/view/minimap/gl/MinimapMarkersGL.d.ts.map +1 -1
  499. package/src/view/minimap/gl/MinimapTerrainGL.d.ts +1 -2
  500. package/src/view/minimap/gl/MinimapTerrainGL.d.ts.map +1 -1
  501. package/src/view/renderModel.d.ts.map +1 -1
  502. package/src/view/renderModel.js +3 -7
  503. package/src/view/task/TaskProgressView.d.ts.map +1 -1
  504. package/src/view/task/TaskProgressView.js +0 -5
  505. package/src/engine/asset/loaders/LegacyThreeJSONAssetLoader.d.ts +0 -9
  506. package/src/engine/asset/loaders/LegacyThreeJSONAssetLoader.d.ts.map +0 -1
  507. package/src/engine/asset/loaders/LegacyThreeJSONAssetLoader.js +0 -105
  508. package/src/engine/graphics/geometry/decimation/SimplifyModifier.d.ts +0 -117
  509. package/src/engine/graphics/geometry/decimation/SimplifyModifier.d.ts.map +0 -1
  510. package/src/engine/graphics/geometry/decimation/SimplifyModifier.js +0 -971
  511. package/src/engine/graphics/loader/threejs/GLTFLoader.js +0 -3179
  512. package/src/engine/graphics/loader/threejs/LegacyJSONLoader.d.ts +0 -6
  513. package/src/engine/graphics/loader/threejs/LegacyJSONLoader.d.ts.map +0 -1
  514. package/src/engine/graphics/loader/threejs/LegacyJSONLoader.js +0 -845
  515. package/src/engine/graphics/postprocess/Postprocess.js +0 -284
  516. package/src/engine/graphics/postprocess/threejs/Mirror.js +0 -330
  517. package/src/engine/graphics/postprocess/threejs/WaterShader.js +0 -306
  518. package/src/engine/graphics/postprocess/threejs/postprocessing/AdaptiveToneMappingPass.js +0 -338
  519. package/src/engine/graphics/postprocess/threejs/postprocessing/BloomPass.js +0 -132
  520. package/src/engine/graphics/postprocess/threejs/postprocessing/BokehPass.js +0 -115
  521. package/src/engine/graphics/postprocess/threejs/postprocessing/ClearMaskPass.d.ts +0 -4
  522. package/src/engine/graphics/postprocess/threejs/postprocessing/ClearMaskPass.d.ts.map +0 -1
  523. package/src/engine/graphics/postprocess/threejs/postprocessing/ClearMaskPass.js +0 -23
  524. package/src/engine/graphics/postprocess/threejs/postprocessing/DotScreenPass.d.ts +0 -1
  525. package/src/engine/graphics/postprocess/threejs/postprocessing/DotScreenPass.d.ts.map +0 -1
  526. package/src/engine/graphics/postprocess/threejs/postprocessing/DotScreenPass.js +0 -60
  527. package/src/engine/graphics/postprocess/threejs/postprocessing/EffectComposer.js +0 -150
  528. package/src/engine/graphics/postprocess/threejs/postprocessing/FilmPass.d.ts +0 -1
  529. package/src/engine/graphics/postprocess/threejs/postprocessing/FilmPass.d.ts.map +0 -1
  530. package/src/engine/graphics/postprocess/threejs/postprocessing/FilmPass.js +0 -61
  531. package/src/engine/graphics/postprocess/threejs/postprocessing/GlitchPass.d.ts +0 -1
  532. package/src/engine/graphics/postprocess/threejs/postprocessing/GlitchPass.d.ts.map +0 -1
  533. package/src/engine/graphics/postprocess/threejs/postprocessing/GlitchPass.js +0 -117
  534. package/src/engine/graphics/postprocess/threejs/postprocessing/RenderPass.js +0 -63
  535. package/src/engine/graphics/postprocess/threejs/postprocessing/SMAAPass.js +0 -187
  536. package/src/engine/graphics/postprocess/threejs/postprocessing/SavePass.d.ts +0 -1
  537. package/src/engine/graphics/postprocess/threejs/postprocessing/SavePass.d.ts.map +0 -1
  538. package/src/engine/graphics/postprocess/threejs/postprocessing/SavePass.js +0 -67
  539. package/src/engine/graphics/postprocess/threejs/postprocessing/TexturePass.js +0 -50
  540. package/src/engine/graphics/postprocess/threejs/shaders/BokehShader.d.ts +0 -42
  541. package/src/engine/graphics/postprocess/threejs/shaders/BokehShader.d.ts.map +0 -1
  542. package/src/engine/graphics/postprocess/threejs/shaders/BokehShader.js +0 -117
  543. package/src/engine/graphics/postprocess/threejs/shaders/ConvolutionShader.d.ts +0 -30
  544. package/src/engine/graphics/postprocess/threejs/shaders/ConvolutionShader.d.ts.map +0 -1
  545. package/src/engine/graphics/postprocess/threejs/shaders/ConvolutionShader.js +0 -106
  546. package/src/engine/graphics/postprocess/threejs/shaders/FXAAShader.d.ts +0 -19
  547. package/src/engine/graphics/postprocess/threejs/shaders/FXAAShader.d.ts.map +0 -1
  548. package/src/engine/graphics/postprocess/threejs/shaders/FXAAShader.js +0 -90
  549. package/src/engine/graphics/postprocess/threejs/shaders/GammaCorrectionShader.d.ts +0 -12
  550. package/src/engine/graphics/postprocess/threejs/shaders/GammaCorrectionShader.d.ts.map +0 -1
  551. package/src/engine/graphics/postprocess/threejs/shaders/GammaCorrectionShader.js +0 -52
  552. package/src/engine/graphics/postprocess/threejs/shaders/LuminosityShader.d.ts +0 -12
  553. package/src/engine/graphics/postprocess/threejs/shaders/LuminosityShader.d.ts.map +0 -1
  554. package/src/engine/graphics/postprocess/threejs/shaders/LuminosityShader.js +0 -51
  555. package/src/engine/graphics/postprocess/threejs/shaders/SMAAShader.d.ts +0 -76
  556. package/src/engine/graphics/postprocess/threejs/shaders/SMAAShader.d.ts.map +0 -1
  557. package/src/engine/graphics/postprocess/threejs/shaders/SMAAShader.js +0 -468
  558. package/src/engine/graphics/postprocess/threejs/shaders/SSAOShader.d.ts +0 -61
  559. package/src/engine/graphics/postprocess/threejs/shaders/SSAOShader.d.ts.map +0 -1
  560. package/src/engine/graphics/postprocess/threejs/shaders/SSAOShader.js +0 -230
  561. package/src/engine/graphics/postprocess/threejs/shaders/ToneMapShader.d.ts +0 -36
  562. package/src/engine/graphics/postprocess/threejs/shaders/ToneMapShader.d.ts.map +0 -1
  563. package/src/engine/graphics/postprocess/threejs/shaders/ToneMapShader.js +0 -76
  564. package/src/engine/graphics/shaders/GaussianBlurShader.d.ts +0 -22
  565. package/src/engine/graphics/shaders/GaussianBlurShader.d.ts.map +0 -1
  566. package/src/engine/graphics/shaders/GaussianBlurShader.js +0 -79
  567. package/src/engine/graphics/shaders/GaussianGlowShader.d.ts +0 -26
  568. package/src/engine/graphics/shaders/GaussianGlowShader.d.ts.map +0 -1
  569. package/src/engine/graphics/shaders/GaussianGlowShader.js +0 -83
  570. package/src/engine/graphics/shaders/NormalMapShader.d.ts +0 -33
  571. package/src/engine/graphics/shaders/NormalMapShader.d.ts.map +0 -1
  572. package/src/engine/graphics/shaders/NormalMapShader.js +0 -62
  573. package/src/engine/graphics/shaders/SoftOutlineShader.d.ts +0 -3
  574. package/src/engine/graphics/shaders/SoftOutlineShader.d.ts.map +0 -1
  575. package/src/engine/graphics/shaders/SoftOutlineShader.js +0 -111
  576. package/src/engine/graphics/three/Reflector.d.ts +0 -12
  577. package/src/engine/graphics/three/Reflector.d.ts.map +0 -1
  578. package/src/engine/graphics/three/Reflector.js +0 -281
  579. package/src/engine/graphics/three/Refractor.d.ts +0 -11
  580. package/src/engine/graphics/three/Refractor.d.ts.map +0 -1
  581. package/src/engine/graphics/three/Refractor.js +0 -352
  582. package/src/engine/navigation/ecs/components/PathFinder.d.ts +0 -14
  583. package/src/engine/navigation/ecs/components/PathFinder.d.ts.map +0 -1
  584. package/src/engine/navigation/ecs/components/PathFinder.js +0 -11
  585. package/src/view/elements/navigation/NavigationMenu.d.ts +0 -13
  586. package/src/view/elements/navigation/NavigationMenu.d.ts.map +0 -1
  587. package/src/view/elements/navigation/NavigationMenu.js +0 -27
@@ -59,570 +59,569 @@ const SHRINK_FACTOR = 0.5;
59
59
  */
60
60
  const RESIZE_COUNT_THRESHOLD = 128;
61
61
 
62
- /**
63
- * Dynamically sized bit field
64
- * @constructor
65
- */
66
- function BitSet() {
62
+ export class BitSet {
67
63
  /**
68
- * Number of bits currently in use
69
- * @private
70
- * @type {number}
64
+ * Dynamically sized bit field
65
+ * @constructor
71
66
  */
72
- this.__length = 0;
67
+ constructor() {
68
+ /**
69
+ * Number of bits currently in use
70
+ * @private
71
+ * @type {number}
72
+ */
73
+ this.__length = 0;
74
+
75
+ /**
76
+ * Current capacity in bits, this is at least equal to length
77
+ * @private
78
+ * @type {number}
79
+ */
80
+ this.__capacity = 64;
81
+
82
+ /**
83
+ * Uint32-backed storage
84
+ * @type {Uint32Array}
85
+ * @private
86
+ */
87
+ this.__data_uint32 = new Uint32Array(this.__capacity >> 5);
88
+
89
+ /**
90
+ * @type {number}
91
+ */
92
+ this.__shrinkFactor = SHRINK_FACTOR;
93
+ }
73
94
 
74
- /**
75
- * Current capacity in bits, this is at least equal to length
76
- * @private
77
- * @type {number}
78
- */
79
- this.__capacity = 64;
95
+ preventShrink() {
96
+ this.__shrinkFactor = 0;
97
+ }
80
98
 
81
99
  /**
82
- * Uint32-backed storage
83
- * @type {Uint32Array}
84
- * @private
100
+ *
101
+ * @param {number} x
85
102
  */
86
- this.__data_uint32 = new Uint32Array(this.__capacity >> 5);
103
+ setShrinkFactor(x) {
104
+ assert.greaterThanOrEqual(x, 0, 'x >= 0');
105
+ assert.lessThan(x, 1, 'x < 1');
106
+
107
+ this.__shrinkFactor = x;
108
+ }
87
109
 
88
110
  /**
89
- * @type {number}
111
+ *
112
+ * @param {number} bit_count
90
113
  */
91
- this.__shrinkFactor = SHRINK_FACTOR;
92
- }
114
+ setCapacity(bit_count) {
115
+ assert.isNonNegativeInteger(bit_count, "bit_count");
93
116
 
94
- BitSet.prototype.preventShrink = function () {
95
- this.__shrinkFactor = 0;
96
- }
97
-
98
- /**
99
- *
100
- * @param {number} x
101
- */
102
- BitSet.prototype.setShrinkFactor = function (x) {
103
- assert.greaterThanOrEqual(x, 0, 'x >= 0');
104
- assert.lessThan(x, 1, 'x < 1');
105
-
106
- this.__shrinkFactor = x;
107
- }
117
+ if (this.__length > bit_count) {
118
+ throw new Error(`Current length(=${this.__length}) is greater than requested size(=${bit_count})`);
119
+ }
108
120
 
109
- /**
110
- *
111
- * @param {number} bit_count
112
- */
113
- BitSet.prototype.setCapacity = function (bit_count) {
114
- assert.isNonNegativeInteger(bit_count, "bit_count");
121
+ this.__resize(bit_count);
122
+ }
115
123
 
116
- if (this.__length > bit_count) {
117
- throw new Error(`Current length(=${this.__length}) is greater than requested size(=${bit_count})`);
124
+ /**
125
+ * Number of bits currently used for flags.
126
+ * @returns {number}
127
+ */
128
+ size() {
129
+ return this.__length;
118
130
  }
119
131
 
120
- this.__resize(bit_count);
121
- };
132
+ /**
133
+ * Number of bits reserved for the field, note that not all of these bits are typically being used.
134
+ * @returns {number}
135
+ */
136
+ capacity() {
137
+ return this.__capacity;
138
+ }
122
139
 
123
- /**
124
- * Number of bits currently used for flags.
125
- * @returns {number}
126
- */
127
- BitSet.prototype.size = function () {
128
- return this.__length;
129
- };
140
+ /**
141
+ *
142
+ * @param {int} bitCapacity
143
+ * @private
144
+ */
145
+ __resize(bitCapacity) {
146
+ assert.isNonNegativeInteger(bitCapacity, 'bitCapacity');
130
147
 
131
- /**
132
- * Number of bits reserved for the field, note that not all of these bits are typically being used.
133
- * @returns {number}
134
- */
135
- BitSet.prototype.capacity = function () {
136
- return this.__capacity;
137
- };
148
+ const uint32_capacity = Math.ceil(bitCapacity / 32);
138
149
 
139
- /**
140
- *
141
- * @param {int} bitCapacity
142
- * @private
143
- */
144
- BitSet.prototype.__resize = function (bitCapacity) {
145
- assert.isNonNegativeInteger(bitCapacity, 'bitCapacity');
150
+ const oldData = this.__data_uint32;
151
+ const newData = new Uint32Array(uint32_capacity);
146
152
 
147
- const uint32_capacity = Math.ceil(bitCapacity / 32);
153
+ //copy data from old container
148
154
 
149
- const oldData = this.__data_uint32;
150
- const newData = new Uint32Array(uint32_capacity);
155
+ const oldDataSize = oldData.length;
151
156
 
152
- //copy data from old container
157
+ if (oldDataSize < uint32_capacity) {
158
+ newData.set(oldData);
159
+ } else {
160
+ //creating a sub-array is using heap memory, so we prefer to avoid it
161
+ newData.set(oldData.subarray(0, uint32_capacity));
162
+ }
153
163
 
154
- const oldDataSize = oldData.length;
164
+ this.__data_uint32 = newData;
155
165
 
156
- if (oldDataSize < uint32_capacity) {
157
- newData.set(oldData);
158
- } else {
159
- //creating a sub-array is using heap memory, so we prefer to avoid it
160
- newData.set(oldData.subarray(0, uint32_capacity));
166
+ this.__capacity = uint32_capacity * 32;
161
167
  }
162
168
 
163
- this.__data_uint32 = newData;
164
-
165
- this.__capacity = uint32_capacity * 32;
166
- };
169
+ __updateLength() {
170
+ const found_length = this.previousSetBit(this.__length) + 1;
167
171
 
168
- BitSet.prototype.__updateLength = function () {
169
- const found_length = this.previousSetBit(this.__length) + 1;
170
-
171
- if (found_length < this.__length) {
172
- this.__setLength(found_length);
172
+ if (found_length < this.__length) {
173
+ this.__setLength(found_length);
174
+ }
173
175
  }
174
- }
175
176
 
176
- /**
177
- *
178
- * @param {int} new_length
179
- * @private
180
- */
181
- BitSet.prototype.__setLength = function (new_length) {
182
- this.__length = new_length;
177
+ /**
178
+ *
179
+ * @param {int} new_length
180
+ * @private
181
+ */
182
+ __setLength(new_length) {
183
+ this.__length = new_length;
183
184
 
184
- const capacity = this.__capacity;
185
+ const capacity = this.__capacity;
185
186
 
186
- if (new_length > capacity) {
187
+ if (new_length > capacity) {
187
188
 
188
- const growSize = Math.ceil(max3(
189
- new_length,
190
- capacity + RESIZE_COUNT_THRESHOLD,
191
- capacity * GROW_FACTOR
192
- ));
189
+ const growSize = Math.ceil(max3(
190
+ new_length,
191
+ capacity + RESIZE_COUNT_THRESHOLD,
192
+ capacity * GROW_FACTOR
193
+ ));
193
194
 
194
- this.__resize(growSize);
195
+ this.__resize(growSize);
195
196
 
196
- } else {
197
- if (
198
- new_length < capacity - RESIZE_COUNT_THRESHOLD
199
- && new_length < capacity * this.__shrinkFactor
200
- ) {
197
+ } else {
198
+ if (
199
+ new_length < capacity - RESIZE_COUNT_THRESHOLD
200
+ && new_length < capacity * this.__shrinkFactor
201
+ ) {
201
202
 
202
- this.__resize(new_length);
203
+ this.__resize(new_length);
203
204
 
205
+ }
204
206
  }
205
207
  }
206
- };
207
208
 
208
- /**
209
- * Returns the index of the nearest bit that is set to true that occurs on or before the specified starting index
210
- * @param {int} fromIndex
211
- * @returns {int} Index of previous set bit, or -1 if no set bit found
212
- */
213
- BitSet.prototype.previousSetBit = function (fromIndex) {
214
- assert.isNonNegativeInteger(fromIndex, `fromIndex`);
209
+ /**
210
+ * Returns the index of the nearest bit that is set to true that occurs on or before the specified starting index
211
+ * @param {int} fromIndex
212
+ * @returns {int} Index of previous set bit, or -1 if no set bit found
213
+ */
214
+ previousSetBit(fromIndex) {
215
+ assert.isNonNegativeInteger(fromIndex, `fromIndex`);
215
216
 
216
- const index = min2(fromIndex, this.__length - 1);
217
+ const index = min2(fromIndex, this.__length - 1);
217
218
 
218
- let word_index = index >> 5;
219
- let bit_index = index & 31; // modulo operation is slow, bitwise and is fast, this is the same as %8
219
+ let word_index = index >> 5;
220
+ let bit_index = index & 31; // modulo operation is slow, bitwise and is fast, this is the same as %8
220
221
 
221
- const data = this.__data_uint32;
222
+ const data = this.__data_uint32;
222
223
 
223
- let word = data[word_index];
224
+ let word = data[word_index];
224
225
 
225
- //handle first byte separately due to potential partial traversal
226
- for (; bit_index >= 0; bit_index--) {
227
- if ((word & (1 << bit_index)) !== 0) {
228
- return word_index * 32 + bit_index;
226
+ //handle first byte separately due to potential partial traversal
227
+ for (; bit_index >= 0; bit_index--) {
228
+ if ((word & (1 << bit_index)) !== 0) {
229
+ return word_index * 32 + bit_index;
230
+ }
229
231
  }
230
- }
231
232
 
232
- //unwind first byte
233
- word_index--;
233
+ //unwind first byte
234
+ word_index--;
234
235
 
235
- //scan the rest
236
- for (; word_index >= 0; word_index--) {
236
+ //scan the rest
237
+ for (; word_index >= 0; word_index--) {
237
238
 
238
- word = data[word_index];
239
+ word = data[word_index];
239
240
 
240
- for (bit_index = 31; bit_index >= 0; bit_index--) {
241
+ for (bit_index = 31; bit_index >= 0; bit_index--) {
241
242
 
242
- if ((word & (1 << bit_index)) !== 0) {
243
- return word_index * 32 + bit_index;
244
- }
243
+ if ((word & (1 << bit_index)) !== 0) {
244
+ return word_index * 32 + bit_index;
245
+ }
245
246
 
247
+ }
246
248
  }
247
- }
248
249
 
249
- return -1;
250
- };
251
-
252
- /**
253
- * Returns the index of the first bit that is set to false that occurs on or after the specified starting index.
254
- * @param {int} fromIndex
255
- * @returns {number} index of the next set bit, or -1 if no bits are set beyond supplied index
256
- */
257
- BitSet.prototype.nextSetBit = function (fromIndex) {
258
- // assert.ok(fromIndex >= 0, `fromIndex must be greater or equal to 0, instead was ${fromIndex}`);
259
- // assert.ok(Number.isInteger(fromIndex), `fromIndex must be an integer, instead was ${fromIndex}`);
260
-
261
- const bit_length = this.__length;
262
- if (fromIndex >= bit_length) {
263
- //index is out of bounds, return -1
264
250
  return -1;
265
251
  }
266
252
 
267
- const data = this.__data_uint32;
253
+ /**
254
+ * Returns the index of the first bit that is set to false that occurs on or after the specified starting index.
255
+ * @param {int} fromIndex
256
+ * @returns {number} index of the next set bit, or -1 if no bits are set beyond supplied index
257
+ */
258
+ nextSetBit(fromIndex) {
259
+ // assert.ok(fromIndex >= 0, `fromIndex must be greater or equal to 0, instead was ${fromIndex}`);
260
+ // assert.ok(Number.isInteger(fromIndex), `fromIndex must be an integer, instead was ${fromIndex}`);
261
+
262
+ const bit_length = this.__length;
263
+ if (fromIndex >= bit_length) {
264
+ //index is out of bounds, return -1
265
+ return -1;
266
+ }
267
+
268
+ const data = this.__data_uint32;
268
269
 
269
- let word_index = fromIndex >> 5;
270
- let word;
271
- let bit_address;
270
+ let word_index = fromIndex >> 5;
271
+ let word;
272
+ let bit_address;
272
273
 
273
- let bit_index = fromIndex & 31;
274
+ let bit_index = fromIndex & 31;
274
275
 
275
- if (bit_index !== 0) {
276
- // bit offset boundary in inside the word, we need to mask part of the word
276
+ if (bit_index !== 0) {
277
+ // bit offset boundary in inside the word, we need to mask part of the word
277
278
 
278
- const fill_mask = ~((1 << bit_index) - 1);
279
+ const fill_mask = ~((1 << bit_index) - 1);
279
280
 
280
- const masked_word = data[word_index] & fill_mask;
281
+ const masked_word = data[word_index] & fill_mask;
281
282
 
282
- if (masked_word !== 0) {
283
- bit_index = lsb_32(masked_word);
284
- return (word_index << 5) + bit_index;
283
+ if (masked_word !== 0) {
284
+ bit_index = lsb_32(masked_word);
285
+ return (word_index << 5) + bit_index;
286
+ }
287
+
288
+ word_index++;
285
289
  }
286
290
 
287
- word_index++;
288
- }
289
291
 
292
+ //scan the rest of the words
293
+ const word_count = (bit_length + 31) >> 5; // Math.ceil(x /32)
294
+ for (; word_index < word_count; word_index++) {
295
+ word = data[word_index];
290
296
 
291
- //scan the rest of the words
292
- const word_count = (bit_length + 31) >> 5; // Math.ceil(x /32)
293
- for (; word_index < word_count; word_index++) {
294
- word = data[word_index];
297
+ if (word === 0) {
298
+ // all 0s
299
+ continue;
300
+ }
295
301
 
296
- if (word === 0) {
297
- // all 0s
298
- continue;
299
- }
302
+ bit_index = lsb_32(word);
303
+
304
+ bit_address = (word_index << 5) + bit_index;
300
305
 
301
- bit_index = lsb_32(word);
306
+ return bit_address;
307
+ }
302
308
 
303
- bit_address = (word_index << 5) + bit_index;
304
309
 
305
- return bit_address;
310
+ return -1;
306
311
  }
307
312
 
313
+ /**
314
+ * Returns the index of the first bit that is set to false that occurs on or after the specified starting index.
315
+ * @param {int} fromIndex
316
+ * @returns {number}
317
+ */
318
+ nextClearBit(fromIndex) {
319
+ //assert.ok(fromIndex >= 0, `fromIndex must be greater or equal to 0, instead was ${fromIndex}`);
320
+ //assert.ok(Number.isInteger(fromIndex), `fromIndex must be an integer, instead was ${fromIndex}`);
308
321
 
309
- return -1;
310
- };
311
-
312
- /**
313
- * Returns the index of the first bit that is set to false that occurs on or after the specified starting index.
314
- * @param {int} fromIndex
315
- * @returns {number}
316
- */
317
- BitSet.prototype.nextClearBit = function (fromIndex) {
318
- //assert.ok(fromIndex >= 0, `fromIndex must be greater or equal to 0, instead was ${fromIndex}`);
319
- //assert.ok(Number.isInteger(fromIndex), `fromIndex must be an integer, instead was ${fromIndex}`);
322
+ let word_index = fromIndex >> 5;
320
323
 
321
- let word_index = fromIndex >> 5;
324
+ let word;
322
325
 
323
- let word;
326
+ // treat first word specially, as we may need to mask out portion of a word to skip certain number of bits
327
+ let bit_index = fromIndex & 31;
324
328
 
325
- // treat first word specially, as we may need to mask out portion of a word to skip certain number of bits
326
- let bit_index = fromIndex & 31;
329
+ const data = this.__data_uint32;
327
330
 
328
- const data = this.__data_uint32;
331
+ if (bit_index !== 0) {
332
+ // bit offset boundary in inside the word, we need to mask part of the word
329
333
 
330
- if (bit_index !== 0) {
331
- // bit offset boundary in inside the word, we need to mask part of the word
334
+ word = data[word_index];
332
335
 
333
- word = data[word_index];
336
+ const fill_mask = (1 << bit_index) - 1;
334
337
 
335
- const fill_mask = (1 << bit_index) - 1;
338
+ // apply mask and convert to uint32 via shift
339
+ const masked_word = (word | fill_mask) >>> 0;
336
340
 
337
- // apply mask and convert to uint32 via shift
338
- const masked_word = (word | fill_mask) >>> 0;
341
+ if (masked_word !== 4294967295) {
342
+ bit_index = lsb_32(~masked_word);
343
+ return bit_index + word_index * 32;
344
+ }
339
345
 
340
- if (masked_word !== 4294967295) {
341
- bit_index = lsb_32(~masked_word);
342
- return bit_index + word_index * 32;
346
+ word_index++;
343
347
  }
348
+ const set_length = this.__length;
349
+ const word_count = (set_length + 31) >> 5; // Math.ceil(x /32)
344
350
 
345
- word_index++;
346
- }
347
- const set_length = this.__length;
348
- const word_count = (set_length + 31) >> 5; // Math.ceil(x /32)
351
+ //scan the rest
352
+ for (; word_index < word_count; word_index++) {
353
+ word = data[word_index];
349
354
 
350
- //scan the rest
351
- for (; word_index < word_count; word_index++) {
352
- word = data[word_index];
355
+ if (word === 4294967295) {
356
+ // no 0s
357
+ continue;
358
+ }
353
359
 
354
- if (word === 4294967295) {
355
- // no 0s
356
- continue;
357
- }
360
+ bit_index = lsb_32(~word);
361
+ return bit_index + word_index * 32;
358
362
 
359
- bit_index = lsb_32(~word);
360
- return bit_index + word_index * 32;
363
+ }
361
364
 
365
+ return set_length;
362
366
  }
363
367
 
364
- return set_length;
365
- };
368
+ /**
369
+ *
370
+ * @param {int} bitIndex
371
+ * @param {boolean} value
372
+ */
373
+ set(bitIndex, value) {
374
+ //assert.ok(typeof bitIndex, 'number', `bitIndex must be a number, instead was '${typeof bitIndex}'`);
375
+ //assert.ok(typeof value, 'boolean', `value must be a boolean, instead was '${typeof bitIndex}'`);
366
376
 
367
- /**
368
- *
369
- * @param {int} bitIndex
370
- * @param {boolean} value
371
- */
372
- BitSet.prototype.set = function (bitIndex, value) {
373
- //assert.ok(typeof bitIndex, 'number', `bitIndex must be a number, instead was '${typeof bitIndex}'`);
374
- //assert.ok(typeof value, 'boolean', `value must be a boolean, instead was '${typeof bitIndex}'`);
377
+ const word_offset = bitIndex >> 5;
378
+ const bit_offset = bitIndex & 31;
375
379
 
376
- const word_offset = bitIndex >> 5;
377
- const bit_offset = bitIndex & 31;
380
+ //const oldLength = this.__length;
378
381
 
379
- //const oldLength = this.__length;
382
+ const word_mask = 1 << bit_offset;
380
383
 
381
- const word_mask = 1 << bit_offset;
384
+ if (value) {
385
+ const bitIndexInc = bitIndex + 1;
382
386
 
383
- if (value) {
384
- const bitIndexInc = bitIndex + 1;
387
+ if (bitIndexInc > this.__length) {
388
+ // ensure capacity
389
+ this.__setLength(bitIndexInc);
390
+ }
385
391
 
386
- if (bitIndexInc > this.__length) {
387
- // ensure capacity
388
- this.__setLength(bitIndexInc);
389
- }
392
+ //set
393
+ this.__data_uint32[word_offset] |= word_mask;
390
394
 
391
- //set
392
- this.__data_uint32[word_offset] |= word_mask;
393
395
 
396
+ } else if (bitIndex < this.__length) {
397
+ //clear
398
+ this.__data_uint32[word_offset] &= ~word_mask;
394
399
 
395
- } else if (bitIndex < this.__length) {
396
- //clear
397
- this.__data_uint32[word_offset] &= ~word_mask;
400
+ // trim down set size potentially
401
+ this.__updateLength();
402
+ }
398
403
 
399
- // trim down set size potentially
400
- this.__updateLength();
404
+ //DEBUG validate firstClearBit value
405
+ //assert.ok(this.__firstClearBitIndex === -1 || this.__firstClearBitIndex === scanToFirstClearBit(this), `Invalid first clear bit index, oldLength=${oldLength}, bitIndex=${bitIndex}`);
401
406
  }
402
407
 
403
- //DEBUG validate firstClearBit value
404
- //assert.ok(this.__firstClearBitIndex === -1 || this.__firstClearBitIndex === scanToFirstClearBit(this), `Invalid first clear bit index, oldLength=${oldLength}, bitIndex=${bitIndex}`);
405
- };
408
+ /**
409
+ * Sets the bit specified by the index to false.
410
+ * @param {int} bitIndex
411
+ */
412
+ clear(bitIndex) {
413
+ this.set(bitIndex, false);
414
+ }
406
415
 
407
- /**
408
- * Sets the bit specified by the index to false.
409
- * @param {int} bitIndex
410
- */
411
- BitSet.prototype.clear = function (bitIndex) {
412
- this.set(bitIndex, false);
413
- };
416
+ /**
417
+ * Set all bits in a given range
418
+ * @param {number} startIndex first bit to be set
419
+ * @param {number} endIndex last bit to be set
420
+ */
421
+ setRange(startIndex, endIndex) {
422
+ assert.greaterThanOrEqual(startIndex, 0, "invalid start index");
423
+ assert.greaterThanOrEqual(endIndex, 0, "invalid end index");
414
424
 
415
- /**
416
- * Set all bits in a given range
417
- * @param {number} startIndex first bit to be set
418
- * @param {number} endIndex last bit to be set
419
- */
420
- BitSet.prototype.setRange = function (startIndex, endIndex) {
421
- assert.greaterThanOrEqual(startIndex, 0, "invalid start index");
422
- assert.greaterThanOrEqual(endIndex, 0, "invalid end index");
423
425
 
426
+ for (let i = startIndex; i <= endIndex; i++) {
427
+ this.set(i, true);
428
+ }
424
429
 
425
- for (let i = startIndex; i <= endIndex; i++) {
426
- this.set(i, true);
427
430
  }
428
431
 
429
- };
430
-
431
- /**
432
- * Clears bit values in a given (inclusive) range
433
- * @param {number} startIndex first bit to be cleared
434
- * @param {number} endIndex clear up to here, excluding this position
435
- */
436
- BitSet.prototype.clearRange = function (startIndex, endIndex) {
437
- assert.greaterThanOrEqual(startIndex, 0, "invalid start index");
438
- assert.greaterThanOrEqual(endIndex, 0, "invalid end index");
432
+ /**
433
+ * Clears bit values in a given (inclusive) range
434
+ * @param {number} startIndex first bit to be cleared
435
+ * @param {number} endIndex clear up to here, excluding this position
436
+ */
437
+ clearRange(startIndex, endIndex) {
438
+ assert.greaterThanOrEqual(startIndex, 0, "invalid start index");
439
+ assert.greaterThanOrEqual(endIndex, 0, "invalid end index");
439
440
 
440
- for (let i = startIndex; i < endIndex; i++) {
441
- this.set(i, false);
441
+ for (let i = startIndex; i < endIndex; i++) {
442
+ this.set(i, false);
443
+ }
442
444
  }
443
- };
444
445
 
446
+ /**
447
+ *
448
+ * @param {BitSet} set
449
+ */
450
+ and(set) {
451
+ throw new Error("NIY");
452
+ }
445
453
 
446
- /**
447
- *
448
- * @param {BitSet} set
449
- */
450
- BitSet.prototype.and = function (set) {
451
- throw new Error("NIY");
452
- };
454
+ /**
455
+ * Returns the value of the bit with the specified index.
456
+ * @param {int} bitIndex
457
+ * @returns {boolean}
458
+ */
459
+ get(bitIndex) {
460
+ assert.isNonNegativeInteger(bitIndex, "bitIndex");
453
461
 
454
- /**
455
- * Returns the value of the bit with the specified index.
456
- * @param {int} bitIndex
457
- * @returns {boolean}
458
- */
459
- BitSet.prototype.get = function (bitIndex) {
460
- assert.isNonNegativeInteger(bitIndex, "bitIndex");
462
+ if (bitIndex >= this.__length) {
463
+ //bit is outside the recorded region
464
+ return false;
465
+ }
461
466
 
462
- if (bitIndex >= this.__length) {
463
- //bit is outside the recorded region
464
- return false;
465
- }
467
+ const byteOffset = bitIndex >> 5;
468
+ const bitOffset = bitIndex & 31;
466
469
 
467
- const byteOffset = bitIndex >> 5;
468
- const bitOffset = bitIndex & 31;
470
+ const word = this.__data_uint32[byteOffset];
469
471
 
470
- const word = this.__data_uint32[byteOffset];
472
+ const masked_word = word & (1 << bitOffset);
471
473
 
472
- const masked_word = word & (1 << bitOffset);
474
+ return masked_word !== 0;
475
+ }
473
476
 
474
- return masked_word !== 0;
475
- };
477
+ /**
478
+ * Set a bit at the specified index and return its previous value
479
+ * @param {number} index
480
+ * @returns {boolean}
481
+ */
482
+ getAndSet(index) {
483
+ const v = this.get(index);
476
484
 
477
- /**
478
- * Set a bit at the specified index and return its previous value
479
- * @param {number} index
480
- * @returns {boolean}
481
- */
482
- BitSet.prototype.getAndSet = function (index) {
483
- const v = this.get(index);
485
+ if (!v) {
486
+ this.set(index, true);
487
+ }
484
488
 
485
- if (!v) {
486
- this.set(index, true);
489
+ return v;
487
490
  }
488
491
 
489
- return v;
490
- };
492
+ /**
493
+ * Clear a bit at the specified index and return its previous value
494
+ * @param {number} index
495
+ * @returns {boolean}
496
+ */
497
+ getAndClear(index) {
498
+ const v = this.get(index);
491
499
 
492
- /**
493
- * Clear a bit at the specified index and return its previous value
494
- * @param {number} index
495
- * @returns {boolean}
496
- */
497
- BitSet.prototype.getAndClear = function (index) {
498
- const v = this.get(index);
500
+ if (v) {
501
+ this.set(index, false);
502
+ }
499
503
 
500
- if (v) {
501
- this.set(index, false);
504
+ return v;
502
505
  }
503
506
 
504
- return v;
505
- };
506
-
507
- /**
508
- *
509
- * @param {number} distance
510
- * @param {number} start_index
511
- * @param {number} end_index
512
- */
513
- BitSet.prototype.shift_right = function (distance, start_index, end_index) {
514
- assert.isNonNegativeInteger(distance, 'distance');
507
+ /**
508
+ *
509
+ * @param {number} distance
510
+ * @param {number} start_index
511
+ * @param {number} end_index
512
+ */
513
+ shift_right(distance, start_index, end_index) {
514
+ assert.isNonNegativeInteger(distance, 'distance');
515
515
 
516
- for (let i = end_index; i >= start_index; i--) {
517
- const v = this.get(i);
518
- this.set(i + distance, v);
516
+ for (let i = end_index; i >= start_index; i--) {
517
+ const v = this.get(i);
518
+ this.set(i + distance, v);
519
+ }
519
520
  }
520
- }
521
521
 
522
- /**
523
- *
524
- * @param {number} distance
525
- * @param {number} start_index
526
- * @param {number} end_index
527
- */
528
- BitSet.prototype.shift_left = function (distance, start_index, end_index) {
529
- assert.isNonNegativeInteger(distance, 'distance');
522
+ /**
523
+ *
524
+ * @param {number} distance
525
+ * @param {number} start_index
526
+ * @param {number} end_index
527
+ */
528
+ shift_left(distance, start_index, end_index) {
529
+ assert.isNonNegativeInteger(distance, 'distance');
530
530
 
531
- for (let i = start_index; i <= end_index; i++) {
532
- const v = this.get(i);
533
- this.set(i - distance, v);
531
+ for (let i = start_index; i <= end_index; i++) {
532
+ const v = this.get(i);
533
+ this.set(i - distance, v);
534
+ }
534
535
  }
535
- }
536
536
 
537
- /**
538
- *
539
- * @param {number} distance
540
- * @param {number} start_index
541
- * @param {number} end_index
542
- */
543
- BitSet.prototype.shift = function (distance, start_index, end_index) {
544
- if (distance > 0) {
545
- this.shift_right(distance, start_index, end_index);
546
- } else {
547
- this.shift_right(-distance, start_index, end_index);
537
+ /**
538
+ *
539
+ * @param {number} distance
540
+ * @param {number} start_index
541
+ * @param {number} end_index
542
+ */
543
+ shift(distance, start_index, end_index) {
544
+ if (distance > 0) {
545
+ this.shift_right(distance, start_index, end_index);
546
+ } else {
547
+ this.shift_right(-distance, start_index, end_index);
548
+ }
548
549
  }
549
- };
550
550
 
551
- /**
552
- * Sets all the bits in this BitSet to false.
553
- */
554
- BitSet.prototype.reset = function () {
555
- const current_length = this.__length;
551
+ /**
552
+ * Sets all the bits in this BitSet to false.
553
+ */
554
+ reset() {
555
+ const current_length = this.__length;
556
556
 
557
- if (current_length <= 0) {
558
- // no action required
559
- return;
560
- }
557
+ if (current_length <= 0) {
558
+ // no action required
559
+ return;
560
+ }
561
+
562
+ if (current_length <= 32) {
563
+ // one word, set first word to 0 manually
564
+ this.__data_uint32[0] = 0;
565
+ } else {
566
+ this.__data_uint32.fill(0, 0, Math.ceil(current_length / 32));
567
+ }
561
568
 
562
- if (current_length <= 32) {
563
- // one word, set first word to 0 manually
564
- this.__data_uint32[0] = 0;
565
- } else {
566
- this.__data_uint32.fill(0, 0, Math.ceil(current_length / 32));
569
+ this.__length = 0;
567
570
  }
568
571
 
569
- this.__length = 0;
570
- };
572
+ /**
573
+ * Copy contents of another bit set into this one
574
+ * @param {BitSet} other
575
+ */
576
+ copy(other) {
577
+ const length = other.__length;
571
578
 
572
- /**
573
- * Copy contents of another bit set into this one
574
- * @param {BitSet} other
575
- */
576
- BitSet.prototype.copy = function (other) {
577
- const length = other.__length;
579
+ const uint32_size = length >> 5;
578
580
 
579
- const uint32_size = length >> 5;
581
+ const old_length = this.__length;
580
582
 
581
- const old_length = this.__length;
582
583
 
584
+ if (old_length !== length) {
583
585
 
584
- if (old_length !== length) {
586
+ if (old_length < length) {
587
+ this.__resize(length);
588
+ } else {
589
+ // clear everything past the target region
590
+ this.__data_uint32.fill(0, uint32_size);
591
+ }
585
592
 
586
- if (old_length < length) {
587
- this.__resize(length);
588
- } else {
589
- // clear everything past the target region
590
- this.__data_uint32.fill(0, uint32_size);
593
+ this.__length = length;
591
594
  }
592
595
 
593
- this.__length = length;
594
- }
595
-
596
596
 
597
- for (let i = 0; i < uint32_size; i++) {
598
- this.__data_uint32[i] = other.__data_uint32[i];
599
- }
597
+ for (let i = 0; i < uint32_size; i++) {
598
+ this.__data_uint32[i] = other.__data_uint32[i];
599
+ }
600
600
 
601
- const byte_aligned_bit_size = uint32_size << 5;
601
+ const byte_aligned_bit_size = uint32_size << 5;
602
602
 
603
- const overflow_bits = length - byte_aligned_bit_size;
603
+ const overflow_bits = length - byte_aligned_bit_size;
604
604
 
605
- for (let i = 0; i < overflow_bits; i++) {
606
- const bitIndex = byte_aligned_bit_size + i;
605
+ for (let i = 0; i < overflow_bits; i++) {
606
+ const bitIndex = byte_aligned_bit_size + i;
607
607
 
608
- this.set(bitIndex, other.get(bitIndex));
608
+ this.set(bitIndex, other.get(bitIndex));
609
+ }
609
610
  }
610
- };
611
611
 
612
- /**
613
- *
614
- * @param {number} x
615
- * @returns {BitSet}
616
- */
617
- BitSet.fixedSize = function (x) {
618
- const r = new BitSet();
612
+ /**
613
+ *
614
+ * @param {number} x
615
+ * @returns {BitSet}
616
+ */
617
+ static fixedSize(x) {
618
+ const r = new BitSet();
619
619
 
620
- r.setCapacity(x);
620
+ r.setCapacity(x);
621
621
 
622
- //prevent resizing
623
- r.__shrinkFactor = 0;
622
+ //prevent resizing
623
+ r.__shrinkFactor = 0;
624
624
 
625
- return r;
625
+ return r;
626
+ }
626
627
  }
627
-
628
- export { BitSet };