Skip to content
New issue

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

Inspector component breaks Threlte App #20

Open
lortschi opened this issue May 10, 2024 · 7 comments
Open

Inspector component breaks Threlte App #20

lortschi opened this issue May 10, 2024 · 7 comments

Comments

@lortschi
Copy link

lortschi commented May 10, 2024

After regular install of the three-inspect module and following the documentation for adding to Threlte Ecosystem ended up with this error bellow on the screenshot.

Current module dependencies:

"@threlte/core": "latest",
"@threlte/extras": "latest",
"svelte": "^4.2.15",
"three": "^0.163.0",
"three-inspect": "^0.4.5",
"vite": "^5.2.9"

image

I am going to paste the terminal error log. This is a bit more retrieving as the browser log:

1:35:47 PM [vite] Error when evaluating SSR module /src/routes/+page.svelte: failed to import "/src/lib/components/App.svelte"
|- TypeError: vite_ssr_import_2.default.install is not a function
at /node_modules/.pnpm/three-inspect@0.4.5_@types[email protected][email protected]/node_modules/three-inspect/dist/components/Internal/CameraControls.svelte:17:16
at async instantiateModule

TypeError: vite_ssr_import_2.default.install is not a function
at /node_modules/.pnpm/three-inspect@0.4.5_@types[email protected][email protected]/node_modules/three-inspect/dist/components/Internal/CameraControls.svelte:17:16

Actually looks to me very TS specific error. I am not using TS in my project. ..just wanted to mention.

@supermoos
Copy link

Same issue for me.

@michealparks
Copy link
Member

michealparks commented Jun 7, 2024

Hello! It's a bit hard to pinpoint the issue without a full project to investigate. It's possible that the issue may be elsewhere and not specifically with three-inspect. Here is an example of a very barebones Threlte + Vite setup - not involving Typescript - where the inspector is functioning as intended:

https://stackblitz.com/edit/vitejs-vite-sfwjke?file=src%2FScene.svelte&terminal=dev

@supermoos
Copy link

I understand! Here's the issue reproduced: https://stackblitz.com/edit/svelte-kit-z4jvcg?file=src%2Froutes%2F%2Bpage.svelte

09:03:48 [vite-plugin-svelte] /home/projects/svelte-kit-z4jvcg/node_modules/svelte-tweakpane-ui/dist/control/CubicBezier.svelte:91:1 No scopable elements found in template. If you're using global styles in the style tag, you should move it into an external stylesheet file and import it in JS. See https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/faq.md#where-should-i-put-my-global-styles. 09:03:50 [vite] Error when evaluating SSR module /node_modules/three-inspect/dist/components/Tools/FreeCamera.svelte: failed to import "/node_modules/three-inspect/dist/components/Internal/CameraControls.svelte" |- Error: line must be greater than 0 (lines start at line 1) at originalPositionFor$1 (file:///home/projects/svelte-kit-z4jvcg/node_modules/vite/dist/node/chunks/dep-BKbDVx1T.js:10470:15)

@michealparks
Copy link
Member

Thanks for including an example! That's interesting. I'm not sure why, but I was able to fix the issue in your stackblitz by creating a new <Scene> component placed within <Canvas> and moving <Inspector> there. Since I don't have much time to investigate further I'll update the docs accordingly to make it clear that setup is required.

@supermoos
Copy link

Thanks for providing the workaround, however it only seems to work when I make the changes while having 'npm run dev' already going. If I restart the dev process it throws the same errors as above again.

@michealparks
Copy link
Member

Another workaround you could go for while I continue to investigate is to disable SSR in the part of you SvelteKit app that imports and renders the inspector:

// +page.ts
export let ssr = false

@michealparks
Copy link
Member

This should be fixed in v0.7.2. Let me know if it's still showing up for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants