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 ProjectedMaterialdoes not update parent matrices, they are updated in this example.
I believe the problem is in the projection direction calculation here:
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).
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 thoughProjectedMaterial
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).