Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No effect when changing the near and far plane #95

Open
j-era opened this issue Apr 29, 2021 · 4 comments
Open

No effect when changing the near and far plane #95

j-era opened this issue Apr 29, 2021 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@j-era
Copy link
Contributor

j-era commented Apr 29, 2021

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?

setCamera(id, cameraID);

arglCameraFrustumRH(&((arc->paramLT)->param), arc->nearPlane, arc->farPlane, arc->cameraLens);

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
Copy link
Member

kalwalt commented May 3, 2021

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?

setCamera(id, cameraID);

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

postMessage({ type: 'loaded', proj: JSON.stringify(cameraMatrix) })
that is readed in the threejs_worke_ES6r.js script in the onmessage:
worker.onmessage = function (ev) {
var msg = ev.data;
switch (msg.type) {
case "loaded": {
var proj = JSON.parse(msg.proj);
var ratioW = pw / w;
var ratioH = ph / h;
proj[0] *= ratioW;
proj[4] *= ratioW;
proj[8] *= ratioW;
proj[12] *= ratioW;
proj[1] *= ratioH;
proj[5] *= ratioH;
proj[9] *= ratioH;
proj[13] *= ratioH;
setMatrix(camera.projectionMatrix, proj);
break;

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

arglCameraFrustumRH(&((arc->paramLT)->param), arc->nearPlane, arc->farPlane, arc->cameraLens);

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?

@kalwalt kalwalt added the question Further information is requested label May 3, 2021
@kalwalt kalwalt self-assigned this May 3, 2021
@anand-dotworld
Copy link

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
Copy link
Member

kalwalt commented Dec 19, 2022

@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
Copy link
Member

kalwalt commented Feb 11, 2023

I think when camera settings are changed it's needed to re-run the setCamera method

int setCamera(int id, int cameraID) {
if (arControllers.find(id) == arControllers.end()) { return -1; }
arController *arc = &(arControllers[id]);
if (cameraParams.find(cameraID) == cameraParams.end()) { return -1; }
arc->param = cameraParams[cameraID];
if (arc->param.xsize != arc->width || arc->param.ysize != arc->height) {
ARLOGw("*** Camera Parameter resized from %d, %d. ***\n", arc->param.xsize, arc->param.ysize);
arParamChangeSize(&(arc->param), arc->width, arc->height, &(arc->param));
}
// ARLOGi("*** Camera Parameter ***\n");
// arParamDisp(&(arc->param));
deleteHandle(arc);
if ((arc->paramLT = arParamLTCreate(&(arc->param), AR_PARAM_LT_DEFAULT_OFFSET)) == NULL) {
webarkitLOGe("setCamera(): Error: arParamLTCreate.");
return -1;
}
// ARLOGi("setCamera(): arParamLTCreated\n..%d, %d\n", (arc->paramLT->param).xsize, (arc->paramLT->param).ysize);
// setup camera
if ((arc->arhandle = arCreateHandle(arc->paramLT)) == NULL) {
webarkitLOGe("setCamera(): Error: arCreateHandle.");
return -1;
}
// AR_DEFAULT_PIXEL_FORMAT
int set = arSetPixelFormat(arc->arhandle, arc->pixFormat);
arc->ar3DHandle = ar3DCreateHandle(&(arc->param));
if (arc->ar3DHandle == NULL) {
webarkitLOGe("setCamera(): Error creating 3D handle");
return -1;
}
arglCameraFrustumRH(&((arc->paramLT)->param), arc->nearPlane, arc->farPlane, arc->cameraLens);
arc->kpmHandle = createKpmHandle(arc->paramLT);
return 0;
}
actually is only used in the setup method
int setup(int width, int height, int cameraID) {
int id = gARControllerID++;
arController *arc = &(arControllers[id]);
arc->id = id;
arc->width = width;
arc->height = height;
arc->videoFrameSize = width * height * 4 * sizeof(ARUint8);
arc->videoFrame = (ARUint8*) malloc(arc->videoFrameSize);
arc->videoLuma = (ARUint8*) malloc(arc->videoFrameSize / 4);
setCamera(id, cameraID);
so it's not available in the final Emscripten export, i will try to add this and see if it make the difference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants