Aframe положение камеры не обновляется и кликает события при регистрации на мобильном телефоне - PullRequest
0 голосов
/ 08 ноября 2019

У меня есть приложение, в котором мне нужна камера для движения по траектории. На рабочем столе камера движется по траектории и реагирует на события щелчка. Однако на мобильном устройстве камера не двигается и не реагирует на события касания или нажатия.

Вот камера:

        <a-entity id="rig">
            <a-entity camera id="curve-camera" position="-1.2 0 1" look-controls>
                <a-cursor id="cursor"></a-cursor>
            </a-entity>
        </a-entity>

Вот движение:

        AFRAME.scenes[0].canvas.addEventListener("touchstart", () => {
            currentState = states[clickCount % states.length];
            clickCount = clickCount + 1;
        })

        AFRAME.scenes[0].canvas.addEventListener("click", () => {
            currentState = states[clickCount % states.length];
            clickCount = clickCount + 1;
        })

        let positionIndex = 0
        const moveForward = (positions, rotations) => {
            if (positionIndex !== positions.length) {
                const camera_el = document.getElementById("curve-camera");
                let position = positions[positionIndex];
                let rotation = rotations[positionIndex];
                camera_el.setAttribute("position", position);
                // camera_el.setAttribute("rotation", rotation);
                positionIndex = positionIndex + 1;
            }
        }

        const moveBackward = (positions, rotations) => {
            if (positionIndex !== 0) {
                const camera_el = document.getElementById("curve-camera");
                let position = positions[positionIndex];
                let rotation = rotations[positionIndex];
                camera_el.setAttribute("position", position);
                // camera_el.setAttribute("rotation", rotation);
                positionIndex = positionIndex - 1;
            }
        }

Когда обновляется счетчик кликов, вызываются либо функции перемещения назад или движения вперед. Полный репо здесь: https://github.com/davidfstein/hs19-var

...