Skip to content

Commit

Permalink
toArray/fromArray fixes (#7318)
Browse files Browse the repository at this point in the history
* Fixed examples for toArray in vec2 and vec4

* Overloaded methods with ArrayBufferView
  • Loading branch information
kpal81xd authored Jan 29, 2025
1 parent 6b66a27 commit be27bc1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/core/math/vec2.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ class Vec2 {
/**
* Set the values of the vector from an array.
*
* @param {number[]} arr - The array to set the vector values from.
* @param {number[]|ArrayBufferView} arr - The array to set the vector values from.
* @param {number} [offset] - The zero-based index at which to start copying elements from the
* array. Default is 0.
* @returns {Vec2} Self for chaining.
Expand Down Expand Up @@ -677,13 +677,13 @@ class Vec2 {
/**
* Converts the vector to an array.
*
* @param {number[]} [arr] - The array to populate with the color components. If not specified,
* @param {number[]|ArrayBufferView} [arr] - The array to populate with the color components. If not specified,
* a new array is created.
* @param {number} [offset] - The zero-based index at which to start copying elements to the
* array. Default is 0.
* @returns {number[]} The vector as an array.
* @returns {number[]|ArrayBufferView} The vector as an array.
* @example
* const v = new pc.Vec3(20, 10);
* const v = new pc.Vec2(20, 10);
* // Outputs [20, 10]
* console.log(v.toArray());
*/
Expand Down
6 changes: 3 additions & 3 deletions src/core/math/vec3.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ class Vec3 {
/**
* Set the values of the vector from an array.
*
* @param {number[]} arr - The array to set the vector values from.
* @param {number[]|ArrayBufferView} arr - The array to set the vector values from.
* @param {number} [offset] - The zero-based index at which to start copying elements from the
* array. Default is 0.
* @returns {Vec3} Self for chaining.
Expand Down Expand Up @@ -695,11 +695,11 @@ class Vec3 {
/**
* Converts the vector to an array.
*
* @param {number[]} [arr] - The array to populate with the color components. If not specified,
* @param {number[]|ArrayBufferView} [arr] - The array to populate with the color components. If not specified,
* a new array is created.
* @param {number} [offset] - The zero-based index at which to start copying elements to the
* array. Default is 0.
* @returns {number[]} The vector as an array.
* @returns {number[]|ArrayBufferView} The vector as an array.
* @example
* const v = new pc.Vec3(20, 10, 5);
* // Outputs [20, 10, 5]
Expand Down
8 changes: 4 additions & 4 deletions src/core/math/vec4.js
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ class Vec4 {
/**
* Set the values of the vector from an array.
*
* @param {number[]} arr - The array to set the vector values from.
* @param {number[]|ArrayBufferView} arr - The array to set the vector values from.
* @param {number} [offset] - The zero-based index at which to start copying elements from the
* array. Default is 0.
* @returns {Vec4} Self for chaining.
Expand Down Expand Up @@ -659,13 +659,13 @@ class Vec4 {
/**
* Converts the vector to an array.
*
* @param {number[]} [arr] - The array to populate with the color components. If not specified,
* @param {number[]|ArrayBufferView} [arr] - The array to populate with the color components. If not specified,
* a new array is created.
* @param {number} [offset] - The zero-based index at which to start copying elements to the
* array. Default is 0.
* @returns {number[]} The vector as an array.
* @returns {number[]|ArrayBufferView} The vector as an array.
* @example
* const v = new pc.Vec3(20, 10, 5, 1);
* const v = new pc.Vec4(20, 10, 5, 1);
* // Outputs [20, 10, 5, 1]
* console.log(v.toArray());
*/
Expand Down

0 comments on commit be27bc1

Please sign in to comment.