zappar-xr / zappar-react-three-fiber

Our SDK for the 3D rendering platform React-Three-Fiber.
MIT License
59 stars 9 forks source link

Camera shows gray background #91

Closed GwenGuts closed 2 weeks ago

GwenGuts commented 2 weeks ago

Hi, I tried to launch an example with InstantTracker as described here: https://codesandbox.io/s/instant-tracking-zl565?file=/src/App.jsx

When I launch the example, I have the prompt for authorizing the use of the camera, when I accept, I'm redirected to a page with the Button "Tap here..." at the bottom of the page. But the camera isn't capturing anything and instead, I have a gray background.

What I want to do is to tap the screen when seeing a Qr Code to place an object on it, as in the example.

What I see on my tablet screen:

image

The tablet:

The config of my dev environment:

function App() { let [placementMode, setPlacementMode] = useState(true);

return (
  <>
   <BrowserCompatibility />
    <ZapparCanvas>
      <ZapparCamera />
      <InstantTracker placementMode={placementMode} placementCameraOffset={[0, 0, -5]}>
        <mesh>
          <sphereGeometry />
          <meshStandardMaterial color="hotpink" />
        </mesh>
      </InstantTracker>
      <directionalLight position={[2.5, 8, 5]} intensity={1.5} />

    </ZapparCanvas>
    <div
      id="zappar-placement-ui"
      onClick={() => {
        setPlacementMode((currentPlacementMode) => !currentPlacementMode);
      }}
      onKeyDown={() => {
        setPlacementMode((currentPlacementMode) => !currentPlacementMode);
      }}
      role="button"
      tabIndex={0}
    >
      Tap here to
      {placementMode ? ' place ' : ' pick up '}
      the object
    </div>
  </>
);

}

export default App;



I also tried on an Android smartphone, same result.

Thanks for your help
GwenGuts commented 2 weeks ago

So it was vite which was the guilty one. If I use webpack and the initial react-app-rewired module (like in the code sandbox), it works... Maybe add support for vite in the future ?

Thanks

nyan-left commented 2 weeks ago

Hi @GwenGuts ,

Vite requires a bit of extra setup, here's an example repo https://github.com/nyan-left/uar-r3f-vite-ts-ft

GwenGuts commented 2 weeks ago

Hi @GwenGuts ,

Vite requires a bit of extra setup, here's an example repo https://github.com/nyan-left/uar-r3f-vite-ts-ft

Ho thanks for the tip !