Closed ketourneau closed 1 year ago
And yet your code works in an itowns example. The error appears when importing fragment shaders (which is done in the point clouds shaders in itowns). I'm not familiar with vite but maybe it's not supported with vite and you need to use a plugin like this one ?
I manage to reproduce your issue locally. From the warning on the console, it seems that Multiple instances of Three.js [are] being imported
.
Three.js glsl prepocessor resolves include directives from the ShaderChunk object. When imported, itowns appends its own "chunks" of glsl (e.g. itowns/WebGL2_pars_vertex
) to its three's instance ShaderChunk
. If your project and itowns import different instances of three, such chunks would not be available to your project's three instance leading to such error.
I suspect that vite, when bundling, duplicates the three
dependency.
We try to use itowns in a vite project to display potree point cloud but we got error:
Error appears when we pass custom renderer to itowns view.
I made a codesanbox to reproduce the issue here