Skip to content

Commit a1271b4

Browse files
committedFeb 26, 2025·
Add syntax highlighting to all code block
1 parent d484e4b commit a1271b4

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed
 

‎README.md

+11-13
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ The URL for the PhysX wasm module needs to be specified on the `physx` component
1717

1818
You can either download the module from the `dist` directory of this repo and the wasm file from the `wasm` directory and include them like this:
1919

20-
```
20+
```html
2121
<script src="physx.min.js"></script>
2222
<a-scene physx="autoLoad: true; wasmUrl: physx.release.wasm">
2323
```
2424

2525
Or you can download via JSDelivr CDN (specifying the version number you want to use)
2626

27-
```
27+
```html
2828
<script src="https://cdn.jsdelivr.net/gh/c-frame/physx@v0.1.x/dist/physx.min.js"></script>
2929
<a-scene physx="autoLoad: true; wasmUrl: https://cdn.jsdelivr.net/gh/c-frame/physx@v0.1.x/wasm/physx.release.wasm">
3030
```
@@ -33,9 +33,7 @@ Or you can download via JSDelivr CDN (specifying the version number you want to
3333

3434
Install the dependency:
3535

36-
```sh
37-
npm install @c-frame/physx
38-
```
36+
`npm install @c-frame/physx`
3937

4038
In your project import it:
4139

@@ -75,7 +73,7 @@ Implements the a physics system using an emscripten compiled PhysX engine.
7573

7674
If `autoLoad` is `true`, or when you call `startPhysX()`, the `physx` system will automatically load and initialize the physics system with reasonable defaults and a ground plane. All you have to do is add [`physx-body`](#component-physx-body) to the bodies that you want to be part of the simulation. The system will take try to take care of things like collision meshes, position updates, etc automatically. The simplest physics scene looks something like:
7775

78-
```
76+
```html
7977
<a-scene physx="autoLoad: true; wasmUrl: https://cdn.jsdelivr.net/gh/c-frame/physx@v0.1.x/wasm/physx.release.wasm">
8078
<a-assets><a-asset-item id="#mymodel" src="..."></a-asset-item></a-assets>
8179

@@ -89,8 +87,8 @@ If you want a little more control over how things behave, you can set the [`phys
8987

9088
If you need more low-level control, the PhysX bindings are exposed through the `PhysX` property of the system. So for instance, if you wanted to make use of the [`PxCapsuleGeometry`](https://nvidiagameworks.github.io/PhysX/4.1/documentation/physxapi/files/classPxCapsuleGeometry.html) in your own component, you would call:
9189

92-
```
93-
let myGeometry = new this.el.sceneEl.systems.physx.PhysX.PxCapsuleGeometry(1.0, 2.0)
90+
```js
91+
let myGeometry = new this.el.sceneEl.systems.physx.PhysX.PxCapsuleGeometry(1.0, 2.0)
9492
```
9593

9694
The system uses [a fork](https://github.com/c-frame/PhysXSDK) of PhysX, built using the [Docker Wrapper](https://github.com/c-frame/physx-js). To see what's exposed to JavaScript, see [PxWebBindings.cpp](https://github.com/c-frame/PhysXSDK/blob/emscripten_wip/physx/source/physxwebbindings/src/PxWebBindings.cpp)
@@ -117,7 +115,7 @@ It is also helpful to refer to the [NVIDIA PhysX documentation](https://nvidiaga
117115

118116
| Signature | Description |
119117
| --------------- | ------------------------------------- |
120-
| startPhysX `()` | Loads PhysX and starts the simulation |
118+
| startPhysX() | Loads PhysX and starts the simulation |
121119

122120
------
123121

@@ -129,7 +127,7 @@ Controls physics properties for individual shapes or rigid bodies. You can set t
129127

130128
For instance, in the following scene fragment:
131129

132-
```
130+
```html
133131
<a-entity id="bodyA" physx-body physx-material="staticFriction: 0.5">
134132
<a-box id="shape1" physx-material="staticFriction: 1.0"></a-box>
135133
<a-sphere id="shape2"></a-sphere>
@@ -175,7 +173,7 @@ When the component is initialized, and on the `object3dset` event, all visible m
175173

176174
Visible meshes can be excluded from this shape generation process by setting the `physx-no-collision` attribute on the corresponding `a-entity` element. Invisible meshes can be included into this shape generation process by settingt the `physx-hidden-collision` attribute on the corresponding `a-entity` element. This can be especially useful when using an external tool (like [Blender V-HACD](https://github.com/andyp123/blender_vhacd)) to create a low-poly convex collision mesh for a high-poly or concave mesh. This leads to this pattern for such cases:
177175

178-
```
176+
```html
179177
<a-entity physx-body="type: dynamic">
180178
<a-entity gltf-model="HighPolyOrConcaveURL.gltf" physx-no-collision=""></a-entity>
181179
<a-entity gltf-model="LowPolyConvexURL.gltf" physx-hidden-collision="" visible="false"></a-entity>
@@ -212,7 +210,7 @@ Creates a driver which exerts force to return the joint to the specified (curren
212210

213211
This can only be used on an entity with a `physx-joint` component. Currently only supports **D6** joint type. E.g.
214212

215-
```
213+
```html
216214
<a-box physx-body>
217215
<a-entity position="0.2 0.3 0.4" rotation="0 90 0"
218216
physx-joint="type: D6; target: #other-body"
@@ -353,7 +351,7 @@ The position and rotation of the `physx-joint` will be used to create the corres
353351

354352
Here's a simplified version of the stapler from the [physics playground demo]()
355353

356-
```
354+
```html
357355
<a-entity id="stapler">
358356
<a-entity id="stapler-top" physx-body="type: dynamic" class="grab-root">
359357
<a-entity class="clickable" propogate-grab="" gltf-part-plus="src: #asset-stapler; part: Top"></a-entity>

0 commit comments

Comments
 (0)
Please sign in to comment.