yamada-k-25
yamada-k-25

Reputation: 21

How can I fix camera rotation on mobile?

How can I fix the camera rotation on mobile? I've tried to handle the rotation event and override the handle gesture by referring to this link: https://www.keanw.com/2017/04/fixing-pinch-zoom-in-forge-viewer-applications.html I've fixed the rotation but I can't pinch-to-zoom to the position I touched.

Upvotes: 0

Views: 53

Answers (1)

Augusto Goncalves
Augusto Goncalves

Reputation: 8574

Please review this article. Here is the code snippet:

let viewer = null;

function onGestureEnd() {
    var hitTest = viewer.clientToWorld(window.innerWidth/2, window.innerHeight/2, true);
    viewer.navigation.setPivotPoint(hitTest.point);
}

function loadModel(urn) {

    const options = {
        env: 'AutodeskProduction',
        accessToken: _adsk.token.access_token,
    };

    Autodesk.Viewing.Initializer(options, () => {

        const div = document.getElementById('forgeViewer');
        viewer = new Autodesk.Viewing.Private.GuiViewer3D(div);
        viewer.start();
        Autodesk.Viewing.Document.load(`urn:${urn}`, (doc) => {
            var viewables = doc.getRoot().getDefaultGeometry();
            viewer.loadDocumentNode(doc, viewables).then( onLoadFinished );
        });
    });

    function onLoadFinished() {
        document.addEventListener('touchend', onGestureEnd);
    }
}

Upvotes: 1

Related Questions