Change sphere material

Hi,
I need to chnage material of sphere in 360 lookaround project by script. Any help pls?
Overview | Dashboard | 360 lookaround camera | PlayCanvas | 3D HTML5 & WebGL Game Engine

Hi @Lukas_Zahumensky,

Here is some sample code that finds a material asset by its name (make sure the name matches) and assigns it to the pSphere1 model.

const material = this.app.assets.find('My 360 Material');
if(material){
   const sphereEntity = this.app.root.findByName('pSphere1');
   sphereEntity.render.meshInstances[0].material = material.resource;
}
2 Likes

Hi @Leonidas thank you!