webarkit / jsartoolkitNFT

jsartolkitNFT is a smaller version of jsartoolkit5 with only NFT support
GNU Lesser General Public License v3.0
132 stars 25 forks source link

No effect when changing the near and far plane #95

Open j-era opened 3 years ago

j-era commented 3 years ago

Hey, i believe that i have become aware of an error concerning changing the near and far plane after camera initialization. When i change those after initialization (e.g. arControllerNft.setProjectionFarPlane(..)) the camera matrix will not be updated:

Seems the values are only taken into account in the setup method? https://github.com/webarkit/jsartoolkitNFT/blob/f6390101c2f98fb07ec42d95f73fc72da81028f4/emscripten/ARToolKitJS.cpp#L716 https://github.com/webarkit/jsartoolkitNFT/blob/f6390101c2f98fb07ec42d95f73fc72da81028f4/emscripten/ARToolKitJS.cpp#L514

I try to increase the far plane value, because the augmentation model gets lost when the tracking image is to far away from the camera, but it's still tracked (what i can read from the logs).

Did I get something wrong? Thanks a lot.

kalwalt commented 3 years ago

Hey, i believe that i have become aware of an error concerning changing the near and far plane after camera initialization. When i change those after initialization (e.g. arControllerNft.setProjectionFarPlane(..)) the camera matrix will not be updated:

Seems the values are only taken into account in the setup method?

https://github.com/webarkit/jsartoolkitNFT/blob/f6390101c2f98fb07ec42d95f73fc72da81028f4/emscripten/ARToolKitJS.cpp#L716

Yes i think that is only in setup. But the fact is we get the camera Matrix in the Worker and we send this value with a postmessage https://github.com/webarkit/jsartoolkitNFT/blob/f6390101c2f98fb07ec42d95f73fc72da81028f4/js/artoolkitNFT_ES6.worker.js#L41 that is readed in the threejs_worke_ES6r.js script in the onmessage: https://github.com/webarkit/jsartoolkitNFT/blob/f6390101c2f98fb07ec42d95f73fc72da81028f4/examples/threejs_worker_ES6.js#L85-L101

I think you modified the far plane in these files i think (or something similar i think).

https://github.com/webarkit/jsartoolkitNFT/blob/f6390101c2f98fb07ec42d95f73fc72da81028f4/emscripten/ARToolKitJS.cpp#L514

I try to increase the far plane value, because the augmentation model gets lost when the tracking image is to far away from the camera, but it's still tracked (what i can read from the logs).

Did I get something wrong? Thanks a lot.

But how much Dpi has your NFT Marker?

anand-dotworld commented 1 year ago

Hello, I am getting the same issue. My objects get clipped after a certain distance but the tracker can track the target. I want to increase the far plane or the clipping distance.

kalwalt commented 1 year ago

@anand-dotworld this depends not by the far plane of the jsartoolkitNFT camera but by two factors dpi of the NFT marker and the far clipping plane of you render engine Threee.js used in the render engine or what else.

kalwalt commented 1 year ago

I think when camera settings are changed it's needed to re-run the setCamera method https://github.com/webarkit/jsartoolkitNFT/blob/2bbc6b35db9b1faa8a121d57a436c7efa8fe0ce9/emscripten/ARToolKitJS.cpp#L413-L457 actually is only used in the setup method https://github.com/webarkit/jsartoolkitNFT/blob/2bbc6b35db9b1faa8a121d57a436c7efa8fe0ce9/emscripten/ARToolKitJS.cpp#L704-L716 so it's not available in the final Emscripten export, i will try to add this and see if it make the difference.