Closed alvarosabu closed 9 months ago
Workaround for now.
If TresCanvas
is imported from @tresjs/core
explicitly, it does work β
<script setup lang="ts">
import { TresCanvas } from '@tresjs/core'
</script>
<template>
<TresCanvas window-size>
<TresPerspectiveCamera />
<TresMesh>
<TresTorusGeometry :args="[1, 0.5, 16, 32]" />
<TresMeshBasicMaterial color="orange" />
</TresMesh>
</TresCanvas>
</template>
Hey @danielroe sorry to bother you, but we might need a hand.
We're struggling a lot with the SSR version of the TresCanvas, before we had this error https://github.com/Tresjs/nuxt/issues/41 when changing routes using NuxtLink, the workaround was to wrap it on <ClientOnly />
but after updating v3.10.0
it's completely broken
We are registering the component on the module like this:
addComponent({
name: 'TresCanvas',
filePath: '@tresjs/core',
export: 'TresCanvas',
mode: 'client',
_raw: true,
})
addComponent({
name: 'TresCanvas',
filePath: resolver.resolve('./runtime/ServerTresCanvas.vue'),
mode: 'server',
})
Where ServerTresCanvas.vue
is:
<template>
<div>
<canvas style="" />
</div>
</template>
Any idea how could address it? Thanks ππ»
Update, @danielroe
I tested removing the ServerPlaceholder and removing the mode:client
and _raw: true
properties of the addComponent
of the module like this:
addComponent({
name: 'TresCanvas',
filePath: '@tresjs/core',
export: 'TresCanvas',
})
Which is weird, isn't it? Should break because TresCanvas
can only be used on the client side.
Now it renders on the home page, but it gives a blank page when navigating using <NuxtLink>
as #41 (if I use anchor or router-link this doesn't happen)
https://github.com/Tresjs/nuxt/assets/4699008/39dd207c-161d-49bc-9c06-b2252d79076d
If the TresCanvas
inside is wrapped by <ClientOnly>
it does render correctly.
In ServerTresCanvas.vue
try removing the <canvas>
tag.
Nodejs doesn't support Canvas tag and Canvas API.
Describe the bug
SSR version of TresCanvas is broken when the project is using
npm
as the package manager.Reproduction
https://stackblitz.com/edit/nuxt-starter-hzbvpr?file=nuxt.config.ts
Steps to reproduce
npm install
andnpm run dev
/page1
linkSystem Info
Used Package Manager
npm, pnpm
Code of Conduct