three-projected-material icon indicating copy to clipboard operation
three-projected-material copied to clipboard

projectionDirection seems to be incorrect in some cases

Open trusktr opened this issue 3 years ago • 1 comments

Continuing #41, here is a simple reproduction of the issue:

https://codepen.io/trusktr/pen/xxYYrYj

Note that the projection should cover the whole yellow circle (from the camera's perspective) but it comes in from the side.

Note that I called camera.updateWorldMatrix(true, true) manually, so even though ProjectedMaterial does not update parent matrices, they are updated in this example.

I believe the problem is in the projection direction calculation here:

https://github.com/marcofugaro/three-projected-material/blob/29099152d9775a5007fa5296d7f79540967fa519/src/ProjectedMaterial.js#L207-L214

Namely when both the camera and target object are children, and both not at the origin of the scene.


I've been fixing some things in my fork, although I haven't fixed this one yet. https://github.com/lume/three-projected-material

To save you time looking at my fork, everything before this commit is the same (including PRs in your repo) although I updated examples to exercise the code in more ways, and the only difference is that the code is TypeScript. From that commit and going forward are actual feature changes/fixes that are not in your repo (yet).

trusktr avatar May 29 '22 00:05 trusktr

Hi @marcofugaro. Have a chance to take a look at this?

trusktr avatar Aug 04 '22 06:08 trusktr

Fixed in v2.2.1, the parent was not taking into consideration.

marcofugaro avatar Jan 30 '23 18:01 marcofugaro