Issues adapting Zappar's script

I’ve been working on a specific project involving using a third-party API. After talking a while with @George I received a snippet of code that should help me, but unfortunately it seems like I’m missing an important library or something.

When I launch it on desktop, the console gives me an error regarding Z.DataTexture.toArrayBuffer():

Uncaught TypeError: DataTexture.toArrayBuffer is not a function
    at eval (wip:28)
    at zappar._device._processSnapShotToTextureCallBack (zappar.js:1)
    at zappar._device._message (zappar.js:1)
    at Object.zappar.msg (zappar.js:1)
    at <anonymous>:1:8
    at WebFrame.(/C:/Users/meneg/AppData/Local/Programs/ZapWorks-Studio/resources/app/zapparembed/data/js/anonymous function) [as executeJavaScript] (C:\Users\meneg\AppData\Local\Programs\ZapWorks-Studio\resources\electron.asar\renderer\api\web-frame.js:56:27)
    at resolve (C:\Users\meneg\AppData\Local\Programs\ZapWorks-Studio\resources\electron.asar\renderer\web-frame-init.js:15)
    at new Promise (<anonymous>)
    at EventEmitter.ipcRenderer.on (C:\Users\meneg\AppData\Local\Programs\ZapWorks-Studio\resources\electron.asar\renderer\web-frame-init.js:14)
    at EventEmitter.emit (events.js:182)

I have no idea what causes this to not work, especially because it looks like Zappar’s missing a definition for what a DataTexture is or DataTexture is missing the toArrayBuffer() function.

I also encountered issues with other parts of the same code, specifically a line assigning the image’s format before sending it to the API:
format: (<any>Z).DataTexture.ImageFormat.jpg,

saying that it doesn’t recognize “ImageFormat.jpg”

I’m thoroughly lost. All I wanted to do is take a photo and remove the photo’s background using any sort of segmentation and it seems I’ve stumbled upon an iceberg of an issue.

Please help :frowning:

Hi @menegonmaciej,

I’ve just responded to your support email. This functionality will only work in the web browser. Please could you try launching it on a mobile device in the browser?


Hi! Thanks for the response :slight_smile:
I didn’t expect it to only work in WebAR but it seems to be the case. Now I just have to get the third party API working, so this topic is solved.

Thanks again :slight_smile:

1 Like

Hey @menegonmaciej , have you been able to make it work? I am sending the image in base64 to the backend but I am not being able to convert it into an image again :frowning: