Skip to content

Commit 37414c7

Browse files
committed
v1.4.0
1 parent 97e4fcd commit 37414c7

20 files changed

+499
-285
lines changed

.changeset/pretty-houses-design.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/swift-eyes-cheat.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/twenty-roses-sing.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# planck
22

3+
## 1.4.0
4+
5+
### Minor Changes
6+
7+
- 0dcc98b: Split TestbedInterface and Testbed class
8+
9+
### Patch Changes
10+
11+
- e1a2717: Mark serialize and deserialize functions as @hidden instead of @internal
12+
- 3446820: Fix AABB.rayCast
13+
314
## 1.3.0
415

516
### Minor Changes

dist/planck-with-testbed.d.ts

Lines changed: 109 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export declare class Vec2 {
1818
constructor(x: number, y: number);
1919
constructor(obj: Vec2Value);
2020
constructor();
21+
/** @hidden */
22+
_serialize(): object;
23+
/** @hidden */
24+
static _deserialize(data: any): Vec2;
2125
static zero(): Vec2;
2226
/** @hidden */
2327
static neo(x: number, y: number): Vec2;
@@ -585,24 +589,25 @@ export interface Style {
585589
fill?: string;
586590
lineWidth?: number;
587591
}
588-
export type KEY = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "right" | "left" | "up" | "down" | "fire";
589592
export type ActiveKeys = {
590593
[key in KEY]?: boolean;
591594
};
592595
export type TestbedMountOptions = {
593596
[key: string]: any;
594597
};
595-
export declare abstract class Testbed {
598+
export declare class Testbed {
596599
/**
597600
* Mounts testbed. Call start with a world to start simulation and rendering.
598601
*/
599-
static mount(options?: TestbedMountOptions): Testbed;
602+
static mount(options?: TestbedMountOptions): TestbedInterface;
600603
/**
601604
* Mounts testbed if needed, then starts simulation and rendering.
602605
*
603606
* If you need to customize testbed before starting, first run `const testbed = Testbed.mount()` and then `testbed.start()`.
604607
*/
605-
static start(world: World): Testbed;
608+
static start(world: World): TestbedInterface;
609+
}
610+
export interface TestbedInterface {
606611
/** World viewbox width. */
607612
width: number;
608613
/** World viewbox height. */
@@ -621,53 +626,34 @@ export declare abstract class Testbed {
621626
mouseForce?: number;
622627
activeKeys: ActiveKeys;
623628
/** callback, to be implemented by user */
624-
step: (dt: number, t: number) => void;
629+
step?: (dt: number, t: number) => void;
625630
/** callback, to be implemented by user */
626-
keydown: (keyCode: number, label: string) => void;
631+
keydown?: (keyCode: number, label: string) => void;
627632
/** callback, to be implemented by user */
628-
keyup: (keyCode: number, label: string) => void;
629-
abstract status(name: string, value: any): void;
630-
abstract status(value: object | string): void;
631-
abstract info(text: string): void;
633+
keyup?: (keyCode: number, label: string) => void;
634+
status(name: string, value: any): void;
635+
status(value: object | string): void;
636+
info(text: string): void;
632637
color(r: number, g: number, b: number): string;
633-
abstract drawPoint(p: {
634-
x: number;
635-
y: number;
636-
}, r: any, color: string): void;
637-
abstract drawCircle(p: {
638-
x: number;
639-
y: number;
640-
}, r: number, color: string): void;
641-
abstract drawEdge(a: {
642-
x: number;
643-
y: number;
644-
}, b: {
645-
x: number;
646-
y: number;
647-
}, color: string): void;
648-
abstract drawSegment(a: {
649-
x: number;
650-
y: number;
651-
}, b: {
652-
x: number;
653-
y: number;
654-
}, color: string): void;
655-
abstract drawPolygon(points: Array<{
656-
x: number;
657-
y: number;
658-
}>, color: string): void;
659-
abstract drawAABB(aabb: AABBValue, color: string): void;
660-
abstract start(world: World): void;
661-
abstract findOne(query: string): (Body$1 | Joint | Fixture | null);
662-
abstract findAll(query: string): (Body$1 | Joint | Fixture)[];
638+
drawPoint(p: Vec2Value, r: any, color: string): void;
639+
drawCircle(p: Vec2Value, r: number, color: string): void;
640+
drawEdge(a: Vec2Value, b: Vec2Value, color: string): void;
641+
drawSegment(a: Vec2Value, b: Vec2Value, color: string): void;
642+
drawPolygon(points: Array<Vec2Value>, color: string): void;
643+
drawChain(points: Array<Vec2Value>, color: string): void;
644+
drawAABB(aabb: AABBValue, color: string): void;
645+
start(world: World): void;
646+
findOne(query: string): Body$1 | Joint | Fixture | null;
647+
findAll(query: string): (Body$1 | Joint | Fixture)[];
663648
}
664649
export type TestbedFactoryOptions = string | TestbedMountOptions;
665650
/** @deprecated */
666-
export type TestbedCallback = (testbed: Testbed) => (World | undefined);
651+
export type TestbedCallback = (testbed: TestbedInterface) => World | undefined;
667652
/** @deprecated */
668653
export declare function testbed(callback: TestbedCallback): void;
669654
/** @deprecated */
670655
export declare function testbed(options: TestbedFactoryOptions, callback: TestbedCallback): void;
656+
export type KEY = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "right" | "left" | "up" | "down" | "fire";
671657
/**
672658
* A shape is used for collision detection. You can create a shape however you
673659
* like. Shapes used for simulation in World are created automatically when a
@@ -1025,6 +1011,10 @@ export declare class Fixture {
10251011
constructor(body: Body$1, shape: Shape, density?: number);
10261012
/** @hidden Re-setup fixture. */
10271013
_reset(): void;
1014+
/** @hidden */
1015+
_serialize(): object;
1016+
/** @hidden */
1017+
static _deserialize(data: any, body: any, restore: any): Fixture;
10281018
/**
10291019
* Get the type of the child shape. You can use this to down cast to the
10301020
* concrete shape.
@@ -1568,6 +1558,10 @@ declare class Body$1 {
15681558
style: Style;
15691559
/** @hidden @experimental Similar to userData, but used by dev-tools or runtime environment. */
15701560
appData: Record<string, any>;
1561+
/** @hidden */
1562+
_serialize(): object;
1563+
/** @hidden */
1564+
static _deserialize(data: any, world: any, restore: any): Body$1;
15711565
isWorldLocked(): boolean;
15721566
getWorld(): World;
15731567
getNext(): Body$1 | null;
@@ -1962,6 +1956,10 @@ export declare class World {
19621956
* @param def World definition or gravity vector.
19631957
*/
19641958
constructor(def?: WorldDef | Vec2Value);
1959+
/** @hidden */
1960+
_serialize(): object;
1961+
/** @hidden */
1962+
static _deserialize(data: any, context: any, restore: any): World;
19651963
/**
19661964
* Get the world body list. With the returned body, use Body.getNext to get the
19671965
* next body in the world list. A null body indicates the end of the list.
@@ -2244,6 +2242,10 @@ export declare class Vec3 {
22442242
constructor(obj: Vec3Value);
22452243
constructor();
22462244
/** @hidden */
2245+
_serialize(): object;
2246+
/** @hidden */
2247+
static _deserialize(data: any): Vec3;
2248+
/** @hidden */
22472249
static neo(x: number, y: number, z: number): Vec3;
22482250
static zero(): Vec3;
22492251
static clone(v: Vec3Value): Vec3;
@@ -2378,6 +2380,10 @@ export declare class CircleShape extends Shape {
23782380
constructor(position: Vec2Value, radius?: number);
23792381
constructor(radius?: number);
23802382
/** @hidden */
2383+
_serialize(): object;
2384+
/** @hidden */
2385+
static _deserialize(data: any): CircleShape;
2386+
/** @hidden */
23812387
_reset(): void;
23822388
getType(): "circle";
23832389
getRadius(): number;
@@ -2442,6 +2448,10 @@ export declare class EdgeShape extends Shape {
24422448
/** @hidden */ m_hasVertex3: boolean;
24432449
constructor(v1?: Vec2Value, v2?: Vec2Value);
24442450
/** @hidden */
2451+
_serialize(): object;
2452+
/** @hidden */
2453+
static _deserialize(data: any): EdgeShape;
2454+
/** @hidden */
24452455
_reset(): void;
24462456
getRadius(): number;
24472457
getType(): "edge";
@@ -2523,6 +2533,10 @@ export declare class PolygonShape extends Shape {
25232533
/** @hidden */ m_count: number;
25242534
/** @hidden */ m_radius: number;
25252535
constructor(vertices?: Vec2Value[]);
2536+
/** @hidden */
2537+
_serialize(): object;
2538+
/** @hidden */
2539+
static _deserialize(data: any, fixture: any, restore: any): PolygonShape;
25262540
getType(): "polygon";
25272541
getRadius(): number;
25282542
/**
@@ -2595,6 +2609,10 @@ export declare class ChainShape extends Shape {
25952609
/** @hidden */ m_hasNextVertex: boolean;
25962610
/** @hidden */ m_isLoop: boolean;
25972611
constructor(vertices?: Vec2Value[], loop?: boolean);
2612+
/** @hidden */
2613+
_serialize(): object;
2614+
/** @hidden */
2615+
static _deserialize(data: any, fixture: any, restore: any): ChainShape;
25982616
getType(): "chain";
25992617
getRadius(): number;
26002618
/** @hidden */
@@ -2680,10 +2698,10 @@ export declare const CollideCircles: (manifold: Manifold, circleA: CircleShape,
26802698
export declare const CollideEdgeCircle: (manifold: Manifold, edgeA: EdgeShape, xfA: TransformValue, circleB: CircleShape, xfB: TransformValue) => void;
26812699
/**
26822700
*
2683-
* Find edge normal of max separation on A - return if separating axis is found<br>
2684-
* Find edge normal of max separation on B - return if separation axis is found<br>
2685-
* Choose reference edge as min(minA, minB)<br>
2686-
* Find incident edge<br>
2701+
* Find edge normal of max separation on A - return if separating axis is found
2702+
* Find edge normal of max separation on B - return if separation axis is found
2703+
* Choose reference edge as min(minA, minB)
2704+
* Find incident edge
26872705
* Clip
26882706
*
26892707
* The normal points from 1 to 2
@@ -2753,6 +2771,10 @@ export declare class DistanceJoint extends Joint {
27532771
*/
27542772
constructor(def: DistanceJointOpt, bodyA: Body$1, bodyB: Body$1, anchorA?: Vec2Value, anchorB?: Vec2Value);
27552773
/** @hidden */
2774+
_serialize(): object;
2775+
/** @hidden */
2776+
static _deserialize(data: any, world: any, restore: any): DistanceJoint;
2777+
/** @hidden */
27562778
_reset(def: Partial<DistanceJointDef>): void;
27572779
/**
27582780
* The local anchor point relative to bodyA's origin.
@@ -2840,6 +2862,10 @@ export declare class FrictionJoint extends Joint {
28402862
*/
28412863
constructor(def: FrictionJointOpt, bodyA: Body$1, bodyB: Body$1, anchor?: Vec2Value);
28422864
/** @hidden */
2865+
_serialize(): object;
2866+
/** @hidden */
2867+
static _deserialize(data: any, world: any, restore: any): FrictionJoint;
2868+
/** @hidden */
28432869
_reset(def: Partial<FrictionJointDef>): void;
28442870
/**
28452871
* The local anchor point relative to bodyA's origin.
@@ -2970,6 +2996,10 @@ export declare class RevoluteJoint extends Joint {
29702996
constructor(def: RevoluteJointDef);
29712997
constructor(def: RevoluteJointOpt, bodyA: Body$1, bodyB: Body$1, anchor?: Vec2Value);
29722998
/** @hidden */
2999+
_serialize(): object;
3000+
/** @hidden */
3001+
static _deserialize(data: any, world: any, restore: any): RevoluteJoint;
3002+
/** @hidden */
29733003
_reset(def: Partial<RevoluteJointDef>): void;
29743004
/**
29753005
* The local anchor point relative to bodyA's origin.
@@ -3136,6 +3166,10 @@ export declare class PrismaticJoint extends Joint {
31363166
constructor(def: PrismaticJointDef);
31373167
constructor(def: PrismaticJointOpt, bodyA: Body$1, bodyB: Body$1, anchor?: Vec2Value, axis?: Vec2Value);
31383168
/** @hidden */
3169+
_serialize(): object;
3170+
/** @hidden */
3171+
static _deserialize(data: any, world: any, restore: any): PrismaticJoint;
3172+
/** @hidden */
31393173
_reset(def: Partial<PrismaticJointDef>): void;
31403174
/**
31413175
* The local anchor point relative to bodyA's origin.
@@ -3273,6 +3307,10 @@ export declare class GearJoint extends Joint {
32733307
constructor(def: GearJointDef);
32743308
constructor(def: GearJointOpt, bodyA: Body$1, bodyB: Body$1, joint1: RevoluteJoint | PrismaticJoint, joint2: RevoluteJoint | PrismaticJoint, ratio?: number);
32753309
/** @hidden */
3310+
_serialize(): object;
3311+
/** @hidden */
3312+
static _deserialize(data: any, world: any, restore: any): GearJoint;
3313+
/** @hidden */
32763314
_reset(def: Partial<GearJointDef>): void;
32773315
/**
32783316
* Get the first joint.
@@ -3357,6 +3395,10 @@ export declare class MotorJoint extends Joint {
33573395
constructor(def: MotorJointDef);
33583396
constructor(def: MotorJointOpt, bodyA: Body$1, bodyB: Body$1);
33593397
/** @hidden */
3398+
_serialize(): object;
3399+
/** @hidden */
3400+
static _deserialize(data: any, world: any, restore: any): MotorJoint;
3401+
/** @hidden */
33603402
_reset(def: Partial<MotorJointDef>): void;
33613403
/**
33623404
* Set the maximum friction force in N.
@@ -3468,6 +3510,10 @@ export declare class MouseJoint extends Joint {
34683510
constructor(def: MouseJointDef);
34693511
constructor(def: MouseJointOpt, bodyA: Body$1, bodyB: Body$1, target?: Vec2Value);
34703512
/** @hidden */
3513+
_serialize(): object;
3514+
/** @hidden */
3515+
static _deserialize(data: any, world: any, restore: any): MouseJoint;
3516+
/** @hidden */
34713517
_reset(def: Partial<MouseJointDef>): void;
34723518
/**
34733519
* Use this to update the target point.
@@ -3587,6 +3633,10 @@ export declare class PulleyJoint extends Joint {
35873633
constructor(def: PulleyJointDef);
35883634
constructor(def: PulleyJointOpt, bodyA: Body$1, bodyB: Body$1, groundA?: Vec2Value, groundB?: Vec2Value, anchorA?: Vec2Value, anchorB?: Vec2Value, ratio?: number);
35893635
/** @hidden */
3636+
_serialize(): object;
3637+
/** @hidden */
3638+
static _deserialize(data: any, world: any, restore: any): PulleyJoint;
3639+
/** @hidden */
35903640
_reset(def: Partial<PulleyJointDef>): void;
35913641
/**
35923642
* Get the first ground anchor.
@@ -3692,6 +3742,10 @@ export declare class RopeJoint extends Joint {
36923742
constructor(def: RopeJointDef);
36933743
constructor(def: RopeJointOpt, bodyA: Body$1, bodyB: Body$1, anchor?: Vec2Value);
36943744
/** @hidden */
3745+
_serialize(): object;
3746+
/** @hidden */
3747+
static _deserialize(data: any, world: any, restore: any): RopeJoint;
3748+
/** @hidden */
36953749
_reset(def: Partial<RopeJointDef>): void;
36963750
/**
36973751
* The local anchor point relative to bodyA's origin.
@@ -3781,6 +3835,10 @@ export declare class WeldJoint extends Joint {
37813835
constructor(def: WeldJointDef);
37823836
constructor(def: WeldJointOpt, bodyA: Body$1, bodyB: Body$1, anchor?: Vec2Value);
37833837
/** @hidden */
3838+
_serialize(): object;
3839+
/** @hidden */
3840+
static _deserialize(data: any, world: any, restore: any): WeldJoint;
3841+
/** @hidden */
37843842
_reset(def: Partial<WeldJointDef>): void;
37853843
/**
37863844
* The local anchor point relative to bodyA's origin.
@@ -3900,6 +3958,10 @@ export declare class WheelJoint extends Joint {
39003958
constructor(def: WheelJointDef);
39013959
constructor(def: WheelJointOpt, bodyA: Body$1, bodyB: Body$1, anchor?: Vec2Value, axis?: Vec2Value);
39023960
/** @hidden */
3961+
_serialize(): object;
3962+
/** @hidden */
3963+
static _deserialize(data: any, world: any, restore: any): WheelJoint;
3964+
/** @hidden */
39033965
_reset(def: Partial<WheelJointDef>): void;
39043966
/**
39053967
* The local anchor point relative to bodyA's origin.
@@ -4223,13 +4285,14 @@ export declare const internal: {
42234285
toString(newline?: string): string;
42244286
};
42254287
};
4288+
/** @hidden */
42264289
export interface DataDriverListener<D, R> {
42274290
enter: (d: D) => R | null;
42284291
exit: (d: D, ref: R) => void;
42294292
update: (d: D, ref: R) => void;
42304293
}
42314294
/**
4232-
* @experimental
4295+
* @experimental @hidden
42334296
*
42344297
* DataDriver is used it to create, update and destroy physics entities based on game objects.
42354298
*/

0 commit comments

Comments
 (0)