Ambigious docs on "mul" vs "mul2"

This is more of a (I assume) a docs issue than a coding issue, so I thought I’d post in Suggestions & Feedback.

If you look up mul in the API reference, you’ll see it has the same description as mul2.

I’m confused because I’d assume, following the example of add & add2, and sub & sub2, that one would do the operation in place while the other would just return the result. But it seems like they both set the result to the vector it’s called on? Does this seem confusing to anyone else?

Oops. We need to fix that :slight_smile:


This will multiply vec_1 with vec_2 and set the result in vec_1.

vec_1.mul2(vec_2, vec_3);

This will multiply vec_2 with vec_3 and set the result in vec_1.

Yes, this is correct as we avoid allocating as much as we can in the engine for performance reasons. All the add, add2, sub, sub2 also return the vector it was called on to allow for chaining so you can do:


Oh, thanks for the explanation Steven!

Is there a way for the community to contribute fixes to the docs/api reference? I didn’t see a docs repo on the PlayCanvas Github.

The coding API is generated from the comments in the main engine repo:

And the documentation is in a separate repo here:

Please feel free to contribute changes there!