threejs-cannones-rigger 1.0.1 → 1.0.3

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/LICENSE CHANGED
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,44 +1,44 @@
1
1
  {
2
- "name": "threejs-cannones-rigger",
3
- "author": {
4
- "name": "pablo bandinopla",
5
- "url": "https://github.com/bandinopla"
6
- },
7
- "description": "Create and position physics colliders in Blender then export them as GLB and load them automatically in ThreeJs with Cannon-es.",
8
- "version": "1.0.1",
9
- "type": "module",
10
- "packageManager": "pnpm@8.15.4",
11
- "files": [
12
- "dist"
13
- ],
14
- "main": "./dist/threejs-cannones-rigger.cjs",
15
- "module": "./dist/threejs-cannones-rigger.js",
16
- "types": "./dist/threejs-cannones-rigger.d.ts",
17
- "exports": {
18
- ".": {
19
- "import": "./dist/threejs-cannones-rigger.js",
20
- "require": "./dist/threejs-cannones-rigger.cjs"
21
- }
22
- },
23
- "scripts": {
24
- "dev": "vite --config vite.config.site.js",
25
- "build": "tsc && vite build",
26
- "build-test-app": "vite build --config vite.config.site.js",
27
- "preview": "vite preview --config vite.config.site.js"
28
- },
29
- "devDependencies": {
30
- "@types/three": "^0.178.1",
31
- "cannon-es": "^0.20.0",
32
- "cannon-es-debugger": "^1.0.0",
33
- "three": "^0.179.0",
34
- "threejs-cannones-tube": "^0.0.9",
35
- "typescript": "~5.8.3",
36
- "vite": "^7.0.4",
37
- "vite-plugin-dts": "^4.5.4"
38
- },
39
- "peerDependencies": {
40
- "cannon-es": ">=0.20.0 <1.0.0",
41
- "three": ">=0.178.0 <1.0.0",
42
- "threejs-cannones-tube": ">=0.0.7 <1.0.0"
2
+ "name": "threejs-cannones-rigger",
3
+ "author": {
4
+ "name": "pablo bandinopla",
5
+ "url": "https://github.com/bandinopla"
6
+ },
7
+ "description": "Create and position physics colliders in Blender then export them as GLB and load them automatically in ThreeJs with Cannon-es.",
8
+ "version": "1.0.3",
9
+ "type": "module",
10
+ "packageManager": "pnpm@8.15.4",
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "main": "./dist/threejs-cannones-rigger.cjs",
15
+ "module": "./dist/threejs-cannones-rigger.js",
16
+ "types": "./dist/threejs-cannones-rigger.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "import": "./dist/threejs-cannones-rigger.js",
20
+ "require": "./dist/threejs-cannones-rigger.cjs"
43
21
  }
44
- }
22
+ },
23
+ "devDependencies": {
24
+ "@types/three": "^0.178.1",
25
+ "cannon-es": "^0.20.0",
26
+ "cannon-es-debugger": "^1.0.0",
27
+ "three": "^0.179.0",
28
+ "threejs-cannones-tube": "^0.0.9",
29
+ "typescript": "~5.8.3",
30
+ "vite": "^7.0.4",
31
+ "vite-plugin-dts": "^4.5.4"
32
+ },
33
+ "peerDependencies": {
34
+ "cannon-es": ">=0.20.0 <1.0.0",
35
+ "three": ">=0.178.0 <1.0.0",
36
+ "threejs-cannones-tube": ">=0.0.7 <1.0.0"
37
+ },
38
+ "scripts": {
39
+ "dev": "vite --config vite.config.site.js",
40
+ "build": "tsc && vite build",
41
+ "build-test-app": "vite build --config vite.config.site.js",
42
+ "preview": "vite preview --config vite.config.site.js"
43
+ }
44
+ }
package/readme.md CHANGED
@@ -5,12 +5,27 @@
5
5
 
6
6
  ![cover](https://raw.githubusercontent.com/bandinopla/threejs-cannones-rigger/refs/heads/main/cover.png)
7
7
 
8
+
9
+ ## Table of Contents
10
+ - [Who is this for?](#who-is-this-for)
11
+ - [Features](#features)
12
+ - [Test your rig](#test-your-rig)
13
+ - [Usage](#usage)
14
+ - [API](#api)
15
+ - [Colliders / Bodies](#colliders--bodies)
16
+ - [Constraints](#constraints)
17
+ - [Relationship Lines](#relationship-lines)
18
+ - [Collision groups and masks](#collision-groups-and-masks)
19
+ - [Custom constaint](#sparkles-custom-constaint)
20
+ - [License](#license)
21
+
8
22
  # ThreeJs / Cannon-es Scene Rigger
9
23
  ### Design in Blender, simulate in Three!
10
24
 
11
25
  Create and place physics colliders in [Blender](http://blender.org/), export as GLB, and automatically set them up in [three.js](https://threejs.org/) with [cannon-es](https://github.com/pmndrs/cannon-es).
12
26
 
13
- Watch a use case: [Video Tutorial (Rigging a mechanical claw)](https://youtu.be/RtO2KUH9Vig)
27
+ Watch [Video Tutorial (Rigging a mechanical claw)](https://youtu.be/RtO2KUH9Vig)
28
+ Demo showcase app that inspired this addon: [Mechanical Claw Machine](https://threejs-claw-machine.vercel.app/)
14
29
 
15
30
  This solution includes two tools:
16
31
 
@@ -18,6 +33,9 @@ This solution includes two tools:
18
33
  2) An NPM package to rig the physics in Three.js using cannon-es
19
34
 
20
35
 
36
+ ## Who is this for?
37
+ Manually building complex physical rigs vía code can be a headache in the making. This toolset aims to make it a smooth visual experience. Focus on the design aspect in Blender, and let the devs work on the details once the rig is exported. Separate concerns.
38
+
21
39
  ## Features
22
40
 
23
41
  - Automatically creates Cannon bodies for Three.js objects defined inside of Blender ( _using the addon_ ).
@@ -39,8 +57,11 @@ Just make sure your glb has a camera and it is in the right angle where you want
39
57
  ## Usage
40
58
 
41
59
  ### 1) Install the blender addon
42
- Blender PreferencesAdd-ons → Install → select `threejs-cannones-addon.py`
43
- > Blender addon : [threejs-cannones-addon.py](https://github.com/bandinopla/threejs-cannones-rigger/raw/refs/heads/main/threejs-cannones-addon.py)
60
+ Install from disk[threejs-cannones-addon.py](https://github.com/bandinopla/threejs-cannones-rigger/raw/refs/heads/main/threejs-cannones-addon.py)
61
+
62
+ | Blender → Preferences | Add-ons → Install (.py) | New Object Panel |
63
+ |---------|---------|---------|
64
+ | ![Step 1](https://raw.githubusercontent.com/bandinopla/threejs-cannones-rigger/refs/heads/main/imgs/install-1.jpg) | ![Step 2](https://raw.githubusercontent.com/bandinopla/threejs-cannones-rigger/refs/heads/main/imgs/install-2.jpg) | ![Step 3](https://raw.githubusercontent.com/bandinopla/threejs-cannones-rigger/refs/heads/main/imgs/install-3.jpg) |
44
65
 
45
66
  After installing, when you select an object in the scene inside of blender, you should see new expandable box appear in the Object's tab.
46
67
 
@@ -102,8 +123,8 @@ constructor(world: World, scene?: Object3D)
102
123
  - `getBodyByName(name: string)`: Returns a Cannon body by the name (the name in `userData.name` )
103
124
 
104
125
  ---
105
- # Constraints
106
- In all cases, when you call `get___Constraint( name )` the expected name is the name of the object as you read it in blender. Which is automatically put in `userData.name` when you export to glb.
126
+ # Colliders / Bodies
127
+ ![Colliders](https://raw.githubusercontent.com/bandinopla/threejs-cannones-rigger/refs/heads/main/imgs/colliders.jpg)
107
128
 
108
129
  #### Box / Sphere Collider
109
130
  > Use a default Cube or UV Sphere. Scale and rotate as needed. Only spheres must be scaled uniformly; boxes can be stretched freely.
@@ -112,7 +133,22 @@ rigger.getBodyByName(name) //-> CANNON.Body
112
133
  ```
113
134
 
114
135
  #### Compound Collider
115
- > Assign this to an empty. All children will be glued into one collider/Body.
136
+ Assign this to an empty. All children will be glued into one collider/Body. The children **should be empty boxes** with your desire scale, rotation and positioning.
137
+
138
+ #### Tube / Cable
139
+ >Creates a flexible cable using [threejs-cannones-tube](https://www.npmjs.com/package/threejs-cannones-tube).
140
+ Add two child empties to the constraint object — one for the head, one for the tail. A and B can optionally anchor the ends.
141
+
142
+ **Material** : If the constraint body is a mesh (like a Box) it will use whatever material that mesh has and assign it to the mesh of the tube.
143
+ ```js
144
+ rigger.getCableConstraint(name) //-> CableConstraint
145
+ rigger.getCableConstraint(name).cable //-> CannonTubeRig
146
+ ```
147
+
148
+ # Constraints
149
+ ![Constraints](https://raw.githubusercontent.com/bandinopla/threejs-cannones-rigger/refs/heads/main/imgs/constraints.jpg)
150
+
151
+ In all cases, when you call `get___Constraint( name )` the expected name is the name of the object as you read it in blender. Which is automatically put in `userData.name` when you export to glb.
116
152
 
117
153
  #### Glue/Lock Colliders
118
154
  > Connect two colliders (A & B) so they behave as a single rigid body. Creates a LockConstraint...
@@ -142,17 +178,27 @@ rigger.getDistanceConstraint(name) //-> CANNON.DistanceConstraint
142
178
  > Use this on a visible object (e.g. mesh) to match the position & rotation of a physics collider.
143
179
  ```js
144
180
  rigger.getSyncConstraint(name) //-> SyncConstraint
145
- ```
181
+ ```
146
182
 
147
- #### Tube / Cable
148
- >Creates a flexible cable using [threejs-cannones-tube](https://www.npmjs.com/package/threejs-cannones-tube).
149
- Add two child empties to the constraint object one for the head, one for the tail. A and B can optionally anchor the ends.
183
+ # Relationship Lines
184
+ ![Colliders](https://raw.githubusercontent.com/bandinopla/threejs-cannones-rigger/refs/heads/main/imgs/lines.jpg)
185
+ When a contraints references other objects, lines will appear to easily see their relationships with the currently selected object. You can toogle thouse lines on and off using the "Show Overlays" button.
150
186
 
151
- **Material** : If the constraint body is a mesh (like a Box) it will use whatever material that mesh has and assign it to the mesh of the tube.
152
- ```js
153
- rigger.getCableConstraint(name) //-> CableConstraint
154
- rigger.getCableConstraint(name).cable //-> CannonTubeRig
155
- ```
187
+ # Collision groups and masks
188
+ The panel will show two key properties for physics-based collision management when you select a collider's body type. You can select 1 or many (clicking and holding SHIFT)
189
+ >
190
+
191
+ ![Bitmasks](https://raw.githubusercontent.com/bandinopla/threejs-cannones-rigger/refs/heads/main/imgs/bitmask.jpg)
192
+
193
+ - **Collision Group `collisionGroup`**: "I'm in group...". Bitmask. Defines which group(s) the selected object belongs to. This is a single group index (0–31) that identifies the object's collision category.
194
+ - **Collision Mask `collisionMask`**: "I collide with...".Bitmask. Specifies which group(s) the object collides with, using a 32-bit boolean array (checkboxes). Each checkbox corresponds to one of the 32 possible collision groups.
195
+
196
+ ### Understanding Collision Group and Mask
197
+ - **Collision Group**: Sets which group your object belongs to (0–31). Think of it as the object’s "team" in the physics simulation.
198
+ - **Collision Mask**: Controls which groups your object can collide with. Check boxes (1–32) to choose which "teams" it interacts with. For example, checking Group 2 means it collides with objects in Group 2.
199
+
200
+ > #### When Collisions Don’t Happen
201
+ > A collision between two objects won’t occur if their **Collision Masks** don’t include each other’s **Collision Group**. For example, if Object A’s mask doesn’t check Group 2, and Object B is in Group 2, they won’t collide, even if they touch in the physics simulation.
156
202
 
157
203
  # :sparkles: Custom constaint
158
204
  In blender you can select "**Custom Constraint**" and pass a custom id (an arbitraty string of your choosing) then in javascript side, you define it like so: