Tresjs/tres

Enable usage of <Teleport>

Open

#464 opened on Dec 5, 2023

View on GitHub
 (1 comment) (1 reaction) (0 assignees)Vue (188 forks)github user discovery
help wantedinvestigation

Repository metrics

Stars
 (3,582 stars)
PR merge metrics
 (PR metrics pending)

Description

Description

Sometimes I want to contain some shared logic for HTML User-Interface and 3d Content in the same component, for example the user clicks a <button> and something in the 3d scene acts accordingly. With the help of portal-vue or Teleport I have used this approach in the past, but with a custom made implementation of BabylonJS without using a custom renderer.

Example:

<template>
  <GLTFModel path="my-model.glb" v-if="isVisible" />
  
  <Teleport to="body">
    <button @click="isVisible.value = false">Hide GLTF</button>
  </Teleport>
</template>

Suggested solution

Enable usage of portal-vue and/or Teleport. I have tried both, but they both throw different kinds of error:

  • portal-vue: "[portal-vue]: Necessary Injection not found. Make sur you installed the plugin properly."
  • Teleport: "Failed to locate Teleport target with selector "body" […]"

I suspect both errors are caused by the usage of a custom-renderer thus portal-vue/Teleport simply can't access their targets. It's a wild guess, but when moving everything outside of the <TresCanvas> context it works just fine.

Alternative

No response

Additional context

I guess https://github.com/Tresjs/tres/issues/312 is somewhat of a similar topic

Validations

Contributor guide