Skip to content

OrbitControls and DeviceOrientationControls #9047

Description

@kbjz

Hi , is there anyway to enable both DeviceOrientationControls and OrbitControls to use pan and orientation on mobile ?
Here is my actual code:

// Controls gyroscope
orbitControls = new THREE.OrbitControls(camera, renderer.domElement);
orbitControls.target.set(camera.position.x - 1, camera.position.y, camera.position.z);
clock = new THREE.Clock();
resize();
window.addEventListener("deviceorientation", deviceOrientationListener, false);
window.addEventListener("resize", resize, false);

var deviceOrientationListener = function(e) {
    if (!e.alpha) {
        return;
    }   
    orbitControls = new THREE.DeviceOrientationControls(camera, true);
    orbitControls.connect();
    orbitControls.update();
    resize();
    window.removeEventListener("deviceorientation", deviceOrientationListener);
};

var loop = function() {
        requestAnimationFrame($.proxy(loop, this));
        orbitControls.update(clock.getDelta());
        if (stereoEffect) {
            stereoEffect.render(scene, camera);
        } else {
            renderer.render(scene, camera);
        }
        TWEEN.update(); 
        Reticulum.update();
        videoTexture.update();      
};

Thank you for this amazing library by the way !

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions