Enable fixed physics update to prevent issues with low frame rates
This commit is contained in:
parent
a8b61f0223
commit
629a4ad7eb
@ -40,7 +40,10 @@ function DiceInteraction({ onSceneMount, onPointerDown, onPointerUp }) {
|
|||||||
const scene = new Scene(engine);
|
const scene = new Scene(engine);
|
||||||
scene.clearColor = new Color4(0, 0, 0, 0);
|
scene.clearColor = new Color4(0, 0, 0, 0);
|
||||||
// Enable physics
|
// Enable physics
|
||||||
scene.enablePhysics(new Vector3(0, -98, 0), new AmmoJSPlugin(true, AMMO));
|
scene.enablePhysics(
|
||||||
|
new Vector3(0, -98, 0),
|
||||||
|
new AmmoJSPlugin(false, AMMO)
|
||||||
|
);
|
||||||
|
|
||||||
let camera = new TargetCamera("camera", new Vector3(0, 33.5, 0), scene);
|
let camera = new TargetCamera("camera", new Vector3(0, 33.5, 0), scene);
|
||||||
camera.fov = 0.65;
|
camera.fov = 0.65;
|
||||||
@ -67,13 +70,14 @@ function DiceInteraction({ onSceneMount, onPointerDown, onPointerUp }) {
|
|||||||
const delta = newPosition.subtract(currentPosition);
|
const delta = newPosition.subtract(currentPosition);
|
||||||
selectedMesh.setAbsolutePosition(newPosition);
|
selectedMesh.setAbsolutePosition(newPosition);
|
||||||
const velocity = delta.scale(1000 / scene.deltaTime);
|
const velocity = delta.scale(1000 / scene.deltaTime);
|
||||||
selectedMeshVelocityWindowRef.current = selectedMeshVelocityWindowRef.current.slice(
|
selectedMeshVelocityWindowRef.current =
|
||||||
Math.max(
|
selectedMeshVelocityWindowRef.current.slice(
|
||||||
selectedMeshVelocityWindowRef.current.length -
|
Math.max(
|
||||||
selectedMeshVelocityWindowSize,
|
selectedMeshVelocityWindowRef.current.length -
|
||||||
0
|
selectedMeshVelocityWindowSize,
|
||||||
)
|
0
|
||||||
);
|
)
|
||||||
|
);
|
||||||
selectedMeshVelocityWindowRef.current.push(velocity);
|
selectedMeshVelocityWindowRef.current.push(velocity);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user