✅ Solved: Data Binding Image in Low Level WebGL2 API not working

SOLUTION:

The image property in Rive-Advanced is a function, not a property. Setting it removes the function but using imageProperty.value(image) fixes it. I’ve updated my example to work. Here’s the other post where I figured this out using the cat card example:

#✅ Solved: Image Binding Example not working with Low-Level


I’m updating the saved games in my menu with lists since before I had a set number of image assets. Before I was replacing the image by getting the asset with a custom asset loader and then setting the image when the save game loaded. This was working correctly. I now want to have an unlimited number of save files using list and image binding.

Each save game has a uInt8array attached so I can using the rive to decode the image. This was working when setting the image asset but not working when setting the value to the view model property.

I was using the example here which is in the high-level api:

Data Binding - Rive


Since I’m using the high-level, my code looks like this:

// asyncronously load the portrait image
                const portrait = viewModel.image('Portrait');
                
                var portraitBytes = save.data.playerPortrait;
                            if(portraitBytes != undefined) {
                                var imageArray = Object.entries(portraitBytes);
                                var uIntArray = new Uint8Array(imageArray.length);
                                for(var i = 0; i < imageArray.length; i++) {
                                    uIntArray[i] = imageArray[i][1];
                                }
                                if(uIntArray != undefined) {
                                    RiveRenderer.rive.decodeImage(uIntArray, (image) => {
                                        // override the player portait here
                                        console.log("Loaded portrait for save slot");
                                        // wrap image for appropriate value
                                        portrait.value = image;
                                        return true;
                                    });
                                } else {
                                    console.log("No image data found for save");
                                }
                            }

It doesn’t throw an error but it doesn’t show the image either. Any ideas? Is there an example for this in the low-level api?