Skip to content

Commit

Permalink
Upgrade
Browse files Browse the repository at this point in the history
Everything is mostly working but:
 - Leva is weirdly small. Waiting until they get things working on R18 here.
   pmndrs/leva#330
  • Loading branch information
disambiguator committed Jul 21, 2022
1 parent a82c228 commit aee1a6e
Show file tree
Hide file tree
Showing 33 changed files with 285 additions and 249 deletions.
9 changes: 7 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"presets": ["next/babel"],
"plugins": ["glsl"]
"presets": [
"next/babel"
],
"plugins": [
"glsl",
"module:@react-three/babel"
]
}
11 changes: 11 additions & 0 deletions @types/react-new-window.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React, { PropsWithChildren } from 'react';

// Bypassing a type issue until fixed.
// https://github.com/rmariuzzo/react-new-window/issues/118
declare module 'react-new-window' {
import { INewWindowProps } from 'react-new-window';

export default class NewWindow extends React.PureComponent<
PropsWithChildren<INewWindowProps>
> {}
}
2 changes: 1 addition & 1 deletion components/cubedraw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type BoxData = {
creationTime: number;
};
const Box = ({ position, color, rotation, creationTime }: BoxData) => {
const meshRef = useRef<THREE.Mesh<THREE.BoxGeometry>>();
const meshRef = useRef<THREE.Mesh<THREE.BoxGeometry>>(null);
useFrame(({ clock }) => {
const mesh = meshRef.current!;
const factor = Math.sin(creationTime + clock.elapsedTime / 3);
Expand Down
4 changes: 2 additions & 2 deletions components/effects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ declare global {
/* eslint-enable @typescript-eslint/no-namespace */

const TunnelEffects = () => {
const ref = useRef<AfterimagePass>();
const ref = useRef<AfterimagePass>(null);
const viewport = useThree((three) => three.viewport);
const size = useThree((three) => three.size);
const trailNoiseTimeRef = useRef(0);
Expand Down Expand Up @@ -146,7 +146,7 @@ const TunnelEffects = () => {
return (
<afterimagePass
ref={ref}
attachArray="passes"
attach="passes-1"
args={[0.96, TunnelShader]}
uniforms-aspect-value={viewport.aspect}
uniforms-resolution-value={new Vector2(
Expand Down
16 changes: 6 additions & 10 deletions components/scene.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ export const FiberScene = ({
controls,
children,
...rest
}: Props & { controls?: boolean }) => {
return (
<>
<Canvas mode="concurrent" {...rest}>
{controls && <OrbitControls />}
{children}
</Canvas>
</>
);
};
}: Props & { controls?: boolean }) => (
<Canvas {...rest}>
{controls && <OrbitControls />}
{children}
</Canvas>
);
2 changes: 1 addition & 1 deletion components/shader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Shaders = React.memo(function Shader({
}) {
const viewport = useThree((t) => t.viewport);
const size = useThree((t) => t.size);
const ref = useRef<ShaderMaterial>();
const ref = useRef<ShaderMaterial>(null);

useFrame(({ clock }) => {
ref.current!.uniforms.time.value = clock.elapsedTime;
Expand Down
Loading

0 comments on commit aee1a6e

Please sign in to comment.