worldorbit 2.5.15 → 2.5.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/browser/core/dist/index.js +2444 -342
- package/dist/browser/editor/dist/index.js +11702 -0
- package/dist/browser/markdown/dist/index.js +2207 -392
- package/dist/browser/viewer/dist/index.js +2302 -382
- package/dist/unpkg/core/dist/index.js +2447 -345
- package/dist/unpkg/editor/dist/index.js +11727 -0
- package/dist/unpkg/markdown/dist/index.js +2210 -395
- package/dist/unpkg/viewer/dist/index.js +2305 -385
- package/dist/unpkg/worldorbit-core.min.js +12 -12
- package/dist/unpkg/worldorbit-editor.min.js +894 -0
- package/dist/unpkg/worldorbit-markdown.min.js +66 -58
- package/dist/unpkg/worldorbit-viewer.min.js +76 -68
- package/dist/unpkg/worldorbit.js +797 -78
- package/dist/unpkg/worldorbit.min.js +80 -72
- package/package.json +3 -2
- package/packages/core/dist/atlas-edit.js +74 -0
- package/packages/core/dist/atlas-validate.js +122 -8
- package/packages/core/dist/draft-parse.js +212 -8
- package/packages/core/dist/draft.d.ts +5 -2
- package/packages/core/dist/draft.js +59 -3
- package/packages/core/dist/format.js +63 -1
- package/packages/core/dist/normalize.js +1 -0
- package/packages/core/dist/scene.js +248 -46
- package/packages/core/dist/types.d.ts +41 -2
- package/packages/editor/dist/editor.d.ts +2 -0
- package/packages/editor/dist/editor.js +3578 -0
- package/packages/editor/dist/index.d.ts +2 -0
- package/packages/editor/dist/index.js +1 -0
- package/packages/editor/dist/types.d.ts +55 -0
- package/packages/editor/dist/types.js +1 -0
- package/packages/markdown/dist/html.d.ts +3 -0
- package/packages/markdown/dist/html.js +57 -0
- package/packages/markdown/dist/index.d.ts +4 -0
- package/packages/markdown/dist/index.js +3 -0
- package/packages/markdown/dist/rehype.d.ts +10 -0
- package/packages/markdown/dist/rehype.js +49 -0
- package/packages/markdown/dist/remark.d.ts +9 -0
- package/packages/markdown/dist/remark.js +28 -0
- package/packages/markdown/dist/types.d.ts +11 -0
- package/packages/markdown/dist/types.js +1 -0
- package/packages/viewer/dist/atlas-state.js +6 -0
- package/packages/viewer/dist/atlas-viewer.js +1 -0
- package/packages/viewer/dist/render.js +31 -2
- package/packages/viewer/dist/theme.js +1 -0
- package/packages/viewer/dist/tooltip.js +9 -0
- package/packages/viewer/dist/types.d.ts +8 -1
- package/packages/viewer/dist/viewer.js +12 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SceneRenderOptions, WorldOrbitAtlasDocument, WorldOrbitAtlasSystem, WorldOrbitDiagnostic, WorldOrbitDocument, WorldOrbitObject } from "./types.js";
|
|
1
|
+
import type { SceneRenderOptions, WorldOrbitAtlasDocument, WorldOrbitEvent, WorldOrbitAtlasSystem, WorldOrbitDiagnostic, WorldOrbitDocument, WorldOrbitObject } from "./types.js";
|
|
2
2
|
interface UpgradeOptions extends Pick<SceneRenderOptions, "preset" | "projection"> {
|
|
3
3
|
}
|
|
4
4
|
export declare function upgradeDocumentToV2(document: WorldOrbitDocument, options?: UpgradeOptions): WorldOrbitAtlasDocument;
|
|
@@ -10,9 +10,12 @@ export declare function upgradeDocumentToDraftV2(document: WorldOrbitDocument, o
|
|
|
10
10
|
system: WorldOrbitAtlasSystem | null;
|
|
11
11
|
groups: import("./types.js").WorldOrbitGroup[];
|
|
12
12
|
relations: import("./types.js").WorldOrbitRelation[];
|
|
13
|
+
events: WorldOrbitEvent[];
|
|
13
14
|
objects: WorldOrbitObject[];
|
|
14
15
|
diagnostics: WorldOrbitDiagnostic[];
|
|
15
16
|
};
|
|
16
|
-
export declare function materializeAtlasDocument(document: WorldOrbitAtlasDocument
|
|
17
|
+
export declare function materializeAtlasDocument(document: WorldOrbitAtlasDocument, options?: {
|
|
18
|
+
activeEventId?: string | null;
|
|
19
|
+
}): WorldOrbitDocument;
|
|
17
20
|
export declare function materializeDraftDocument(document: WorldOrbitAtlasDocument): WorldOrbitDocument;
|
|
18
21
|
export {};
|
|
@@ -24,6 +24,7 @@ export function upgradeDocumentToV2(document, options = {}) {
|
|
|
24
24
|
system,
|
|
25
25
|
groups: structuredClone(document.groups ?? []),
|
|
26
26
|
relations: structuredClone(document.relations ?? []),
|
|
27
|
+
events: structuredClone(document.events ?? []),
|
|
27
28
|
objects: document.objects.map(cloneWorldOrbitObject),
|
|
28
29
|
diagnostics,
|
|
29
30
|
};
|
|
@@ -31,7 +32,7 @@ export function upgradeDocumentToV2(document, options = {}) {
|
|
|
31
32
|
export function upgradeDocumentToDraftV2(document, options = {}) {
|
|
32
33
|
return convertAtlasDocumentToLegacyDraft(upgradeDocumentToV2(document, options));
|
|
33
34
|
}
|
|
34
|
-
export function materializeAtlasDocument(document) {
|
|
35
|
+
export function materializeAtlasDocument(document, options = {}) {
|
|
35
36
|
const system = document.system
|
|
36
37
|
? {
|
|
37
38
|
type: "system",
|
|
@@ -44,6 +45,8 @@ export function materializeAtlasDocument(document) {
|
|
|
44
45
|
info: materializeDraftSystemInfo(document.system),
|
|
45
46
|
}
|
|
46
47
|
: null;
|
|
48
|
+
const objects = document.objects.map(cloneWorldOrbitObject);
|
|
49
|
+
applyEventPoseOverrides(objects, document.events ?? [], options.activeEventId ?? null);
|
|
47
50
|
return {
|
|
48
51
|
format: "worldorbit",
|
|
49
52
|
version: "1.0",
|
|
@@ -51,7 +54,8 @@ export function materializeAtlasDocument(document) {
|
|
|
51
54
|
system,
|
|
52
55
|
groups: structuredClone(document.groups ?? []),
|
|
53
56
|
relations: structuredClone(document.relations ?? []),
|
|
54
|
-
|
|
57
|
+
events: document.events.map(cloneWorldOrbitEvent),
|
|
58
|
+
objects,
|
|
55
59
|
};
|
|
56
60
|
}
|
|
57
61
|
export function materializeDraftDocument(document) {
|
|
@@ -195,6 +199,7 @@ function mapSceneViewpointToDraftViewpoint(viewpoint) {
|
|
|
195
199
|
summary: viewpoint.summary,
|
|
196
200
|
focusObjectId: viewpoint.objectId,
|
|
197
201
|
selectedObjectId: viewpoint.selectedObjectId,
|
|
202
|
+
events: [...viewpoint.eventIds],
|
|
198
203
|
projection: viewpoint.projection,
|
|
199
204
|
preset: viewpoint.preset,
|
|
200
205
|
zoom: viewpoint.scale,
|
|
@@ -239,6 +244,54 @@ function cloneWorldOrbitObject(object) {
|
|
|
239
244
|
info: { ...object.info },
|
|
240
245
|
};
|
|
241
246
|
}
|
|
247
|
+
function cloneWorldOrbitEvent(event) {
|
|
248
|
+
return {
|
|
249
|
+
...event,
|
|
250
|
+
participantObjectIds: [...event.participantObjectIds],
|
|
251
|
+
tags: [...event.tags],
|
|
252
|
+
positions: event.positions.map(cloneWorldOrbitEventPose),
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
function cloneWorldOrbitEventPose(pose) {
|
|
256
|
+
return {
|
|
257
|
+
objectId: pose.objectId,
|
|
258
|
+
placement: clonePlacement(pose.placement),
|
|
259
|
+
inner: pose.inner ? { ...pose.inner } : undefined,
|
|
260
|
+
outer: pose.outer ? { ...pose.outer } : undefined,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function clonePlacement(placement) {
|
|
264
|
+
return placement ? structuredClone(placement) : null;
|
|
265
|
+
}
|
|
266
|
+
function applyEventPoseOverrides(objects, events, activeEventId) {
|
|
267
|
+
if (!activeEventId) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
const event = events.find((entry) => entry.id === activeEventId);
|
|
271
|
+
if (!event) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
const objectMap = new Map(objects.map((object) => [object.id, object]));
|
|
275
|
+
for (const pose of event.positions) {
|
|
276
|
+
const object = objectMap.get(pose.objectId);
|
|
277
|
+
if (!object) {
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
object.placement = clonePlacement(pose.placement);
|
|
281
|
+
if (pose.inner) {
|
|
282
|
+
object.properties.inner = { ...pose.inner };
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
delete object.properties.inner;
|
|
286
|
+
}
|
|
287
|
+
if (pose.outer) {
|
|
288
|
+
object.properties.outer = { ...pose.outer };
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
delete object.properties.outer;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
242
295
|
function cloneProperties(properties) {
|
|
243
296
|
const next = {};
|
|
244
297
|
for (const [key, value] of Object.entries(properties)) {
|
|
@@ -347,6 +400,9 @@ function materializeDraftSystemInfo(system) {
|
|
|
347
400
|
if ((viewpoint.filter?.groupIds.length ?? 0) > 0) {
|
|
348
401
|
info[`${prefix}.groups`] = viewpoint.filter?.groupIds.join(" ") ?? "";
|
|
349
402
|
}
|
|
403
|
+
if (viewpoint.events.length > 0) {
|
|
404
|
+
info[`${prefix}.events`] = viewpoint.events.join(" ");
|
|
405
|
+
}
|
|
350
406
|
}
|
|
351
407
|
for (const annotation of system.annotations) {
|
|
352
408
|
const prefix = `annotation.${annotation.id}`;
|
|
@@ -371,7 +427,7 @@ function serializeViewpointLayers(layers) {
|
|
|
371
427
|
if (orbitFront !== undefined || orbitBack !== undefined) {
|
|
372
428
|
tokens.push(orbitFront !== false || orbitBack !== false ? "orbits" : "-orbits");
|
|
373
429
|
}
|
|
374
|
-
for (const key of ["background", "guides", "relations", "objects", "labels", "metadata"]) {
|
|
430
|
+
for (const key of ["background", "guides", "relations", "events", "objects", "labels", "metadata"]) {
|
|
375
431
|
if (layers[key] !== undefined) {
|
|
376
432
|
tokens.push(layers[key] ? key : `-${key}`);
|
|
377
433
|
}
|
|
@@ -100,6 +100,10 @@ export function formatAtlasDocument(document) {
|
|
|
100
100
|
lines.push("");
|
|
101
101
|
lines.push(...formatAtlasRelation(relation));
|
|
102
102
|
}
|
|
103
|
+
for (const event of [...document.events].sort(compareIdLike)) {
|
|
104
|
+
lines.push("");
|
|
105
|
+
lines.push(...formatAtlasEvent(event));
|
|
106
|
+
}
|
|
103
107
|
const sortedObjects = [...document.objects].sort(compareObjects);
|
|
104
108
|
if (sortedObjects.length > 0 && lines.at(-1) !== "") {
|
|
105
109
|
lines.push("");
|
|
@@ -132,6 +136,10 @@ export function formatDraftDocument(document) {
|
|
|
132
136
|
lines.push("");
|
|
133
137
|
lines.push(...formatAtlasRelation(relation));
|
|
134
138
|
}
|
|
139
|
+
for (const event of [...legacy.events].sort(compareIdLike)) {
|
|
140
|
+
lines.push("");
|
|
141
|
+
lines.push(...formatAtlasEvent(event));
|
|
142
|
+
}
|
|
135
143
|
const sortedObjects = [...legacy.objects].sort(compareObjects);
|
|
136
144
|
if (sortedObjects.length > 0 && lines.at(-1) !== "") {
|
|
137
145
|
lines.push("");
|
|
@@ -345,6 +353,9 @@ function formatAtlasViewpoint(viewpoint) {
|
|
|
345
353
|
if (layerTokens.length > 0) {
|
|
346
354
|
lines.push(` layers ${layerTokens.join(" ")}`);
|
|
347
355
|
}
|
|
356
|
+
if (viewpoint.events.length > 0) {
|
|
357
|
+
lines.push(` events ${viewpoint.events.join(" ")}`);
|
|
358
|
+
}
|
|
348
359
|
if (viewpoint.filter) {
|
|
349
360
|
lines.push(" filter");
|
|
350
361
|
if (viewpoint.filter.query) {
|
|
@@ -417,6 +428,54 @@ function formatAtlasRelation(relation) {
|
|
|
417
428
|
}
|
|
418
429
|
return lines;
|
|
419
430
|
}
|
|
431
|
+
function formatAtlasEvent(event) {
|
|
432
|
+
const lines = [`event ${event.id}`, ` kind ${quoteIfNeeded(event.kind)}`];
|
|
433
|
+
if (event.label) {
|
|
434
|
+
lines.push(` label ${quoteIfNeeded(event.label)}`);
|
|
435
|
+
}
|
|
436
|
+
if (event.summary) {
|
|
437
|
+
lines.push(` summary ${quoteIfNeeded(event.summary)}`);
|
|
438
|
+
}
|
|
439
|
+
if (event.targetObjectId) {
|
|
440
|
+
lines.push(` target ${event.targetObjectId}`);
|
|
441
|
+
}
|
|
442
|
+
if (event.participantObjectIds.length > 0) {
|
|
443
|
+
lines.push(` participants ${event.participantObjectIds.join(" ")}`);
|
|
444
|
+
}
|
|
445
|
+
if (event.timing) {
|
|
446
|
+
lines.push(` timing ${quoteIfNeeded(event.timing)}`);
|
|
447
|
+
}
|
|
448
|
+
if (event.visibility) {
|
|
449
|
+
lines.push(` visibility ${quoteIfNeeded(event.visibility)}`);
|
|
450
|
+
}
|
|
451
|
+
if (event.tags.length > 0) {
|
|
452
|
+
lines.push(` tags ${event.tags.map(quoteIfNeeded).join(" ")}`);
|
|
453
|
+
}
|
|
454
|
+
if (event.color) {
|
|
455
|
+
lines.push(` color ${quoteIfNeeded(event.color)}`);
|
|
456
|
+
}
|
|
457
|
+
if (event.hidden) {
|
|
458
|
+
lines.push(" hidden true");
|
|
459
|
+
}
|
|
460
|
+
if (event.positions.length > 0) {
|
|
461
|
+
lines.push("");
|
|
462
|
+
lines.push(" positions");
|
|
463
|
+
for (const pose of [...event.positions].sort(comparePoseObjectId)) {
|
|
464
|
+
lines.push(` pose ${pose.objectId}`);
|
|
465
|
+
for (const fieldLine of formatEventPoseFields(pose)) {
|
|
466
|
+
lines.push(` ${fieldLine}`);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
return lines;
|
|
471
|
+
}
|
|
472
|
+
function formatEventPoseFields(pose) {
|
|
473
|
+
return [
|
|
474
|
+
...formatPlacement(pose.placement),
|
|
475
|
+
...formatOptionalUnit("inner", pose.inner),
|
|
476
|
+
...formatOptionalUnit("outer", pose.outer),
|
|
477
|
+
];
|
|
478
|
+
}
|
|
420
479
|
function formatValue(value) {
|
|
421
480
|
if (Array.isArray(value)) {
|
|
422
481
|
return value.map((item) => quoteIfNeeded(item)).join(" ");
|
|
@@ -462,7 +521,7 @@ function formatDraftLayers(layers) {
|
|
|
462
521
|
? "orbits"
|
|
463
522
|
: "-orbits");
|
|
464
523
|
}
|
|
465
|
-
for (const key of ["background", "guides", "relations", "objects", "labels", "metadata"]) {
|
|
524
|
+
for (const key of ["background", "guides", "relations", "events", "objects", "labels", "metadata"]) {
|
|
466
525
|
if (layers[key] !== undefined) {
|
|
467
526
|
tokens.push(layers[key] ? key : `-${key}`);
|
|
468
527
|
}
|
|
@@ -490,6 +549,9 @@ function compareObjects(left, right) {
|
|
|
490
549
|
function compareIdLike(left, right) {
|
|
491
550
|
return left.id.localeCompare(right.id);
|
|
492
551
|
}
|
|
552
|
+
function comparePoseObjectId(left, right) {
|
|
553
|
+
return left.objectId.localeCompare(right.objectId);
|
|
554
|
+
}
|
|
493
555
|
function objectTypeIndex(objectType) {
|
|
494
556
|
switch (objectType) {
|
|
495
557
|
case "star":
|