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

Example with GLTF model #34

Open
albertorizzi opened this issue Jun 11, 2023 · 1 comment
Open

Example with GLTF model #34

albertorizzi opened this issue Jun 11, 2023 · 1 comment

Comments

@albertorizzi
Copy link

How can I implement this example?
I would when the marker is recognized that appear a GLTF model.

<!DOCTYPE html>
<html>
    <script src="https://aframe.io/releases/1.3.0/aframe.min.js"></script>
    <!-- we import arjs version without NFT but with marker + location based support -->
    <script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js"></script>
    <body style="margin : 0px; overflow: hidden;">
        <a-scene embedded arjs>
        <a-marker preset="hiro">
            <!-- we use cors proxy to avoid cross-origin problems ATTENTION! you need to set up your server -->
            <a-entity
            position="0 0 0"
            scale="0.05 0.05 0.05"
            gltf-model="your-server/https://raw.githack.com/AR-js-org/AR.js/master/aframe/examples/image-tracking/nft/trex/scene.gltf"
            ></a-entity>
        </a-marker>
        <a-entity camera></a-entity>
        </a-scene>
    </body>
</html>
@j-era
Copy link
Contributor

j-era commented Jul 24, 2023

Hi @albertorizzi, this works easily with the useGltf hook from @react-three/drei

import { useGLTF } from "@react-three/drei"

const Model = (url) => {
  const { scene } = useGLTF(url)

  return <primitive object={scene} />
}

...
<ARMarker 
  params={{ smooth: true }}
  type={"pattern"}
  patternUrl={"data/patt.hiro"}
>
  <Suspense fallback={null}>
    <Model url={url} />
  </Suspense>
</ARMarker>
...

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