@@ -14,25 +14,44 @@ Bullet physics plugin for Node.js 3D Core
1414
1515![ Example] ( examples/screenshot.jpg )
1616
17+ This plugin provides the ` Shape ` class to simplify the common use cases with Three.js and
18+ Bullet Physics addon.
1719
18- ``` typescript
20+ * Can display debug shapes.
21+ * Updates mesh pose from physics engine.
22+ * Removes meshes when the body is destroyed.
23+ * ` Shape ` extends ` Body ` and works with ` scene.hit()/scene.trace() ` .
24+
25+ ``` ts
1926import * as three from ' three' ;
2027import { init , addThreeHelpers } from ' 3d-core-raub' ;
21- import { init as initBullet } from ' 3d-qml -raub' ;
28+ import { init as initBullet } from ' 3d-bullet -raub' ;
2229
23- // Standard Node3D init
24- const {
25- doc, Image : Img, gl,
26- } = init ({
27- isGles3: true , isWebGL2: true , autoEsc: true ,
28- });
30+ const { gl, loop, Screen } = init ();
2931addThreeHelpers (three , gl );
32+ const { scene, Shape } = initBullet ({ three });
33+
34+ const screen = new Screen ({ three });
35+
36+ const plane = new Shape ({
37+ sceneThree: screen .scene ,
38+ color: 0xface8d ,
39+ type: ' plane' ,
40+ debug: ' solid' ,
41+ });
42+
43+ const box = new Shape ({
44+ sceneThree: screen .scene ,
45+ pos: [0 , 10 , 0 ], // use { xyz } or [xyz]
46+ mass: 3 ,
47+ debug: ' solid' ,
48+ color: 0xbeefed ,
49+ size: { x: 3 , y: 2 , z: 1 }, // use { xyz } or [xyz]
50+ });
3051
31- // Initialize Bullet and fetch the helpers
32- const {
33- Box, Ball, Roll, Caps, Scene, Body, bullet,
34- } = initBullet ({
35- three ,
52+ loop (() => {
53+ scene .update ();
54+ screen .draw ();
3655});
3756```
3857
0 commit comments