فهرست منبع

Object3D: Honor `up` in `toJSON()` and `ObjectLoader`. (#25687)

Michael Herzog 2 سال پیش
والد
کامیت
794bbb02ac
3فایلهای تغییر یافته به همراه10 افزوده شده و 3 حذف شده
  1. 1 0
      src/core/Object3D.js
  2. 2 0
      src/loaders/ObjectLoader.js
  3. 7 3
      test/unit/src/core/Object3D.tests.js

+ 1 - 0
src/core/Object3D.js

@@ -718,6 +718,7 @@ class Object3D extends EventDispatcher {
 
 		object.layers = this.layers.mask;
 		object.matrix = this.matrix.toArray();
+		object.up = this.up.toArray();
 
 		if ( this.matrixAutoUpdate === false ) object.matrixAutoUpdate = false;
 

+ 2 - 0
src/loaders/ObjectLoader.js

@@ -963,6 +963,8 @@ class ObjectLoader extends Loader {
 
 		}
 
+		if ( data.up !== undefined ) object.up.fromArray( data.up );
+
 		if ( data.castShadow !== undefined ) object.castShadow = data.castShadow;
 		if ( data.receiveShadow !== undefined ) object.receiveShadow = data.receiveShadow;
 

+ 7 - 3
test/unit/src/core/Object3D.tests.js

@@ -1261,6 +1261,7 @@ export default QUnit.module( 'Core', () => {
 			a.castShadow = true;
 			a.receiveShadow = true;
 			a.userData[ 'foo' ] = 'bar';
+			a.up.set( 1, 0, 0 );
 
 			child.uuid = '5D4E9AE8-DA61-4912-A575-71A5BE3D72CD';
 			childChild.uuid = 'B43854B3-E970-4E85-BD41-AAF8D7BFA189';
@@ -1294,11 +1295,14 @@ export default QUnit.module( 'Core', () => {
 									'uuid': 'B43854B3-E970-4E85-BD41-AAF8D7BFA189',
 									'type': 'Object3D',
 									'layers': 1,
-									'matrix': [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]
+									'matrix': [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ],
+									'up': [ 0, 1, 0 ]
 								}
-							]
+							],
+							'up': [ 0, 1, 0 ]
 						}
-					]
+					],
+					'up': [ 1, 0, 0 ]
 				}
 			};