@react-three/rapier 1.0.0 → 1.0.1
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/dist/react-three-rapier.cjs.dev.js +17 -10
- package/dist/react-three-rapier.cjs.prod.js +17 -10
- package/dist/react-three-rapier.esm.js +17 -10
- package/package.json +3 -3
- package/readme.md +1 -1
@@ -664,6 +664,14 @@ const createSingletonProxy = createInstance => {
|
|
664
664
|
}
|
665
665
|
|
666
666
|
return Reflect.get(instance, prop);
|
667
|
+
},
|
668
|
+
|
669
|
+
set(target, prop, value) {
|
670
|
+
if (!instance) {
|
671
|
+
instance = createInstance();
|
672
|
+
}
|
673
|
+
|
674
|
+
return Reflect.set(instance, prop, value);
|
667
675
|
}
|
668
676
|
|
669
677
|
};
|
@@ -810,27 +818,26 @@ const Physics = props => {
|
|
810
818
|
* @see https://gafferongames.com/post/fix_your_timestep/
|
811
819
|
*/
|
812
820
|
|
813
|
-
const clampedDelta = three.MathUtils.clamp(dt, 0, 0.
|
821
|
+
const clampedDelta = three.MathUtils.clamp(dt, 0, 0.5);
|
814
822
|
|
815
|
-
const stepWorld =
|
823
|
+
const stepWorld = delta => {
|
816
824
|
// Trigger beforeStep callbacks
|
817
825
|
beforeStepCallbacks.forEach(callback => {
|
818
|
-
callback.current(
|
826
|
+
callback.current(world);
|
819
827
|
});
|
828
|
+
world.timestep = delta;
|
820
829
|
world.step(eventQueue); // Trigger afterStep callbacks
|
821
830
|
|
822
831
|
afterStepCallbacks.forEach(callback => {
|
823
|
-
callback.current(
|
832
|
+
callback.current(world);
|
824
833
|
});
|
825
834
|
};
|
826
835
|
|
827
836
|
if (timeStepVariable) {
|
828
|
-
|
829
|
-
stepWorld();
|
837
|
+
stepWorld(clampedDelta);
|
830
838
|
} else {
|
831
|
-
|
839
|
+
// don't step time forwards if paused
|
832
840
|
// Increase accumulator
|
833
|
-
|
834
841
|
steppingState.accumulator += clampedDelta;
|
835
842
|
|
836
843
|
while (steppingState.accumulator >= timeStep) {
|
@@ -846,7 +853,7 @@ const Physics = props => {
|
|
846
853
|
});
|
847
854
|
}
|
848
855
|
|
849
|
-
stepWorld();
|
856
|
+
stepWorld(timeStep);
|
850
857
|
steppingState.accumulator -= timeStep;
|
851
858
|
}
|
852
859
|
}
|
@@ -1007,7 +1014,7 @@ const Physics = props => {
|
|
1007
1014
|
world.forEachActiveRigidBody(() => {
|
1008
1015
|
invalidate();
|
1009
1016
|
});
|
1010
|
-
}, [paused, timeStep, interpolate]);
|
1017
|
+
}, [paused, timeStep, interpolate, worldProxy]);
|
1011
1018
|
const context = React.useMemo(() => ({
|
1012
1019
|
rapier,
|
1013
1020
|
world: worldProxy,
|
@@ -664,6 +664,14 @@ const createSingletonProxy = createInstance => {
|
|
664
664
|
}
|
665
665
|
|
666
666
|
return Reflect.get(instance, prop);
|
667
|
+
},
|
668
|
+
|
669
|
+
set(target, prop, value) {
|
670
|
+
if (!instance) {
|
671
|
+
instance = createInstance();
|
672
|
+
}
|
673
|
+
|
674
|
+
return Reflect.set(instance, prop, value);
|
667
675
|
}
|
668
676
|
|
669
677
|
};
|
@@ -810,27 +818,26 @@ const Physics = props => {
|
|
810
818
|
* @see https://gafferongames.com/post/fix_your_timestep/
|
811
819
|
*/
|
812
820
|
|
813
|
-
const clampedDelta = three.MathUtils.clamp(dt, 0, 0.
|
821
|
+
const clampedDelta = three.MathUtils.clamp(dt, 0, 0.5);
|
814
822
|
|
815
|
-
const stepWorld =
|
823
|
+
const stepWorld = delta => {
|
816
824
|
// Trigger beforeStep callbacks
|
817
825
|
beforeStepCallbacks.forEach(callback => {
|
818
|
-
callback.current(
|
826
|
+
callback.current(world);
|
819
827
|
});
|
828
|
+
world.timestep = delta;
|
820
829
|
world.step(eventQueue); // Trigger afterStep callbacks
|
821
830
|
|
822
831
|
afterStepCallbacks.forEach(callback => {
|
823
|
-
callback.current(
|
832
|
+
callback.current(world);
|
824
833
|
});
|
825
834
|
};
|
826
835
|
|
827
836
|
if (timeStepVariable) {
|
828
|
-
|
829
|
-
stepWorld();
|
837
|
+
stepWorld(clampedDelta);
|
830
838
|
} else {
|
831
|
-
|
839
|
+
// don't step time forwards if paused
|
832
840
|
// Increase accumulator
|
833
|
-
|
834
841
|
steppingState.accumulator += clampedDelta;
|
835
842
|
|
836
843
|
while (steppingState.accumulator >= timeStep) {
|
@@ -846,7 +853,7 @@ const Physics = props => {
|
|
846
853
|
});
|
847
854
|
}
|
848
855
|
|
849
|
-
stepWorld();
|
856
|
+
stepWorld(timeStep);
|
850
857
|
steppingState.accumulator -= timeStep;
|
851
858
|
}
|
852
859
|
}
|
@@ -1007,7 +1014,7 @@ const Physics = props => {
|
|
1007
1014
|
world.forEachActiveRigidBody(() => {
|
1008
1015
|
invalidate();
|
1009
1016
|
});
|
1010
|
-
}, [paused, timeStep, interpolate]);
|
1017
|
+
}, [paused, timeStep, interpolate, worldProxy]);
|
1011
1018
|
const context = React.useMemo(() => ({
|
1012
1019
|
rapier,
|
1013
1020
|
world: worldProxy,
|
@@ -639,6 +639,14 @@ const createSingletonProxy = createInstance => {
|
|
639
639
|
}
|
640
640
|
|
641
641
|
return Reflect.get(instance, prop);
|
642
|
+
},
|
643
|
+
|
644
|
+
set(target, prop, value) {
|
645
|
+
if (!instance) {
|
646
|
+
instance = createInstance();
|
647
|
+
}
|
648
|
+
|
649
|
+
return Reflect.set(instance, prop, value);
|
642
650
|
}
|
643
651
|
|
644
652
|
};
|
@@ -785,27 +793,26 @@ const Physics = props => {
|
|
785
793
|
* @see https://gafferongames.com/post/fix_your_timestep/
|
786
794
|
*/
|
787
795
|
|
788
|
-
const clampedDelta = MathUtils.clamp(dt, 0, 0.
|
796
|
+
const clampedDelta = MathUtils.clamp(dt, 0, 0.5);
|
789
797
|
|
790
|
-
const stepWorld =
|
798
|
+
const stepWorld = delta => {
|
791
799
|
// Trigger beforeStep callbacks
|
792
800
|
beforeStepCallbacks.forEach(callback => {
|
793
|
-
callback.current(
|
801
|
+
callback.current(world);
|
794
802
|
});
|
803
|
+
world.timestep = delta;
|
795
804
|
world.step(eventQueue); // Trigger afterStep callbacks
|
796
805
|
|
797
806
|
afterStepCallbacks.forEach(callback => {
|
798
|
-
callback.current(
|
807
|
+
callback.current(world);
|
799
808
|
});
|
800
809
|
};
|
801
810
|
|
802
811
|
if (timeStepVariable) {
|
803
|
-
|
804
|
-
stepWorld();
|
812
|
+
stepWorld(clampedDelta);
|
805
813
|
} else {
|
806
|
-
|
814
|
+
// don't step time forwards if paused
|
807
815
|
// Increase accumulator
|
808
|
-
|
809
816
|
steppingState.accumulator += clampedDelta;
|
810
817
|
|
811
818
|
while (steppingState.accumulator >= timeStep) {
|
@@ -821,7 +828,7 @@ const Physics = props => {
|
|
821
828
|
});
|
822
829
|
}
|
823
830
|
|
824
|
-
stepWorld();
|
831
|
+
stepWorld(timeStep);
|
825
832
|
steppingState.accumulator -= timeStep;
|
826
833
|
}
|
827
834
|
}
|
@@ -982,7 +989,7 @@ const Physics = props => {
|
|
982
989
|
world.forEachActiveRigidBody(() => {
|
983
990
|
invalidate();
|
984
991
|
});
|
985
|
-
}, [paused, timeStep, interpolate]);
|
992
|
+
}, [paused, timeStep, interpolate, worldProxy]);
|
986
993
|
const context = useMemo(() => ({
|
987
994
|
rapier,
|
988
995
|
world: worldProxy,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@react-three/rapier",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.1",
|
4
4
|
"source": "src/index.ts",
|
5
5
|
"main": "dist/react-three-rapier.cjs.js",
|
6
6
|
"module": "dist/react-three-rapier.esm.js",
|
@@ -17,11 +17,11 @@
|
|
17
17
|
"@types/three": "0.139.0",
|
18
18
|
"@vitejs/plugin-react": "^2.1.0",
|
19
19
|
"@vitest/ui": "0.29.7",
|
20
|
-
"happy-dom": "
|
20
|
+
"happy-dom": "9.19.2",
|
21
21
|
"react": "18.2.0",
|
22
22
|
"react-dom": "18.2.0",
|
23
23
|
"three": "0.146.0",
|
24
|
-
"vitest": "0.
|
24
|
+
"vitest": "0.31.1"
|
25
25
|
},
|
26
26
|
"peerDependencies": {
|
27
27
|
"@react-three/fiber": ">=8.9.0",
|
package/readme.md
CHANGED
@@ -27,7 +27,7 @@ The goal of this library to is to provide a fast physics engine with minimal fri
|
|
27
27
|
```tsx
|
28
28
|
import { Box, Torus } from "@react-three/drei";
|
29
29
|
import { Canvas } from "@react-three/fiber";
|
30
|
-
import { Physics, RigidBody,
|
30
|
+
import { Physics, RigidBody, CuboidCollider } from "@react-three/rapier";
|
31
31
|
|
32
32
|
const App = () => {
|
33
33
|
return (
|