Initial commit
This commit is contained in:
commit
05c65aad4d
155 changed files with 93617 additions and 0 deletions
77
viewer/manifesto/manifesto-api.js
Normal file
77
viewer/manifesto/manifesto-api.js
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
import { AIM3DManifest } from "./manifesto";
|
||||
|
||||
export async function loadAIM3IFManifest(manifestUrlOrJson) {
|
||||
const aim3dManifest = new AIM3DManifest(manifestUrlOrJson);
|
||||
|
||||
await aim3dManifest.loadManifest();
|
||||
|
||||
const modelUrls = [];
|
||||
let modelTarget = null;
|
||||
let filteredAnnos = [];
|
||||
|
||||
for (const scene of aim3dManifest.scenes) {
|
||||
scene.background =
|
||||
scene.backgroundColor ||
|
||||
"#000000";
|
||||
|
||||
const annos = aim3dManifest.annotationsFromScene(scene);
|
||||
|
||||
filteredAnnos = annos.filter(
|
||||
anno =>
|
||||
anno.motivation?.includes("painting") &&
|
||||
anno.body?.type === "Model"
|
||||
);
|
||||
|
||||
for (const anno of filteredAnnos) {
|
||||
const modelUrl = anno.body?.id;
|
||||
|
||||
if (modelUrl) {
|
||||
modelUrls.push(modelUrl);
|
||||
}
|
||||
|
||||
modelTarget = anno.target;
|
||||
}
|
||||
}
|
||||
|
||||
aim3dManifest.modelUrls = modelUrls;
|
||||
aim3dManifest.modelTarget = modelTarget;
|
||||
|
||||
return {
|
||||
manifest: aim3dManifest.manifest,
|
||||
scenes: aim3dManifest.scenes,
|
||||
annotations: filteredAnnos,
|
||||
modelUrls,
|
||||
modelTarget
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export function applyManifestConfig(manifest, objectsConfig) {
|
||||
const transform =
|
||||
manifest.AIM3DViewer?.modelTransform;
|
||||
|
||||
if (!transform) return;
|
||||
|
||||
const model = objectsConfig.models[0];
|
||||
|
||||
model.position = {
|
||||
x: transform.position?.[0] ?? 0,
|
||||
y: transform.position?.[1] ?? 0,
|
||||
z: transform.position?.[2] ?? 0
|
||||
};
|
||||
|
||||
model.rotation = {
|
||||
x: transform.rotation?.x ?? 0,
|
||||
y: transform.rotation?.y ?? 0,
|
||||
z: transform.rotation?.z ?? 0
|
||||
};
|
||||
|
||||
model.scale = {
|
||||
x: transform.scale?.[0] ?? 1,
|
||||
y: transform.scale?.[1] ?? 1,
|
||||
z: transform.scale?.[2] ?? 1
|
||||
};
|
||||
|
||||
model.wireframe =
|
||||
transform.wireframe ?? false;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue