Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(physics): the 2D shapes and joints a scene can carry, in one

esengineae8da8664a4f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0a494c5bc..10d2a9637 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,20 @@ published separately; it ships inside the editor.
### Added
+- **Every 2D collider shape and joint, authored in a scene.** The capsule,
+ segment, chain and polygon colliders and three of the six joints had no
+ instance in any scene either. physics-playground's showcase now hangs a
+ pendulum on a distance joint, drops a capsule onto a segment rail, welds two
+ crates, lays a chain of edges as terrain, and drives a motorised cart up a
+ polygon ramp — which is the one of those a box cannot be.
+
+- **A joint's anchors say whose body they are on.** `anchorA` is on the
+ CONNECTED body and `anchorB` on the joint's own entity, and nothing said so:
+ the fields are two identical-looking vectors whose defaults pin both centres
+ to a single point rather than keeping the offset they were placed with. Both
+ now carry that in their tooltip, along with the 3D joints' single `anchor`,
+ which is in its own entity's frame instead.
+
- **Every 3D collider shape and joint, authored in a scene.** physics-3d carried
45 boxes and one hinge, and that was the whole corpus: the sphere, capsule,
convex and mesh colliders and four of the five joints shipped with no instance
diff --git a/desktop b/desktop
index 6a7d707e1..2e75d5959 160000
--- a/desktop
+++ b/desktop
@@ -1 +1 @@
-Subproject commit 6a7d707e1750e2eae18dfb821d4f1a149e2168be
+Subproject commit 2e75d5959b71cef1f43e90067cb2a203f046ec03
diff --git a/docs/astro/src/data/components.generated.json b/docs/astro/src/data/components.generated.json
index c2848e076..3558a63e2 100644
--- a/docs/astro/src/data/components.generated.json
+++ b/docs/astro/src/data/components.generated.json
@@ -1006,12 +1006,14 @@
{
"key": "anchorA",
"type": "Vec2",
- "default": "(0, 0)"
+ "default": "(0, 0)",
+ "doc": "Where the joint attaches on the connected body, in that body's frame (pixels)."
},
{
"key": "anchorB",
"type": "Vec2",
- "default": "(0, 0)"
+ "default": "(0, 0)",
+ "doc": "Where it attaches on this entity, in its own frame (pixels)."
},
{
"key": "length",
@@ -1365,12 +1367,14 @@
{
"key": "anchorA",
"type": "Vec2",
- "default": "(0, 0)"
+ "default": "(0, 0)",
+ "doc": "Where the joint attaches on the connected body, in that body's frame (pixels)."
},
{
"key": "anchorB",
"type": "Vec2",
- "default": "(0, 0)"
+ "default": "(0, 0)",
+ "doc": "Where it attaches on this entity, in its own frame (pixels)."
},
{
"key": "linearHertz",
@@ -1614,12 +1618,14 @@
{
"key": "anchorA",
"type": "Vec2",
- "default": "(0, 0)"
+ "default": "(0, 0)",
+ "doc": "Where the joint attaches on the connected body, in that body's frame (pixels)."
},
{
"key": "anchorB",
"type": "Vec2",
- "default": "(0, 0)"
+ "default": "(0, 0)",
+ "doc": "Where it attaches on this entity, in its own frame (pixels)."
},
{
"key": "enableMotor",
@@ -1686,7 +1692,8 @@
{
"key": "anchor",
"type": "Vec3",
- "default": "(0, 0, 0)"
+ "default": "(0, 0, 0)",
+ "doc": "Where the joint attaches, in THIS entity's frame (world units)."
},
{
"key": "axis",
@@ -3160,7 +3167,8 @@
{
"key": "anchor",
"type": "Vec3",
- "default": "(0, 0, 0)"
+ "default": "(0, 0, 0)",
+ "doc": "Where the joint attaches, in THIS entity's frame (world units)."
},
{
"key": "collideConnected",
@@ -3617,17 +3625,20 @@
{
"key": "anchorA",
"type": "Vec2",
- "default": "(0, 0)"
+ "default": "(0, 0)",
+ "doc": "Where the joint attaches on the connected body, in that body's frame (pixels)."
},
{
"key": "anchorB",
"type": "Vec2",
- "default": "(0, 0)"
+ "default": "(0, 0)",
+ "doc": "Where it attaches on this entity, in its own frame (pixels)."
},
{
"key": "axis",
"type": "Vec2",
- "default": "(1, 0)"
+ "default": "(1, 0)",
+ "doc": "Direction of travel, in the connected body's frame."
},
{
"key": "enableSpring",
@@ -3713,7 +3724,8 @@
{
"key": "anchor",
"type": "Vec3",
- "default": "(0, 0, 0)"
+ "default": "(0, 0, 0)",
+ "doc": "Where the joint attaches, in THIS entity's frame (world units)."
},
{
"key": "axis",
@@ -5527,17 +5539,20 @@
{
"key": "anchorA",
"type": "Vec2",
- "default": "(0, 0)"
+ "default": "(0, 0)",
+ "doc": "Where the joint attaches on the connected body, in that body's frame (pixels)."
},
{
"key": "anchorB",
"type": "Vec2",
- "default": "(0, 0)"
+ "default": "(0, 0)",
+ "doc": "Where it attaches on this entity, in its own frame (pixels)."
},
{
"key": "axis",
"type": "Vec2",
- "default": "(0, 1)"
+ "default": "(0, 1)",
+ "doc": "Direction of travel, in the connected body's frame."
},
{
"key": "enableSpring",
diff --git a/examples/physics-playground/assets/scenes/showcase.esscene b/examples/physics-playground/assets/scenes/showcase.esscene
index eff884c91..45a7004f4 100644
--- a/examples/physics-playground/assets/scenes/showcase.esscene
+++ b/examples/physics-playground/assets/scenes/showcase.esscene
@@ -8,8 +8,25 @@
"parent": null,
"children": [],
"components": [
- { "type": "Transform", "data": { "position": { "x": 0, "y": 0, "z": 10 } } },
- { "type": "Camera", "data": { "projectionType": 1, "orthoSize": 300, "isActive": true, "priority": 0 } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": 0,
+ "z": 10
+ }
+ }
+ },
+ {
+ "type": "Camera",
+ "data": {
+ "projectionType": 1,
+ "orthoSize": 300,
+ "isActive": true,
+ "priority": 0
+ }
+ }
],
"visible": true
},
@@ -19,10 +36,46 @@
"parent": null,
"children": [],
"components": [
- { "type": "Transform", "data": { "position": { "x": 0, "y": -260, "z": 0 } } },
- { "type": "Sprite", "data": { "size": { "x": 780, "y": 20 }, "color": { "r": 0.4, "g": 0.4, "b": 0.45, "a": 1 } } },
- { "type": "RigidBody2D", "data": { "bodyType": 0 } },
- { "type": "BoxCollider2D", "data": { "halfExtents": { "x": 3.9, "y": 0.1 } } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 0,
+ "y": -260,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 780,
+ "y": 20
+ },
+ "color": {
+ "r": 0.4,
+ "g": 0.4,
+ "b": 0.45,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 0
+ }
+ },
+ {
+ "type": "BoxCollider2D",
+ "data": {
+ "halfExtents": {
+ "x": 3.9,
+ "y": 0.1
+ }
+ }
+ }
],
"visible": true
},
@@ -32,10 +85,46 @@
"parent": null,
"children": [],
"components": [
- { "type": "Transform", "data": { "position": { "x": -390, "y": -20, "z": 0 } } },
- { "type": "Sprite", "data": { "size": { "x": 20, "y": 520 }, "color": { "r": 0.4, "g": 0.4, "b": 0.45, "a": 1 } } },
- { "type": "RigidBody2D", "data": { "bodyType": 0 } },
- { "type": "BoxCollider2D", "data": { "halfExtents": { "x": 0.1, "y": 2.6 } } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -390,
+ "y": -20,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 20,
+ "y": 520
+ },
+ "color": {
+ "r": 0.4,
+ "g": 0.4,
+ "b": 0.45,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 0
+ }
+ },
+ {
+ "type": "BoxCollider2D",
+ "data": {
+ "halfExtents": {
+ "x": 0.1,
+ "y": 2.6
+ }
+ }
+ }
],
"visible": true
},
@@ -45,10 +134,46 @@
"parent": null,
"children": [],
"components": [
- { "type": "Transform", "data": { "position": { "x": 390, "y": -20, "z": 0 } } },
- { "type": "Sprite", "data": { "size": { "x": 20, "y": 520 }, "color": { "r": 0.4, "g": 0.4, "b": 0.45, "a": 1 } } },
- { "type": "RigidBody2D", "data": { "bodyType": 0 } },
- { "type": "BoxCollider2D", "data": { "halfExtents": { "x": 0.1, "y": 2.6 } } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 390,
+ "y": -20,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 20,
+ "y": 520
+ },
+ "color": {
+ "r": 0.4,
+ "g": 0.4,
+ "b": 0.45,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 0
+ }
+ },
+ {
+ "type": "BoxCollider2D",
+ "data": {
+ "halfExtents": {
+ "x": 0.1,
+ "y": 2.6
+ }
+ }
+ }
],
"visible": true
},
@@ -58,11 +183,56 @@
"parent": null,
"children": [],
"components": [
- { "type": "Transform", "data": { "position": { "x": -170, "y": 30, "z": 0 } } },
- { "type": "Sprite", "data": { "size": { "x": 300, "y": 16 }, "color": { "r": 0.3, "g": 0.8, "b": 0.9, "a": 0.55 } } },
- { "type": "RigidBody2D", "data": { "bodyType": 0 } },
- { "type": "BoxCollider2D", "data": { "halfExtents": { "x": 1.5, "y": 0.08 } } },
- { "type": "OneWayPlatform2D", "data": { "normal": { "x": 0, "y": 1 }, "enabled": true } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -170,
+ "y": 30,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 300,
+ "y": 16
+ },
+ "color": {
+ "r": 0.3,
+ "g": 0.8,
+ "b": 0.9,
+ "a": 0.55
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 0
+ }
+ },
+ {
+ "type": "BoxCollider2D",
+ "data": {
+ "halfExtents": {
+ "x": 1.5,
+ "y": 0.08
+ }
+ }
+ },
+ {
+ "type": "OneWayPlatform2D",
+ "data": {
+ "normal": {
+ "x": 0,
+ "y": 1
+ },
+ "enabled": true
+ }
+ }
],
"visible": true
},
@@ -72,8 +242,22 @@
"parent": null,
"children": [],
"components": [
- { "type": "Transform", "data": { "position": { "x": 150, "y": -90, "z": 0 } } },
- { "type": "RigidBody2D", "data": { "bodyType": 0 } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 150,
+ "y": -90,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 0
+ }
+ }
],
"visible": true
},
@@ -83,25 +267,69 @@
"parent": null,
"children": [],
"components": [
- { "type": "Transform", "data": { "position": { "x": 150, "y": -90, "z": 0 } } },
- { "type": "Sprite", "data": { "size": { "x": 160, "y": 24 }, "color": { "r": 0.95, "g": 0.6, "b": 0.2, "a": 1 } } },
- { "type": "RigidBody2D", "data": { "bodyType": 2, "fixedRotation": true } },
- { "type": "BoxCollider2D", "data": { "halfExtents": { "x": 0.8, "y": 0.12 }, "friction": 0.8 } },
- { "type": "MotorJoint2D", "data": {
- "connectedEntity": 5,
- "linearVelocity": { "x": 180, "y": 0 },
- "maxVelocityForce": 3000,
- "angularVelocity": 0,
- "maxVelocityTorque": 0,
- "linearHertz": 0,
- "linearDampingRatio": 0,
- "maxSpringForce": 0,
- "angularHertz": 0,
- "angularDampingRatio": 0,
- "maxSpringTorque": 0,
- "collideConnected": false,
- "enabled": true
- } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 150,
+ "y": -90,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 160,
+ "y": 24
+ },
+ "color": {
+ "r": 0.95,
+ "g": 0.6,
+ "b": 0.2,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 2,
+ "fixedRotation": true
+ }
+ },
+ {
+ "type": "BoxCollider2D",
+ "data": {
+ "halfExtents": {
+ "x": 0.8,
+ "y": 0.12
+ },
+ "friction": 0.8
+ }
+ },
+ {
+ "type": "MotorJoint2D",
+ "data": {
+ "connectedEntity": 5,
+ "linearVelocity": {
+ "x": 180,
+ "y": 0
+ },
+ "maxVelocityForce": 3000,
+ "angularVelocity": 0,
+ "maxVelocityTorque": 0,
+ "linearHertz": 0,
+ "linearDampingRatio": 0,
+ "maxSpringForce": 0,
+ "angularHertz": 0,
+ "angularDampingRatio": 0,
+ "maxSpringTorque": 0,
+ "collideConnected": false,
+ "enabled": true
+ }
+ }
],
"visible": true
},
@@ -111,8 +339,17 @@
"parent": null,
"children": [],
"components": [
- { "type": "Transform", "data": {} },
- { "type": "SpawnTimer", "data": { "interval": 0.9, "timer": 0 } }
+ {
+ "type": "Transform",
+ "data": {}
+ },
+ {
+ "type": "SpawnTimer",
+ "data": {
+ "interval": 0.9,
+ "timer": 0
+ }
+ }
],
"visible": true
},
@@ -122,8 +359,22 @@
"parent": null,
"children": [],
"components": [
- { "type": "Transform", "data": { "position": { "x": 300, "y": 80, "z": 0 } } },
- { "type": "RigidBody2D", "data": { "bodyType": 0 } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 300,
+ "y": 80,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 0
+ }
+ }
],
"visible": true
},
@@ -133,29 +384,719 @@
"parent": null,
"children": [],
"components": [
- { "type": "Transform", "data": { "position": { "x": 300, "y": 40, "z": 0 } } },
- { "type": "Sprite", "data": { "size": { "x": 100, "y": 16 }, "color": { "r": 0.65, "g": 0.5, "b": 0.95, "a": 1 } } },
- { "type": "RigidBody2D", "data": { "bodyType": 2, "fixedRotation": true } },
- { "type": "BoxCollider2D", "data": { "halfExtents": { "x": 0.5, "y": 0.08 } } },
- { "type": "SliderJoint2D", "data": {
- "connectedEntity": 8,
- "anchorA": { "x": 0, "y": 0 },
- "anchorB": { "x": 0, "y": 0 },
- "axis": { "x": 0, "y": 1 },
- "enableSpring": true,
- "hertz": 1.5,
- "dampingRatio": 0.3,
- "enableLimit": true,
- "lowerTranslation": -120,
- "upperTranslation": 40,
- "enableMotor": false,
- "maxMotorForce": 0,
- "motorSpeed": 0,
- "collideConnected": false,
- "enabled": true
- } }
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 300,
+ "y": 40,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 100,
+ "y": 16
+ },
+ "color": {
+ "r": 0.65,
+ "g": 0.5,
+ "b": 0.95,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 2,
+ "fixedRotation": true
+ }
+ },
+ {
+ "type": "BoxCollider2D",
+ "data": {
+ "halfExtents": {
+ "x": 0.5,
+ "y": 0.08
+ }
+ }
+ },
+ {
+ "type": "SliderJoint2D",
+ "data": {
+ "connectedEntity": 8,
+ "anchorA": {
+ "x": 0,
+ "y": 0
+ },
+ "anchorB": {
+ "x": 0,
+ "y": 0
+ },
+ "axis": {
+ "x": 0,
+ "y": 1
+ },
+ "enableSpring": true,
+ "hertz": 1.5,
+ "dampingRatio": 0.3,
+ "enableLimit": true,
+ "lowerTranslation": -120,
+ "upperTranslation": 40,
+ "enableMotor": false,
+ "maxMotorForce": 0,
+ "motorSpeed": 0,
+ "collideConnected": false,
+ "enabled": true
+ }
+ }
],
"visible": true
+ },
+ {
+ "id": 10,
+ "name": "PendulumPivot",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -300,
+ "y": 190,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 0
+ }
+ }
+ ]
+ },
+ {
+ "id": 11,
+ "name": "PendulumBob",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -230,
+ "y": 150,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 36,
+ "y": 36
+ },
+ "color": {
+ "r": 0.95,
+ "g": 0.72,
+ "b": 0.25,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 2,
+ "linearDamping": 0.1,
+ "angularDamping": 0.2
+ }
+ },
+ {
+ "type": "CircleCollider2D",
+ "data": {
+ "radius": 0.18,
+ "friction": 0.3,
+ "restitution": 0.2
+ }
+ },
+ {
+ "type": "DistanceJoint2D",
+ "data": {
+ "connectedEntity": 10,
+ "anchorA": {
+ "x": 0,
+ "y": 0
+ },
+ "anchorB": {
+ "x": 0,
+ "y": 0
+ },
+ "length": 110,
+ "enableLimit": true,
+ "minLength": 110,
+ "maxLength": 110
+ }
+ }
+ ]
+ },
+ {
+ "id": 12,
+ "name": "Rail",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -300,
+ "y": 20,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 200,
+ "y": 6
+ },
+ "color": {
+ "r": 0.42,
+ "g": 0.45,
+ "b": 0.52,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 0
+ }
+ },
+ {
+ "type": "SegmentCollider2D",
+ "data": {
+ "point1": {
+ "x": -1,
+ "y": 0.35
+ },
+ "point2": {
+ "x": 1,
+ "y": -0.35
+ },
+ "friction": 0.2
+ }
+ }
+ ]
+ },
+ {
+ "id": 13,
+ "name": "Pill",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -360,
+ "y": 130,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 28,
+ "y": 60
+ },
+ "color": {
+ "r": 0.35,
+ "g": 0.82,
+ "b": 0.62,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 2,
+ "linearDamping": 0.05,
+ "angularDamping": 0.05
+ }
+ },
+ {
+ "type": "CapsuleCollider2D",
+ "data": {
+ "radius": 0.14,
+ "halfHeight": 0.16,
+ "friction": 0.25,
+ "restitution": 0.1
+ }
+ }
+ ]
+ },
+ {
+ "id": 14,
+ "name": "Hill",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": -290,
+ "y": -244,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 6,
+ "y": 6
+ },
+ "color": {
+ "r": 0,
+ "g": 0,
+ "b": 0,
+ "a": 0
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 0
+ }
+ },
+ {
+ "type": "ChainCollider2D",
+ "data": {
+ "isLoop": false,
+ "friction": 0.6,
+ "points": [
+ {
+ "x": -1.1,
+ "y": 0
+ },
+ {
+ "x": -0.5,
+ "y": 0.35
+ },
+ {
+ "x": 0.1,
+ "y": 0.1
+ },
+ {
+ "x": 0.7,
+ "y": 0.45
+ },
+ {
+ "x": 1.2,
+ "y": 0.05
+ }
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "id": 15,
+ "name": "WeldA",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 300,
+ "y": 180,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 44,
+ "y": 44
+ },
+ "color": {
+ "r": 0.93,
+ "g": 0.42,
+ "b": 0.55,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 2,
+ "linearDamping": 0.05
+ }
+ },
+ {
+ "type": "BoxCollider2D",
+ "data": {
+ "halfExtents": {
+ "x": 0.22,
+ "y": 0.22
+ },
+ "friction": 0.4
+ }
+ }
+ ]
+ },
+ {
+ "id": 16,
+ "name": "WeldB",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 348,
+ "y": 180,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 44,
+ "y": 44
+ },
+ "color": {
+ "r": 0.35,
+ "g": 0.82,
+ "b": 0.62,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 2,
+ "linearDamping": 0.05
+ }
+ },
+ {
+ "type": "BoxCollider2D",
+ "data": {
+ "halfExtents": {
+ "x": 0.22,
+ "y": 0.22
+ },
+ "friction": 0.4
+ }
+ },
+ {
+ "type": "FixedJoint2D",
+ "data": {
+ "connectedEntity": 15,
+ "anchorA": {
+ "x": 48,
+ "y": 0
+ },
+ "anchorB": {
+ "x": 0,
+ "y": 0
+ }
+ }
+ }
+ ]
+ },
+ {
+ "id": 17,
+ "name": "Wedge",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 190,
+ "y": -248,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 6,
+ "y": 6
+ },
+ "color": {
+ "r": 0,
+ "g": 0,
+ "b": 0,
+ "a": 0
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 0
+ }
+ },
+ {
+ "type": "PolygonCollider2D",
+ "data": {
+ "friction": 0.5,
+ "vertices": [
+ {
+ "x": -0.9,
+ "y": 0
+ },
+ {
+ "x": 0.9,
+ "y": 0
+ },
+ {
+ "x": -0.9,
+ "y": 0.7
+ }
+ ]
+ }
+ }
+ ]
+ },
+ {
+ "id": 18,
+ "name": "CartBody",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 345,
+ "y": -216,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 80,
+ "y": 20
+ },
+ "color": {
+ "r": 0.95,
+ "g": 0.72,
+ "b": 0.25,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 2,
+ "linearDamping": 0.02,
+ "angularDamping": 0.02
+ }
+ },
+ {
+ "type": "BoxCollider2D",
+ "data": {
+ "halfExtents": {
+ "x": 0.4,
+ "y": 0.1
+ },
+ "friction": 0.3
+ }
+ }
+ ]
+ },
+ {
+ "id": 19,
+ "name": "CartWheelFront",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 375,
+ "y": -236,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 28,
+ "y": 28
+ },
+ "color": {
+ "r": 0.42,
+ "g": 0.45,
+ "b": 0.52,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 2,
+ "linearDamping": 0.02,
+ "angularDamping": 0.02
+ }
+ },
+ {
+ "type": "CircleCollider2D",
+ "data": {
+ "radius": 0.14,
+ "friction": 0.9
+ }
+ },
+ {
+ "type": "WheelJoint2D",
+ "data": {
+ "connectedEntity": 18,
+ "anchorA": {
+ "x": 30,
+ "y": -20
+ },
+ "anchorB": {
+ "x": 0,
+ "y": 0
+ },
+ "axis": {
+ "x": 0,
+ "y": 1
+ },
+ "enableSpring": true,
+ "hertz": 6,
+ "dampingRatio": 0.8,
+ "enableMotor": true,
+ "motorSpeed": 7,
+ "maxMotorTorque": 60
+ }
+ }
+ ]
+ },
+ {
+ "id": 20,
+ "name": "CartWheelRear",
+ "parent": null,
+ "children": [],
+ "visible": true,
+ "components": [
+ {
+ "type": "Transform",
+ "data": {
+ "position": {
+ "x": 315,
+ "y": -236,
+ "z": 0
+ }
+ }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": {
+ "x": 28,
+ "y": 28
+ },
+ "color": {
+ "r": 0.42,
+ "g": 0.45,
+ "b": 0.52,
+ "a": 1
+ }
+ }
+ },
+ {
+ "type": "RigidBody2D",
+ "data": {
+ "bodyType": 2,
+ "linearDamping": 0.02,
+ "angularDamping": 0.02
+ }
+ },
+ {
+ "type": "CircleCollider2D",
+ "data": {
+ "radius": 0.14,
+ "friction": 0.9
+ }
+ },
+ {
+ "type": "WheelJoint2D",
+ "data": {
+ "connectedEntity": 18,
+ "anchorA": {
+ "x": -30,
+ "y": -20
+ },
+ "anchorB": {
+ "x": 0,
+ "y": 0
+ },
+ "axis": {
+ "x": 0,
+ "y": 1
+ },
+ "enableSpring": true,
+ "hertz": 6,
+ "dampingRatio": 0.8,
+ "enableMotor": true,
+ "motorSpeed": 7,
+ "maxMotorTorque": 60
+ }
+ }
+ ]
}
]
}
diff --git a/sdk/src/physics/PhysicsComponents.ts b/sdk/src/physics/PhysicsComponents.ts
index e8b65f93b..8cdb651dd 100644
--- a/sdk/src/physics/PhysicsComponents.ts
+++ b/sdk/src/physics/PhysicsComponents.ts
@@ -258,6 +258,14 @@ export const OneWayPlatform2D = defineComponent<OneWayPlatform2DData>('OneWayPla
// Joint Components
// =============================================================================
+// The joint's OWN entity is body B; `connectedEntity` is body A. So an axis or a
+// limit "from A" is measured from the body the joint points at, and two zero
+// anchors pin both centres to one point rather than keeping their offset.
+const JOINT_ANCHORS = {
+ anchorA: { tooltip: 'Where the joint attaches on the connected body, in that body\'s frame (pixels).' },
+ anchorB: { tooltip: 'Where it attaches on this entity, in its own frame (pixels).' },
+} as const;
+
export interface HingeJoint2DData {
connectedEntity: number;
anchorA: Vec2;
@@ -284,7 +292,11 @@ export const HingeJoint2D = defineComponent<HingeJoint2DData>('HingeJoint2D', {
upperAngle: 0,
collideConnected: false,
enabled: true,
-}, { entityFields: ['connectedEntity'] });
+}, {
+ entityFields: ['connectedEntity'],
+ fields: { ...JOINT_ANCHORS,
+ },
+});
export interface DistanceJoint2DData {
connectedEntity: number;
@@ -320,7 +332,11 @@ export const DistanceJoint2D = defineComponent<DistanceJoint2DData>('DistanceJoi
motorSpeed: 0,
collideConnected: false,
enabled: true,
-}, { entityFields: ['connectedEntity'] });
+}, {
+ entityFields: ['connectedEntity'],
+ fields: { ...JOINT_ANCHORS,
+ },
+});
export interface SliderJoint2DData {
connectedEntity: number;
@@ -356,7 +372,12 @@ export const SliderJoint2D = defineComponent<SliderJoint2DData>('SliderJoint2D',
motorSpeed: 0,
collideConnected: false,
enabled: true,
-}, { entityFields: ['connectedEntity'] });
+}, {
+ entityFields: ['connectedEntity'],
+ fields: { ...JOINT_ANCHORS,
+ axis: { tooltip: 'Direction of travel, in the connected body\'s frame.' },
+ },
+});
export interface FixedJoint2DData {
connectedEntity: number;
@@ -380,7 +401,11 @@ export const FixedJoint2D = defineComponent<FixedJoint2DData>('FixedJoint2D', {
angularDampingRatio: 1,
collideConnected: false,
enabled: true,
-}, { entityFields: ['connectedEntity'] });
+}, {
+ entityFields: ['connectedEntity'],
+ fields: { ...JOINT_ANCHORS,
+ },
+});
export interface WheelJoint2DData {
connectedEntity: number;
@@ -416,7 +441,12 @@ export const WheelJoint2D = defineComponent<WheelJoint2DData>('WheelJoint2D', {
motorSpeed: 0,
collideConnected: false,
enabled: true,
-}, { entityFields: ['connectedEntity'] });
+}, {
+ entityFields: ['connectedEntity'],
+ fields: { ...JOINT_ANCHORS,
+ axis: { tooltip: 'Direction of travel, in the connected body\'s frame.' },
+ },
+});
export interface MotorJoint2DData {
connectedEntity: number;
diff --git a/sdk/src/physics3d/Physics3DJoints.ts b/sdk/src/physics3d/Physics3DJoints.ts
index 99f04ca29..dc61bf2ac 100644
--- a/sdk/src/physics3d/Physics3DJoints.ts
+++ b/sdk/src/physics3d/Physics3DJoints.ts
@@ -38,7 +38,10 @@ export const PointJoint3D = defineComponent<PointJoint3DData>('PointJoint3D', {
anchor: { x: 0, y: 0, z: 0 },
collideConnected: false,
enabled: true,
-}, { entityFields: ['connectedEntity'] });
+}, {
+ entityFields: ['connectedEntity'],
+ fields: { anchor: { tooltip: 'Where the joint attaches, in THIS entity\'s frame (world units).' } },
+});
export interface HingeJoint3DData {
connectedEntity: number;
@@ -75,7 +78,10 @@ export const HingeJoint3D = defineComponent<HingeJoint3DData>('HingeJoint3D', {
collideConnected: false,
enabled: true,
angle: 0,
-}, { entityFields: ['connectedEntity'] });
+}, {
+ entityFields: ['connectedEntity'],
+ fields: { anchor: { tooltip: 'Where the joint attaches, in THIS entity\'s frame (world units).' } },
+});
export interface SliderJoint3DData {
connectedEntity: number;
@@ -113,7 +119,10 @@ export const SliderJoint3D = defineComponent<SliderJoint3DData>('SliderJoint3D',
collideConnected: false,
enabled: true,
translation: 0,
-}, { entityFields: ['connectedEntity'] });
+}, {
+ entityFields: ['connectedEntity'],
+ fields: { anchor: { tooltip: 'Where the joint attaches, in THIS entity\'s frame (world units).' } },
+});
export interface DistanceJoint3DData {
connectedEntity: number;
diff --git a/tools/check-corpus-authoring.mjs b/tools/check-corpus-authoring.mjs
index fd745f772..79ff569b2 100644
--- a/tools/check-corpus-authoring.mjs
+++ b/tools/check-corpus-authoring.mjs
@@ -118,13 +118,6 @@ const DISPOSITION = {
// — owed: a creator-facing component nothing in the shipped corpus authors.
// Each reason names where the coverage belongs. —
- CapsuleCollider2D: ['owed', 'physics-playground and physics-spinner build capsules in code; the Inspector shape and its gizmo have no authored instance'],
- ChainCollider2D: ['owed', 'physics-spinner builds its chain in code — the one 2D shape whose authored form (a point list) the editor actually has an editing mode for'],
- PolygonCollider2D: ['owed', 'no project authors a polygon collider, in code or in a scene'],
- SegmentCollider2D: ['owed', 'no project authors a segment collider, in code or in a scene'],
- DistanceJoint2D: ['owed', 'physics-playground authors Hinge/Motor/Slider and stops there'],
- FixedJoint2D: ['owed', 'same scene, same gap'],
- WheelJoint2D: ['owed', 'a vehicle is the demonstration, and the corpus has no vehicle'],
SortingGroup: ['owed', 'the component that makes a subtree sort as one unit — the fix for every "my character\'s sword draws behind the wrong prop", demonstrated nowhere'],
CacheAsBitmap: ['owed', 'flattening a static subtree into one texture is a performance decision with no example showing when to take it'],