@ignifx/physics 0.6.1 → 0.7.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.
- package/dist/index.js +19 -6
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/skills/physics/SKILL.md +7 -3
package/dist/index.js
CHANGED
|
@@ -2097,20 +2097,33 @@ function moveController(controller, displacement) {
|
|
|
2097
2097
|
/**
|
|
2098
2098
|
* Probes the surface under the character without moving it.
|
|
2099
2099
|
*
|
|
2100
|
+
* @remarks
|
|
2101
|
+
* `checkSupport` wants a **unit** direction. It classifies by `1 - dot(slide, direction)²` against
|
|
2102
|
+
* `maxSlopeCosine²` (`lib/physics/character-controller.js`, `checkSupport`), which is `cos²` of the
|
|
2103
|
+
* slope only when `direction` has length 1. Passed raw gravity (length 9.81), the term fell below
|
|
2104
|
+
* the limit on any incline steeper than 4° to 5°, so every walkable slope read as `SLIDING` and
|
|
2105
|
+
* `isGrounded` was false on it (fixed 2026-10-14). Zero gravity probes straight down.
|
|
2106
|
+
*
|
|
2100
2107
|
* @param controller - The controller.
|
|
2101
2108
|
* @param deltaSeconds - The fixed step.
|
|
2102
|
-
* @param gravity - The probe direction, normally gravity.
|
|
2109
|
+
* @param gravity - The probe direction, normally gravity; only its direction is used.
|
|
2103
2110
|
* @param groundNormal - Written with the averaged supporting normal.
|
|
2104
2111
|
* @returns The support classification.
|
|
2105
2112
|
*
|
|
2106
2113
|
* @internal
|
|
2107
2114
|
*/
|
|
2108
2115
|
function probeSupport(controller, deltaSeconds, gravity, groundNormal) {
|
|
2109
|
-
const
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2116
|
+
const length = Math.hypot(gravity.x, gravity.y, gravity.z);
|
|
2117
|
+
const direction = length > 0 ? {
|
|
2118
|
+
x: gravity.x / length,
|
|
2119
|
+
y: gravity.y / length,
|
|
2120
|
+
z: gravity.z / length
|
|
2121
|
+
} : {
|
|
2122
|
+
x: 0,
|
|
2123
|
+
y: -1,
|
|
2124
|
+
z: 0
|
|
2125
|
+
};
|
|
2126
|
+
const surface = controller.checkSupport(deltaSeconds, direction);
|
|
2114
2127
|
const normal = surface.averageSurfaceNormal;
|
|
2115
2128
|
groundNormal.set(normal.x, normal.y, normal.z);
|
|
2116
2129
|
return toSupportState(surface.supportedState);
|