@found-in-space/skykit 0.2.0-dev.20260527.0 → 0.2.0
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 +40 -35
- package/examples/xr-free-roam/xr-free-roam.js +31 -57
- package/package.json +11 -21
- package/src/__tests__/skykit-browser.test.js +184 -40
- package/src/__tests__/skykit-xr.test.js +56 -0
- package/src/__tests__/skykit.test.js +90 -503
- package/src/actions.js +0 -8
- package/src/browser.d.ts +2 -19
- package/src/browser.js +18 -31
- package/src/embed.js +22 -2
- package/src/hr-diagram.js +3 -1
- package/src/index.d.ts +10 -78
- package/src/index.js +6 -1
- package/src/plugins.js +0 -730
- package/src/utils.js +1 -0
- package/src/xr/plugins.js +74 -0
- package/src/xr.d.ts +18 -0
- package/src/xr.js +1 -0
- package/src/browser-journey.d.ts +0 -8
- package/src/browser-journey.js +0 -240
- package/src/story.d.ts +0 -57
- package/src/story.js +0 -396
package/src/browser.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export type SkykitBrowserHost = string | {
|
|
|
32
32
|
export type SkykitBrowserStatusTarget = string | { textContent?: string | null };
|
|
33
33
|
export type SkykitBrowserMouseMode = 'grab' | 'look' | 'strafe' | 'none';
|
|
34
34
|
export type SkykitConstellationArtMode = 'off' | 'lazy' | 'preload';
|
|
35
|
+
export type SkykitPersistentCacheMode = 'on' | 'off';
|
|
35
36
|
|
|
36
37
|
export interface SkykitBrowserAddonContext {
|
|
37
38
|
id?: string;
|
|
@@ -58,24 +59,6 @@ export interface SkykitBrowserGlobal {
|
|
|
58
59
|
getBrowsers(): SkykitBrowser[];
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
export interface SkykitBrowserJourneyFacade {
|
|
62
|
-
transitionTo(viewOrScene: unknown, options?: Record<string, unknown>): Promise<PromiseSettledResult<unknown>[]>;
|
|
63
|
-
applyScene(sceneSpec: unknown): Promise<unknown>;
|
|
64
|
-
load(input: string | Record<string, unknown>, options?: Record<string, unknown>): Promise<SkykitBrowserJourneyInstance>;
|
|
65
|
-
getSnapshot(): unknown | Promise<unknown>;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface SkykitBrowserJourneyInstance {
|
|
69
|
-
goTo(sceneId: string): Promise<unknown>;
|
|
70
|
-
next(): Promise<unknown>;
|
|
71
|
-
previous(): Promise<unknown>;
|
|
72
|
-
play(payload?: unknown): number;
|
|
73
|
-
pause(): number;
|
|
74
|
-
seek(timeSecs: number): number;
|
|
75
|
-
getSnapshot(): unknown;
|
|
76
|
-
dispose(): void;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
62
|
export interface SkykitBrowserConstellationsOptions {
|
|
80
63
|
skyculture?: string;
|
|
81
64
|
manifest?: Record<string, unknown>;
|
|
@@ -111,6 +94,7 @@ export interface SkykitBrowserOptions {
|
|
|
111
94
|
provider?: StarOctreeProviderService;
|
|
112
95
|
starField?: ThreeStarField;
|
|
113
96
|
octreeUrl?: string;
|
|
97
|
+
persistentCache?: SkykitPersistentCacheMode | string;
|
|
114
98
|
strategy?: StarCellStrategy;
|
|
115
99
|
session?: StarOctreeSessionOptions;
|
|
116
100
|
keyboard?: false | SkykitKeyboardNavigationOptions;
|
|
@@ -144,7 +128,6 @@ export interface SkykitBrowser {
|
|
|
144
128
|
starField: ThreeStarField;
|
|
145
129
|
loop: SkykitAnimationLoop;
|
|
146
130
|
capabilities: Set<string>;
|
|
147
|
-
journey: SkykitBrowserJourneyFacade;
|
|
148
131
|
constellations: SkykitBrowserConstellationsFacade;
|
|
149
132
|
install(input: SkykitBrowserInstallInput): Promise<SkykitPluginTeardown>;
|
|
150
133
|
addObject(
|
package/src/browser.js
CHANGED
|
@@ -6,6 +6,12 @@ import {
|
|
|
6
6
|
} from '@found-in-space/star-octree-provider';
|
|
7
7
|
import { createObserverShellStrategy } from '@found-in-space/star-trees';
|
|
8
8
|
import { createThreeStarField } from '@found-in-space/three-star-field';
|
|
9
|
+
import {
|
|
10
|
+
createRaDecLookAt,
|
|
11
|
+
parseDeclination,
|
|
12
|
+
parseRightAscension,
|
|
13
|
+
parseSpatialLookAtText,
|
|
14
|
+
} from '@found-in-space/spatial';
|
|
9
15
|
|
|
10
16
|
import { createSkykitAnimationLoop } from './animation-loop.js';
|
|
11
17
|
import { SKYKIT_ACTIONS, SKYKIT_CONTROLS } from './actions.js';
|
|
@@ -13,7 +19,6 @@ import {
|
|
|
13
19
|
createKeyboardNavigationPlugin,
|
|
14
20
|
createObject3dPlugin,
|
|
15
21
|
createMouseLookPlugin,
|
|
16
|
-
createSkykitJourneyPlugin,
|
|
17
22
|
createSkykitNavigationPlugin,
|
|
18
23
|
createSkyGrabPlugin,
|
|
19
24
|
createSkykitStatusPlugin,
|
|
@@ -52,6 +57,7 @@ export async function createSkykitBrowser(input = {}) {
|
|
|
52
57
|
);
|
|
53
58
|
const provider = options.provider ?? createStarOctreeProviderService({
|
|
54
59
|
url: options.octreeUrl ?? OCTREE_DEFAULT,
|
|
60
|
+
persistentCache: normalizePersistentCacheMode(options.persistentCache),
|
|
55
61
|
});
|
|
56
62
|
const starField = options.starField ?? createThreeStarField({
|
|
57
63
|
limitingMagnitude,
|
|
@@ -113,7 +119,6 @@ export async function createSkykitBrowser(input = {}) {
|
|
|
113
119
|
resize,
|
|
114
120
|
dispose,
|
|
115
121
|
};
|
|
116
|
-
browser.journey = createLazyJourneyFacade(browser);
|
|
117
122
|
browser.constellations = createLazyConstellationsFacade(browser, host);
|
|
118
123
|
|
|
119
124
|
function resize() {
|
|
@@ -182,9 +187,12 @@ export async function createSkykitBrowser(input = {}) {
|
|
|
182
187
|
skykit: {
|
|
183
188
|
SKYKIT_ACTIONS,
|
|
184
189
|
SKYKIT_CONTROLS,
|
|
190
|
+
createRaDecLookAt,
|
|
185
191
|
createObject3dPlugin,
|
|
186
|
-
createSkykitJourneyPlugin,
|
|
187
192
|
createSkykitNavigationPlugin,
|
|
193
|
+
parseDeclination,
|
|
194
|
+
parseRightAscension,
|
|
195
|
+
parseSpatialLookAtText,
|
|
188
196
|
},
|
|
189
197
|
};
|
|
190
198
|
}
|
|
@@ -226,34 +234,6 @@ function isBrowserAddon(input) {
|
|
|
226
234
|
return Boolean(input && typeof input === 'object' && typeof /** @type {{ install?: unknown }} */ (input).install === 'function');
|
|
227
235
|
}
|
|
228
236
|
|
|
229
|
-
/**
|
|
230
|
-
* @param {import('./browser.d.ts').SkykitBrowser} browser
|
|
231
|
-
* @returns {import('./browser.d.ts').SkykitBrowserJourneyFacade}
|
|
232
|
-
*/
|
|
233
|
-
function createLazyJourneyFacade(browser) {
|
|
234
|
-
/** @type {Promise<import('./browser.d.ts').SkykitBrowserJourneyFacade> | null} */
|
|
235
|
-
let loaded = null;
|
|
236
|
-
const loadCapability = () => {
|
|
237
|
-
loaded ??= import('./browser-journey.js')
|
|
238
|
-
.then((module) => module.installSkykitJourneyBrowserCapability({ browser }));
|
|
239
|
-
return loaded;
|
|
240
|
-
};
|
|
241
|
-
return {
|
|
242
|
-
async transitionTo(viewOrScene, options) {
|
|
243
|
-
return (await loadCapability()).transitionTo(viewOrScene, options);
|
|
244
|
-
},
|
|
245
|
-
async applyScene(sceneSpec) {
|
|
246
|
-
return (await loadCapability()).applyScene(sceneSpec);
|
|
247
|
-
},
|
|
248
|
-
async load(input, options) {
|
|
249
|
-
return (await loadCapability()).load(input, options);
|
|
250
|
-
},
|
|
251
|
-
async getSnapshot() {
|
|
252
|
-
return (await loadCapability()).getSnapshot();
|
|
253
|
-
},
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
|
|
257
237
|
/**
|
|
258
238
|
* @param {import('./browser.d.ts').SkykitBrowser} browser
|
|
259
239
|
* @param {Element | import('./browser.d.ts').SkykitBrowserHost} host
|
|
@@ -317,6 +297,13 @@ function normalizeMouseMode(value) {
|
|
|
317
297
|
return 'grab';
|
|
318
298
|
}
|
|
319
299
|
|
|
300
|
+
function normalizePersistentCacheMode(value) {
|
|
301
|
+
const mode = String(value ?? 'on').trim().toLowerCase();
|
|
302
|
+
return mode === 'off' || mode === 'false' || mode === 'no' || mode === '0' || mode === 'disabled'
|
|
303
|
+
? 'off'
|
|
304
|
+
: 'on';
|
|
305
|
+
}
|
|
306
|
+
|
|
320
307
|
function createStatusPlugin(target) {
|
|
321
308
|
return createSkykitStatusPlugin({
|
|
322
309
|
intervalSeconds: 0.5,
|
package/src/embed.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
parseSpatialLookAtText,
|
|
3
|
+
resolveSpatialTarget,
|
|
4
|
+
} from '@found-in-space/spatial';
|
|
2
5
|
|
|
3
6
|
import {
|
|
4
7
|
installSkykitBrowserGlobal,
|
|
@@ -59,7 +62,14 @@ async function installRequestedCapabilities(host, browser) {
|
|
|
59
62
|
/** @param {Element} host */
|
|
60
63
|
function readOptions(host) {
|
|
61
64
|
const data = isHtmlElement(host) ? host.dataset : {};
|
|
65
|
+
const observerPc = data.skykitObserver ? parseSpatialTargetText(data.skykitObserver) : null;
|
|
62
66
|
const lookAt = data.skykitLookAt ? parseSpatialLookAtText(data.skykitLookAt) : null;
|
|
67
|
+
const view = observerPc || lookAt
|
|
68
|
+
? {
|
|
69
|
+
...(observerPc ? { observerPc } : {}),
|
|
70
|
+
...(lookAt ? { lookAt } : {}),
|
|
71
|
+
}
|
|
72
|
+
: null;
|
|
63
73
|
return {
|
|
64
74
|
host,
|
|
65
75
|
...(data.skykitStatus ? { status: data.skykitStatus } : {}),
|
|
@@ -67,10 +77,20 @@ function readOptions(host) {
|
|
|
67
77
|
...(data.skykitSpeed ? { speedPcPerSec: Number(data.skykitSpeed) } : {}),
|
|
68
78
|
...(data.skykitExposure ? { exposure: Number(data.skykitExposure) } : {}),
|
|
69
79
|
...(data.skykitMouseMode ? { mouseMode: data.skykitMouseMode } : {}),
|
|
70
|
-
...(
|
|
80
|
+
...(data.skykitPersistentCache ? { persistentCache: data.skykitPersistentCache } : {}),
|
|
81
|
+
...(view ? { view } : {}),
|
|
71
82
|
};
|
|
72
83
|
}
|
|
73
84
|
|
|
85
|
+
/** @param {string} text */
|
|
86
|
+
function parseSpatialTargetText(text) {
|
|
87
|
+
const targetSpec = parseSpatialLookAtText(text);
|
|
88
|
+
const target = resolveSpatialTarget(targetSpec);
|
|
89
|
+
return target && typeof /** @type {Promise<unknown>} */ (target).then !== 'function'
|
|
90
|
+
? target
|
|
91
|
+
: null;
|
|
92
|
+
}
|
|
93
|
+
|
|
74
94
|
/**
|
|
75
95
|
* @param {Element} host
|
|
76
96
|
* @param {import('./browser.d.ts').SkykitBrowser} browser
|
package/src/hr-diagram.js
CHANGED
|
@@ -393,7 +393,9 @@ function cloneViewState(view) {
|
|
|
393
393
|
...view,
|
|
394
394
|
observerPc: clonePoint(view.observerPc),
|
|
395
395
|
renderObserverPosition: clonePoint(view.renderObserverPosition),
|
|
396
|
-
...(view.lookAt
|
|
396
|
+
...(view.lookAt
|
|
397
|
+
? { lookAt: typeof view.lookAt === 'object' ? { ...view.lookAt } : view.lookAt }
|
|
398
|
+
: {}),
|
|
397
399
|
...(view.targetPc ? { targetPc: clonePoint(view.targetPc) } : {}),
|
|
398
400
|
...(view.motion
|
|
399
401
|
? {
|
package/src/index.d.ts
CHANGED
|
@@ -11,17 +11,6 @@ import type {
|
|
|
11
11
|
SpatialTargetInput,
|
|
12
12
|
SpatialVector3,
|
|
13
13
|
} from '@found-in-space/spatial';
|
|
14
|
-
import type {
|
|
15
|
-
CreateTimedJourneyEvaluatorOptions,
|
|
16
|
-
JourneyController,
|
|
17
|
-
JourneyDefinition,
|
|
18
|
-
JourneyGraph,
|
|
19
|
-
JourneySceneSpec,
|
|
20
|
-
TimedJourney,
|
|
21
|
-
TimedJourneyCue,
|
|
22
|
-
TimedJourneyEvaluator,
|
|
23
|
-
TimedJourneyFrame,
|
|
24
|
-
} from '@found-in-space/journey';
|
|
25
14
|
import type {
|
|
26
15
|
StarCellDelta,
|
|
27
16
|
StarCellStore,
|
|
@@ -67,7 +56,9 @@ export interface QuaternionLike {
|
|
|
67
56
|
w: number;
|
|
68
57
|
}
|
|
69
58
|
|
|
70
|
-
export
|
|
59
|
+
export type SkykitLookAtInput = string | SkykitLookAtSpecInput;
|
|
60
|
+
|
|
61
|
+
export interface SkykitLookAtSpecInput {
|
|
71
62
|
targetPc?: Vector3Like | [number, number, number];
|
|
72
63
|
raDeg?: number;
|
|
73
64
|
raHours?: number;
|
|
@@ -79,6 +70,13 @@ export interface SkykitLookAtInput {
|
|
|
79
70
|
[key: string]: unknown;
|
|
80
71
|
}
|
|
81
72
|
|
|
73
|
+
export {
|
|
74
|
+
createRaDecLookAt,
|
|
75
|
+
parseDeclination,
|
|
76
|
+
parseRightAscension,
|
|
77
|
+
parseSpatialLookAtText,
|
|
78
|
+
} from '@found-in-space/spatial';
|
|
79
|
+
|
|
82
80
|
export interface SkykitObserverMotion {
|
|
83
81
|
velocityPcPerSec: Vector3Like;
|
|
84
82
|
speedPcPerSec: number;
|
|
@@ -908,63 +906,6 @@ export interface SkykitNavigationPluginOptions extends SpatialNavigationAutomati
|
|
|
908
906
|
) => SpatialTargetInput | Promise<SpatialTargetInput | null> | null;
|
|
909
907
|
}
|
|
910
908
|
|
|
911
|
-
export interface SkykitJourneyPluginOptions {
|
|
912
|
-
id?: string;
|
|
913
|
-
priority?: number;
|
|
914
|
-
journey?: JourneyDefinition;
|
|
915
|
-
controller?: JourneyController | null;
|
|
916
|
-
graph?: JourneyGraph;
|
|
917
|
-
scenes?: Record<string, JourneySceneSpec>;
|
|
918
|
-
transitions?: Iterable<Record<string, unknown>>;
|
|
919
|
-
initialSceneId?: string | null;
|
|
920
|
-
timedJourney?: TimedJourney | Record<string, unknown>;
|
|
921
|
-
evaluator?: TimedJourneyEvaluator | null;
|
|
922
|
-
evaluatorOptions?: CreateTimedJourneyEvaluatorOptions;
|
|
923
|
-
autoPlay?: boolean;
|
|
924
|
-
loop?: boolean;
|
|
925
|
-
startTimeSecs?: number;
|
|
926
|
-
disposeController?: boolean;
|
|
927
|
-
applyFrame?: (
|
|
928
|
-
frame: TimedJourneyFrame,
|
|
929
|
-
context: SkykitThreePluginContext | null,
|
|
930
|
-
skykitFrame: { viewer: SkykitViewer; view: SkykitViewState }
|
|
931
|
-
) => boolean | void;
|
|
932
|
-
onScene?: (
|
|
933
|
-
scene: JourneySceneSpec | Record<string, unknown> | null,
|
|
934
|
-
context: SkykitThreePluginContext,
|
|
935
|
-
event: unknown
|
|
936
|
-
) => void;
|
|
937
|
-
onSceneArrive?: (
|
|
938
|
-
scene: JourneySceneSpec | Record<string, unknown>,
|
|
939
|
-
context: SkykitThreePluginContext,
|
|
940
|
-
event: unknown
|
|
941
|
-
) => void | Promise<void>;
|
|
942
|
-
onCue?: (
|
|
943
|
-
cue: TimedJourneyCue,
|
|
944
|
-
frame: TimedJourneyFrame,
|
|
945
|
-
context: SkykitThreePluginContext | null
|
|
946
|
-
) => void;
|
|
947
|
-
onPreloadHints?: (
|
|
948
|
-
hints: SpatialPreloadHint[],
|
|
949
|
-
source: TimedJourneyFrame | JourneySceneSpec | Record<string, unknown>,
|
|
950
|
-
context: SkykitThreePluginContext | null
|
|
951
|
-
) => void;
|
|
952
|
-
onLayerState?: (
|
|
953
|
-
scene: JourneySceneSpec | Record<string, unknown>,
|
|
954
|
-
context: SkykitThreePluginContext
|
|
955
|
-
) => void;
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
export interface SkykitJourneyPlugin extends SkykitPlugin {
|
|
959
|
-
goTo(payload: unknown): Promise<JourneySceneSpec | null>;
|
|
960
|
-
next(): Promise<JourneySceneSpec | null>;
|
|
961
|
-
previous(): Promise<JourneySceneSpec | null>;
|
|
962
|
-
seek(payload: unknown): number;
|
|
963
|
-
play(payload?: unknown): number;
|
|
964
|
-
pause(): number;
|
|
965
|
-
getSnapshot(): unknown;
|
|
966
|
-
}
|
|
967
|
-
|
|
968
909
|
export interface SkykitSpatialPreloadStrategyOptions {
|
|
969
910
|
combine?: boolean;
|
|
970
911
|
baseStrategy?: StarCellStrategy;
|
|
@@ -1134,14 +1075,6 @@ export declare const SKYKIT_ACTIONS: {
|
|
|
1134
1075
|
readonly flyToSelected: 'skykit:selection.flyToSelected';
|
|
1135
1076
|
readonly openExternal: 'skykit:selection.openExternal';
|
|
1136
1077
|
};
|
|
1137
|
-
readonly journey: {
|
|
1138
|
-
readonly goToChapter: 'skykit:journey.goToChapter';
|
|
1139
|
-
readonly next: 'skykit:journey.next';
|
|
1140
|
-
readonly previous: 'skykit:journey.previous';
|
|
1141
|
-
readonly seek: 'skykit:journey.seek';
|
|
1142
|
-
readonly play: 'skykit:journey.play';
|
|
1143
|
-
readonly pause: 'skykit:journey.pause';
|
|
1144
|
-
};
|
|
1145
1078
|
readonly xr: {
|
|
1146
1079
|
readonly enter: 'skykit:xr.enter';
|
|
1147
1080
|
readonly exit: 'skykit:xr.exit';
|
|
@@ -1197,7 +1130,6 @@ export declare function createKeyboardNavigationPlugin(options?: SkykitKeyboardN
|
|
|
1197
1130
|
export declare function createSkykitNavigationPlugin(options?: SkykitNavigationPluginOptions): SkykitPlugin & {
|
|
1198
1131
|
getSnapshot(): unknown;
|
|
1199
1132
|
};
|
|
1200
|
-
export declare function createSkykitJourneyPlugin(options?: SkykitJourneyPluginOptions): SkykitJourneyPlugin;
|
|
1201
1133
|
export declare function createSkykitStarPreloadRequestsFromSpatialHints(
|
|
1202
1134
|
hints: Iterable<SpatialPreloadHint>,
|
|
1203
1135
|
options?: SkykitSpatialPreloadStrategyOptions
|
package/src/index.js
CHANGED
|
@@ -12,6 +12,12 @@ export {
|
|
|
12
12
|
} from './actions.js';
|
|
13
13
|
export { createSkykitAnimationLoop } from './animation-loop.js';
|
|
14
14
|
export { createSkykitDebugBridge, installSkykitDebugGlobal } from './debug.js';
|
|
15
|
+
export {
|
|
16
|
+
createRaDecLookAt,
|
|
17
|
+
parseDeclination,
|
|
18
|
+
parseRightAscension,
|
|
19
|
+
parseSpatialLookAtText,
|
|
20
|
+
} from '@found-in-space/spatial';
|
|
15
21
|
export { createSkykitHrDiagramPlugin } from './hr-diagram.js';
|
|
16
22
|
export { createObject3dLayer } from './layers.js';
|
|
17
23
|
export { createDesktopSkykitObserverRig } from './observer-rig.js';
|
|
@@ -21,7 +27,6 @@ export {
|
|
|
21
27
|
createKeyboardNavigationPlugin,
|
|
22
28
|
createMouseLookPlugin,
|
|
23
29
|
createObject3dPlugin,
|
|
24
|
-
createSkykitJourneyPlugin,
|
|
25
30
|
createSkykitNavigationPlugin,
|
|
26
31
|
createSkykitStarPreloadRequestsFromSpatialHints,
|
|
27
32
|
createSkykitStarStrategiesFromSpatialHints,
|