Skip to content

Commit 088abf6

Browse files
Update animationDuration globally
1 parent 10d6290 commit 088abf6

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

fission/src/systems/preferences/PreferenceTypes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export type IntakePreferences = {
9292
parentNode: string | undefined
9393
showZoneAlways: boolean
9494
maxPieces: number
95+
animationDuration: number
9596
}
9697

9798
export type EjectorPreferences = {
@@ -181,6 +182,7 @@ export function defaultRobotPreferences(): RobotPreferences {
181182
parentNode: undefined,
182183
showZoneAlways: false,
183184
maxPieces: 1,
185+
animationDuration: 0.5,
184186
},
185187
ejector: {
186188
deltaTransformation: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],

fission/src/test/PreferencesSystem.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ describe("Preference System Robot/Field", () => {
123123
parentNode: undefined,
124124
showZoneAlways: true,
125125
maxPieces: 3,
126+
animationDuration: 0.5,
126127
},
127128
ejector: {
128129
deltaTransformation: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
@@ -142,6 +143,7 @@ describe("Preference System Robot/Field", () => {
142143
parentNode: undefined,
143144
showZoneAlways: false,
144145
maxPieces: 1,
146+
animationDuration: 0.5,
145147
},
146148
ejector: {
147149
deltaTransformation: [1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],

fission/src/test/mirabuf/MirabufSceneObject.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ describe("MirabufSceneObject", () => {
188188
zoneDiameter: 1,
189189
showZoneAlways: false,
190190
maxPieces: 0,
191+
animationDuration: 0.5,
191192
})
192193
expect(instance.setEjectable(bodyId)).toBe(false)
193194
})
@@ -205,6 +206,7 @@ describe("MirabufSceneObject", () => {
205206
zoneDiameter: 1,
206207
showZoneAlways: false,
207208
maxPieces: 2,
209+
animationDuration: 0.5,
208210
})
209211
setPrivate(instance, "_ejectables", [])
210212
const bodyId = mockBodyId()

fission/src/ui/panels/configuring/assembly-config/interfaces/ConfigureGamepiecePickupInterface.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ function save(
6161
selectedRobot: MirabufSceneObject,
6262
selectedNode?: RigidNodeId,
6363
showZoneAlways?: boolean,
64-
maxPieces?: number
64+
maxPieces?: number,
65+
animationDuration?: number
6566
) {
6667
if (!selectedRobot?.intakePreferences || !gizmo) {
6768
return
@@ -92,6 +93,7 @@ function save(
9293
}
9394

9495
selectedRobot.intakePreferences.maxPieces = maxPieces!
96+
selectedRobot.intakePreferences.animationDuration = animationDuration!
9597

9698
PreferencesSystem.savePreferences()
9799
}
@@ -110,16 +112,18 @@ const ConfigureGamepiecePickupInterface: React.FC<ConfigPickupProps> = ({ select
110112
const [zoneSize, setZoneSize] = useState<number>((MIN_ZONE_SIZE + MAX_ZONE_SIZE) / 2.0)
111113
const [showZoneAlways, setShowZoneAlways] = useState<boolean>(false)
112114
const [maxPieces, setMaxPieces] = useState<number>(selectedRobot.intakePreferences?.maxPieces || 1)
113-
const [animationDuration, setAnimationDuration] = useState<number>(EjectableSceneObject.getAnimationDuration())
115+
const [animationDuration, setAnimationDuration] = useState<number>(
116+
selectedRobot.intakePreferences?.animationDuration || 0.5
117+
)
114118

115119
const gizmoRef = useRef<GizmoSceneObject | undefined>(undefined)
116120

117121
const saveEvent = useCallback(() => {
118122
if (gizmoRef.current && selectedRobot) {
119-
save(zoneSize, gizmoRef.current, selectedRobot, selectedNode, showZoneAlways, maxPieces)
123+
save(zoneSize, gizmoRef.current, selectedRobot, selectedNode, showZoneAlways, maxPieces, animationDuration)
120124
selectedRobot.updateIntakeSensor()
121125
}
122-
}, [selectedRobot, selectedNode, zoneSize, showZoneAlways, maxPieces])
126+
}, [selectedRobot, selectedNode, zoneSize, showZoneAlways, maxPieces, animationDuration])
123127

124128
useEffect(() => {
125129
ConfigurationSavedEvent.listen(saveEvent)
@@ -198,9 +202,11 @@ const ConfigureGamepiecePickupInterface: React.FC<ConfigPickupProps> = ({ select
198202
setSelectedNode(selectedRobot.intakePreferences.parentNode)
199203
setMaxPieces(selectedRobot.intakePreferences.maxPieces)
200204
setShowZoneAlways(selectedRobot.intakePreferences.showZoneAlways ?? false)
205+
setAnimationDuration(selectedRobot.intakePreferences.animationDuration ?? 0.5)
201206
} else {
202207
setSelectedNode(undefined)
203208
setShowZoneAlways(false)
209+
setAnimationDuration(0.5)
204210
}
205211
}, [selectedRobot])
206212

@@ -260,7 +266,7 @@ const ConfigureGamepiecePickupInterface: React.FC<ConfigPickupProps> = ({ select
260266
<Slider
261267
min={MIN_ANIMATION_DURATION}
262268
max={MAX_ANIMATION_DURATION}
263-
value={animationDuration}
269+
value={animationDuration ?? 0.5}
264270
onChange={(_, v) => {
265271
const val = typeof v === "number" ? v : v[0]
266272
setAnimationDuration(val)
@@ -353,6 +359,7 @@ const ConfigureGamepiecePickupInterface: React.FC<ConfigPickupProps> = ({ select
353359
setZoneSize(0.5)
354360
setSelectedNode(selectedRobot?.rootNodeId)
355361
setMaxPieces(selectedRobot.intakePreferences?.maxPieces ?? 1)
362+
setAnimationDuration(0.5)
356363
}}
357364
/>
358365
</>

0 commit comments

Comments
 (0)