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

Guidance on using events (OnClick, OnPointerOver etc) for CSG #24

Open
arek-e opened this issue Sep 27, 2023 · 1 comment
Open

Guidance on using events (OnClick, OnPointerOver etc) for CSG #24

arek-e opened this issue Sep 27, 2023 · 1 comment

Comments

@arek-e
Copy link

arek-e commented Sep 27, 2023

Hello!
Im trying to implement OnPointerOver like the basic demo of React Three Fiber. Im not super experienced with the CSG part of r3f.

Currently im doing this but with no success, this is a add component that is nested in the geometry.

export default function AddFloor({ position }: AddFloorProps) {
  const addRef = useRef<any>(null!);
  const { update } = useCSG();
  const [hovered, hover] = useState<boolean>(null!);
  console.log(hovered);

  return (
    <PivotControls
      activeAxes={[true, true, true]}
      scale={1}
      anchor={[-1, 1, -1]}
      onDrag={update}
    >
        <mesh>
          <Addition
            position={position}
            ref={addRef}
            onPointerOver={() => hover(true)}
            onPointerOut={() => hover(false)}
          >
            <boxGeometry args={[1, 1, 1]} />
            <meshStandardMaterial color="orange" />
          </Addition>
        </mesh>
    </PivotControls>
  );
}

I've tried placing it on the mesh aswell but with no success. Does anyone have any pointers on what i can do next?

@marcofiletto
Copy link

Hey!
Have you tried move handlers to the parent mesh?

<mesh
    onPointerOver={() => hover(true)}
    onPointerOut={() => hover(false)}
>
          <Addition
            position={position}
            ref={addRef}
          >
            <boxGeometry args={[1, 1, 1]} />
            <meshStandardMaterial color="orange" />
          </Addition>
        </mesh>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants