SparkAR-无法在代码中更改材质的纹理? [英] SparkAR - can't change texture of material in code?

查看:106
本文介绍了SparkAR-无法在代码中更改材质的纹理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里,请确保在脚本的Promise.all中找到所有对象,材质和纹理,因为它们需要花费一些时间来加载.然后,我将材质设置为材质,并且不会绘制任何错误.但是,材料没有改变.

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?

推荐答案

如果没有错误显示,请检查您提到的名称是否区分大小写,以免出现某些原因.发出catch语句后,他们会看到"then"发生了什么部分

if there is no error showing do check the names u have mentioned its case sensitive so that might be some reason . put a catch statement and they seeing what's happening to the "then " part

这篇关于SparkAR-无法在代码中更改材质的纹理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆