From d9644f2370141b98decc963489602e6d91f2757a Mon Sep 17 00:00:00 2001 From: Aria Minaei Date: Thu, 1 Dec 2022 15:01:53 +0100 Subject: [PATCH] Unify Derivation and Prism 12/n --- theatre/core/src/sequences/Sequence.ts | 2 +- theatre/core/src/sheetObjects/SheetObject.ts | 8 ++++---- theatre/core/src/sheetObjects/SheetObjectTemplate.ts | 2 +- theatre/core/src/sheetObjects/TheatreSheetObject.ts | 2 +- theatre/studio/src/TheatreStudio.ts | 8 ++++---- .../SequenceEditorPanel/RightOverlay/Playhead.tsx | 2 +- .../propEditors/useEditingToolsForCompoundProp.tsx | 2 +- .../src/propEditors/useEditingToolsForSimpleProp.tsx | 12 +++++------- 8 files changed, 18 insertions(+), 20 deletions(-) diff --git a/theatre/core/src/sequences/Sequence.ts b/theatre/core/src/sequences/Sequence.ts index b0c42b6..c227047 100644 --- a/theatre/core/src/sequences/Sequence.ts +++ b/theatre/core/src/sequences/Sequence.ts @@ -118,7 +118,7 @@ export default class Sequence { return this._lengthD.getValue() } - get positionDerivation() { + get positionPrism() { return this._positionD } diff --git a/theatre/core/src/sheetObjects/SheetObject.ts b/theatre/core/src/sheetObjects/SheetObject.ts index d927f09..ee21417 100644 --- a/theatre/core/src/sheetObjects/SheetObject.ts +++ b/theatre/core/src/sheetObjects/SheetObject.ts @@ -253,7 +253,7 @@ export default class SheetObject implements IdentityPrismProvider { const interpolate = propConfig.interpolate! as Interpolator<$IntentionalAny> - const updateSequenceValueFromItsDerivation = () => { + const updateSequenceValueFromItsPrism = () => { const triple = pr.getValue() if (!triple) return valsAtom.setIn(pathToProp, undefined) @@ -279,9 +279,9 @@ export default class SheetObject implements IdentityPrismProvider { interpolate(left, right, triple.progression), ) } - const untap = pr.onStale(updateSequenceValueFromItsDerivation) + const untap = pr.onStale(updateSequenceValueFromItsPrism) - updateSequenceValueFromItsDerivation() + updateSequenceValueFromItsPrism() untaps.push(untap) } return () => { @@ -304,7 +304,7 @@ export default class SheetObject implements IdentityPrismProvider { this.template.project.pointers.historic.sheetsById[this.address.sheetId] .sequence.tracksByObject[this.address.objectKey].trackData[trackId] - const timeD = this.sheet.getSequence().positionDerivation + const timeD = this.sheet.getSequence().positionPrism return interpolationTripleAtPosition(this._internalUtilCtx, trackP, timeD) } diff --git a/theatre/core/src/sheetObjects/SheetObjectTemplate.ts b/theatre/core/src/sheetObjects/SheetObjectTemplate.ts index abe5a63..61c530c 100644 --- a/theatre/core/src/sheetObjects/SheetObjectTemplate.ts +++ b/theatre/core/src/sheetObjects/SheetObjectTemplate.ts @@ -128,7 +128,7 @@ export default class SheetObjectTemplate { * Returns values that are set statically (ie, not sequenced, and not defaults) */ getStaticValues(): Prism { - return this._cache.get('getDerivationOfStatics', () => + return this._cache.get('getStaticValues', () => prism(() => { const pointerToSheetState = this.sheetTemplate.project.pointers.historic.sheetsById[ diff --git a/theatre/core/src/sheetObjects/TheatreSheetObject.ts b/theatre/core/src/sheetObjects/TheatreSheetObject.ts index 91659c2..478fe6d 100644 --- a/theatre/core/src/sheetObjects/TheatreSheetObject.ts +++ b/theatre/core/src/sheetObjects/TheatreSheetObject.ts @@ -148,7 +148,7 @@ export default class TheatreSheetObject< } private _valuesPrism(): Prism { - return this._cache.get('onValuesChangeDerivation', () => { + return this._cache.get('_valuesPrism', () => { const sheetObject = privateAPI(this) const d: Prism> = prism(() => { return val(sheetObject.getValues().getValue()) as $FixMe diff --git a/theatre/studio/src/TheatreStudio.ts b/theatre/studio/src/TheatreStudio.ts index cb38e8b..7dc56e5 100644 --- a/theatre/studio/src/TheatreStudio.ts +++ b/theatre/studio/src/TheatreStudio.ts @@ -410,8 +410,8 @@ export default class TheatreStudio implements IStudio { }) } - private _getSelectionDerivation(): Prism<(ISheetObject | ISheet)[]> { - return this._cache.get('_getStateDerivation()', () => + private _getSelectionPrism(): Prism<(ISheetObject | ISheet)[]> { + return this._cache.get('_getSelectionPrism()', () => prism((): (ISheetObject | ISheet)[] => { return getOutlineSelection() .filter( @@ -424,7 +424,7 @@ export default class TheatreStudio implements IStudio { } private _getSelection(): (ISheetObject | ISheet)[] { - return this._getSelectionDerivation().getValue() + return this._getSelectionPrism().getValue() } setSelection(selection: Array): void { @@ -440,7 +440,7 @@ export default class TheatreStudio implements IStudio { } onSelectionChange(fn: (s: (ISheetObject | ISheet)[]) => void): VoidFn { - return this._getSelectionDerivation().onChange(studioTicker, fn, true) + return this._getSelectionPrism().onChange(studioTicker, fn, true) } get selection(): Array { diff --git a/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/Playhead.tsx b/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/Playhead.tsx index b19ac57..4916d15 100644 --- a/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/Playhead.tsx +++ b/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/Playhead.tsx @@ -265,7 +265,7 @@ const Playhead: React.FC<{layoutP: Pointer}> = ({ getIsPlayheadAttachedToFocusRange(sequence), ) - const posInUnitSpace = sequence.positionDerivation.getValue() + const posInUnitSpace = sequence.positionPrism.getValue() const posInClippedSpace = val(layoutP.clippedSpace.fromUnitSpace)( posInUnitSpace, diff --git a/theatre/studio/src/propEditors/useEditingToolsForCompoundProp.tsx b/theatre/studio/src/propEditors/useEditingToolsForCompoundProp.tsx index e1c8f28..4de5cf3 100644 --- a/theatre/studio/src/propEditors/useEditingToolsForCompoundProp.tsx +++ b/theatre/studio/src/propEditors/useEditingToolsForCompoundProp.tsx @@ -235,7 +235,7 @@ function ControlIndicators({ return usePrism(() => { const pathToProp = getPointerParts(pointerToProp).path - const sequencePosition = val(obj.sheet.getSequence().positionDerivation) + const sequencePosition = val(obj.sheet.getSequence().positionPrism) /* 2/10 perf concern: diff --git a/theatre/studio/src/propEditors/useEditingToolsForSimpleProp.tsx b/theatre/studio/src/propEditors/useEditingToolsForSimpleProp.tsx index 5882278..0c1241a 100644 --- a/theatre/studio/src/propEditors/useEditingToolsForSimpleProp.tsx +++ b/theatre/studio/src/propEditors/useEditingToolsForSimpleProp.tsx @@ -65,7 +65,7 @@ const cache = new WeakMap<{}, Prism>>() * Note: we're able to get `obj` and `propConfig` from `pointerToProp`, * so the only reason they're still in the arguments list is that */ -function createDerivation( +function createPrism( pointerToProp: Pointer, obj: SheetObject, propConfig: PropTypeConfig_AllSimples, @@ -181,9 +181,7 @@ function createDerivation( sequenceTrackId ], ) - const sequencePosition = val( - obj.sheet.getSequence().positionDerivation, - ) + const sequencePosition = val(obj.sheet.getSequence().positionPrism) return getNearbyKeyframesOfTrack( obj, track && { @@ -325,7 +323,7 @@ function createDerivation( }) } -function getDerivation( +function getPrism( pointerToProp: Pointer, obj: SheetObject, propConfig: PropTypeConfig_AllSimples, @@ -333,7 +331,7 @@ function getDerivation( if (cache.has(pointerToProp)) { return cache.get(pointerToProp)! } else { - const d = createDerivation(pointerToProp, obj, propConfig) + const d = createPrism(pointerToProp, obj, propConfig) cache.set(pointerToProp, d) return d } @@ -354,7 +352,7 @@ export function useEditingToolsForSimplePropInDetailsPanel< obj: SheetObject, propConfig: PropTypeConfig_AllSimples, ): EditingTools { - const der = getDerivation(pointerToProp, obj, propConfig) + const der = getPrism(pointerToProp, obj, propConfig) return usePrismInstance(der) }