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

Facemesh v2 #1437

Merged
merged 4 commits into from
May 10, 2023
Merged
Changes from 1 commit
Commits
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
Prev Previous commit
fix: initial useState value as function initializer
  • Loading branch information
abernier committed May 10, 2023
commit 753194938b81dae5d2bceae0187347325167827a
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