Skip to content

Commit 0b6265b

Browse files
authored
Merge pull request #131 from musehq/dev
v2.5.2
2 parents c83f794 + d22939e commit 0b6265b

File tree

5 files changed

+30
-44
lines changed

5 files changed

+30
-44
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "spacesvr",
3-
"version": "2.5.1",
3+
"version": "2.5.2",
44
"private": true,
55
"description": "A standardized reality for future of the 3D Web",
66
"keywords": [
@@ -58,7 +58,7 @@
5858
"@geckos.io/snapshot-interpolation": "^1.1.0",
5959
"@juggle/resize-observer": "^3.2.0",
6060
"@react-spring/three": "^9.4.5",
61-
"@react-three/cannon": "^6.4.0",
61+
"@react-three/cannon": "^6.5.0",
6262
"@react-three/drei": "9.11.3",
6363
"@react-three/fiber": "^8.0.22",
6464
"@react-three/xr": "^4.0.1",

src/layers/Environment/ui/PauseMenu/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default function PauseMenu(props: PauseMenuProps) {
4848
const PAUSE_ITEMS: PauseItem[] = [
4949
...pauseMenuItems,
5050
{
51-
text: "v2.5.1",
51+
text: "v2.5.2",
5252
link: "https://www.npmjs.com/package/spacesvr",
5353
},
5454
...menuItems,

src/layers/Player/colliders/CapsuleCollider.tsx

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,15 @@ import { Group } from "three";
66
// height of 0.9 (eye level) for a perceived height of 1
77
const HEIGHT = 0.9;
88
const RADIUS = 0.2;
9-
const SEGMENTS = 12;
9+
const SEGMENTS = 10;
1010

1111
const SPHERE_SHAPE: ShapeType = "Sphere";
12-
const CYLINDER_SHAPE: ShapeType = "Cylinder";
1312

1413
const sphereProps = { type: SPHERE_SHAPE, args: [RADIUS, SEGMENTS, SEGMENTS] };
15-
const cylinderProps = {
16-
type: CYLINDER_SHAPE,
17-
args: [RADIUS, RADIUS, HEIGHT - RADIUS * 2, SEGMENTS],
18-
};
1914

20-
const sphere1 = { ...sphereProps, position: [0, -(HEIGHT - RADIUS), 0] };
21-
const cylinder = { ...cylinderProps, position: [0, -(HEIGHT / 2), 0] };
22-
const sphere2 = { ...sphereProps, position: [0, -RADIUS, 0] };
15+
const topSphere = { ...sphereProps, position: [0, -RADIUS, 0] };
16+
const middleSphere = { ...sphereProps, position: [0, -(HEIGHT / 2), 0] };
17+
const bottomSphere = { ...sphereProps, position: [0, -(HEIGHT - RADIUS), 0] };
2318

2419
export const useCapsuleCollider = (pos = [0, 0, 0]) => {
2520
const vPos = useRef(pos as Triplet);
@@ -33,7 +28,7 @@ export const useCapsuleCollider = (pos = [0, 0, 0]) => {
3328
segments: SEGMENTS,
3429
fixedRotation: true,
3530
type: "Dynamic",
36-
shapes: [sphere1, cylinder, sphere2],
31+
shapes: [topSphere, middleSphere, bottomSphere],
3732
}),
3833
undefined,
3934
[]
@@ -54,18 +49,11 @@ export function VisibleCapsuleCollider() {
5449
</mesh>
5550
);
5651

57-
const createCylinder = (cylinder: any) => (
58-
<mesh position={cylinder.position}>
59-
<cylinderBufferGeometry args={cylinder.args} />
60-
<meshStandardMaterial color="blue" wireframe={true} />
61-
</mesh>
62-
);
63-
6452
return (
6553
<group name="collider" position={[1.5, -HEIGHT, 0]}>
66-
{createSphere(sphere1)}
67-
{createCylinder(cylinder)}
68-
{createSphere(sphere2)}
54+
{createSphere(topSphere)}
55+
{createSphere(middleSphere)}
56+
{createSphere(bottomSphere)}
6957
</group>
7058
);
7159
}

src/layers/Player/index.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,17 @@ export function Player(props: PlayerLayer) {
7979
);
8080
}, []);
8181

82-
// due to use-cannon bugs, we have to manually check for the active subscription
83-
const activeSubId = useRef<number>();
8482
useEffect(() => {
85-
const subId = Math.random();
86-
activeSubId.current = subId;
87-
bodyApi.position.subscribe((p) => {
88-
if (activeSubId.current !== subId) return;
89-
position.current.fromArray(p);
90-
});
91-
bodyApi.velocity.subscribe((v) => {
92-
if (activeSubId.current !== subId) return;
93-
velocity.current.fromArray(v);
94-
});
83+
const unsubPos = bodyApi.position.subscribe((p) =>
84+
position.current.fromArray(p)
85+
);
86+
const unsubVel = bodyApi.velocity.subscribe((v) =>
87+
velocity.current.fromArray(v)
88+
);
89+
return () => {
90+
unsubPos();
91+
unsubVel();
92+
};
9593
}, [bodyApi, bodyApi.position, bodyApi.velocity]);
9694

9795
useFrame(() => {

yarn.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,10 +1235,10 @@
12351235
"@nodelib/fs.scandir" "2.1.5"
12361236
fastq "^1.6.0"
12371237

1238-
"@pmndrs/cannon-worker-api@^2.1.0":
1239-
version "2.1.0"
1240-
resolved "https://registry.yarnpkg.com/@pmndrs/cannon-worker-api/-/cannon-worker-api-2.1.0.tgz#c4650a59a9f4e919157c85a0dfcd37894dd2b31f"
1241-
integrity sha512-sXqDYEWfY99LYwnHcr3nPeTSqkXii2MBFG2O2Yv/+PIy63tiBJz5CIijkPr1+dmLV2YGSQjSzQFcaTNFMcOcRA==
1238+
"@pmndrs/cannon-worker-api@^2.3.0":
1239+
version "2.3.0"
1240+
resolved "https://registry.yarnpkg.com/@pmndrs/cannon-worker-api/-/cannon-worker-api-2.3.0.tgz#5ef133833ef858a264d95fc70106ca567f113475"
1241+
integrity sha512-XFR/IABU6uIEllocfGBV9SVakQWIYrZq/Ijk2ZYTv2jYorDebvT4cW8GWIE6UO/T/NChpI+fBTGlUs6wwZW5sg==
12421242

12431243
"@react-spring/animated@~9.4.5":
12441244
version "9.4.5"
@@ -1286,12 +1286,12 @@
12861286
resolved "https://registry.yarnpkg.com/@react-spring/types/-/types-9.4.5.tgz#9c71e5ff866b5484a7ef3db822bf6c10e77bdd8c"
12871287
integrity sha512-mpRIamoHwql0ogxEUh9yr4TP0xU5CWyZxVQeccGkHHF8kPMErtDXJlxyo0lj+telRF35XNihtPTWoflqtyARmg==
12881288

1289-
"@react-three/cannon@^6.4.0":
1290-
version "6.4.0"
1291-
resolved "https://registry.yarnpkg.com/@react-three/cannon/-/cannon-6.4.0.tgz#89aee95752c0f02caac04fa97675ccec59bd9b61"
1292-
integrity sha512-hrT7ploQOCKyP/vVSm9RWN2r2WPxjpTHDNnkxzwa/doK3IyREJ+40Ghor7E7pf76sjRgJFBrypVUSpKDcescTA==
1289+
"@react-three/cannon@^6.5.0":
1290+
version "6.5.0"
1291+
resolved "https://registry.yarnpkg.com/@react-three/cannon/-/cannon-6.5.0.tgz#72077716a5e51f37339134de261de5244d034787"
1292+
integrity sha512-C3ZC0bJwQAXQtvaNMURoVLISsbHfvASLhFmZSzseAfA6vEiza8RvcVsmByTPrKxF9udDpRmN9tQgtX6DA3deYg==
12931293
dependencies:
1294-
"@pmndrs/cannon-worker-api" "^2.1.0"
1294+
"@pmndrs/cannon-worker-api" "^2.3.0"
12951295
cannon-es "^0.20.0"
12961296
cannon-es-debugger "^1.0.0"
12971297

0 commit comments

Comments
 (0)