|
@@ -375,6 +375,16 @@ class Object3D extends EventDispatcher {
|
|
|
*/
|
|
*/
|
|
|
this.userData = {};
|
|
this.userData = {};
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * The pivot point for rotation and scale transformations.
|
|
|
|
|
+ * When set, rotation and scale are applied around this point
|
|
|
|
|
+ * instead of the object's origin.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @type {?Vector3}
|
|
|
|
|
+ * @default null
|
|
|
|
|
+ */
|
|
|
|
|
+ this.pivot = null;
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1122,6 +1132,19 @@ class Object3D extends EventDispatcher {
|
|
|
|
|
|
|
|
this.matrix.compose( this.position, this.quaternion, this.scale );
|
|
this.matrix.compose( this.position, this.quaternion, this.scale );
|
|
|
|
|
|
|
|
|
|
+ const pivot = this.pivot;
|
|
|
|
|
+
|
|
|
|
|
+ if ( pivot !== null ) {
|
|
|
|
|
+
|
|
|
|
|
+ const px = pivot.x, py = pivot.y, pz = pivot.z;
|
|
|
|
|
+ const te = this.matrix.elements;
|
|
|
|
|
+
|
|
|
|
|
+ te[ 12 ] += px - te[ 0 ] * px - te[ 4 ] * py - te[ 8 ] * pz;
|
|
|
|
|
+ te[ 13 ] += py - te[ 1 ] * px - te[ 5 ] * py - te[ 9 ] * pz;
|
|
|
|
|
+ te[ 14 ] += pz - te[ 2 ] * px - te[ 6 ] * py - te[ 10 ] * pz;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
this.matrixWorldNeedsUpdate = true;
|
|
this.matrixWorldNeedsUpdate = true;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -1287,6 +1310,8 @@ class Object3D extends EventDispatcher {
|
|
|
object.matrix = this.matrix.toArray();
|
|
object.matrix = this.matrix.toArray();
|
|
|
object.up = this.up.toArray();
|
|
object.up = this.up.toArray();
|
|
|
|
|
|
|
|
|
|
+ if ( this.pivot !== null ) object.pivot = this.pivot.toArray();
|
|
|
|
|
+
|
|
|
if ( this.matrixAutoUpdate === false ) object.matrixAutoUpdate = false;
|
|
if ( this.matrixAutoUpdate === false ) object.matrixAutoUpdate = false;
|
|
|
|
|
|
|
|
// object specific properties
|
|
// object specific properties
|
|
@@ -1562,6 +1587,12 @@ class Object3D extends EventDispatcher {
|
|
|
this.quaternion.copy( source.quaternion );
|
|
this.quaternion.copy( source.quaternion );
|
|
|
this.scale.copy( source.scale );
|
|
this.scale.copy( source.scale );
|
|
|
|
|
|
|
|
|
|
+ if ( source.pivot !== null ) {
|
|
|
|
|
+
|
|
|
|
|
+ this.pivot = source.pivot.clone();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
this.matrix.copy( source.matrix );
|
|
this.matrix.copy( source.matrix );
|
|
|
this.matrixWorld.copy( source.matrixWorld );
|
|
this.matrixWorld.copy( source.matrixWorld );
|
|
|
|
|
|