-
-
Notifications
You must be signed in to change notification settings - Fork 240
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
compatability with react-three-fiber? #85
Comments
Did you try without camera controls? Then if still it happens, can you provide a simplified working example on jsfiddle or somewhere? Otherwise I need to prepare the environment to reproduce. |
Thank you for the speedy reply! |
I don't know about internals of react-three-fiber but I don't use getDelta() in my app yet! |
FYI: Second arg of useFrame callback is delta:
|
You don't need this line: |
just got this working here is my final code, seems to be working nicely thank you to both above i was trying to get a nice solution for dollyToCursor with OrbitControls with no luck and this one is perfect, i can go to bed now XD import React from 'react';
import * as THREE from 'three';
import { extend, ReactThreeFiber, useFrame, useThree } from '@react-three/fiber';
import CameraControls from 'camera-controls';
CameraControls.install({ THREE: THREE });
extend({ CameraControls });
declare global {
namespace JSX {
interface IntrinsicElements {
cameraControls: ReactThreeFiber.Object3DNode<
CameraControls,
typeof CameraControls
>;
}
}
}
export const CustomOrbitControls: React.FC<any> = React.forwardRef((props, ref) => {
const { camera, gl } = useThree();
useFrame((state, delta) => {
if (ref.current) {
ref.current.update(delta);
}
});
return (
<cameraControls
ref={ref}
args={[camera, gl.domElement]}
dollyToCursor
mouseButtons={{
left: CameraControls.ACTION.TRUCK,
middle: CameraControls.ACTION.NONE,
right: CameraControls.ACTION.NONE,
shiftLeft: CameraControls.ACTION.NONE,
wheel: CameraControls.ACTION.ZOOM,
}}
/>
);
}); |
hi ;)
I gave it a try with react-three-fiber and it got very laggy! specially as I try to rotate things!
here is the piece of Code that I wrote to make it work with react-three-fiber:
am I doing something wrong here? or its not somehow compatible with react-three?
The text was updated successfully, but these errors were encountered: