[SOLVED] Vector data usage warning

Hello,

I would like to use the vector’s Float32Array directly (e.g. pc.Vec3().data). Is there a way to do it without the pesky console warning?

Vec3 no longer stores it’s data as a Float Array hence the warning.

Ah, I see. Thank you, @yaustar! The warning message only suggested that it is a private API, hence I thought I can still use it. I now see that it actaully creates a new Float32Array whenever I try to read that property:

So, if one wants to pass a vector to shader, the proper way would be the following:

var vector = new pc.Vec3(1, 2, 3);
var data = new Float32Array([vector.x, vector.y, vector.z]);
// Float32Array(3) [1, 2, 3]
2 Likes