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

how to add orbit controller #16

Open
lalamax3d opened this issue Jun 27, 2021 · 1 comment
Open

how to add orbit controller #16

lalamax3d opened this issue Jun 27, 2021 · 1 comment

Comments

@lalamax3d
Copy link

Hi,
not an issue to be precise, just query. from all the templates, it really suits my needs. I am having trouble in adding controller ( orbitController ) it needs canvas as input argument.

controls = new THREE.OrbitControls(camera, canvas);

thanks in advance.

@danivicario
Copy link

You can add this import

import { OrbitControls } from "three/examples/jsm/controls/OrbitControls";

in your init function you do

controls = new OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.1;

and then in your animate function you can do

function animate() {
    requestAnimationFrame(animate);
    
    // orbit control update per animation frame
    controls.update();
  
    // your animation stuff here
  
    // and finally...
    renderer.render(scene, camera);
}

hope this helps! if you have more questions, I'll paying attention to it.

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