Skip to content

Commit 5a2d9fb

Browse files
committed
fix: correct timestep update
1 parent 8636675 commit 5a2d9fb

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

examples/jsm/physics/RapierPhysics.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,11 @@ export class Physic {
349349
/**
350350
* @description Update the physic world.
351351
*
352-
* @param {number | undefined} delta
352+
* @param {number | undefined} timestep The timestep length, in seconds.
353353
*/
354-
step(delta = undefined) {
355-
this.world.step(delta);
354+
step(timestep = undefined) {
355+
if (typeof timestep === "number") this.world.timestep = timestep;
356+
this.world.step();
356357

357358
for (let i = 0, l = this.dynamicObjects.length; i < l; i++) {
358359
const object = this.dynamicObjects[i];

examples/physics_rapier_instancing.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,11 @@
173173

174174
}
175175

176-
function animate() {
176+
const clock = new THREE.Clock();
177177

178-
physics.step();
178+
function animate() {
179+
180+
physics.step( clock.getDelta() );
179181

180182
controls.update();
181183

0 commit comments

Comments
 (0)