pc.script.attribute("indexN","number",0);
pc.script.attribute("cubeMaps","asset",[],{type:"cubemap"});
pc.script.attribute("meshMat","asset",[],{type:"material"});
pc.script.create('hander', function (app) {
// Creates a new Hander instance
var Hander = function (entity) {
this.entity = entity;
};
Hander.prototype = {
// Called once after all resources are loaded and before the first update
initialize: function () {
this.nMat=app.assets.get(this.meshMat[0]).resource;
},
// Called every frame, dt is time in seconds since last update
update: function (dt) {
if(this.indexN%2===0){
var cm=app.assets.get(this.cubeMaps[0]).resource;
app.scene.skybox=cm;
this.nMat.cubeMap=cm;
//console.log(this.nMat.cubeMap.name);
}else{
var cm1=app.assets.get(this.cubeMaps[1]).resource;
app.scene.skybox=cm1;
this.nMat.cubeMap=cm1;
//console.log(this.nMat.cubeMap.name);
}
}
};
return Hander;
});
Here are some helpful threads
Thank you very much!
I forget update the material:
this.nMat.cubeMap=cm1;
this.nMat.update();
I am a beginner,any answer is helpful for me .
Thanks again!