Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Three.js 三个js纹理偏移不更新_Three.js - Fatal编程技术网

Three.js 三个js纹理偏移不更新

Three.js 三个js纹理偏移不更新,three.js,Three.js,我目前正在尝试创建一个使用datatexture着色的网格,我的初始着色显示得很好,但现在我的下一个目标是沿y轴偏移纹理。非常类似于这个例子 如何创建纹理/网格: this.colorTexture = new DataTexture(colors, this.frameWidth, frameCount, RGBFormat, FloatType, UVMapping, RepeatWrapping, RepeatWrapping); const material = new Me

我目前正在尝试创建一个使用datatexture着色的网格,我的初始着色显示得很好,但现在我的下一个目标是沿y轴偏移纹理。非常类似于这个例子

如何创建纹理/网格:

this.colorTexture = new DataTexture(colors, this.frameWidth, frameCount, RGBFormat, FloatType, UVMapping, RepeatWrapping, RepeatWrapping);

    const material = new MeshBasicMaterial({
        side: FrontSide,
        vertexColors: true,
        wireframe: false,
        map: this.colorTexture
    });
    
    this.mesh = new Mesh(geometry, material);
如何尝试使用偏移设置纹理动画:

    this.mesh.material.map.offset.y -= 0.001;
    this.mesh.material.map.needsUpdate = true;
    this.mesh.material.needsUpdate = true;
    this.mesh.needsUpdate = true;
我已经确认,我用来尝试偏移的函数在每个动画帧期间都被调用,但是可视化本身并没有设置动画或显示除了我写入纹理的颜色的初始位置之外的变化。
非常感谢您的帮助:)

只要设置为
true
(这也是默认值),纹理的uv变换矩阵就会自动更新。您只需调节
纹理偏移量即可。无需设置任何
needsUpdate
标志(
Mesh.needsUpdate
无论如何都不存在)


最好严格遵守示例中的代码。如果这个代码不起作用,请用一个生动的例子来演示这个问题。

谢谢你的回应,我在这个代码笔中重新创建了一个问题,在那里我生成了一个几何/网格非常相似,并添加到纹理中间的一条直线上,这条线应该沿着Y轴移动并最终环绕。几何体没有
uv
属性。如果没有纹理坐标,你就不能使用纹理。对UV进行了更多的阅读,为我的几何体生成了一组UV,效果很好!非常感谢你。对于那些遇到类似问题的人,这里是我的固定代码。