Initial commit
This commit is contained in:
commit
05c65aad4d
155 changed files with 93617 additions and 0 deletions
40
viewer/IIIF/iiif.js
Normal file
40
viewer/IIIF/iiif.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
//import manifest from "@iiif/3d-manifesto-dev/dist-esmodule/";
|
||||
import * as manifesto from "@iiif/3d-manifesto-dev/dist-esmodule";
|
||||
|
||||
export class IIIFManifest {
|
||||
constructor(manifest) {
|
||||
// Is manifest JSON or URL?
|
||||
if (isJsonString(manifest)) {
|
||||
this.manifestJson = manifest;
|
||||
this.manifestUrl = null;
|
||||
this.manifest = manifesto.parseManifest(manifest);
|
||||
} else {
|
||||
this.manifestJson = null;
|
||||
this.manifestUrl = manifest;
|
||||
}
|
||||
}
|
||||
|
||||
async loadManifest() {
|
||||
if (this.manifestUrl)
|
||||
this.manifestJson = await manifesto.loadManifest(this.manifestUrl);
|
||||
|
||||
if (this.manifestJson)
|
||||
this.manifest = await manifesto.parseManifest(this.manifestJson);
|
||||
|
||||
if (this.manifest)
|
||||
this.scenes = this.manifest?.getSequences()[0]?.getScenes() || [];
|
||||
}
|
||||
|
||||
annotationsFromScene(scene) {
|
||||
return scene?.getContent() || [];
|
||||
}
|
||||
}
|
||||
|
||||
function isJsonString(str) {
|
||||
try {
|
||||
JSON.parse(str);
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue