SparkAR - can't change texture of material in code?

三世轮回 提交于 2020-07-23 06:40:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!