From 690cf3b8690cefc6812bfa380f598e9b5b19f318 Mon Sep 17 00:00:00 2001 From: Mugen87 Date: Thu, 2 Jun 2022 10:01:14 +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 8000533a7c1f3e..f415209e83547d 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 8ab45747d6d8da..1ff08f472a2bbe 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 d2edcf22df7db9..c893b3cc1a73aa 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 ) {