We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Right now there is no way to access the TresCanvas context without hacking the script setup using TresCanvas:
<script setup lang="ts"> import { TresCanvas } from '@tresjs/core'; import { computed, ref, onMounted } from 'vue'; import { extend, useTresContext } from '@tresjs/core'; import { OrbitControls } from 'three/addons/controls/OrbitControls'; import { TextGeometry } from 'three/addons/geometries/TextGeometry'; const trescanvas = ref(); const state = ref(); onMounted(() => { setTimeout(() => { state.value = trescanvas.value?.context; }, 0); }); // Add the element to the catalogue extend({ TextGeometry, OrbitControls }); </script> <template> <TresCanvas ref="trescanvas" shadows alpha> <TresPerspectiveCamera :position="[5, 5, 5]" /> <TresOrbitControls v-if="state?.renderer" :args="[state?.camera, state?.renderer?.domElement]" /> <TresMesh> <TresTextGeometry :args="['TresJS', { font, ...fontOptions }]" center /> <TresMeshMatcapMaterial :matcap="matcapTexture" /> </TresMesh> </TresCanvas> </template>
Add default slot props, we¡ve the default slot there without any binding:
<canvas ref="canvas" :data-scene="scene.uuid" :class="$attrs.class" :data-tres="`tresjs ${pkg.version}`" :style="{ display: 'block', width: '100%', height: '100%', position: windowSize ? 'fixed' : 'relative', top: 0, left: 0, pointerEvents: 'auto', touchAction: 'none', ...$attrs.style as Object, }" > <slot v-bind="context" /> </canvas>
then in the sfc template:
<TresCanvas shadows alpha v-slot="{ camera, renderer }"> <TresPerspectiveCamera :position="[5, 5, 5]" /> <TresOrbitControls v-if="renderer" :args="[camera, renderer.domElement]" /> </TresCanvas>
check the hack in the description
related #565
The text was updated successfully, but these errors were encountered:
Closed as duplicate. See #572 .
Sorry, something went wrong.
No branches or pull requests
Description
Right now there is no way to access the TresCanvas context without hacking the script setup using TresCanvas:
Hack
Suggested solution
Add default slot props, we¡ve the default slot there without any binding:
then in the sfc template:
Alternative
check the hack in the description
Additional context
related #565
Validations
The text was updated successfully, but these errors were encountered: