-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
disable 3d viewer toggle if no stereo3d_* attributes
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,33 @@ | ||
// eslint-disable-next-line import/prefer-default-export | ||
import { Attribute } from 'vue-media-annotator/use/useAttributes'; | ||
|
||
const EXPECTED_ATTRIBUTE_NAMES = [ | ||
'stereo3d_x', | ||
'stereo3d_y', | ||
'stereo3d_z', | ||
]; | ||
|
||
export const noOp = () => undefined; | ||
|
||
export function isStereo3dReady(attrs: Attribute[]) { | ||
const attributeNamesToFind = [...EXPECTED_ATTRIBUTE_NAMES]; | ||
|
||
// eslint-disable-next-line no-restricted-syntax | ||
for (const attr of attrs) { | ||
// eslint-disable-next-line no-plusplus | ||
for (let i = 0; i < attributeNamesToFind.length; i++) { | ||
if (attr.name === attributeNamesToFind[i]) { | ||
if (attr.belongs === 'detection' && attr.datatype === 'number') { | ||
attributeNamesToFind.splice(i, 1); | ||
} else { | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
if (attributeNamesToFind.length === 0) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} |