From 7001aa273eeeaafc9ceedc46e23abd4a6debfc28 Mon Sep 17 00:00:00 2001 From: Prozi Jacek Pietal Date: Sun, 10 Nov 2024 05:12:38 +0100 Subject: [PATCH] feat: improve readme --- README.md | 12 +++++- docs/index.html | 7 +++- package.json | 12 +++--- yarn.lock | 100 +++++++++++++++++++++++++++++------------------- 4 files changed, 83 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index f12f36d..68a5fb1 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ Detect-Collisions 💫 is a lightning-fast ⚡️ TypeScript library built to de - [Tank](https://prozi.github.io/detect-collisions/demo/) - [Stress Test](https://prozi.github.io/detect-collisions/demo/?stress) - [Stackblitz](https://stackblitz.com/edit/detect-collisions) +- [CodePan](https://code.pietal.dev/#/boilerplate/detect-collisions?pans=html,console) ## Installation @@ -160,7 +161,10 @@ Detect-Collisions provides the functionality to gather raycast data. Here's how: ```ts const start = { x: 0, y: 0 }; const end = { x: 0, y: -10 }; -const hit = system.raycast(start, end); +const hit = system.raycast(start, end, (body, ray) => { + // if you don't want the body to be hit by raycast return false + return true; +}); if (hit) { const { point, body } = hit; @@ -171,6 +175,12 @@ if (hit) { In this example, `point` is a `Vector` with the coordinates of the nearest intersection, and `body` is a reference to the closest body. +## Usage in Browsers + +Just do what I did here, import from proper cdn as module, and v'oila: + + + ## Contributing to the Project We welcome contributions! Feel free to open a merge request. When doing so, please adhere to the following code style guidelines: diff --git a/docs/index.html b/docs/index.html index a1307e3..674a9b7 100644 --- a/docs/index.html +++ b/docs/index.html @@ -6,6 +6,7 @@
  • Tank
  • Stress Test
  • Stackblitz
  • +
  • CodePan
  • npm i detect-collisions --save
     
    @@ -53,10 +54,12 @@

    Detect-Collisions provides the functionality to gather raycast data. Here's how:

    -
    const start = { x: 0, y: 0 };
    const end = { x: 0, y: -10 };
    const hit = system.raycast(start, end);

    if (hit) {
    const { point, body } = hit;

    console.log({ point, body });
    } +
    const start = { x: 0, y: 0 };
    const end = { x: 0, y: -10 };
    const hit = system.raycast(start, end, (body, ray) => {
    // if you don't want the body to be hit by raycast return false
    return true;
    });

    if (hit) {
    const { point, body } = hit;

    console.log({ point, body });
    }

    In this example, point is a Vector with the coordinates of the nearest intersection, and body is a reference to the closest body.

    +

    Just do what I did here, import from proper cdn as module, and v'oila:

    +

    https://code.pietal.dev/#/boilerplate/detect-collisions?pans=html,console

    We welcome contributions! Feel free to open a merge request. When doing so, please adhere to the following code style guidelines:

    • Execute the npm run precommit script prior to submitting your merge request
    • @@ -70,4 +73,4 @@

      MIT

      https://paypal.me/jacekpietal

      -
      +
      diff --git a/package.json b/package.json index 2ceb0ae..a58dd99 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "detect-collisions", - "version": "9.23.2", + "version": "9.24.0", "description": "Points, Lines, Boxes, Polygons (also hollow), Ellipses, Circles. RayCasting, offsets, rotation, scaling, bounding box padding, flags for static and ghost/trigger bodies", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -73,11 +73,11 @@ "sat": "^0.9.0" }, "devDependencies": { - "@stylistic/eslint-plugin": "^2.10.0", - "@types/node": "^22.8.6", + "@stylistic/eslint-plugin": "^2.10.1", + "@types/node": "^22.9.0", "@types/rbush": "^4.0.0", "chef-express": "^2.4.2", - "eslint": "^9.13.0", + "eslint": "^9.14.0", "eslint-plugin-json": "^4.0.1", "html-webpack-plugin": "^5.6.3", "husky": "^9.1.6", @@ -88,9 +88,9 @@ "tinybench": "^3.0.3", "ts-jest": "^29.2.5", "ts-loader": "^9.5.1", - "typedoc": "^0.26.10", + "typedoc": "^0.26.11", "typescript": "^5", - "webpack": "^5.96.0", + "webpack": "^5.96.1", "webpack-cli": "^5.1.4", "webpack-dev-server": "^5.1.0" }, diff --git a/yarn.lock b/yarn.lock index 47f2f01..7ca5fbf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -313,7 +313,7 @@ dependencies: eslint-visitor-keys "^3.4.3" -"@eslint-community/regexpp@^4.11.0": +"@eslint-community/regexpp@^4.12.1": version "4.12.1" resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.12.1.tgz#cfc6cffe39df390a3841cde2abccf92eaa7ae0e0" integrity sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ== @@ -347,10 +347,10 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" -"@eslint/js@9.13.0": - version "9.13.0" - resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.13.0.tgz#c5f89bcd57eb54d5d4fa8b77693e9c28dc97e547" - integrity sha512-IFLyoY4d72Z5y/6o/BazFBezupzI/taV8sGumxTAVw3lXG9A6md1Dc34T9s1FoD/an9pJH8RHbAxsaEbBed9lA== +"@eslint/js@9.14.0": + version "9.14.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-9.14.0.tgz#2347a871042ebd11a00fd8c2d3d56a265ee6857e" + integrity sha512-pFoEtFWCPyDOl+C6Ift+wC7Ro89otjigCf5vcuWqWgqNSQbRrpjSvdeE6ofLz4dHmyxD5f7gIdGT4+p36L6Twg== "@eslint/object-schema@^2.1.4": version "2.1.4" @@ -369,7 +369,7 @@ resolved "https://registry.yarnpkg.com/@humanfs/core/-/core-0.19.1.tgz#17c55ca7d426733fe3c561906b8173c336b40a77" integrity sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA== -"@humanfs/node@^0.16.5": +"@humanfs/node@^0.16.6": version "0.16.6" resolved "https://registry.yarnpkg.com/@humanfs/node/-/node-0.16.6.tgz#ee2a10eaabd1131987bf0488fd9b820174cd765e" integrity sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw== @@ -382,11 +382,16 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz#af5b2691a22b44be847b0ca81641c5fb6ad0172c" integrity sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA== -"@humanwhocodes/retry@^0.3.0", "@humanwhocodes/retry@^0.3.1": +"@humanwhocodes/retry@^0.3.0": version "0.3.1" resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.3.1.tgz#c72a5c76a9fbaf3488e231b13dc52c0da7bab42a" integrity sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA== +"@humanwhocodes/retry@^0.4.0": + version "0.4.1" + resolved "https://registry.yarnpkg.com/@humanwhocodes/retry/-/retry-0.4.1.tgz#9a96ce501bc62df46c4031fbd970e3cc6b10f07b" + integrity sha512-c7hNEllBlenFTHBky65mhq8WD2kbN9Q6gk0bTk8lSBvc554jpXSkST1iePudpt7+A/AQvuHs9EMqjHDXMY1lrA== + "@istanbuljs/load-nyc-config@^1.0.0": version "1.1.0" resolved "https://registry.yarnpkg.com/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz#fd3db1d59ecf7cf121e80650bb86712f9b55eced" @@ -761,10 +766,10 @@ dependencies: "@sinonjs/commons" "^3.0.0" -"@stylistic/eslint-plugin@^2.10.0": - version "2.10.0" - resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin/-/eslint-plugin-2.10.0.tgz#eb861c61406aad0e98688b6c8357fc27987607c0" - integrity sha512-neWEgjp0qKxutbrKac5g23V5LX2c2Clyiz3zFxxybY8VSMfr+MmvwM204zg8YFbe9n2zcTwkpppCL2luwYcMhg== +"@stylistic/eslint-plugin@^2.10.1": + version "2.10.1" + resolved "https://registry.yarnpkg.com/@stylistic/eslint-plugin/-/eslint-plugin-2.10.1.tgz#809924752a1a13ebff2b0b6d7884fd61d389a907" + integrity sha512-U+4yzNXElTf9q0kEfnloI9XbOyD4cnEQCxjUI94q0+W++0GAEQvJ/slwEj9lwjDHfGADRSr+Tco/z0XJvmDfCQ== dependencies: "@typescript-eslint/utils" "^8.12.2" eslint-visitor-keys "^4.2.0" @@ -835,7 +840,23 @@ dependencies: "@types/node" "*" -"@types/estree@^1.0.6": +"@types/eslint-scope@^3.7.7": + version "3.7.7" + resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.7.tgz#3108bd5f18b0cdb277c867b3dd449c9ed7079ac5" + integrity sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg== + dependencies: + "@types/eslint" "*" + "@types/estree" "*" + +"@types/eslint@*": + version "9.6.1" + resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-9.6.1.tgz#d5795ad732ce81715f27f75da913004a56751584" + integrity sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag== + dependencies: + "@types/estree" "*" + "@types/json-schema" "*" + +"@types/estree@*", "@types/estree@^1.0.6": version "1.0.6" resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50" integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw== @@ -910,7 +931,7 @@ dependencies: "@types/istanbul-lib-report" "*" -"@types/json-schema@^7.0.15", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": +"@types/json-schema@*", "@types/json-schema@^7.0.15", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": version "7.0.15" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== @@ -941,10 +962,10 @@ dependencies: undici-types "~6.19.2" -"@types/node@^22.8.6": - version "22.8.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.8.6.tgz#e8a0c0871623283d8b3ef7d7b9b1bfdfd3028e22" - integrity sha512-tosuJYKrIqjQIlVCM4PEGxOmyg3FCPa/fViuJChnGeEIhjA46oy8FMVoF9su1/v8PNs2a8Q0iFNyOx0uOF91nw== +"@types/node@^22.9.0": + version "22.9.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.9.0.tgz#b7f16e5c3384788542c72dc3d561a7ceae2c0365" + integrity sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ== dependencies: undici-types "~6.19.8" @@ -2229,7 +2250,7 @@ eslint-scope@5.1.1: esrecurse "^4.3.0" estraverse "^4.1.1" -eslint-scope@^8.1.0: +eslint-scope@^8.2.0: version "8.2.0" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-8.2.0.tgz#377aa6f1cb5dc7592cfd0b7f892fd0cf352ce442" integrity sha512-PHlWUfG6lvPc3yvP5A4PNyBL1W8fkDUccmI21JUu/+GKZBoH/W5u6usENXUrWFRsyoW5ACUjFGgAFQp5gUlb/A== @@ -2242,26 +2263,26 @@ eslint-visitor-keys@^3.4.3: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== -eslint-visitor-keys@^4.1.0, eslint-visitor-keys@^4.2.0: +eslint-visitor-keys@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz#687bacb2af884fcdda8a6e7d65c606f46a14cd45" integrity sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw== -eslint@^9.13.0: - version "9.13.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.13.0.tgz#7659014b7dda1ff876ecbd990f726e11c61596e6" - integrity sha512-EYZK6SX6zjFHST/HRytOdA/zE72Cq/bfw45LSyuwrdvcclb/gqV8RRQxywOBEWO2+WDpva6UZa4CcDeJKzUCFA== +eslint@^9.14.0: + version "9.14.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-9.14.0.tgz#534180a97c00af08bcf2b60b0ebf0c4d6c1b2c95" + integrity sha512-c2FHsVBr87lnUtjP4Yhvk4yEhKrQavGafRA/Se1ouse8PfbfC/Qh9Mxa00yWsZRlqeUB9raXip0aiiUZkgnr9g== dependencies: "@eslint-community/eslint-utils" "^4.2.0" - "@eslint-community/regexpp" "^4.11.0" + "@eslint-community/regexpp" "^4.12.1" "@eslint/config-array" "^0.18.0" "@eslint/core" "^0.7.0" "@eslint/eslintrc" "^3.1.0" - "@eslint/js" "9.13.0" + "@eslint/js" "9.14.0" "@eslint/plugin-kit" "^0.2.0" - "@humanfs/node" "^0.16.5" + "@humanfs/node" "^0.16.6" "@humanwhocodes/module-importer" "^1.0.1" - "@humanwhocodes/retry" "^0.3.1" + "@humanwhocodes/retry" "^0.4.0" "@types/estree" "^1.0.6" "@types/json-schema" "^7.0.15" ajv "^6.12.4" @@ -2269,9 +2290,9 @@ eslint@^9.13.0: cross-spawn "^7.0.2" debug "^4.3.2" escape-string-regexp "^4.0.0" - eslint-scope "^8.1.0" - eslint-visitor-keys "^4.1.0" - espree "^10.2.0" + eslint-scope "^8.2.0" + eslint-visitor-keys "^4.2.0" + espree "^10.3.0" esquery "^1.5.0" esutils "^2.0.2" fast-deep-equal "^3.1.3" @@ -2288,7 +2309,7 @@ eslint@^9.13.0: optionator "^0.9.3" text-table "^0.2.0" -espree@^10.0.1, espree@^10.2.0, espree@^10.3.0: +espree@^10.0.1, espree@^10.3.0: version "10.3.0" resolved "https://registry.yarnpkg.com/espree/-/espree-10.3.0.tgz#29267cf5b0cb98735b65e64ba07e0ed49d1eed8a" integrity sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg== @@ -4992,10 +5013,10 @@ type-is@~1.6.18: media-typer "0.3.0" mime-types "~2.1.24" -typedoc@^0.26.10: - version "0.26.10" - resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.26.10.tgz#d372f171dc2c4458cbac6c473be9591042ab781d" - integrity sha512-xLmVKJ8S21t+JeuQLNueebEuTVphx6IrP06CdV7+0WVflUSW3SPmR+h1fnWVdAR/FQePEgsSWCUHXqKKjzuUAw== +typedoc@^0.26.11: + version "0.26.11" + resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.26.11.tgz#124b43a5637b7f3237b8c721691b44738c5c9dc9" + integrity sha512-sFEgRRtrcDl2FxVP58Ze++ZK2UQAEvtvvH8rRlig1Ja3o7dDaMHmaBfvJmdGnNEFaLTpQsN8dpvZaTqJSu/Ugw== dependencies: lunr "^2.3.9" markdown-it "^14.1.0" @@ -5271,11 +5292,12 @@ webpack-sources@^3.2.3: resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== -webpack@^5.96.0: - version "5.96.0" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.96.0.tgz#1e4dc9d1d819ff1b1f89d53e45a299ffe9231a8a" - integrity sha512-gvn84AfQ4f6vUeNWmFuRp3vGERyxK4epADKTaAo60K0EQbY/YBNQbXH3Ji/ZRK5M25O/XneAOuChF4xQZjQ4xA== +webpack@^5.96.1: + version "5.96.1" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.96.1.tgz#3676d1626d8312b6b10d0c18cc049fba7ac01f0c" + integrity sha512-l2LlBSvVZGhL4ZrPwyr8+37AunkcYj5qh8o6u2/2rzoPc8gxFJkLj1WxNgooi9pnoc06jh0BjuXnamM4qlujZA== dependencies: + "@types/eslint-scope" "^3.7.7" "@types/estree" "^1.0.6" "@webassemblyjs/ast" "^1.12.1" "@webassemblyjs/wasm-edit" "^1.12.1"