AR-js-org / AR.js

Image tracking, Location Based AR, Marker tracking. All on the Web.
MIT License
5.3k stars 909 forks source link

es-modules @ar-js-org/ar.js doesn't work #607

Open gnvcor opened 2 weeks ago

gnvcor commented 2 weeks ago

Do you want to request a feature or report a bug? Bug

What is the current behavior? I import package @ar-js-org/ar.js in my project and i catch error:

image

If the current behavior is a bug, please provide the steps to reproduce. import package @ar-js-org/ar.js

image

My code:

import React, { useEffect, useState } from 'react';
import '@ar-js-org/ar.js';

function ARScene() {
    const [coordinates, setCoordinates] = useState({ latitude: 0, longitude: 0 });

    useEffect(() => {
        navigator.geolocation.getCurrentPosition(
            position => {
                const { latitude, longitude } = position.coords;
                setCoordinates({ latitude, longitude });
            },
            error => {
                console.error('Error getting geolocation:', error);
            }
        );
    }, []);

    return (
        <a-scene
            vr-mode-ui="enabled: false"
            arjs="sourceType: webcam; videoTexture: true; debugUIEnabled: false;"
        >
            <a-assets>
                <img id="banner" src="./banner_2.jpg" />
            </a-assets>
            <a-entity gps-entity-place={`latitude: ${coordinates.latitude}; longitude: ${coordinates.longitude};`}>
                <a-plane
                  position="0 1.6 -3"
                  rotation="0 0 0"
                  width="3"
                  height="1.5"
                  src="#banner"
                ></a-plane>
              </a-entity>
            <a-camera camera="active: true" rotation-reader></a-camera>
        </a-scene>
    );
}

function AppWithCamera() {
    return (
        <div className="App">
            <ARScene />
        </div>
    );
}

export default AppWithCamera;

Please mention other relevant information such as the browser version, Operating System and Device Name Google Chrome 126.0.6478.56 macos 14.4 (23E214)

What is the expected behavior?

If this is a feature request, what is motivation or use case for changing the behavior?

gnvcor commented 1 week ago

Guys, is there anyone here whose es-modules work?