lume / three-meshline

Mesh-based replacement for `THREE.Line` to allow lines thicker than 1 pixel and other features.
https://docs.lume.io/three-meshline/
MIT License
42 stars 4 forks source link

Fix shader ERROR: 0:155: 'isPerspectiveMatrix' : no matching overloaded function found #15

Closed Matheos96 closed 2 months ago

Matheos96 commented 8 months ago

Fixes #14.

See related issue above.

I am not sure why, but I was only able to reproduce the problem in a larger project of ours where we use a lot of typescript files with Three.JS + esbuild. I tried to reproduce in a small test Three.js project with typescript and esbuild but I could not reproduce it...

Either way, I found the following OLD GH issue on the original MeshLine project for this very issue https://github.com/spite/THREE.MeshLine/issues/123

The fix is rather simple, adding the #include <common> line to the top of the vertex shader solves the issue. Even if no issue ever was, I don't think this introduces anything but benefits? Correct me if I am wrong. At least it solves our problem.

Currently we are working around this with the following code:

const lineMat = new MeshLineMaterial({
            useMap: false,
            color: new THREE.Color(color),
            opacity: 1,
            lineWidth: 10,
            sizeAttenuation: false,
            resolution: resolutionReference
        } as THREE.ShaderMaterialParameters & MeshLineMaterial);

lineMat.vertexShader = "#include <common>\n" + lineMat.vertexShader; // Fix weird bug with vertex shader

Could this finally be merged to this fork? It was seemingly never merged in the original before the project died.