Loading a texture remotely

Trying out PlayCanvas for the first time, and very impressed at how fast it is to get started!

I’d like to load a texture remotely and assign it to a primitive’s material(?) - I’m not sure how to go about that. Please help. Thanks!

Scriptwise, I’ve found pc.gfx.Texture and such, but I am not sure how the texels and materials work as components of a cube primitive.


Sorry, took a little while to respond to this…

Currently you can’t modify the material on a primitive. We’re going to be fixing this soon. But at the moment the best way to achieve this is to export a simple primitive from Blender or 3DS Max etc. And then import that as an asset. You can then edit the material by selecting the model in the design view and then clicking again on material that you want to edit. You’ll see the Material Editor on the right.

Maybe @will can talk you through modifying materials via scripts?

Hi there!

Here’s an example that loads a Google Maps image tile:


Here’s the accompanying project:


Here’s the script that does the work:


Note that we’ll soon be updating primitive component to support material assignment so the code might have to change a little, but it’ll work fine for now. :slight_smile: Also, I wasn’t sure what you meant by ‘remotely’. I thought you might be asking about loading images for textures from other domains (cross origin). See here for details on that:


Anyway, if you just want to load images you’ve uploaded to your asset list in your PlayCanvas project, let me know and I’ll tweak the code to show how that’s done.

1 Like