pc.Vec4#data is not public API

I set several material properties for my shader, and some of them are based on Vec4 and Color settings that I expose in the editor.
So in my code I have:

this.material.setParameter('radius', this.corners.data);

but this raises several warnings like:

  • pc.Vec4#data is not public API and should not be used. Access vector components via their individual properties.
  • pc.Color#data is not public API and should not be used. Access color components via their individual properties.

Is there a better way to set the shader params without doing a new array every time like this:

this.material.setParameter('radius', new Float32Array([this.corners.x, this.corners.y, this.corners.z, this.corners.w]));

We removed data property and changed vec3 and color to use individual properties because it is more performant.

For this use-case you should create a member variable of type Float32Array and use that for your material parameter.

1 Like

Would be nice to have setParameter to accept directly a Color or a Vec type, but probably it wouldn’t be efficient.
In my case I will have to subscribe to the event of the property change in the components, so to update the Float32Array only when needed.