Browse Source

Revert "Core: Use `structuredClone()` when available. (#25535)"

This reverts commit cfe9eaf39440c7b5289b9b4d81bdb03e94065f3c.
Mr.doob 2 years ago
parent
commit
d57885abbf
5 changed files with 6 additions and 21 deletions
  1. 2 2
      src/core/BufferGeometry.js
  2. 1 2
      src/core/Object3D.js
  3. 1 2
      src/materials/Material.js
  4. 1 2
      src/textures/Texture.js
  5. 1 13
      src/utils.js

+ 2 - 2
src/core/BufferGeometry.js

@@ -8,7 +8,7 @@ import { Object3D } from './Object3D.js';
 import { Matrix4 } from '../math/Matrix4.js';
 import { Matrix3 } from '../math/Matrix3.js';
 import * as MathUtils from '../math/MathUtils.js';
-import { arrayNeedsUint32, deepClone } from '../utils.js';
+import { arrayNeedsUint32 } from '../utils.js';
 
 let _id = 0;
 
@@ -1069,7 +1069,7 @@ class BufferGeometry extends EventDispatcher {
 
 		// user data
 
-		this.userData = deepClone( source.userData );
+		this.userData = source.userData;
 
 		return this;
 

+ 1 - 2
src/core/Object3D.js

@@ -6,7 +6,6 @@ import { Euler } from '../math/Euler.js';
 import { Layers } from './Layers.js';
 import { Matrix3 } from '../math/Matrix3.js';
 import * as MathUtils from '../math/MathUtils.js';
-import { deepClone } from '../utils.js';
 
 let _object3DId = 0;
 
@@ -946,7 +945,7 @@ class Object3D extends EventDispatcher {
 		this.frustumCulled = source.frustumCulled;
 		this.renderOrder = source.renderOrder;
 
-		this.userData = deepClone( source.userData );
+		this.userData = JSON.parse( JSON.stringify( source.userData ) );
 
 		if ( recursive === true ) {
 

+ 1 - 2
src/materials/Material.js

@@ -1,7 +1,6 @@
 import { EventDispatcher } from '../core/EventDispatcher.js';
 import { FrontSide, NormalBlending, LessEqualDepth, AddEquation, OneMinusSrcAlphaFactor, SrcAlphaFactor, AlwaysStencilFunc, KeepStencilOp } from '../constants.js';
 import * as MathUtils from '../math/MathUtils.js';
-import { deepClone } from '../utils.js';
 
 let materialId = 0;
 
@@ -474,7 +473,7 @@ class Material extends EventDispatcher {
 
 		this.toneMapped = source.toneMapped;
 
-		this.userData = deepClone( source.userData );
+		this.userData = JSON.parse( JSON.stringify( source.userData ) );
 
 		return this;
 

+ 1 - 2
src/textures/Texture.js

@@ -14,7 +14,6 @@ import * as MathUtils from '../math/MathUtils.js';
 import { Vector2 } from '../math/Vector2.js';
 import { Matrix3 } from '../math/Matrix3.js';
 import { Source } from './Source.js';
-import { deepClone } from '../utils.js';
 
 let textureId = 0;
 
@@ -139,7 +138,7 @@ class Texture extends EventDispatcher {
 		this.unpackAlignment = source.unpackAlignment;
 		this.encoding = source.encoding;
 
-		this.userData = deepClone( source.userData );
+		this.userData = JSON.parse( JSON.stringify( source.userData ) );
 
 		this.needsUpdate = true;
 

+ 1 - 13
src/utils.js

@@ -68,16 +68,4 @@ function createElementNS( name ) {
 
 }
 
-function deepClone( value ) {
-
-	if ( typeof structuredClone === 'function' ) {
-
-		return structuredClone( value );
-
-	}
-
-	return JSON.parse( JSON.stringify( value ) );
-
-}
-
-export { arrayMin, arrayMax, arrayNeedsUint32, getTypedArray, createElementNS, deepClone };
+export { arrayMin, arrayMax, arrayNeedsUint32, getTypedArray, createElementNS };