{"name":"check2d","version":"9.31.0","keywords":["javascript","typescript","library","computational-geometry","alghoritm","computational-geometry-alghoritm","collisions","collision-checking","concave","rotation","angle","separating-axis-theorem","bounding-volume-hierarchy","Circle","Polygon","Box","Ellipse","Line","Point"],"author":{"name":"Jacek Pietal"},"license":"MIT","_id":"check2d@9.31.0","maintainers":[{"name":"pietal.dev","email":"prozi85+pietal.dev@gmail.com"}],"homepage":"https://jackie-aniki.github.io/check2d/","bugs":{"url":"https://github.com/jackie-aniki/check2d/issues"},"dist":{"shasum":"7406a85b5c56a8aa8049ffb9285deb5bbf761fa3","tarball":"http://registry-npm.ywwl.com/check2d/download/check2d-9.31.0.tgz","fileCount":34,"integrity":"sha512-D4MCEYr0P6fePev6hci/2O12+9dqbm70E8mhjHr8jM/bro1KpXbkAdtWFpElVptz6Pphi23wLQEzZxzJjYf3WA==","signatures":[{"sig":"MEUCIHO/g23a/zrwTFznJSIpy2FjGdwWbdrJr9mmxPDfxHZEAiEAzeWvbp30C2NXcfP6ymmYFvoeBts5Nv0YtYzZAxUB76g=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":245588,"size":59761,"noattachment":false,"key":"/check2d/-/check2d-9.31.0.tgz"},"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./esm/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./esm/index.js","require":"./dist/index.js"}},"gitHead":"586317c1c8a3a0c0f00ed80608186157c06bf6cb","scripts":{"dev":"webpack serve --port 3000","demo":"yarn build:demo && npm start","docs":"yarn build:docs && chef-express docs --debug --port 3000","lint":"eslint src --fix","test":"jest --silent --verbose --forceExit","amend":"yarn precommit && git commit -a --am --no-edit","build":"yarn build:commonjs && yarn build:esm","start":"chef-express dist/demo --debug","format":"prettier . --write","restart":"yarn build && yarn start","prebuild":"yarn copy-npm-modules","benchmark":"./clean-dist.sh && yarn benchmark-insertion && yarn benchmark-stress","build:esm":"rollup -c","postbuild":"yarn test && yarn build:demo","precommit":"yarn lint && yarn build && yarn format && yarn build:docs","build:demo":"webpack","build:docs":"typedoc --customCss typedoc.css","copy-rbush":"cp node_modules/rbush/index.js src/external/rbush.js","prebuild:esm":"rimraf esm","prebuild:docs":"rimraf docs","build:commonjs":"tsc","docs-from-main":"yarn docs-from-main-macos || yarn docs-from-main-linux","postbuild:docs":"yarn docs-from-main && cp -r dist/demo docs","benchmark-stress":"node -e 'import(\"./dist/benchmarks/index.js\").then(({ stressBenchmark }) => stressBenchmark());'","copy-npm-modules":"yarn copy-rbush && yarn copy-quickselect && yarn use-latest-quickselect","copy-quickselect":"cp node_modules/quickselect/index.js src/external/quickselect.js","prebuild:commonjs":"rimraf dist","benchmark-insertion":"node -e 'import(\"./dist/benchmarks/index.js\").then(({ insertionBenchmark }) => insertionBenchmark());'","docs-from-main-linux":"find docs -type f -name '*.html' -exec sed -i -r 's_/blob/[^/]+/_/blob/main/_g' {} +","docs-from-main-macos":"find docs -type f -name '*.html' -exec sed -i '' -e 's_/blob/[^/]+/_/blob/main/_g' {} +","use-latest-quickselect":"yarn use-latest-quickselect-macos || yarn use-latest-quickselect-linux","use-latest-quickselect-linux":"sed -i -r \"s_'quickselect'_'./quickselect'_g\" src/external/rbush.js","use-latest-quickselect-macos":"sed -i '' -e \"s_'quickselect'_'./quickselect'_g\" src/external/rbush.js"},"_npmUser":{"name":"pietal.dev","email":"prozi85+pietal.dev@gmail.com"},"repository":{"url":"git://github.com/jackie-aniki/check2d.git","type":"git"},"_npmVersion":"11.6.1","description":"Polygons, Ellipses, Circles, Boxes, Lines, Points. Ray-Casting, offsets, rotation, scaling, padding, groups.","directories":{},"resolutions":{"json5":"^2.2.2","semver":"^7.5.3","terser":"^5.14.2","express":"^4.19.2","minimist":"^1.2.6","escodegen":"^2.1.0","@types/node":"^22.4.1"},"_nodeVersion":"24.11.0","dependencies":{"sat":"^0.9.0","@types/sat":"^0.0.35","poly-decomp-es":"^0.4.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^30.2.0","husky":"^9.1.7","rbush":"^4.0.1","eslint":"~9.35.0","rimraf":"^6.1.0","rollup":"^4.52.5","ts-jest":"^29.4.5","typedoc":"^0.28.14","webpack":"^5.102.1","prettier":"^3.6.2","tinybench":"~5.0.1","ts-loader":"^9.5.4","typescript":"^5","@types/node":"^24.10.0","quickselect":"^3.0.0","random-seed":"^0.3.0","webpack-cli":"^6.0.1","@types/rbush":"^4.0.0","chef-express":"^3.2.3","eslint-plugin-json":"^4.0.1","webpack-dev-server":"^5.2.2","html-webpack-plugin":"^5.6.4","@rollup/plugin-commonjs":"^29.0.0","@stylistic/eslint-plugin":"^5.5.0","@rollup/plugin-typescript":"^12.3.0","@rollup/plugin-node-resolve":"^16.0.3"},"_npmOperationalInternal":{"tmp":"tmp/check2d_9.31.0_1762212105711_0.4985418448505803","host":"s3://npm-registry-packages-npm-production"},"readme":"# check2d\n\n## [<img valign=\"middle\" src=\"https://img.shields.io/npm/dw/check2d.svg?style=for-the-badge&color=success\" alt=\"npm downloads per week\" />](https://www.npmjs.com/package/check2d) + [<img valign=\"middle\" src=\"https://img.shields.io/npm/dw/detect-collisions.svg?style=for-the-badge&color=success\" alt=\"npm downloads per week\" />](https://www.npmjs.com/package/detect-collisions) @ [<img valign=\"middle\" src=\"https://img.shields.io/npm/v/check2d?style=for-the-badge&color=success\" alt=\"npm version\" />](https://www.npmjs.com/package/check2d?activeTab=versions)\n\n**check2d** is a **feature-complete 2D collision detection library** for JavaScript, designed for **real-time games and simulations**.\n\nIt combines a **Bounding Volume Hierarchy (BVH)** broad phase with **Separating Axis Theorem (SAT)** narrow phase detection, providing fast and accurate collision checks across many shape types.\n\n### highlights\n\n- BVH-based broad phase for high performance\n- SAT-based precise collision detection\n- supports boxes, circles, ellipses, polygons, lines, points\n- raycasting, offsets, rotation, scaling\n- group-based collision filtering\n- visual debugging helpers\n- browser and Node.js support\n- battle-tested and well benchmarked\n\n---\n\n## demos\n\n- Stress test  \n  https://nenjack.github.io/check2d/demo/?stress\n- Tank demo  \n  https://nenjack.github.io/check2d/demo/\n- StackBlitz  \n  https://stackblitz.com/edit/check2d\n- CodePan  \n  https://nenjack.github.io/codepan/#/boilerplate/check2d?pans=console,html\n\n---\n\n## quick start\n\n```ts\nconst { System } = require('check2d')\n\nconst system = new System()\n````\n\n### creating bodies\n\n```ts\nconst { Box, Circle, Polygon } = require('check2d')\n\nconst box = system.createBox({ x: 0, y: 0 }, 10, 10)\nconst circle = new Circle({ x: 5, y: 0 }, 5)\n\nsystem.insert(circle)\n```\n\n---\n\n## body manipulation\n\nBodies can be transformed freely. Changes are batched and applied once.\n\n```ts\nbox.setPosition(10, 5, false)\nbox.setAngle(Math.PI / 4, false)\nbox.setScale(2, 1, false)\nbox.move(1, false)\n\nbox.updateBody()\n```\n\nSupported features include:\n\n* position, rotation, scale\n* movement in facing direction\n* offsets relative to body center\n* AABB access\n* padding to reduce BVH reinserts\n* group-based collision filtering\n\n---\n\n## collision checks\n\n```ts\nsystem.checkAll((result) => {\n  console.log(result)\n})\n\nsystem.checkOne(box, (result) => {\n  console.log(result)\n})\n\n// optional automatic separation\nsystem.separate()\n```\n\n### collision points\n\n```ts\nconst points = system.getCollisionPoints(result.a, result.b)\n```\n\n---\n\n## raycasting\n\n```ts\nconst hit = system.raycast(\n  { x: 0, y: 0 },\n  { x: 0, y: -10 },\n  (body) => true\n)\n\nif (hit) {\n  const { point, body } = hit\n  console.log(point, body)\n}\n```\n\n---\n\n## visual debugging\n\nDraw bodies directly to a `<canvas>` context:\n\n```ts\ncontext.beginPath()\nsystem.draw(context)\ncontext.stroke()\n```\n\nDraw BVH bounding boxes:\n\n```ts\ncontext.beginPath()\nsystem.drawBVH(context)\ncontext.stroke()\n```\n\n---\n\n## browser usage\n\n```js\nimport { System } from 'https://esm.sh/check2d'\n```\n\n---\n\n## testing & benchmark\n\n```bash\nTest Suites: 12 passed, 12 total\nTests:       84 passed, 84 total\n```\n\nRun benchmarks and stress tests:\n\n```bash\ngit clone https://github.com/nenjack/check2d.git\ncd check2d\nnpm i\nnpm run benchmark\n```\n\n---\n\n## installation\n\n```bash\nyarn add check2d\n```\n\n---\n\n## documentation\n\nAPI reference and guides:\n[https://nenjack.github.io/check2d/](https://nenjack.github.io/check2d/)\n\n---\n\n## why not a physics engine?\n\nPhysics engines like Matter.js or Planck.js are excellent when full simulation is required, but they often introduce unnecessary overhead when **only collision detection is needed**.\n\n**check2d** focuses purely on collision detection:\n\n* no gravity\n* no forces\n* no assumptions about movement\n\nThis makes it ideal as a **standalone collision system** or as the foundation of a custom physics engine.\n\n---\n\n## contributing\n\nContributions are welcome.\n\n* run `npm run precommit`\n* follow conventional commits\n* avoid using `any`\n\n---\n\n## license\n\nMIT\n","publish_time":1762212105902,"_cnpm_publish_time":1762212105902,"dist-tags":{"latest":"9.36.4"}}