Vec3.angle()

How can I add a method to calculate the angle in degress between any two vectors?

For example:

const v0 = new pc.Vec3();
const v1 = new pc.Vec3();
const angle = Vec3.angle(v0, v1);

or

const angle = v0.angle(v1);

Couldn’t find any information on how to do this.

Create a new file in the Editor with the following content:

(function() {
    pc.Vec3.prototype.angle = function (v1) {
        // Add code here
    };
})();

And change the loading of the script asset to be ‘After Engine’

Then you can later do:

const angle = v0.angle(v1);