-
-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
performance upgrades and required changes such as propagating pointer…
… event properties manually inside the UI
- Loading branch information
1 parent
9b95d71
commit f2da9f0
Showing
28 changed files
with
497 additions
and
233 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
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
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
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,42 @@ | ||
import { Canvas, useThree } from '@react-three/fiber' | ||
import { Canvas } from '@react-three/fiber' | ||
import { DefaultProperties, Container, Text, Root } from '@react-three/uikit' | ||
import { OrbitControls } from '@react-three/drei' | ||
import { Perf } from 'r3f-perf' | ||
import { forwardHtmlEvents } from '@pmndrs/pointer-events' | ||
import { useEffect } from 'react' | ||
|
||
//events={() => ({ enabled: false, priority: 0 })} | ||
import { noEvents, PointerEvents } from '@react-three/xr' | ||
|
||
export default function App() { | ||
return ( | ||
<Canvas | ||
events={() => ({ enabled: false, priority: 0 })} | ||
style={{ height: '100dvh', touchAction: 'none' }} | ||
gl={{ localClippingEnabled: true }} | ||
> | ||
<Canvas events={noEvents} style={{ height: '100dvh', touchAction: 'none' }} gl={{ localClippingEnabled: true }}> | ||
<color attach="background" args={['black']} /> | ||
<SwitchToXRPointerEvents /> | ||
<PointerEvents /> | ||
<OrbitControls /> | ||
<Perf /> | ||
<Root width={1920 * 2} positionType="relative"> | ||
<DefaultProperties fontSize={4}> | ||
<Container positionType="absolute" gap={1} flexWrap="wrap" inset={0}> | ||
{new Array(20000).fill(null).map((_, i) => ( | ||
<Container | ||
key={i} | ||
padding={2} | ||
borderRadius={Math.random() * 5} | ||
backgroundColor={Math.random() * 0xffffff} | ||
borderWidth={Math.random() * 1} | ||
borderColor={Math.random() * 0xffffff} | ||
onClick={() => console.log('what up?')} | ||
> | ||
<Text>Hello World</Text> | ||
</Container> | ||
))} | ||
{new Array(20000).fill(null).map((_, i) => { | ||
const borderWidth = Math.random() * 1 | ||
return ( | ||
<Container | ||
key={i} | ||
borderRadius={Math.random() * 5} | ||
backgroundColor={Math.random() * 0xffffff} | ||
borderWidth={borderWidth} | ||
borderColor={Math.random() * 0xffffff} | ||
height={4 + 4 + 2 * borderWidth} | ||
padding={2} | ||
pointerEvents="none" | ||
hover={{ backgroundColor: 'white', borderColor: 'black' }} | ||
> | ||
<Text pointerEvents="auto" hover={{ color: 'red' }}> | ||
Hello World | ||
</Text> | ||
</Container> | ||
) | ||
})} | ||
</Container> | ||
</DefaultProperties> | ||
</Root> | ||
</Canvas> | ||
) | ||
} | ||
|
||
function SwitchToXRPointerEvents() { | ||
const domElement = useThree((s) => s.gl.domElement) | ||
const camera = useThree((s) => s.camera) | ||
const scene = useThree((s) => s.scene) | ||
useEffect(() => forwardHtmlEvents(domElement, camera, scene), [domElement, camera, scene]) | ||
return null | ||
} |
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
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
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
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
Oops, something went wrong.