From 710309cb4fddeb303b5b004d0d1d21a2f1c4eb48 Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Fri, 3 Jun 2022 10:01:17 +0200 Subject: [PATCH] Vector*: Add toJSON() methods. --- src/math/Vector2.js | 6 ++++++ src/math/Vector3.js | 6 ++++++ src/math/Vector4.js | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/src/math/Vector2.js b/src/math/Vector2.js index 8000533a7c1f3..f415209e83547 100644 --- a/src/math/Vector2.js +++ b/src/math/Vector2.js @@ -434,6 +434,12 @@ class Vector2 { } + toJSON() { + + return { x: this.x, y: this.y }; + + } + fromBufferAttribute( attribute, index, offset ) { if ( offset !== undefined ) { diff --git a/src/math/Vector3.js b/src/math/Vector3.js index 8ab45747d6d8d..1ff08f472a2bb 100644 --- a/src/math/Vector3.js +++ b/src/math/Vector3.js @@ -696,6 +696,12 @@ class Vector3 { } + toJSON() { + + return { x: this.x, y: this.y, z: this.z }; + + } + fromBufferAttribute( attribute, index, offset ) { if ( offset !== undefined ) { diff --git a/src/math/Vector4.js b/src/math/Vector4.js index d2edcf22df7db..c893b3cc1a73a 100644 --- a/src/math/Vector4.js +++ b/src/math/Vector4.js @@ -622,6 +622,12 @@ class Vector4 { } + toJSON() { + + return { x: this.x, y: this.y, z: this.z, w: this.w }; + + } + fromBufferAttribute( attribute, index, offset ) { if ( offset !== undefined ) {