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

examples code #2

Open
kalwalt opened this issue Mar 15, 2020 · 8 comments
Open

examples code #2

kalwalt opened this issue Mar 15, 2020 · 8 comments

Comments

@kalwalt
Copy link

kalwalt commented Mar 15, 2020

Hi Andreas, i was testing your repo and i'm wondering if you have some example code to share, It will be very appreciated! 🙂

@kalwalt
Copy link
Author

kalwalt commented Mar 22, 2020

@andypotato i created this gist as a starting point, if you have other resources let me know.

@andypotato
Copy link
Owner

@kalwalt @MikiDi I have updated the documentation to better describe the interface. Examples will follow!

@kalwalt
Copy link
Author

kalwalt commented Apr 20, 2020

@andypotato great! Thank you very much!

@andypotato
Copy link
Owner

@kalwalt @MikiDi I pushed a very detailed example on how to use this library with Three.js here:

https://github.com/andypotato/artoolkit5-js-demo/

Also I have a bit of time now so I will implement the remaining NFT features and add a couple of demos.

@kalwalt
Copy link
Author

kalwalt commented Apr 25, 2020

Thank you @andypotato i will try it! and can't wait for NFT .... 😄

@andypotato
Copy link
Owner

Now that NFT markers are available more example code should be created. I'll add some examples to the demo repository but other contributions are welcome.

@felixniemeyer
Copy link

I just had a look at the demo repository because I have troubles with getting the transformation matrices right in portrait orientation.

The demo project unfortunately suffers from the same problem:
andypotato/artoolkit5-js-demo#29 (comment)

@felixniemeyer
Copy link

felixniemeyer commented Feb 11, 2023

I found a workaround which looks like this

// on every resize
      if(screenRatio < 1) {
        arController.orientation = 'portrait'
        mat4.mul(projectionMatrix, correction, cameraMatrix)
      } else {
        arController.orientation = 'landscape'
        mat4.copy(projectionMatrix, cameraMatrix)
      }

where the correction appied in case of portrait orientation is a 90 degree rotation around Z

  let correction = mat4.create()
  mat4.fromZRotation(correction, Math.PI / 2)

I think that compensates the rotation made when copying into the heap here:

if(this.orientation === 'portrait') {
this.ctx.translate(this.canvas.width, 0);
this.ctx.rotate(Math.PI / 2);
this.ctx.drawImage(sourceImage, 0, 0, this.canvas.height, this.canvas.width); // draw video
} else {

But yea, it adds to the complexity of this already quite complex topic of ar.
Shouldn't artoolkit be able to natively handle all kinds of resolutions from 640x480 to 480x640 and beyond?

Thank you for all your sweat and thoughts that have flown into this.

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

No branches or pull requests

3 participants