@@ -30,8 +30,11 @@ class CreateRectChange extends CreateGeomChange {
3030 this . rect = new Rect ( 0 , 0 )
3131 const material = new LinesMaterial ( 'circle' )
3232 material . baseColorParam . value = this . color
33- this . geomItem = new CustomGeom ( 'Rect' , this . rect , material )
33+ this . geomItem = new CustomGeom ( 'Rect' , this . rect , material , this . xfo )
3434 this . geomItem . pickableParam . value = false // At the conclusion of creation, we set selectable to true.
35+ if ( this . parentItem ) {
36+ this . parentItem . addChild ( this . geomItem )
37+ }
3538 }
3639
3740 /**
@@ -40,18 +43,28 @@ class CreateRectChange extends CreateGeomChange {
4043 * @param updateData - The updateData param.
4144 */
4245 update ( updateData : Record < any , any > ) : void {
43- if ( updateData . baseSize ) {
44- this . rect . sizeXParam . value = updateData . baseSize [ 0 ]
45- this . rect . sizeYParam . value = updateData . baseSize [ 1 ]
46+ if ( updateData . size ) {
47+ this . rect . sizeXParam . value = updateData . size [ 0 ]
48+ this . rect . sizeYParam . value = updateData . size [ 1 ]
4649 }
47- if ( updateData . tr ) {
48- const xfo = this . geomItem . localXfoParam . value
49- xfo . tr . fromJSON ( updateData . tr )
50- this . geomItem . localXfoParam . value = xfo
50+ if ( updateData . xfo ) {
51+ this . geomItem . globalXfoParam . value = updateData . xfo
5152 }
5253
5354 this . emit ( 'updated' , updateData )
5455 }
56+
57+ /**
58+ * Serializes change as a JSON object.
59+ *
60+ * @return - The return value.
61+ */
62+ toJSON ( ) : Record < any , any > {
63+ const j : Record < any , any > = super . toJSON ( )
64+ j . size = [ this . rect . sizeXParam . value , this . rect . sizeYParam . value ]
65+ j . xfo = this . geomItem . globalXfoParam . value . toJSON ( )
66+ return j
67+ }
5568}
5669
5770UndoRedoManager . registerChange ( 'CreateRectChange' , CreateRectChange )
0 commit comments