Git Product home page Git Product logo

Comments (4)

kalwalt avatar kalwalt commented on September 25, 2024

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?

from jsartoolkitnft.

anand-dotworld avatar anand-dotworld commented on September 25, 2024

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.

from jsartoolkitnft.

kalwalt avatar kalwalt commented on September 25, 2024

@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.

from jsartoolkitnft.

kalwalt avatar kalwalt commented on September 25, 2024

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.

from jsartoolkitnft.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.