-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added z rotation controls + annotation fix
- Loading branch information
1 parent
d96b24d
commit 0ffc976
Showing
7 changed files
with
122 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,42 @@ | ||
import create from 'zustand'; | ||
import create from "zustand"; | ||
|
||
const addRecord = (list, annotation) => { | ||
let ann_found = list.some(o => o.id === annotation.id); | ||
if (!ann_found) list.push(annotation); | ||
list.map(o => (o.id === annotation.id) ? annotation : o) | ||
return list; | ||
} | ||
|
||
const useAnnotationStore = create(set => ({ | ||
outputAnnotation : { url: "", videoWidth: 0, videoHeight: 0, annotations:[] }, | ||
addAnnotation : (video_metadata, annotation) => | ||
set(state => ({ | ||
outputAnnotation: { | ||
...state.outputAnnotation, | ||
url: video_metadata.url, | ||
videoWidth: video_metadata.videoWidth, | ||
videoHeight: video_metadata.videoHeight, | ||
annotations: addRecord(state.outputAnnotation.annotations, annotation) | ||
} | ||
})), | ||
|
||
})) | ||
let ann_found = list.some((o) => o.id === annotation.id); // Check if annotation already exists | ||
if (!ann_found) { | ||
list.push(annotation) | ||
return list; | ||
} else { | ||
const modifiedList = list.map((o) => (o.id === annotation.id ? annotation : o)); | ||
return modifiedList; | ||
} | ||
}; | ||
|
||
const useAnnotationStore = create((set, get) => ({ | ||
outputAnnotation: { url: "", videoWidth: 0, videoHeight: 0, annotations: [] }, | ||
setVideoMetadata: (e) => | ||
set((state) => ({ | ||
outputAnnotation: { | ||
...state.outputAnnotation, | ||
url: e.props.url, | ||
videoHeight: e.getInternalPlayer().videoHeight, | ||
videoWidth: e.getInternalPlayer().videoWidth | ||
}, | ||
})), | ||
addAnnotation: (annotation) => | ||
set( | ||
(state) => ( | ||
{ | ||
outputAnnotation: { | ||
...state.outputAnnotation, | ||
annotations: addRecord(state.outputAnnotation.annotations, annotation), | ||
}, | ||
} | ||
) | ||
), | ||
getCurrentAnnotations: () => { | ||
const currentAnnotations = get().outputAnnotation.annotations; | ||
return currentAnnotations; | ||
}, | ||
})); | ||
|
||
export { useAnnotationStore }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters