简体   繁体   English

可以在three.js几何图形中使用Vector4吗?

[英]Can one use Vector4's in three.js geometry?

I'm currently getting to know the three.js library. 我目前正在了解three.js库。 The coordinates that are stored in a mesh's geometry are tuples (x,y,z). 存储在网格几何体中的坐标为元组(x,y,z)。 However, when doing affine transformations behind the scenes, the graphics card uses tuples (x,y,z,w) and encodes the transformations as 4x4-matrices. 但是,在后台进行仿射变换时,图形卡使用元组(x,y,z,w)并将变换编码为4x4矩阵。

Can I store vertices explicitly as tuples (x,y,z,w) in three.js? 我可以在three.js中将顶点显式存储为元组(x,y,z,w)吗?

I don't want the value of w to always be 1. (Yes, this is a slightly strange request, and I'm fully aware that (x,y,z,w) can always be rescaled so as to make w=1. However, the application that I have in mind requires that I store my vertices as 4-tuples and that I can set all 4 coordinates.) 我不希望w的值始终为1。(是的,这是一个有点奇怪的请求,我完全知道(x,y,z,w)可以随时重新缩放以使w = 1.但是,我想到的应用程序要求将顶点存储为4元组,并且可以设置所有4个坐标。)

I don't feel like digging into raw WebGL if I can use three.js. 如果我可以使用three.js,我不喜欢钻研原始WebGL。

I think you should be able to just do this... 我认为您应该能够做到这一点...

var positions = new THREE.Float32Attribute( triangles * 3, 4 );
var geometry = new THREE.BufferGeometry();
geometry.addAttribute( 'position', positions );

positions.array will then be an array like [ x, y, z, w, x, y, z, w, ... ] positions.array然后将是一个[ x, y, z, w, x, y, z, w, ... ]的数组

r67+ R67 +

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM