@galihru/orbinexsim 0.1.1 → 0.1.4

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 CHANGED
@@ -1,14 +1,127 @@
1
1
  # @galihru/orbinexsim
2
2
 
3
- OrbinexSim adalah wrapper tingkat tinggi agar kamu bisa pakai Orbinex desktop + AR tanpa menulis ribuan baris kode.
3
+ [![npm version](https://img.shields.io/npm/v/%40galihru%2Forbinexsim?label=npm%20%40galihru%2Forbinexsim)](https://www.npmjs.com/package/@galihru/orbinexsim)
4
+ [![npm downloads](https://img.shields.io/npm/dm/%40galihru%2Forbinexsim?label=downloads)](https://www.npmjs.com/package/@galihru/orbinexsim)
5
+ [![core physics module](https://img.shields.io/npm/v/%40galihru%2Forbinex?label=core%20%40galihru%2Forbinex)](https://www.npmjs.com/package/@galihru/orbinex)
6
+ [![demo](https://img.shields.io/badge/demo-GitHub%20Pages-0A3B7A)](https://galihru.github.io/OrbinexSimulation/)
4
7
 
5
- ## Install
8
+ High-level scientific wrapper for embedding OrbinexSimulation desktop and AR runtimes with a compact TypeScript API.
9
+
10
+ ## 1. What This Module Provides
11
+
12
+ - Fast embedding of the hosted simulation viewer in desktop or AR mode.
13
+ - Runtime permission orchestration for camera, microphone, geolocation, and motion sensors.
14
+ - Orbit sample utilities backed by [@galihru/orbinex](https://www.npmjs.com/package/@galihru/orbinex).
15
+ - AR marker utilities for marker creation, tracking, catalog proxy ingestion, and primitive model synthesis.
16
+
17
+ ## 2. Demonstration and Related Modules
18
+
19
+ | Resource | Link |
20
+ | --- | --- |
21
+ | Desktop demo | [https://galihru.github.io/OrbinexSimulation/](https://galihru.github.io/OrbinexSimulation/) |
22
+ | AR demo | [https://galihru.github.io/OrbinexSimulation/ar-view.html](https://galihru.github.io/OrbinexSimulation/ar-view.html) |
23
+ | Wrapper package | [@galihru/orbinexsim](https://www.npmjs.com/package/@galihru/orbinexsim) |
24
+ | Core physics package | [@galihru/orbinex](https://www.npmjs.com/package/@galihru/orbinex) |
25
+
26
+ ## 3. Visual Runtime Evidence with Figure Interpretation
27
+
28
+ | Column 1: Function area | Column 2: Screenshot evidence |
29
+ | --- | --- |
30
+ | Startup render stage | ![Startup render](https://raw.githubusercontent.com/galihru/OrbinexSimulation/main/docs/images/startup-render.png) |
31
+ | Main runtime overview | ![Runtime overview](https://raw.githubusercontent.com/galihru/OrbinexSimulation/main/docs/images/desktop-runtime-overview.png) |
32
+ | Focused runtime state | ![Runtime focused](https://raw.githubusercontent.com/galihru/OrbinexSimulation/main/docs/images/desktop-runtime-focused.png) |
33
+ | Object scientific card | ![Object card](https://raw.githubusercontent.com/galihru/OrbinexSimulation/main/docs/images/object-information-card.png) |
34
+ | Search and event modules | ![Search panel](https://raw.githubusercontent.com/galihru/OrbinexSimulation/main/docs/images/search-panel.png) |
35
+ | Event logging module | ![Event log panel](https://raw.githubusercontent.com/galihru/OrbinexSimulation/main/docs/images/event-log-panel.png) |
36
+ | Hierarchy filtering module | ![Hierarchy filter panel](https://raw.githubusercontent.com/galihru/OrbinexSimulation/main/docs/images/hierarchy-filter-panel.png) |
37
+ | AR marker reference | ![Hiro marker](https://raw.githubusercontent.com/galihru/OrbinexSimulation/main/docs/images/ar-marker-hiro.png) |
38
+ | AR QR activation bridge | ![AR QR card](https://raw.githubusercontent.com/galihru/OrbinexSimulation/main/docs/images/ar-qr-code.png) |
39
+ | Handheld in-situ AR runtime after marker lock | ![Handheld AR runtime](https://raw.githubusercontent.com/galihru/OrbinexSimulation/main/docs/images/ar-mobile-latest-result.png) |
40
+
41
+ Figure interpretation notes:
42
+
43
+ 1. Table 1, Column 2, Row 1 documents the initialization stage preceding full scene interactivity.
44
+ 2. Table 1, Column 2, Row 2 and Row 3 document high-density and focused-density runtime regimes.
45
+ 3. Table 1, Column 2, Row 4 isolates object-level scientific descriptors used in the detail panel API flow.
46
+ 4. Table 1, Column 2, Row 5 to Row 7 capture retrieval, event chronology, and hierarchy filtering controls.
47
+ 5. Table 1, Column 2, Row 8 and Row 9 capture AR marker anchoring and QR-based mobile activation.
48
+ 6. Table 1, Column 2, Row 10 captures handheld mobile evidence where object and label overlays remain stable after marker detection.
49
+
50
+ ## 4. Installation and Environment Requirements
51
+
52
+ ### 4.1 Prerequisites
53
+
54
+ | Requirement | Recommended version | Notes |
55
+ | --- | --- | --- |
56
+ | Node.js | 20.x LTS or newer | Required for ESM/CJS build artifacts |
57
+ | npm | 10.x or newer | Used for install, build, pack, publish |
58
+ | Browser context | HTTPS for runtime permissions | Needed for camera/geolocation/motion APIs |
59
+
60
+ ### 4.2 Install Command
6
61
 
7
62
  ```bash
8
- npm i @galihru/orbinexsim
63
+ npm install @galihru/orbinexsim
9
64
  ```
10
65
 
11
- ## Pemakaian Paling Ringkas
66
+ Equivalent commands:
67
+
68
+ ```bash
69
+ pnpm add @galihru/orbinexsim
70
+ yarn add @galihru/orbinexsim
71
+ bun add @galihru/orbinexsim
72
+ ```
73
+
74
+ ### 4.3 Sequential Path (Install Module First)
75
+
76
+ Use this ordered sequence to avoid ambiguity:
77
+
78
+ 1. Install the published wrapper module in your target project.
79
+
80
+ ```bash
81
+ npm install @galihru/orbinexsim
82
+ ```
83
+
84
+ 2. Validate installation and resolve lockfile.
85
+
86
+ ```bash
87
+ npm ls @galihru/orbinexsim
88
+ ```
89
+
90
+ 3. Integrate and run your app runtime entry.
91
+
92
+ ```bash
93
+ npm run dev
94
+ ```
95
+
96
+ 4. If you need source-level package customization, clone this repository and build the local wrapper.
97
+
98
+ ```bash
99
+ git clone https://github.com/galihru/OrbinexSimulation.git
100
+ cd OrbinexSimulation/orbinexsim-npm
101
+ npm ci
102
+ npm run build
103
+ ```
104
+
105
+ ### 4.4 Deterministic Local Build of This Package
106
+
107
+ ```bash
108
+ npm ci
109
+ npm run build
110
+ ```
111
+
112
+ Pack for pre-publish validation:
113
+
114
+ ```bash
115
+ npm pack
116
+ ```
117
+
118
+ Publish (requires npm auth and policy-compliant token/2FA setup):
119
+
120
+ ```bash
121
+ npm publish --access public
122
+ ```
123
+
124
+ ## 5. Quick Start
12
125
 
13
126
  ```ts
14
127
  import { createOrbinexSim } from "@galihru/orbinexsim";
@@ -17,30 +130,244 @@ const sim = createOrbinexSim("#app", {
17
130
  mode: "desktop",
18
131
  model: "Bumi",
19
132
  autoRequestAccess: true,
133
+ width: "100%",
134
+ height: "72vh"
20
135
  });
21
136
 
22
- // pindah ke AR kapan saja
137
+ // Switch runtime mode when needed
23
138
  await sim.launchAr({ camera: true, motionSensors: true });
139
+
140
+ // Scientific quick sample at 1 AU
141
+ console.log(sim.buildQuickReport(1.496e11));
24
142
  ```
25
143
 
26
- ## API Inti
144
+ ## 6. AR Runtime Integration Example
27
145
 
28
- - `createOrbinexSim(target, options)`
29
- - `sim.setMode("desktop" | "ar")`
30
- - `sim.setModel("Bumi")`
31
- - `sim.launchAr({ camera: true })`
32
- - `sim.requestAccess({ camera: true, geolocation: true })`
33
- - `sim.buildQuickReport(radiusMeters)`
146
+ ```ts
147
+ import {
148
+ bindMarkerTracking,
149
+ createMarkersFromCatalog,
150
+ createPrimitiveModelFromCatalogEntry,
151
+ parseArRequestFromSearch,
152
+ resolveCatalogProxyUrl,
153
+ loadCatalogFromProxy,
154
+ resolveObjectNameForMarker,
155
+ createDefaultArMarkers,
156
+ ensureArMarkers,
157
+ resolveArMarkerHint,
158
+ requestRuntimePermissions,
159
+ } from "@galihru/orbinexsim/ar-runtime";
160
+
161
+ const request = parseArRequestFromSearch(window.location.search);
162
+ const markers = createDefaultArMarkers(request.model, request.altModel);
163
+ const markerEls = ensureArMarkers("#ar-scene", markers, {
164
+ createMissing: true,
165
+ ensureModelRoot: true,
166
+ });
34
167
 
35
- ## Catatan
168
+ const stopMarkerTracking = bindMarkerTracking(markerEls, {
169
+ onMarkerFound: (summary) => {
170
+ console.log("found", summary.markerModel, summary.markerLabel);
171
+ },
172
+ });
36
173
 
37
- - Module ini menggunakan `@galihru/orbinex` untuk kalkulasi dasar orbit.
38
- - Untuk mode AR, browser/user tetap bisa menolak permission kamera/sensor.
39
- - Default host viewer: `https://galihru.github.io/OrbinexSimulation/`
174
+ const catalogProxyUrl = resolveCatalogProxyUrl(window.location.search);
175
+ const proxyEntries = catalogProxyUrl ? await loadCatalogFromProxy(catalogProxyUrl) : [];
176
+ const proxyMarkers = createMarkersFromCatalog(proxyEntries, markers);
177
+ ensureArMarkers("#ar-scene", proxyMarkers, { createMissing: true, ensureModelRoot: true });
40
178
 
41
- ## Publish
179
+ if (proxyEntries[0]) {
180
+ createPrimitiveModelFromCatalogEntry("#model-root-hiro", proxyEntries[0], {
181
+ includeLabel: true,
182
+ radiusScale: 1,
183
+ });
184
+ }
185
+
186
+ const hint = resolveArMarkerHint(markerEls[0]);
187
+ const objectName = resolveObjectNameForMarker(markerEls[0], request.model);
188
+ const permissions = await requestRuntimePermissions({
189
+ camera: true,
190
+ motionSensors: true,
191
+ geolocation: true,
192
+ microphone: true,
193
+ });
194
+
195
+ console.log({ hint, objectName, permissions });
196
+ stopMarkerTracking();
197
+ ```
198
+
199
+ ## 7. API Surface
200
+
201
+ ### Main API
202
+
203
+ | Symbol | Type | Description |
204
+ | --- | --- | --- |
205
+ | `createOrbinexSim(target, options)` | Function | Creates a managed simulation instance and iframe host |
206
+ | `OrbinexSim#setMode(mode)` | Method | Switches desktop or AR runtime |
207
+ | `OrbinexSim#setModel(name)` | Method | Changes active object query |
208
+ | `OrbinexSim#launchAr(options)` | Method | Requests permissions and transitions to AR mode |
209
+ | `OrbinexSim#requestAccess(options)` | Method | Returns a permission summary per capability |
210
+ | `OrbinexSim#createOrbitPreviewSample(radiusMeters)` | Method | Returns orbit sample for selected radius |
211
+ | `OrbinexSim#buildQuickReport(radiusMeters)` | Method | Returns concise report string |
212
+ | `orbitSampleFromAu(au)` | Function | Converts AU to orbit sample around solar mass |
213
+ | `constants` | Object | Shared physical constants |
214
+
215
+ ### AR Runtime API
216
+
217
+ | Symbol | Description |
218
+ | --- | --- |
219
+ | `parseArRequestFromSearch` | Parses `model`, `altModel`, and `build` query parameters |
220
+ | `createDefaultArMarkers` | Creates default Hiro and Kanji marker configs |
221
+ | `ensureArMarkers` | Ensures marker nodes exist and applies normalized attributes |
222
+ | `bindMarkerTracking` | Subscribes to marker found/lost events with summaries |
223
+ | `resolveObjectNameForMarker` | Resolves marker-linked object with fallback |
224
+ | `resolveArMarkerHint` | Returns marker image/link/label metadata |
225
+ | `resolveCatalogProxyUrl` | Reads external catalog proxy URL from query parameters |
226
+ | `loadCatalogFromProxy` | Loads and normalizes catalog payloads |
227
+ | `createMarkersFromCatalog` | Maps proxy catalog entries to marker configurations |
228
+ | `extractCatalogEntriesFromPayload` | Normalizes arrays or wrapped API payloads |
229
+ | `createPrimitiveModelFromCatalogEntry` | Generates marker-attached primitive model geometry |
230
+ | `requestRuntimePermissions` | Runtime permission helper without creating iframe instance |
231
+
232
+ ## 8. Scientific Formulations Used by the Module
233
+
234
+ LaTeX notation:
235
+
236
+ $$
237
+ \mu = G M
238
+ $$
239
+
240
+ $$
241
+ v = \sqrt{\frac{\mu}{r}}
242
+ $$
243
+
244
+ $$
245
+ T = 2\pi\sqrt{\frac{a^3}{\mu}}
246
+ $$
247
+
248
+ $$
249
+ \eta_{\mathrm{years}} = \mathrm{clamp}\left(\frac{d / v_{\mathrm{rel}}}{\mathrm{YEAR\_SECONDS}}, 10^{-7}, 5000\right)
250
+ $$
251
+
252
+ $$
253
+ \mathrm{confidence} = \mathrm{clamp}\left(0.45 + \frac{0.5}{1 + d/\mathrm{AU}}, 0.45, 0.98\right)
254
+ $$
255
+
256
+ $$
257
+ r_{\mathrm{visual}} = \mathrm{clamp}\left((0.08 + \log_{10}(\max(r_m, 1)) \cdot 0.04) \cdot \mathrm{radiusScale}, 0.03, 0.68\right)
258
+ $$
259
+
260
+ Plain-text fallback:
261
+
262
+ ```text
263
+ mu = G * M
264
+ v = sqrt(mu / r)
265
+ T = 2 * pi * sqrt(a^3 / mu)
266
+
267
+ eta_years = clamp((distance / relative_speed) / YEAR_SECONDS, 1e-7, 5000)
268
+ confidence = clamp(0.45 + 0.5 / (1 + distance / AU), 0.45, 0.98)
269
+
270
+ r_visual = clamp((0.08 + log10(max(radius_m, 1)) * 0.04) * radiusScale, 0.03, 0.68)
271
+ ```
272
+
273
+ | Formula | Used in | Outcome |
274
+ | --- | --- | --- |
275
+ | `mu = G*M`, `v = sqrt(mu/r)`, `T = 2*pi*sqrt(a^3/mu)` | Orbit preview/sample helpers | Physically interpretable speed and period |
276
+ | `eta ~= distance/speed` + confidence clamp | Forecast summaries | Stable early-warning ranking |
277
+ | Logarithmic visual radius mapping | AR primitive synthesis | Prevents extreme size collapse in marker view |
278
+
279
+ ## 9. Runtime Graph and Architecture (Mermaid)
280
+
281
+ ```mermaid
282
+ flowchart LR
283
+ A[Consumer App] --> B[createOrbinexSim]
284
+ B --> C[Hosted Viewer]
285
+ C --> D[Desktop Runtime]
286
+ C --> E[AR Runtime]
287
+ D --> F[Event and Forecast Stream]
288
+ E --> F
289
+ F --> G[Scientific Decision Support]
290
+ ```
291
+
292
+ ```mermaid
293
+ sequenceDiagram
294
+ participant APP as Consumer
295
+ participant SIM as OrbinexSim API
296
+ participant VIEW as Hosted Runtime
297
+ participant LOG as Event/Forecast Feed
298
+
299
+ APP->>SIM: createOrbinexSim(target, options)
300
+ SIM->>VIEW: Initialize desktop or AR mode
301
+ APP->>SIM: launchAr / setModel / requestAccess
302
+ SIM->>VIEW: Propagate runtime update
303
+ VIEW->>LOG: Emit state, event, and forecast outputs
304
+ LOG-->>APP: Structured simulation summary
305
+ ```
306
+
307
+ Mermaid blocks render as diagrams on GitHub. On npm, the same blocks remain readable as deterministic graph text.
308
+
309
+ ```text
310
+ Consumer app -> createOrbinexSim -> hosted viewer
311
+ -> desktop scene updates
312
+ -> optional AR marker flow
313
+ -> event/forecast summaries
314
+ ```
315
+
316
+ ## 10. Browser and Permission Notes
317
+
318
+ | Capability | Requirement |
319
+ | --- | --- |
320
+ | Camera / microphone | Secure context (HTTPS) and user permission |
321
+ | Geolocation | Secure context and browser location policy |
322
+ | Motion sensors | Platform-specific API permission (notably on iOS) |
323
+ | AR marker runtime | Camera access and marker visibility in scene |
324
+
325
+ Default hosted base URL:
326
+
327
+ - [https://galihru.github.io/OrbinexSimulation/](https://galihru.github.io/OrbinexSimulation/)
328
+
329
+ ## 11. Build and Publish
330
+
331
+ ### 11.1 npm Token Setup (Safe)
332
+
333
+ Do not commit a real npm token into this repository.
334
+
335
+ 1. Create or update user-level `.npmrc` (recommended: in home directory, not in repo):
336
+
337
+ ```ini
338
+ //registry.npmjs.org/:_authToken=${NPM_TOKEN}
339
+ ```
340
+
341
+ 2. Set token as environment variable in your current shell session.
342
+
343
+ PowerShell:
344
+
345
+ ```powershell
346
+ $env:NPM_TOKEN="npm_REPLACE_WITH_YOUR_TOKEN"
347
+ ```
348
+
349
+ 3. Validate authentication before publish.
350
+
351
+ ```bash
352
+ npm whoami
353
+ ```
354
+
355
+ If a token was exposed accidentally, revoke/rotate it in npm account settings before publishing.
356
+
357
+ ```bash
358
+ npm run build
359
+ npm publish --access public
360
+ ```
361
+
362
+ Release-grade sequence:
42
363
 
43
364
  ```bash
365
+ npm ci
44
366
  npm run build
367
+ npm pack
45
368
  npm publish --access public
46
369
  ```
370
+
371
+ ## 12. License
372
+
373
+ MIT