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 Threejs";geometry.colorsenedupdate=true“;从r72开始就坏了?_Three.js - Fatal编程技术网

Three.js Threejs";geometry.colorsenedupdate=true“;从r72开始就坏了?

Three.js Threejs";geometry.colorsenedupdate=true“;从r72开始就坏了?,three.js,Three.js,因为r72我不能更新几何体顶点的颜色,这是一个已知的问题还是我遗漏了什么 以下代码在r71中有效,但在r72/73中无效 updateVertexColors: function(geometry) { var faceIndices = ['a', 'b', 'c', 'd']; for(var i = 0; i < geometry.faces.length; i++) { var f = geometr

因为r72我不能更新几何体顶点的颜色,这是一个已知的问题还是我遗漏了什么

以下代码在r71中有效,但在r72/73中无效

 updateVertexColors: function(geometry) {
            var faceIndices = ['a', 'b', 'c', 'd'];
            for(var i = 0; i < geometry.faces.length; i++) {
                var f = geometry.faces[i];
                var n = (f instanceof THREE.Face3) ? 3 : 4;
                for(var j = 0; j < n; j++) {
                    var vertexIndex = f[faceIndices[j]];
                    var p = geometry.vertices[vertexIndex];
                    var color = this.lut.getColor(Math.abs(p.x));
                    f.vertexColors[j] = color;
                }
            }
            geometry.colorsNeedUpdate = true;
        },
updateVertexColor:函数(几何体){
var FaceIndex=['a'、'b'、'c'、'd'];
对于(变量i=0;i
颜色已正确指定,但不会在渲染时更新


谢谢。

如果您在
THREE.Geometry
上设置
ColorsEndUpdate
——或者设置任何
needsUpdate
标志——并且它似乎不起作用,请确保您没有像这样重新分配值:

face.vertexColors[ j ] = color;
相反,请执行以下操作:

face.vertexColors[ j ].copy( color ); // or use .set(), .setHex, etc.
这可能是库中的错误或限制


three.js r.73

如果您正在
three.Geometry
上设置
colorsenedupdate
——或者设置任何
needsUpdate
标志——并且它似乎不起作用,请确保您没有像这样重新分配值:

face.vertexColors[ j ] = color;
相反,请执行以下操作:

face.vertexColors[ j ].copy( color ); // or use .set(), .setHex, etc.
这可能是库中的错误或限制

three.js r.73

这一个对我有用(更新为随机颜色):

这一款适合我(更新为随机颜色):


尝试
f.vertexColors[j].复制(颜色)非常感谢!这就解决了问题。试试f.vertexColors[j]。复制(颜色)非常感谢!这解决了问题。您可以指定一种随机颜色,如下所示:
color.setHex(Math.random()*0xffffff)
您可以像这样指定随机颜色:
color.setHex(Math.random()*0xffffff)