问题
I've here made sure to find all objects, Materials and Textures in the Promise.all
of my script given that they take time to load in. I then set my textures to my materials, and no errors are drawn. However, the materials do not change.
I can't find anything wrong with my code:
Promise.all([
//These take time to acquire..
Scene.root.findFirst('ipad-perfect'),
Scene.root.findFirst('iphone-perfect'),
Scene.root.findFirst('computer-perfect'),
Materials.findFirst('bg'),
Materials.findFirst('mutablescreen'),
Textures.findFirst('SUPERHOT-min')
]).then(function (results) {
const ipadPerfect = results[0];
const iphonePerfect = results[1];
const computerPerfect = results[2];
const bgMat = results[3];
const mutableScreen = results[4];
const superHotTexture = results[5];
var devicesRot = 0;
var gamesRot = 0;
// Get the timer ready
start();
function start() {
var texture = superHotTexture;
bgMat.diffuse = texture;
bgMat.emission = texture;
What am I doing wrong and how can I programmatically change the texture of a Material?
来源:https://stackoverflow.com/questions/62887649/sparkar-cant-change-texture-of-material-in-code