Skip to content

[Solved] Sharing View / r3f components across Canvas / Scene.tsx ? #170

Open
@rohanrehman

Description

@rohanrehman

@RenaudRohlinger great work on this!

Canvas is instantiated in Scene.txt

Keeping with framework conventions adding a View in the Scene to survive navigation returns an error.

export default function Scene({ ...props }) {
  // Everything defined in here will persist between route changes, only children are swapped
  return (
    <Canvas {...props}
      onCreated={(state) => (state.gl.toneMapping = THREE.AgXToneMapping)}
    >
      
          <View className='relative h-full sm:h-48 sm:w-full'>
              <Duck route='/blob' scale={2} position={[0, -1.6, 0]} />
          </View>

      {/* @ts-ignore */}
      <r3f.Out />
      <Preload all />
    </Canvas>
  )
}

Error: R3F: Div is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively

since you've added <div ref={localRef} {...props} /> to View.tx

Any r3f components created needs to be wrapped in View to be rendered, is there no way to add an r3f component that will be rendered across all app directory pages?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions