{"name":"check2d","version":"9.29.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.29.0","maintainers":[{"name":"eikichi_onizuka","email":"kawaii.akai.neko.aniki@gmail.com"}],"homepage":"https://onizuka-aniki.github.io/check2d/","bugs":{"url":"https://github.com/onizuka-aniki/check2d/issues"},"dist":{"shasum":"ba09f4aef5d500d8eca24177f0c3e611bb0909f0","tarball":"http://registry-npm.ywwl.com/check2d/download/check2d-9.29.0.tgz","fileCount":34,"integrity":"sha512-ifiQOsBXSSfQS1pIcZREWoQFb0TshLHFmYEjFIJOXR/5o95g46LyJ1Hb5Rtdi/zbeMSQ0YRp1wSsqOHFCBA5SQ==","signatures":[{"sig":"MEQCIElpvt2K0qjBlxwXkU5p3DJ4r3gyMlqV1+0bPgK0eaNwAiA1YVhUEizDz7TIYT4USm/V/zMbChQk5SifY9roN1zfFg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":257760,"size":59951,"noattachment":false,"key":"/check2d/-/check2d-9.29.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":"16ed433bc167b353c1a1ac7e2e69e154c9df9d19","scripts":{"dev":"webpack serve --port 3000","demo":"npm run build:demo && npm start","docs":"npm run build:docs && chef-express docs --debug --port 3000","lint":"eslint src --fix","test":"jest --silent --verbose --forceExit","amend":"NO_BENCH=1 npm run precommit;git commit -a --am --no-edit","build":"npm run build:commonjs && npm run build:esm","start":"chef-express dist/demo --debug","format":"prettier . --write","prebuild":"npm run copy-npm-modules","benchmark":"./clean-dist.sh && npm run benchmark-insertion && npm run benchmark-stress","build:esm":"rollup -c","postbuild":"npm run test && npm run build:docs && npm run build:demo && [ -z \"$NO_BENCH\" ] && npm run benchmark","precommit":"npm run lint && npm run format && npm run build","build:demo":"webpack","build:docs":"typedoc --customCss typedoc.css","copy-rbush":"cp node_modules/rbush/index.js src/external/rbush.js","prebuild:esm":"rm -rf esm","prebuild:docs":"rm -rf docs","build:commonjs":"tsc","postbuild:demo":"cp -r dist/demo docs","postbuild:docs":"npm run docs-from-master || echo ok","benchmark-stress":"node -e 'import(\"./dist/benchmarks/index.js\").then(({ stressBenchmark }) => stressBenchmark());'","copy-npm-modules":"npm run copy-rbush && npm run copy-quickselect && npm run use-latest-quickselect","copy-quickselect":"cp node_modules/quickselect/index.js src/external/quickselect.js","docs-from-master":"npm run docs-from-master-macos || npm run docs-from-master-linux","prebuild:commonjs":"rm -rf dist","benchmark-insertion":"node -e 'import(\"./dist/benchmarks/index.js\").then(({ insertionBenchmark }) => insertionBenchmark());'","docs-from-master-linux":"find docs -type f -name '*.html' -exec sed -i -r 's_/blob/[^/]+/_/blob/master/_g' {} +","docs-from-master-macos":"find docs -type f -name '*.html' -exec sed -i '' -r 's_/blob/[^/]+/_/blob/master/_g' {} +","use-latest-quickselect":"npm run use-latest-quickselect-macos || npm run 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":"eikichi_onizuka","email":"kawaii.akai.neko.aniki@gmail.com"},"repository":{"url":"git://github.com/onizuka-aniki/check2d.git","type":"git"},"_npmVersion":"10.9.3","description":"Points, Lines, Boxes, Polygons (also hollow), Ellipses, Circles. RayCasting, offsets, rotation, scaling, bounding box padding, flags for static and ghost/trigger bodies","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":"22.18.0","dependencies":{"sat":"^0.9.0","@types/sat":"^0.0.35","poly-decomp-es":"^0.4.2"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^30.1.3","husky":"^9.1.7","rbush":"^4.0.1","eslint":"^9.35.0","rollup":"^4.50.0","ts-jest":"^29.4.1","typedoc":"^0.28.12","webpack":"^5.101.3","prettier":"^3.6.2","tinybench":"^5.0.1","ts-loader":"^9.5.4","typescript":"^5","@types/node":"^24.3.1","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":"^28.0.6","@stylistic/eslint-plugin":"^5.3.1","@rollup/plugin-typescript":"^12.1.4","@rollup/plugin-node-resolve":"^16.0.1"},"_npmOperationalInternal":{"tmp":"tmp/check2d_9.29.0_1757132904531_0.01759467608488241","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":1757132904740,"_cnpm_publish_time":1757132904740,"dist-tags":{"latest":"9.36.4"}}