{"name":"check2d","version":"9.36.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.36.0","maintainers":[{"name":"pietal.dev","email":"prozi85+pietal.dev@gmail.com"}],"homepage":"https://nenjack.github.io/check2d/","bugs":{"url":"https://github.com/nenjack/check2d/issues"},"dist":{"shasum":"e89d337b0b035031cc0858615d953b75ae795a2b","tarball":"http://registry-npm.ywwl.com/check2d/download/check2d-9.36.0.tgz","fileCount":36,"integrity":"sha512-hXSExwin2QRPmMFdZqK0HlYCDl8xU9WrCVmI2WNReb9K1bhgOfZyHyyWDoJoDjLjKJKJkWsLj4d2fie043O/Nw==","signatures":[{"sig":"MEQCICuIlH7CjwugUwvxvxAgA26P3LLsWUdwuJjHUe8cuhXVAiB+tTwy6H2+K5NwCCqSX17Oti4pV7jPkp+IXdCxl/yNfg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":248512,"size":60519,"noattachment":false,"key":"/check2d/-/check2d-9.36.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":"3ae4fe76d03d5a3481ca54d9c6af1f5d3233f7ec","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","update":"npx npm-check-updates -u && yarn add tinybench@^5 -D","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/nenjack/check2d.git","type":"git"},"_npmVersion":"11.6.2","description":"detect collisions 2d between all possible kinds of shapes. It uses Bounding Volume Hierarchy (BVH) for sweep wide quick tree trim phase, and the Separating Axis Theorem (SAT) for accurate detection inside nearby groups. This library supports RayCasting, o","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.12.0","dependencies":{"sat":"^0.9.0","@types/sat":"^0.0.35","poly-decomp-es":"^0.4.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^30.2.0","rbush":"^4.0.1","eslint":"~9.39.2","rimraf":"^6.1.2","rollup":"^4.53.5","ts-jest":"^29.4.6","typedoc":"^0.28.15","webpack":"^5.104.0","prettier":"^3.7.4","tinybench":"^5","ts-loader":"^9.5.4","typescript":"^5","@types/node":"^25.0.3","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.5","@rollup/plugin-commonjs":"^29.0.0","@stylistic/eslint-plugin":"^5.6.1","@rollup/plugin-typescript":"^12.3.0","@rollup/plugin-node-resolve":"^16.0.3"},"_npmOperationalInternal":{"tmp":"tmp/check2d_9.36.0_1766031015139_0.44646577484889693","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":1766031015356,"_cnpm_publish_time":1766031015356,"dist-tags":{"latest":"9.36.4"}}