hiukim / mind-ar-js

Web Augmented Reality. Image Tracking, Face Tracking. Tensorflow.js
MIT License
2.24k stars 417 forks source link

Face tracking: pass through preserveDrawingBuffer prop to WebGLRenderer #242

Open etekweb opened 2 years ago

etekweb commented 2 years ago

Used for face tracking with Three.js Face Mesh.

Setting this property to true lets the rendered canvas be redrawn, allowing for screenshots of the face mesh. In my case, this is done with html2canvas. If the property is not set to true, html2canvas is not able to capture it.

Since this can theoretically lead to degraded performance, it should be an optional property. Therefore, in this implementation, it is an optional property read into the constructor for MindARThree.

hiukim commented 1 year ago

Hi Thanks for the PR! and sorry about the very late reply.

How about just calling mindarThree.renderer.preserveDrawingBuffer = true after you instantiate mindarThree.

I'm not very convinced it's a necessary change to MindAR. If we are to support that, I guess a more generic way is to add a parameter rendererParams in the constructor, which will pass along to the renderer constructor. So we can put anything including preserveDrawingBuffer as a property of rendererParams

etekweb commented 1 year ago

Hi! Sorry for the late reply on my end as well.

I just tried switching to instead calling mindarThree.renderer.preserveDrawingBuffer = true after instantiating mindarThree, and it did not work. When I set preserveDrawingBuffer that way, it does not include the face mesh in the screenshot (same thing happens if I don't set preserveDrawingBuffer at all).

TomDDH commented 7 months ago

add preserveDrawingBuffer as option for the renderer is best way for screenshot. thanks.