I am attempting to run Three-Inspect in a plain ThreeJS project (plain javascript).
Whether I try to load this by import map (eg. using LiveServer add-on in Visual Studio Code) or Vite it does not work.
Utilization
My simple code to try to use this in my project is:
import { createInspector } from 'three-inspect'
import { Inspector } from 'three-inspect'
/**@type {Inspector}*/
var inspector;
function addInspector(){
inspector = createInspector({ scene, camera, renderer })
}
Errors
However, this fails no matter how I try to get Three-Inspect running in my project.
1) Import Map
In my index.html I have:
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@v0.163.0/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@v0.163.0/examples/jsm/",
"three-inspect": "https://cdn.jsdelivr.net/npm/three-inspect@0.4.5/+esm"
}
}
</script>
However, while such an approach works well for other packages, on running the application in Visual Studio LiveServer, I get the error:
Uncaught SyntaxError: The requested module 'https://cdn.jsdelivr.net/npm/three-inspect@0.4.5/+esm' doesn't provide an export named: 'createInspector'
I am not sure what this represents, but it does not appear to work.
2) Using Vite
I have also tried installing it in Vite with both commands:
npm i --save-dev three-inspect
npm i --save three-inspect
But when I run npx vite or npx vite build on the project, I get:
✘ [ERROR] Failed to resolve entry for package "@threlte/core". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." specifier in "@threlte/core" package [plugin vite:dep-pre-bundle]
A fix appears to be posted here for this identical error:
This is also posted as an error here:
A suggestion there as a workaround is:
I have fixed the issue by installing @sveltejs/vite-plugin-svelte with updating vite.config.js :
import { svelte } from '@sveltejs/vite-plugin-svelte';
export default defineConfig({
plugins: [..., svelte()],
})
But I am not sure where vite.config.js even is located on my system or whether this is the appropriate way this should be managed.
Based on the fix above, I presume we should not be getting this error.
Solution
Any help with either problem? Currently one cannot use Three-Inspect with any approach in a standard ThreeJS project based on both errors.
It looks like a great project and would be very helpful if working. I would greatly appreciate any further fix.
@michealparks as it appears you fixed this once before I'm wondering if you would be willing to take a look? Thanks for any help.
I am attempting to run Three-Inspect in a plain ThreeJS project (plain javascript).
Whether I try to load this by import map (eg. using LiveServer add-on in Visual Studio Code) or Vite it does not work.
Utilization
My simple code to try to use this in my project is:
Errors
However, this fails no matter how I try to get Three-Inspect running in my project.
1) Import Map
In my index.html I have:
However, while such an approach works well for other packages, on running the application in Visual Studio LiveServer, I get the error:
I am not sure what this represents, but it does not appear to work.
2) Using Vite
I have also tried installing it in Vite with both commands:
But when I run
npx viteornpx vite buildon the project, I get:A fix appears to be posted here for this identical error:
This is also posted as an error here:
A suggestion there as a workaround is:
But I am not sure where vite.config.js even is located on my system or whether this is the appropriate way this should be managed.
Based on the fix above, I presume we should not be getting this error.
Solution
Any help with either problem? Currently one cannot use Three-Inspect with any approach in a standard ThreeJS project based on both errors.
It looks like a great project and would be very helpful if working. I would greatly appreciate any further fix.
@michealparks as it appears you fixed this once before I'm wondering if you would be willing to take a look? Thanks for any help.