Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v10 #2318

Merged
merged 30 commits into from
Feb 19, 2025
Merged

v10 #2318

Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0011990
feat!: React 19 support (#2284)
CodyJasonBennett Jan 16, 2025
21a9150
Merge branch 'master' into rc
CodyJasonBennett Jan 16, 2025
a182249
Revert "Merge branch 'master' into rc"
CodyJasonBennett Jan 16, 2025
e49aac6
feat!: React 19 support
CodyJasonBennett Jan 16, 2025
72b3d9e
Merge branch 'master' into rc
CodyJasonBennett Jan 20, 2025
a624e0d
chore: cleanup
CodyJasonBennett Jan 20, 2025
eb739fb
10.0.0-rc.0
CodyJasonBennett Jan 21, 2025
914e0ff
chore: update R3F to rc.5
CodyJasonBennett Jan 23, 2025
9dec26a
10.0.0-rc.1
CodyJasonBennett Jan 23, 2025
9ab9b21
Merge branch 'master' into rc
CodyJasonBennett Jan 30, 2025
8240940
fix(controls): exclude args
CodyJasonBennett Feb 7, 2025
3f0711d
10.0.0-rc.2
CodyJasonBennett Feb 8, 2025
2f7bf54
Merge branch 'master' into rc
CodyJasonBennett Feb 13, 2025
0f90ce2
chore: cleanup testing script
CodyJasonBennett Feb 13, 2025
717bde2
experiment(CI): infer package version
CodyJasonBennett Feb 13, 2025
7dea451
chore: upgrade lockfile
CodyJasonBennett Feb 13, 2025
ef98f5d
experiment: hardcode version
CodyJasonBennett Feb 13, 2025
388973f
chore(CI): restore test script
CodyJasonBennett Feb 13, 2025
77f649d
chore: use rc.8
CodyJasonBennett Feb 17, 2025
5bc49d0
chore(Storybook): update lighting for r155
CodyJasonBennett Feb 18, 2025
9aad422
chore: use rc.9
CodyJasonBennett Feb 18, 2025
e12dc1c
chore: use rc.10
CodyJasonBennett Feb 18, 2025
f94bf57
experiment: run e2e
CodyJasonBennett Feb 18, 2025
962f7c8
10.0.0-rc.3
CodyJasonBennett Feb 18, 2025
e2946b7
chore: cleanup
CodyJasonBennett Feb 18, 2025
f130383
chore(Storybook): update light decay for r155
CodyJasonBennett Feb 18, 2025
2b89cae
Merge branch 'master' into rc
CodyJasonBennett Feb 19, 2025
1e72ac4
chore: resolve conflicts
CodyJasonBennett Feb 19, 2025
7a8e2c3
chore: use R3F v9 stable
CodyJasonBennett Feb 19, 2025
6eb39bb
chore: upgrade lockfile
CodyJasonBennett Feb 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sandboxes": ["4nc1u", "bfplr", "1wh6f"],
"packages": ["dist"],
"node": "18"
"node": "20"
}
4 changes: 2 additions & 2 deletions .storybook/stories/AccumulativeShadows.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as THREE from 'three'
import * as React from 'react'
import { ComponentProps } from 'react'
import { FlakesTexture } from 'three/examples/jsm/textures/FlakesTexture'
import { FlakesTexture } from 'three-stdlib'
import { Meta, StoryObj } from '@storybook/react'

import { Setup } from '../Setup'
Expand Down Expand Up @@ -48,7 +48,7 @@ function Suzi(props: ComponentProps<'group'>) {
material.color.set('orange')
material.roughness = 0
material.normalMap = new THREE.CanvasTexture(
new FlakesTexture(),
new FlakesTexture() as HTMLCanvasElement,
THREE.UVMapping,
THREE.RepeatWrapping,
THREE.RepeatWrapping
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/ArcballControls.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const CustomCamera = ({ ...props }: ComponentProps<typeof ArcballControls>) => {
* we will render our scene in a render target and use it as a map.
*/
const fbo = useFBO(400, 400)
const virtualCamera = useRef<OrthographicCamera | PerspectiveCameraType>()
const virtualCamera = useRef<PerspectiveCameraType>(null!)
const [virtualScene] = useState(() => new Scene())

useFrame(({ gl }) => {
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/BBAnchor.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function BBAnchorScene({
drawBoundingBox: boolean
children?: React.ReactNode
}) {
const ref = React.useRef(null)
const ref = React.useRef<THREE.Mesh<THREE.IcosahedronGeometry>>(null!)

useHelper(drawBoundingBox && ref, BoxHelper, 'cyan')

Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/Bvh.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default {
type Story = StoryObj<typeof Bvh>

function TorusBVH({ z = 0, ...props }: { z: number } & React.ComponentProps<typeof Bvh>) {
const mesh = React.useRef<React.ElementRef<typeof TorusKnot>>(null!)
const mesh = React.useRef<React.ComponentRef<typeof TorusKnot>>(null!)

useHelper(mesh, MeshBVHHelper)

Expand Down Expand Up @@ -122,7 +122,7 @@ const DebugRayCast = ({ grp }) => {
}

function Scene(props: React.ComponentProps<typeof Bvh>) {
const grp = React.useRef<React.ElementRef<'group'>>(null)
const grp = React.useRef<React.ComponentRef<'group'>>(null)

const { raycaster } = useThree()
raycaster.firstHitOnly = true
Expand Down
8 changes: 4 additions & 4 deletions .storybook/stories/CameraControls.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createPortal, useFrame } from '@react-three/fiber'
import React, { ComponentProps, useRef, useState } from 'react'
import { Scene } from 'three'
import * as THREE from 'three'
import { Meta, StoryObj } from '@storybook/react'

import { Setup } from '../Setup'
Expand Down Expand Up @@ -47,9 +47,9 @@ const CameraControlsScene2 = (props: ComponentProps<typeof CameraControls>) => {
* we will render our scene in a render target and use it as a map.
*/
const fbo = useFBO(400, 400)
const virtualCamera = useRef<CameraControls['camera']>()
const [virtualScene] = useState(() => new Scene())
const cameraControlRef = useRef<CameraControls>(null)
const virtualCamera = useRef<THREE.PerspectiveCamera>(null!)
const [virtualScene] = useState(() => new THREE.Scene())
const cameraControlRef = useRef<CameraControls>(null!)

useFrame(({ gl }) => {
if (virtualCamera.current) {
Expand Down
12 changes: 5 additions & 7 deletions .storybook/stories/CubeCamera.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@ export default {

type Story = StoryObj<typeof CubeCamera>

declare global {
namespace JSX {
interface IntrinsicElements {
axisHelper: object
}
declare module '@react-three/fiber' {
interface ThreeElements {
axisHelper: object
}
}

function Sphere({ offset = 0, ...props }: ComponentProps<typeof CubeCamera> & { offset?: number }) {
const ref = React.useRef<React.ElementRef<'mesh'>>(null)
const ref = React.useRef<THREE.Mesh>(null!)
useFrame(({ clock }) => {
ref.current!.position.y = Math.sin(offset + clock.elapsedTime) * 5
ref.current.position.y = Math.sin(offset + clock.elapsedTime) * 5
})

return (
Expand Down
10 changes: 4 additions & 6 deletions .storybook/stories/CurveModifier.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ import { CurveModifier, CurveModifierRef } from '../../src'

extend({ StdText: TextGeometry })

type TextGeometryImpl = JSX.IntrinsicElements['extrudeGeometry'] & {
type TextGeometryImpl = ThreeElements['extrudeGeometry'] & {
args: [string, TextGeometryParameters]
}

declare global {
namespace JSX {
interface IntrinsicElements {
stdText: TextGeometryImpl
}
declare module '@react-three/fiber' {
interface ThreeElements {
stdText: TextGeometryImpl
}
}

Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/Extrude.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default {
type Story = StoryObj<typeof Extrude>

function ExtrudeScene(props: React.ComponentProps<typeof Extrude>) {
const ref = useTurntable<React.ElementRef<typeof Extrude>>()
const ref = useTurntable<React.ComponentRef<typeof Extrude>>()

return (
<>
Expand Down
8 changes: 4 additions & 4 deletions .storybook/stories/FaceControls.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as easing from 'maath/easing'
import { Setup } from '../Setup'

import { FaceLandmarker, FaceControls, Box, WebcamVideoTexture } from '../../src'
import { ComponentProps, ElementRef, useRef, useState } from 'react'
import { ComponentProps, ComponentRef, useRef, useState } from 'react'
import { FaceLandmarkerResult } from '@mediapipe/tasks-vision'
import { useFrame, useThree } from '@react-three/fiber'

Expand Down Expand Up @@ -55,8 +55,8 @@ export const FaceControlsSt = {
//

function FaceControlsScene2(props: ComponentProps<typeof FaceControls>) {
const faceLandmarkerRef = useRef<ElementRef<typeof FaceLandmarker>>(null)
const videoTextureRef = useRef<ElementRef<typeof WebcamVideoTexture>>(null)
const faceLandmarkerRef = useRef<ComponentRef<typeof FaceLandmarker>>(null)
const videoTextureRef = useRef<ComponentRef<typeof WebcamVideoTexture>>(null)

const [faceLandmarkerResult, setFaceLandmarkerResult] = useState<FaceLandmarkerResult>()

Expand Down Expand Up @@ -99,7 +99,7 @@ export const FaceControlsSt2 = {
//

function FaceControlsScene3(props: ComponentProps<typeof FaceControls>) {
const faceControlsRef = useRef<ElementRef<typeof FaceControls>>(null)
const faceControlsRef = useRef<ComponentRef<typeof FaceControls>>(null)

const camera = useThree((state) => state.camera)
const [current] = useState(() => new THREE.Object3D())
Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/Fbo.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default {
type Story = StoryObj<typeof Fbo>

function SpinningThing() {
const mesh = React.useRef<React.ElementRef<typeof TorusKnot>>(null!)
const mesh = React.useRef<React.ComponentRef<typeof TorusKnot>>(null!)

useFrame(() => {
mesh.current.rotation.x = mesh.current.rotation.y = mesh.current.rotation.z += 0.01
Expand All @@ -40,7 +40,7 @@ function FboScene(props: React.ComponentProps<typeof Fbo>) {
}

function TargetWrapper({ target }: { target: THREE.WebGLRenderTarget }) {
const cam = React.useRef<React.ElementRef<typeof PerspectiveCamera>>(null!)
const cam = React.useRef<React.ComponentRef<typeof PerspectiveCamera>>(null!)

const scene = React.useMemo(() => {
const scene = new THREE.Scene()
Expand Down
6 changes: 3 additions & 3 deletions .storybook/stories/HTML.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function HTMLScene({
color?: React.ComponentProps<'meshBasicMaterial'>['color']
children?: React.ReactNode
} & HtmlProps) {
const ref = useTurntable<React.ElementRef<'group'>>()
const ref = useTurntable<React.ComponentRef<'group'>>()

return (
<group ref={ref}>
Expand Down Expand Up @@ -164,8 +164,8 @@ export const HTMLCalculatePositionSt = {
//

function HTMLOccluderScene(props: HtmlProps) {
const turntableRef = useTurntable<React.ElementRef<'group'>>()
const occluderRef = React.useRef<React.ElementRef<typeof Icosahedron>>(null)
const turntableRef = useTurntable<React.ComponentRef<'group'>>()
const occluderRef = React.useRef<React.ComponentRef<typeof Icosahedron>>(null)

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/Lathe.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default {
type Story = StoryObj<typeof Lathe>

function LatheScene(props: React.ComponentProps<typeof Lathe>) {
const ref = useTurntable<React.ElementRef<typeof Lathe>>()
const ref = useTurntable<React.ComponentRef<typeof Lathe>>()

return (
<Lathe ref={ref} {...props}>
Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/MarchingCubes.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ function MarchingCubesScene({
planeY?: boolean
planeZ?: boolean
} & React.ComponentProps<typeof MarchingCubes>) {
const cubeRefOne = React.useRef<React.ElementRef<typeof MarchingCube>>(null)
const cubeRefTwo = React.useRef<React.ElementRef<typeof MarchingCube>>(null)
const cubeRefOne = React.useRef<React.ComponentRef<typeof MarchingCube>>(null)
const cubeRefTwo = React.useRef<React.ComponentRef<typeof MarchingCube>>(null)

useFrame(({ clock }) => {
if (!cubeRefOne.current || !cubeRefTwo.current) return
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/MeshDistortMaterial.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const MeshDistortMaterialSt = {
//

function MeshDistortMaterialRefScene(props: React.ComponentProps<typeof MeshDistortMaterial>) {
const material = React.useRef<React.ElementRef<typeof MeshDistortMaterial>>(null!)
const material = React.useRef<React.ComponentRef<typeof MeshDistortMaterial>>(null!)

useFrame(({ clock }) => {
material.current.distort = Math.sin(clock.getElapsedTime())
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/MeshRefractionMaterial.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function Diamond({
rotation: React.ComponentProps<'mesh'>['rotation']
position: React.ComponentProps<'mesh'>['position']
} & React.ComponentProps<typeof MeshRefractionMaterial>) {
const ref = React.useRef<React.ElementRef<'mesh'>>(null)
const ref = React.useRef<React.ComponentRef<'mesh'>>(null)
const { nodes } = useGLTF('/dflat.glb') as any
// Use a custom envmap/scene-backdrop for the diamond material
// This way we can have a clear BG while cube-cam can still film other objects
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/MeshWobbleMaterial.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const MeshWobbleMaterialSt = {
//

function MeshWobbleMaterialRefScene(props: React.ComponentProps<typeof MeshWobbleMaterial>) {
const material = React.useRef<React.ElementRef<typeof MeshWobbleMaterial>>(null)
const material = React.useRef<React.ComponentRef<typeof MeshWobbleMaterial>>(null)

useFrame(({ clock }) => {
if (material.current === null) return
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/OrbitControls.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const CustomCamera = (props: OrbitControlsProps) => {
* we will render our scene in a render target and use it as a map.
*/
const fbo = useFBO(400, 400)
const virtualCamera = useRef<React.ElementRef<typeof PerspectiveCamera> | null>(null)
const virtualCamera = useRef<React.ComponentRef<typeof PerspectiveCamera> | null>(null)
const [virtualScene] = useState(() => new Scene())

useFrame(({ gl }) => {
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/Reflector.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function ReflectorScene({
const roughnessMap = useTexture('roughness_floor.jpeg')
const normalMap = useTexture('NORM.jpg')
const distortionMap = useTexture('dist_map.jpeg')
const $box = React.useRef<React.ElementRef<typeof TorusKnot>>(null!)
const $box = React.useRef<React.ComponentRef<typeof TorusKnot>>(null!)

React.useEffect(() => {
distortionMap.wrapS = distortionMap.wrapT = RepeatWrapping
Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/RoundedBox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default {
type Story = StoryObj<typeof RoundedBox>

function RoundedBoxScene(props: React.ComponentProps<typeof RoundedBox>) {
const ref = useTurntable<React.ElementRef<typeof RoundedBox>>()
const ref = useTurntable<React.ComponentRef<typeof RoundedBox>>()

return (
<RoundedBox ref={ref} {...props}>
Expand All @@ -44,7 +44,7 @@ export const RoundedBoxSt = {
//

function RoundedBoxScene2(props: React.ComponentProps<typeof RoundedBox>) {
const ref = useTurntable<React.ElementRef<typeof RoundedBox>>()
const ref = useTurntable<React.ComponentRef<typeof RoundedBox>>()

return (
<>
Expand Down
6 changes: 3 additions & 3 deletions .storybook/stories/Sampler.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Meta, StoryObj } from '@storybook/react'
import { Setup } from '../Setup'

import { Sampler, ComputedAttribute, TransformFn } from '../../src'
import { BufferAttribute, Vector3 } from 'three'
import { BufferAttribute, InstancedMesh, Mesh, Vector3 } from 'three'

export default {
title: 'Misc/Sampler',
Expand Down Expand Up @@ -49,8 +49,8 @@ export const SamplerSt = {
//

function RefAPIScene(props: React.ComponentProps<typeof Sampler>) {
const meshRef = React.useRef(null)
const instancesRef = React.useRef(null)
const meshRef = React.useRef<Mesh>(null!)
const instancesRef = React.useRef<InstancedMesh>(null!)

return (
<>
Expand Down
18 changes: 7 additions & 11 deletions .storybook/stories/ScreenQuad.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react'
import * as THREE from 'three'
import { extend, useThree, useFrame } from '@react-three/fiber'
import { extend, useThree, useFrame, ThreeElements } from '@react-three/fiber'
import { Meta, StoryObj } from '@storybook/react'

import { Setup } from '../Setup'
Expand Down Expand Up @@ -47,22 +47,18 @@ const ColorShiftMaterial = shaderMaterial(

extend({ ColorShiftMaterial })

type ColorShiftMaterialImpl = {
time: number
resolution: number[]
} & JSX.IntrinsicElements['shaderMaterial']

declare global {
namespace JSX {
interface IntrinsicElements {
colorShiftMaterial: ColorShiftMaterialImpl
declare module '@react-three/fiber' {
interface ThreeElements {
colorShiftMaterial: ThreeElements['shaderMaterial'] & {
time: number
resolution: number[]
}
}
}

function ScreenQuadScene(props: React.ComponentProps<typeof ScreenQuad>) {
const size = useThree((state) => state.size)
const ref = React.useRef<React.ElementRef<'colorShiftMaterial'>>(null!)
const ref = React.useRef<ThreeElements['colorShiftMaterial']>(null!)

useFrame((state) => {
if (ref.current.uniforms) {
Expand Down
13 changes: 11 additions & 2 deletions .storybook/stories/Segments.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const BasicSegmentsSt = {
//

function AnimatedSegments(props: React.ComponentProps<typeof Segments>) {
const ref = React.useRef<React.ElementRef<typeof Segment>[]>([])
const ref = React.useRef<React.ComponentRef<typeof Segment>[]>([])
useFrame(({ clock }) => {
ref.current.forEach((r, i) => {
const time = clock.elapsedTime
Expand All @@ -64,7 +64,16 @@ function AnimatedSegments(props: React.ComponentProps<typeof Segments>) {
return (
<Segments {...props}>
{Array.from({ length: 10000 }).map((_, i) => (
<Segment key={i} ref={(r) => (ref.current[i] = r!)} color="orange" start={[0, 0, 0]} end={[0, 0, 0]} />
<Segment
key={i}
ref={(r) => {
ref.current[i] = r!
return () => void (ref.current[i] = null!)
}}
color="orange"
start={[0, 0, 0]}
end={[0, 0, 0]}
/>
))}
</Segments>
)
Expand Down
4 changes: 2 additions & 2 deletions .storybook/stories/Shadow.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export default {
type Story = StoryObj<typeof Shadow>

function ShadowScene(props: React.ComponentProps<typeof Shadow>) {
const shadow = React.useRef<React.ElementRef<typeof Shadow>>(null!)
const mesh = React.useRef<React.ElementRef<typeof Icosahedron>>(null!)
const shadow = React.useRef<React.ComponentRef<typeof Shadow>>(null!)
const mesh = React.useRef<React.ComponentRef<typeof Icosahedron>>(null!)

useFrame(({ clock }) => {
shadow.current.scale.x = Math.sin(clock.getElapsedTime()) + 3
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/Shapes.Box.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default {
type Story = StoryObj<typeof Box>

function BoxScene(props: React.ComponentProps<typeof Box>) {
const ref = useTurntable<React.ElementRef<typeof Box>>()
const ref = useTurntable<React.ComponentRef<typeof Box>>()

return (
<Box ref={ref} {...props}>
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories/Shapes.Circle.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default {
type Story = StoryObj<typeof Circle>

function CircleScene(props: React.ComponentProps<typeof Circle>) {
const ref = useTurntable<React.ElementRef<typeof Circle>>()
const ref = useTurntable<React.ComponentRef<typeof Circle>>()

return (
<Circle ref={ref} {...props}>
Expand Down
Loading
Loading