ecctrl icon indicating copy to clipboard operation
ecctrl copied to clipboard

Impossible to orbit the scene when drei's Html element is in the scene

Open chillbert opened this issue 1 year ago • 4 comments

given:

import { Html, KeyboardControls } from '@react-three/drei';
//...
      <Canvas shadows>
         <Html occlude={"blending"} scale={.1} transform position={[.43,2.52,-5.18]}>
             <div style={{transform:"scale(1)"}}>
              <h1>Let's Go!</h1>
             </div>
        </Html> 
<Physics timeStep="vary">
          <Suspense fallback={null}>
            <KeyboardControls map={keyboardMap}>
              <Ecctrl debug>
                <CharacterModel />
              </Ecctrl>
            </KeyboardControls>
            <Room04/>
          </Suspense>
        </Physics>
</Canvas>

you can not look around in the scene with mouse or pointer. How can we fix this? Any ideas?

chillbert avatar May 19 '24 18:05 chillbert

Only the current domElement can interact with camera control. I think adding Html might create another dom element. 🤔 Alternatively, you could use pointerlock like in the example app.

ErdongChen-Andrew avatar May 20 '24 23:05 ErdongChen-Andrew

When occlude is set to true, control is restored, but it brings another issue: the Html flickers, and its occlusion relationship is incorrect.

golden-fruit avatar Jul 10 '24 10:07 golden-fruit

@chillbert In version 1.0.88, you can set camListenerTarget = "document". That should solve the problem.

ErdongChen-Andrew avatar Aug 03 '24 03:08 ErdongChen-Andrew

@ErdongChen-Andrew thanks for the answer, setting camListenerTarget = "document" worked for me I was using the html element to embed a youtube video and seems to work seamlessly

MULUALEM-TEKLE avatar Oct 16 '24 06:10 MULUALEM-TEKLE