-
Notifications
You must be signed in to change notification settings - Fork 27.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'canary' into fix/rewrite-alias-cache
- Loading branch information
Showing
19 changed files
with
584 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# No Document Import in Page | ||
|
||
### Why This Error Occurred | ||
|
||
`next/document` was imported in a page outside of `pages/_document.js`. This can cause unexpected issues in your application. | ||
|
||
### Possible Ways to Fix It | ||
|
||
Only import and use `next/document` within `pages/_document.js` to override the default `Document` component: | ||
|
||
```jsx | ||
// pages/_document.js | ||
import Document, { Html, Head, Main, NextScript } from 'next/document' | ||
|
||
class MyDocument extends Document { | ||
//... | ||
} | ||
|
||
export default MyDocument | ||
``` | ||
|
||
### Useful Links | ||
|
||
- [Custom Document](https://nextjs.org/docs/advanced-features/custom-document) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# No Head Import in Document | ||
|
||
### Why This Error Occurred | ||
|
||
`next/head` was imported in `pages/_document.js`. This can cause unexpected issues in your application. | ||
|
||
### Possible Ways to Fix It | ||
|
||
Only import and use `next/document` within `pages/_document.js` to override the default `Document` component. If you are importing `next/head` to use the `Head` component, import it from `next/document` instead in order to modify `<head>` code across all pages: | ||
|
||
```jsx | ||
// pages/_document.js | ||
import Document, { Html, Head, Main, NextScript } from 'next/document' | ||
|
||
class MyDocument extends Document { | ||
static async getInitialProps(ctx) { | ||
//... | ||
} | ||
|
||
render() { | ||
return ( | ||
<Html> | ||
<Head></Head> | ||
</Html> | ||
) | ||
} | ||
} | ||
|
||
export default MyDocument | ||
``` | ||
|
||
### Useful Links | ||
|
||
- [Custom Document](https://nextjs.org/docs/advanced-features/custom-document) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# No Page Custom Font | ||
|
||
### Why This Error Occurred | ||
|
||
A custom font was added to a page and not with a custom `Document`. This only adds the font to the specific page and not to the entire application. | ||
|
||
### Possible Ways to Fix It | ||
|
||
Create the file `./pages/document.js` and add the font to a custom Document: | ||
|
||
```jsx | ||
// pages/_document.js | ||
|
||
import Document, { Html, Head, Main, NextScript } from 'next/document' | ||
|
||
class MyDocument extends Document { | ||
render() { | ||
return ( | ||
<Html> | ||
<Head> | ||
<link | ||
href="https://fonts.googleapis.com/css2?family=Inter&display=optional" | ||
rel="stylesheet" | ||
/> | ||
</Head> | ||
<body> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
) | ||
} | ||
} | ||
|
||
export default MyDocument | ||
``` | ||
|
||
### When Not To Use It | ||
|
||
If you have a reason to only load a font for a particular page, then you can disable this rule. | ||
|
||
### Useful Links | ||
|
||
- [Custom Document](https://nextjs.org/docs/advanced-features/custom-document) | ||
- [Font Optimization](https://nextjs.org/docs/basic-features/font-optimization) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,40 @@ | ||
import { useRef, useState, useEffect } from 'react' | ||
import * as THREE from 'three' | ||
import { useEffect } from 'react' | ||
import { useFrame } from '@react-three/fiber' | ||
import { useAnimations, useGLTF } from '@react-three/drei' | ||
|
||
import { useFrame, useLoader } from 'react-three-fiber' | ||
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader' | ||
export default function Bird({ speed, factor, url, ...props }) { | ||
const { nodes, animations } = useGLTF(url) | ||
const { ref, mixer } = useAnimations(animations) | ||
|
||
const Bird = ({ speed, factor, url, ...props }) => { | ||
const gltf = useLoader(GLTFLoader, url) | ||
const group = useRef() | ||
const [mixer] = useState(() => new THREE.AnimationMixer()) | ||
|
||
useEffect( | ||
() => void mixer.clipAction(gltf.animations[0], group.current).play(), | ||
[gltf.animations, mixer] | ||
) | ||
useEffect(() => void mixer.clipAction(animations[0], ref.current).play(), [ | ||
mixer, | ||
animations, | ||
ref, | ||
]) | ||
|
||
useFrame((state, delta) => { | ||
group.current.rotation.y += | ||
ref.current.rotation.y += | ||
Math.sin((delta * factor) / 2) * Math.cos((delta * factor) / 2) * 1.5 | ||
mixer.update(delta * speed) | ||
}) | ||
|
||
return ( | ||
<group ref={group}> | ||
<group ref={ref}> | ||
<scene name="Scene" {...props}> | ||
<mesh | ||
name="Object_0" | ||
morphTargetDictionary={gltf.nodes.Object_0.morphTargetDictionary} | ||
morphTargetInfluences={gltf.nodes.Object_0.morphTargetInfluences} | ||
morphTargetDictionary={nodes.Object_0.morphTargetDictionary} | ||
morphTargetInfluences={nodes.Object_0.morphTargetInfluences} | ||
rotation={[1.5707964611537577, 0, 0]} | ||
> | ||
<bufferGeometry attach="geometry" {...gltf.nodes.Object_0.geometry} /> | ||
<bufferGeometry attach="geometry" {...nodes.Object_0.geometry} /> | ||
<meshStandardMaterial | ||
attach="material" | ||
{...gltf.nodes.Object_0.material} | ||
{...nodes.Object_0.material} | ||
name="Material_0_COLOR_0" | ||
/> | ||
</mesh> | ||
</scene> | ||
</group> | ||
) | ||
} | ||
|
||
export default Bird |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useRef, useState } from 'react' | ||
import { useFrame } from '@react-three/fiber' | ||
import { Box as NativeBox } from '@react-three/drei' | ||
|
||
export default function Box(props) { | ||
const mesh = useRef() | ||
|
||
const [hovered, setHover] = useState(false) | ||
const [active, setActive] = useState(false) | ||
|
||
useFrame(() => (mesh.current.rotation.x = mesh.current.rotation.y += 0.01)) | ||
|
||
return ( | ||
<NativeBox | ||
args={[1, 1, 1]} | ||
{...props} | ||
ref={mesh} | ||
scale={active ? [6, 6, 6] : [5, 5, 5]} | ||
onClick={() => setActive(!active)} | ||
onPointerOver={() => setHover(true)} | ||
onPointerOut={() => setHover(false)} | ||
> | ||
<meshStandardMaterial | ||
attach="material" | ||
color={hovered ? '#2b6c76' : '#720b23'} | ||
/> | ||
</NativeBox> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,45 @@ | ||
import dynamic from 'next/dynamic' | ||
import { Suspense } from 'react' | ||
import { Canvas } from 'react-three-fiber' | ||
import { Canvas } from '@react-three/fiber' | ||
import { OrbitControls } from '@react-three/drei' | ||
import Bird from '../components/Bird' | ||
|
||
const Bird = dynamic(() => import('../components/Bird'), { ssr: false }) | ||
|
||
const Birds = () => { | ||
return new Array(5).fill().map((_, i) => { | ||
const x = (15 + Math.random() * 30) * (Math.round(Math.random()) ? -1 : 1) | ||
const y = -10 + Math.random() * 20 | ||
const z = -5 + Math.random() * 10 | ||
const bird = ['stork', 'parrot', 'flamingo'][Math.round(Math.random() * 2)] | ||
let speed = bird === 'stork' ? 0.5 : bird === 'flamingo' ? 2 : 5 | ||
let factor = | ||
bird === 'stork' | ||
? 0.5 + Math.random() | ||
: bird === 'flamingo' | ||
? 0.25 + Math.random() | ||
: 1 + Math.random() - 0.5 | ||
|
||
return ( | ||
<Bird | ||
key={i} | ||
position={[x, y, z]} | ||
rotation={[0, x > 0 ? Math.PI : 0, 0]} | ||
speed={speed} | ||
factor={factor} | ||
url={`/glb/${bird}.glb`} | ||
/> | ||
) | ||
}) | ||
} | ||
|
||
const BirdsPage = (props) => { | ||
export default function BirdsPage() { | ||
return ( | ||
<> | ||
<Canvas camera={{ position: [0, 0, 35] }}> | ||
<ambientLight intensity={2} /> | ||
<pointLight position={[40, 40, 40]} /> | ||
<OrbitControls /> | ||
<Suspense fallback={null}> | ||
<Birds /> | ||
{new Array(6).fill().map((_, i) => { | ||
const x = | ||
(15 + Math.random() * 30) * (Math.round(Math.random()) ? -1 : 1) | ||
const y = -10 + Math.random() * 20 | ||
const z = -5 + Math.random() * 10 | ||
const bird = ['stork', 'parrot', 'flamingo'][ | ||
Math.round(Math.random() * 2) | ||
] | ||
let speed = bird === 'stork' ? 0.5 : bird === 'flamingo' ? 2 : 5 | ||
let factor = | ||
bird === 'stork' | ||
? 0.5 + Math.random() | ||
: bird === 'flamingo' | ||
? 0.25 + Math.random() | ||
: 1 + Math.random() - 0.5 | ||
|
||
return ( | ||
<Bird | ||
key={i} | ||
position={[x, y, z]} | ||
rotation={[0, x > 0 ? Math.PI : 0, 0]} | ||
speed={speed} | ||
factor={factor} | ||
url={`/glb/${bird}.glb`} | ||
/> | ||
) | ||
})} | ||
</Suspense> | ||
</Canvas> | ||
</> | ||
) | ||
} | ||
|
||
export default BirdsPage |
Oops, something went wrong.