是否可以在 THREE.BufferGeometry 中使用 Float64Array 而不是 Float32Array

Is it possible to use Float64Array instead of Float32Array in THREE.BufferGeometry

我在使用 BufferGeometry 时遇到了一些问题,因为它使用 Float32Array 来指定位置。我需要绘制的值(使用 THREE.Points )是很大的数字,例如“2732124.760877”,并且在使用 Float32Array 时我失去了大部分精度,而当我尝试使用 Float64Array 时,绘图变得一团糟。有没有一种方法可以使用 Float64Array 而不是 Float32Array。

如果您想查看从 Float32Array 更改为 Float64Array 时会发生什么,请尝试在以下 jsfiddle(第 43 行)中将 Float32Array 更改为 Float64Array

buffer_geometry.addAttribute( 'position', new THREE.BufferAttribute( new Float64Array(lines * 3), 3 ));

buffer_geometry.addAttribute( 'color', new THREE.BufferAttribute( new Float32Array(lines * 3), 3 ));

http://jsfiddle.net/pulasthi/sr3r92hy/1/

不,看WebGLRenderer 实现

解析几何属性时,它会检查此条件

else if ( array instanceof Float64Array ) {
        console.warn("Unsupported data buffer format: Float64Array");
}

WebGL 不提供传递双精度 64 位数字数组的方法。 如果你真的需要那个精度并且你的 GPU 支持双精度数字

您可以通过某种方式一点一点地传递您创建的 2 个 32 位数字,然后在着色器中将它们转换为双精度数,但我从未尝试过这样的事情..