Skip to content

Commit

Permalink
Added screw driver object, and comments on annotation store
Browse files Browse the repository at this point in the history
  • Loading branch information
sahirgomez1 committed Jul 6, 2021
1 parent d7d257d commit f9320ac
Show file tree
Hide file tree
Showing 4 changed files with 215 additions and 17 deletions.
Binary file removed public/rbgt_banana.mp4
Binary file not shown.
180 changes: 180 additions & 0 deletions public/screwdriver.gltf

Large diffs are not rendered by default.

51 changes: 34 additions & 17 deletions src/stores/AnnotationStore.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import create from "zustand";

/**
* Add new annotation item to the annotations array in the global state, it replaces old annotation or add new one.
*
* @param {Array} list Array of current annotations
* @param {Object} annotation New object annotation.
* @returns
*/
const addRecord = (list, annotation) => {
let ann_found = list.some((o) => o.id === annotation.id); // Check if annotation already exists
if (!ann_found) {
Expand All @@ -15,34 +22,44 @@ const addRecord = (list, annotation) => {
});
return modifiedList;
}
}; // Add a new annotation to the queue, it replaces old annotation or add new
};

const useAnnotationStore = create((set, get) => ({
outputAnnotation: { url: "", videoWidth: 0, videoHeight: 0, object_3d: "", annotations: [] },
reviewMode : false,
setReviewMode : () => set((state) => ({ reviewMode : !state.reviewMode})),
outputAnnotation: {
url: "",
videoWidth: 0,
videoHeight: 0,
object_3d: "",
annotations: [],
},
reviewMode: false,

setReviewMode: () => set((state) => ({ reviewMode: !state.reviewMode })),
setVideoMetadata: (e) =>
set((state) => ({
outputAnnotation: {
...state.outputAnnotation,
url: e.props.url,
videoHeight: e.getInternalPlayer().videoHeight,
videoWidth: e.getInternalPlayer().videoWidth
videoWidth: e.getInternalPlayer().videoWidth,
},
})),
setObjectFile: (object) =>
set((state) => ({
outputAnnotation: {
...state.outputAnnotation,
object_3d: object.gltfFile,
},
})),
setObjectFile: (object) => set ((state) => ({outputAnnotation: {...state.outputAnnotation, object_3d: object.gltfFile }})),
setAnnotationsFromFile: (fileContent) => set ((state) => ({outputAnnotation : fileContent})),
setAnnotationsFromFile: (fileContent) =>
set((state) => ({ outputAnnotation: fileContent })),
addAnnotation: (annotation) =>
set(
(state) => (
{
outputAnnotation: {
...state.outputAnnotation,
annotations: addRecord(state.outputAnnotation.annotations, annotation),
},
}
)
),
set((state) => ({
outputAnnotation: {
...state.outputAnnotation,
annotations: addRecord(state.outputAnnotation.annotations, annotation),
},
})),
getCurrentAnnotations: () => {
const currentAnnotations = get().outputAnnotation.annotations;
return currentAnnotations;
Expand Down
1 change: 1 addition & 0 deletions src/stores/ObjectStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const useObjectStore = create((set) => ({
{ name: "Tomato Can", gltfFile: "/tomato_can.gltf" },
{ name: "Banana", gltfFile: "/banana.gltf" },
{ name: "Hammer", gltfFile: "/hammer.gltf" },
{ name: "Screw Driver", gltfFile: "/screwdriver.gltf" },
],
objectSelected: { name: "Banana", gltfFile: "/banana.gltf" },
objPosition: { x: 0, y: 0.2, z: 0 },
Expand Down

0 comments on commit f9320ac

Please sign in to comment.