MCPcopy
hub / github.com/pmndrs/react-three-fiber / SceneA

Function SceneA

example/src/demos/Activity.tsx:9–36  ·  view source on GitHub ↗
({ onSelect }: { onSelect: Function })

Source from the content-addressed store, hash-verified

7const colors = ['orange', 'hotpink', 'cyan', 'lime', 'yellow', 'red', 'blue', 'purple', 'green', 'coral']
8
9function SceneA({ onSelect }: { onSelect: Function }) {
10 const ref = useRef<Mesh>(null)
11 const [scale, setScale] = useState(1)
12 const [color, setColor] = useState(colors[0])
13
14 // Stable event handler using the new React 19.2 API
15 const handleSelect = useEffectEvent(() => onSelect())
16
17 useFrame((_, dt) => {
18 if (ref.current) ref.current.rotation.y += dt * 1.2
19 })
20
21 return (
22 <mesh
23 ref={ref}
24 scale={scale}
25 position={[-1.5, 0, 0]}
26 onClick={handleSelect}
27 onPointerOver={() => {
28 setScale(1.2)
29 setColor(colors[Math.floor(Math.random() * colors.length)])
30 }}
31 onPointerOut={() => setScale(1)}>
32 <boxGeometry />
33 <meshStandardMaterial color={color} />
34 </mesh>
35 )
36}
37
38const dracoLoader = new DRACOLoader()
39dracoLoader.setDecoderPath('https://www.gstatic.com/draco/versioned/decoders/1.5.5/')

Callers

nothing calls this directly

Calls 1

useFrameFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…