Skip to content

Commit

Permalink
fix: apply billboard axis lock to right group (#2323)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-type authored Jan 27, 2025
1 parent 2943f59 commit 39ef36b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core/Billboard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useFrame } from '@react-three/fiber'
import * as React from 'react'
import { Group, Quaternion } from 'three'
import { useFrame } from '@react-three/fiber'
import { ForwardRefComponent } from '../helpers/ts-utils'

export type BillboardProps = {
Expand Down Expand Up @@ -31,7 +31,7 @@ export const Billboard: ForwardRefComponent<BillboardProps, Group> = /* @__PURE_
if (!follow || !localRef.current) return

// save previous rotation in case we're locking an axis
const prevRotation = localRef.current.rotation.clone()
const prevRotation = inner.current.rotation.clone()

// always face the camera
localRef.current.updateMatrix()
Expand All @@ -40,9 +40,9 @@ export const Billboard: ForwardRefComponent<BillboardProps, Group> = /* @__PURE_
camera.getWorldQuaternion(inner.current.quaternion).premultiply(q.invert())

// readjust any axis that is locked
if (lockX) localRef.current.rotation.x = prevRotation.x
if (lockY) localRef.current.rotation.y = prevRotation.y
if (lockZ) localRef.current.rotation.z = prevRotation.z
if (lockX) inner.current.rotation.x = prevRotation.x
if (lockY) inner.current.rotation.y = prevRotation.y
if (lockZ) inner.current.rotation.z = prevRotation.z
})

React.useImperativeHandle(fref, () => localRef.current, [])
Expand Down

0 comments on commit 39ef36b

Please sign in to comment.