@umicat/three-sdk 0.3.0 → 0.4.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.
|
@@ -14,6 +14,9 @@ export interface CharacterOptions {
|
|
|
14
14
|
stepHeight?: number;
|
|
15
15
|
/** Steeper than this and they slide instead of climbing. Degrees. */
|
|
16
16
|
maxSlopeDegrees?: number;
|
|
17
|
+
/** Fall acceleration, in world units. Defaults to the world's own gravity;
|
|
18
|
+
* set it only to make this character deliberately heavier or floatier than
|
|
19
|
+
* its surroundings. */
|
|
17
20
|
gravity?: number;
|
|
18
21
|
/** Start position. */
|
|
19
22
|
position?: {
|
|
@@ -83,6 +86,21 @@ export declare class CharacterController3D {
|
|
|
83
86
|
get state(): CharacterState;
|
|
84
87
|
/** Rising under its own power, as opposed to merely off the ground. */
|
|
85
88
|
get airborne(): boolean;
|
|
89
|
+
/** How high a HELD jump rises, in world units.
|
|
90
|
+
*
|
|
91
|
+
* Level geometry is authored against these two numbers, so they are exposed
|
|
92
|
+
* rather than left to be re-derived. Getting the algebra wrong is not
|
|
93
|
+
* hypothetical: a course laid out against a mis-computed apex produced a
|
|
94
|
+
* first step the character could not clear, which reads to a player as
|
|
95
|
+
* "that platform is unreachable" rather than as a bug. */
|
|
96
|
+
get maxJumpRise(): number;
|
|
97
|
+
/** How high a TAPPED jump rises — the button released as early as the
|
|
98
|
+
* variable-height cut can see it.
|
|
99
|
+
*
|
|
100
|
+
* **Author rises against this one, not `maxJumpRise`.** A jump is a range,
|
|
101
|
+
* not a number: releasing early cuts it deliberately, so a gap only the
|
|
102
|
+
* held jump clears is a gap half your players will believe is closed. */
|
|
103
|
+
get minJumpRise(): number;
|
|
86
104
|
/** Put the character somewhere, cancelling any fall. The respawn primitive:
|
|
87
105
|
* without clearing the velocity, a character teleported out of a long drop
|
|
88
106
|
* arrives still travelling at the speed it fell. */
|
|
@@ -29,7 +29,14 @@ export class CharacterController3D {
|
|
|
29
29
|
speed: options.speed ?? 4,
|
|
30
30
|
stepHeight: options.stepHeight ?? 0.4,
|
|
31
31
|
maxSlopeDegrees: options.maxSlopeDegrees ?? 50,
|
|
32
|
-
gravity
|
|
32
|
+
// Default to the WORLD's gravity, not to Earth's. A kinematic character
|
|
33
|
+
// integrates its own fall, so a hard-coded 9.81 put a second gravity in
|
|
34
|
+
// the scene: in a world authored in Kenney's unit (gravity -4.17) the
|
|
35
|
+
// character fell 2.35x faster than everything around it, and every jump
|
|
36
|
+
// came out less than half the height the docs promised. One world, one
|
|
37
|
+
// gravity — pass the option only to give this character a deliberately
|
|
38
|
+
// different feel.
|
|
39
|
+
gravity: options.gravity ?? (Math.abs(world.gravity.y) || 9.81),
|
|
33
40
|
jumpSpeed: options.jumpSpeed ?? 0,
|
|
34
41
|
coyoteTime: options.coyoteTime ?? 0.12,
|
|
35
42
|
jumpBuffer: options.jumpBuffer ?? 0.12,
|
|
@@ -53,6 +60,30 @@ export class CharacterController3D {
|
|
|
53
60
|
get state() { return this._state; }
|
|
54
61
|
/** Rising under its own power, as opposed to merely off the ground. */
|
|
55
62
|
get airborne() { return !this.grounded; }
|
|
63
|
+
/** How high a HELD jump rises, in world units.
|
|
64
|
+
*
|
|
65
|
+
* Level geometry is authored against these two numbers, so they are exposed
|
|
66
|
+
* rather than left to be re-derived. Getting the algebra wrong is not
|
|
67
|
+
* hypothetical: a course laid out against a mis-computed apex produced a
|
|
68
|
+
* first step the character could not clear, which reads to a player as
|
|
69
|
+
* "that platform is unreachable" rather than as a bug. */
|
|
70
|
+
get maxJumpRise() {
|
|
71
|
+
if (this.opts.jumpSpeed <= 0)
|
|
72
|
+
return 0;
|
|
73
|
+
return (this.opts.jumpSpeed * this.opts.jumpSpeed) / (2 * this.opts.gravity);
|
|
74
|
+
}
|
|
75
|
+
/** How high a TAPPED jump rises — the button released as early as the
|
|
76
|
+
* variable-height cut can see it.
|
|
77
|
+
*
|
|
78
|
+
* **Author rises against this one, not `maxJumpRise`.** A jump is a range,
|
|
79
|
+
* not a number: releasing early cuts it deliberately, so a gap only the
|
|
80
|
+
* held jump clears is a gap half your players will believe is closed. */
|
|
81
|
+
get minJumpRise() {
|
|
82
|
+
if (this.opts.jumpSpeed <= 0)
|
|
83
|
+
return 0;
|
|
84
|
+
const cut = this.opts.jumpSpeed * this.opts.jumpCut;
|
|
85
|
+
return (cut * cut) / (2 * this.opts.gravity);
|
|
86
|
+
}
|
|
56
87
|
/** Put the character somewhere, cancelling any fall. The respawn primitive:
|
|
57
88
|
* without clearing the velocity, a character teleported out of a long drop
|
|
58
89
|
* arrives still travelling at the speed it fell. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umicat/three-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Three.js runtime for Umicat games: the scene3d design format, its loader with physics, a kinematic character controller, and the Umicat platform via @umicat/platform-sdk.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|