Skip to content

Commit

Permalink
fix: initial useState value as function initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
abernier committed May 10, 2023
1 parent 9e85de5 commit 7531949
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/core/Facemesh.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ export const Facemesh = React.forwardRef<FacemeshApi, FacemeshProps>(
const outerRef = React.useRef<THREE.Group>(null)
const meshRef = React.useRef<THREE.Mesh>(null)

const [sightDir] = React.useState(new THREE.Vector3())
const [sightDirQuaternion] = React.useState(new THREE.Quaternion())
const [sightDir] = React.useState(() => new THREE.Vector3())
const [sightDirQuaternion] = React.useState(() => new THREE.Quaternion())

const { invalidate } = useThree()

React.useEffect(() => {
meshRef.current?.geometry.setIndex(FacemeshDatas.TRIANGULATION)
}, [])

const [a] = React.useState(new THREE.Vector3())
const [b] = React.useState(new THREE.Vector3())
const [c] = React.useState(new THREE.Vector3())
const [ab] = React.useState(new THREE.Vector3())
const [ac] = React.useState(new THREE.Vector3())
const [bboxSize] = React.useState(new THREE.Vector3())
const [a] = React.useState(() => new THREE.Vector3())
const [b] = React.useState(() => new THREE.Vector3())
const [c] = React.useState(() => new THREE.Vector3())
const [ab] = React.useState(() => new THREE.Vector3())
const [ac] = React.useState(() => new THREE.Vector3())
const [bboxSize] = React.useState(() => new THREE.Vector3())
React.useEffect(() => {
const geometry = meshRef.current?.geometry
if (!geometry) return
Expand Down

0 comments on commit 7531949

Please sign in to comment.