1- import { Euler , Quaternion , Vector3 } from 'three' ;
21import { v4 } from 'uuid' ;
32import { drawProgressionPointGraph , GraphType } from '../../../views/animator/logic/ProgressionPointGraph' ;
43import { readFromClipboard , writeToClipboard } from '../../clipboard/Clipboard' ;
@@ -21,11 +20,6 @@ const kfmap_position = "pos_"
2120const kfmap_rotation = "rot_"
2221const kfmap_cubegrow = "cg_"
2322
24- const tempVec = new Vector3 ( )
25- const tempQuat = new Quaternion ( )
26- const tempEuler = new Euler ( )
27-
28- let debug = false
2923
3024type RootDataSectionType = {
3125 section_name : "root_data" ,
@@ -36,7 +30,13 @@ type RootDataSectionType = {
3630 keyframe_layers : readonly { layerId : number } [ ] ,
3731 propertiesMode : "local" | "global" ,
3832 time : number ,
39- [ k : `${typeof skeletal_export_named } _${string } `] : string
33+
34+ loop_exists : boolean ,
35+ loop_start : number ,
36+ loop_end : number ,
37+ loop_duration : number ,
38+
39+ [ k : `${typeof skeletal_export_named } _${string } `] : string ,
4040 }
4141}
4242
@@ -101,7 +101,7 @@ export default class DcaAnimation extends AnimatorGumballConsumer {
101101 readonly playing = new LO ( false , this . onDirty )
102102 displayTimeMatch : boolean = true
103103
104- readonly keyframeData : KeyframeLoopData
104+ readonly loopData : KeyframeLoopData
105105 readonly keyframeLayers = new LO < readonly KeyframeLayerData [ ] > ( [ ] , this . onDirty )
106106
107107 readonly scroll = new LO ( 0 , this . onDirty )
@@ -137,14 +137,35 @@ export default class DcaAnimation extends AnimatorGumballConsumer {
137137
138138 this . name = new LO ( name , this . onDirty ) . applyToSection ( this . _section , "name" )
139139 this . project = project
140- this . keyframeData = new KeyframeLoopData ( )
140+ this . loopData = new KeyframeLoopData ( )
141141 this . animatorGumball = new AnimatorGumball ( project )
142142 this . time . addListener ( value => {
143143 if ( this . displayTimeMatch ) {
144144 this . displayTime . value = value
145145 }
146146 } )
147147
148+ this . loopData . exists . applyToSection ( this . _section , "loop_exists" ) . addListener ( this . onDirty )
149+ this . loopData . start . applyToSection ( this . _section , "loop_start" ) . addListener ( this . onDirty )
150+ this . loopData . end . applyToSection ( this . _section , "loop_end" ) . addListener ( this . onDirty )
151+ this . loopData . duration . applyToSection ( this . _section , "loop_duration" ) . addListener ( this . onDirty )
152+
153+ this . loopData . start . addPreModifyListener ( ( value , _ , naughtyModifyValue ) => {
154+ if ( value > this . loopData . end . value ) {
155+ const end = this . loopData . end . value
156+ this . loopData . end . value = value
157+ naughtyModifyValue ( end )
158+ }
159+ } )
160+
161+ this . loopData . end . addPreModifyListener ( ( value , _ , naughtyModifyValue ) => {
162+ if ( value < this . loopData . start . value ) {
163+ const start = this . loopData . start . value
164+ this . loopData . start . value = value
165+ naughtyModifyValue ( start )
166+ }
167+ } )
168+
148169 this . needsSaving . addPreModifyListener ( ( newValue , oldValue , naughtyModifyValue ) => naughtyModifyValue ( oldValue || ( newValue && ! this . undoRedoHandler . ignoreActions ) ) )
149170
150171 this . keyframes . addListener ( value => {
@@ -392,10 +413,10 @@ export default class DcaAnimation extends AnimatorGumballConsumer {
392413 cloneAnimation ( ) {
393414 const animation = new DcaAnimation ( this . project , this . name . value )
394415
395- animation . keyframeData . exits . value = this . keyframeData . exits . value
396- animation . keyframeData . start . value = this . keyframeData . start . value
397- animation . keyframeData . end . value = this . keyframeData . end . value
398- animation . keyframeData . duration . value = this . keyframeData . duration . value
416+ animation . loopData . exists . value = this . loopData . exists . value
417+ animation . loopData . start . value = this . loopData . start . value
418+ animation . loopData . end . value = this . loopData . end . value
419+ animation . loopData . duration . value = this . loopData . duration . value
399420
400421 animation . keyframes . value = this . keyframes . value . map ( kf => kf . cloneBasics ( animation ) )
401422
@@ -916,7 +937,7 @@ export class KeyframeLayerData {
916937}
917938
918939export class KeyframeLoopData {
919- readonly exits = new LO ( false )
940+ readonly exists = new LO ( false )
920941 readonly start = new LO < number > ( 0 )
921942 readonly end = new LO < number > ( 0 )
922943 readonly duration = new LO < number > ( 0 )
0 commit comments