Skip to content

Commit 2e12ab7

Browse files
authored
Merge pull request #141 from musehq/dev
v2.7.0
2 parents 12bf31f + f27f371 commit 2e12ab7

File tree

17 files changed

+339
-219
lines changed

17 files changed

+339
-219
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "spacesvr",
3-
"version": "2.6.5",
3+
"version": "2.7.0",
44
"private": true,
55
"description": "A standardized reality for future of the 3D Web",
66
"keywords": [

src/ideas/mediated/LostFloor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function LostFloor() {
1515
fragHead +
1616
shader.fragmentShader.replace(
1717
"#include <color_fragment>",
18-
"#include <color_fragment>\n" + fragColorFragment
18+
"#include <color_fragment>\n " + fragColorFragment
1919
);
2020
};
2121
return m;
@@ -199,5 +199,5 @@ const fragHead = `
199199

200200
const fragColorFragment = `
201201
diffuseColor.rgb -= 0.2 * (snoise(vPos) + 1.) / 2.;
202-
diffuseColor.r -= 0.1 * (snoise(-vPos) + 1.) / 2.;
202+
diffuseColor.r -= 0.025 * (snoise(-vPos) + 1.) / 2.;
203203
`;

src/ideas/modifiers/Collidable/components/TrimeshCollider.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,9 @@ export default function TrimeshCollider(props: TrimeshColliderProps) {
3131
return g;
3232
}, [geo, curScale]);
3333

34-
const [, api] = useTrimeshCollision(geometry);
35-
36-
// there's some state update that causes the api not to receive an out of sync position
37-
// i think it's whenever the api gets recreated. for now, just re-apply transforms every 2 seconds
38-
const needsUpdate = useRef(false);
39-
useLimitedFrame(1 / 2, () => {
40-
needsUpdate.current = true;
34+
const [, api] = useTrimeshCollision(geometry, {
35+
pos: pos.toArray(),
36+
rot: [euler.x, euler.y, euler.z],
4137
});
4238

4339
const lastUpdatedMatrix = useRef<Matrix4>(new Matrix4());
@@ -49,16 +45,12 @@ export default function TrimeshCollider(props: TrimeshColliderProps) {
4945
group.current.matrixWorld.decompose(pos, quat, scale);
5046

5147
// no need to update if nothing changed
52-
if (
53-
lastUpdatedMatrix.current.equals(group.current.matrixWorld) &&
54-
!needsUpdate.current
55-
) {
48+
if (lastUpdatedMatrix.current.equals(group.current.matrixWorld)) {
5649
return;
5750
}
5851

5952
// update last values
6053
lastUpdatedMatrix.current.copy(group.current.matrixWorld);
61-
needsUpdate.current = false;
6254

6355
// if a change was found, update collider
6456
api.position.copy(pos);

src/ideas/modifiers/Collidable/utils/trimesh.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import { useTrimesh } from "@react-three/cannon";
1+
import { Triplet, useTrimesh } from "@react-three/cannon";
22
import {
33
BufferAttribute,
44
BufferGeometry,
55
InterleavedBufferAttribute,
66
} from "three";
77

8-
export const useTrimeshCollision = (geometry: BufferGeometry) => {
8+
export const useTrimeshCollision = (
9+
geometry: BufferGeometry,
10+
trans?: { pos?: Triplet; rot?: Triplet }
11+
) => {
912
const indices = (geometry.index as BufferAttribute).array as number[];
1013

1114
const isInterleaved =
@@ -30,6 +33,8 @@ export const useTrimeshCollision = (geometry: BufferGeometry) => {
3033
() => ({
3134
type: "Static",
3235
args: [vertices, indices],
36+
position: trans?.pos,
37+
rotation: trans?.rot,
3338
}),
3439
undefined,
3540
[geometry.uuid]

src/ideas/ui/Button.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function Button(props: ButtonProps) {
2828
font = "https://d27rt3a60hh1lx.cloudfront.net/fonts/Quicksand_Bold.otf",
2929
fontSize = 0.05,
3030
width,
31-
maxWidth = 0.25,
31+
maxWidth,
3232
textColor = "black",
3333
color = "#fff",
3434
outline = true,
@@ -85,7 +85,11 @@ export function Button(props: ButtonProps) {
8585
}, []);
8686

8787
const PADDING = fontSize * 0.9;
88-
const MAX_WIDTH = width ? Math.min(width, maxWidth) : maxWidth;
88+
const MAX_WIDTH = !maxWidth
89+
? Infinity
90+
: width
91+
? Math.max(width, maxWidth)
92+
: maxWidth;
8993
const WIDTH = (width || dims[0]) + PADDING * 2;
9094
const HEIGHT = dims[1] + PADDING;
9195
const DEPTH = fontSize * 1.1;
@@ -123,7 +127,7 @@ export function Button(props: ButtonProps) {
123127
<RoundedBox
124128
args={[WIDTH, HEIGHT, DEPTH]}
125129
radius={RADIUS}
126-
smoothness={8}
130+
smoothness={6}
127131
>
128132
{/* @ts-ignore */}
129133
<animated.meshStandardMaterial color={animColor} />

src/ideas/ui/TextInput/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,15 @@ export function TextInput(props: TextProps) {
348348
<RoundedBox
349349
args={[INPUT_WIDTH, INPUT_HEIGHT, DEPTH]}
350350
radius={RADIUS}
351-
smoothness={8}
351+
smoothness={6}
352352
>
353353
<meshStandardMaterial color="white" />
354354
</RoundedBox>
355355
</Interactable>
356356
<RoundedBox
357357
args={[OUTER_WIDTH, OUTER_HEIGHT, DEPTH]}
358358
radius={RADIUS}
359-
smoothness={8}
359+
smoothness={6}
360360
position-z={-0.001}
361361
>
362362
{/* @ts-ignore */}
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Props as ContainerProps } from "@react-three/fiber/dist/declarations/src/web/Canvas";
22
import { ResizeObserver } from "@juggle/resize-observer";
3+
import { NoToneMapping } from "three";
34

45
export const defaultCanvasProps: Partial<ContainerProps> = {
56
gl: {
@@ -8,11 +9,13 @@ export const defaultCanvasProps: Partial<ContainerProps> = {
89
depth: true,
910
alpha: false,
1011
stencil: false,
12+
physicallyCorrectLights: true,
13+
toneMapping: NoToneMapping,
1114
},
1215
shadows: false,
13-
camera: { position: [0, 2, 0], near: 0.01, far: 150 },
16+
camera: { position: [0, 2, 0], near: 0.01, far: 300 },
1417
resize: { polyfill: ResizeObserver },
1518
dpr: 1,
16-
raycaster: { far: 2 },
19+
raycaster: { far: 3 },
1720
events: undefined,
1821
};

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.6.5",
51+
text: "v2.7.0",
5252
link: "https://www.npmjs.com/package/spacesvr",
5353
},
5454
...menuItems,

src/layers/Player/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export function Player(props: PlayerLayer) {
9494
const velocity = useRef(new Vector3());
9595
const lockControls = useRef(false);
9696
const raycaster = useMemo(
97-
() => new Raycaster(new Vector3(), new Vector3(), 0, 2),
97+
() => new Raycaster(new Vector3(), new Vector3(), 0, 5),
9898
[]
9999
);
100100

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
export default function Lights() {
22
return (
33
<group name="lights">
4-
<ambientLight intensity={0.5} />
5-
<pointLight intensity={0.5} />
4+
<ambientLight intensity={Math.PI * 0.5} />
5+
<pointLight intensity={Math.PI * 0.5} />
66
</group>
77
);
88
}

0 commit comments

Comments
 (0)