worldorbit 2.6.0 → 3.0.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.
Files changed (196) hide show
  1. package/README.md +12 -5
  2. package/dist/browser/core/dist/atlas-edit.d.ts +11 -0
  3. package/dist/browser/core/dist/atlas-edit.js +347 -0
  4. package/dist/browser/core/dist/atlas-utils.d.ts +22 -0
  5. package/dist/browser/core/dist/atlas-utils.js +189 -0
  6. package/dist/browser/core/dist/atlas-validate.d.ts +2 -0
  7. package/dist/browser/core/dist/atlas-validate.js +488 -0
  8. package/dist/browser/core/dist/diagnostics.d.ts +10 -0
  9. package/dist/browser/core/dist/diagnostics.js +109 -0
  10. package/dist/browser/core/dist/draft-parse.d.ts +3 -0
  11. package/dist/browser/core/dist/draft-parse.js +1654 -0
  12. package/dist/browser/core/dist/draft.d.ts +21 -0
  13. package/dist/browser/core/dist/draft.js +482 -0
  14. package/dist/browser/core/dist/errors.d.ts +7 -0
  15. package/dist/browser/core/dist/errors.js +16 -0
  16. package/dist/browser/core/dist/format.d.ts +4 -0
  17. package/dist/browser/core/dist/format.js +613 -0
  18. package/dist/browser/core/dist/index.d.ts +29 -0
  19. package/dist/browser/core/dist/index.js +35 -6542
  20. package/dist/browser/core/dist/load.d.ts +4 -0
  21. package/dist/browser/core/dist/load.js +182 -0
  22. package/dist/browser/core/dist/markdown.d.ts +2 -0
  23. package/dist/browser/core/dist/markdown.js +37 -0
  24. package/dist/browser/core/dist/normalize.d.ts +2 -0
  25. package/dist/browser/core/dist/normalize.js +312 -0
  26. package/dist/browser/core/dist/parse.d.ts +2 -0
  27. package/dist/browser/core/dist/parse.js +133 -0
  28. package/dist/browser/core/dist/scene.d.ts +3 -0
  29. package/dist/browser/core/dist/scene.js +1901 -0
  30. package/dist/browser/core/dist/schema.d.ts +8 -0
  31. package/dist/browser/core/dist/schema.js +298 -0
  32. package/dist/browser/core/dist/spatial-scene.d.ts +3 -0
  33. package/dist/browser/core/dist/spatial-scene.js +420 -0
  34. package/dist/browser/core/dist/tokenize.d.ts +4 -0
  35. package/dist/browser/core/dist/tokenize.js +68 -0
  36. package/dist/browser/core/dist/types.d.ts +637 -0
  37. package/dist/browser/core/dist/types.js +1 -0
  38. package/dist/browser/core/dist/validate.d.ts +2 -0
  39. package/dist/browser/core/dist/validate.js +56 -0
  40. package/dist/browser/editor/dist/editor.d.ts +2 -0
  41. package/dist/browser/editor/dist/editor.js +3700 -0
  42. package/dist/browser/editor/dist/index.d.ts +2 -0
  43. package/dist/browser/editor/dist/index.js +1 -12250
  44. package/dist/browser/editor/dist/types.d.ts +59 -0
  45. package/dist/browser/editor/dist/types.js +1 -0
  46. package/dist/browser/markdown/dist/html.d.ts +3 -0
  47. package/dist/browser/markdown/dist/html.js +64 -0
  48. package/dist/browser/markdown/dist/index.d.ts +4 -0
  49. package/dist/browser/markdown/dist/index.js +3 -6179
  50. package/dist/browser/markdown/dist/rehype.d.ts +10 -0
  51. package/dist/browser/markdown/dist/rehype.js +49 -0
  52. package/dist/browser/markdown/dist/remark.d.ts +9 -0
  53. package/dist/browser/markdown/dist/remark.js +28 -0
  54. package/dist/browser/markdown/dist/types.d.ts +11 -0
  55. package/dist/browser/markdown/dist/types.js +1 -0
  56. package/dist/browser/viewer/dist/atlas-state.d.ts +12 -0
  57. package/dist/browser/viewer/dist/atlas-state.js +269 -0
  58. package/dist/browser/viewer/dist/atlas-viewer.d.ts +2 -0
  59. package/dist/browser/viewer/dist/atlas-viewer.js +495 -0
  60. package/dist/browser/viewer/dist/custom-element.d.ts +1 -0
  61. package/dist/browser/viewer/dist/custom-element.js +78 -0
  62. package/dist/browser/viewer/dist/embed.d.ts +24 -0
  63. package/dist/browser/viewer/dist/embed.js +172 -0
  64. package/dist/browser/viewer/dist/errors.d.ts +6 -0
  65. package/dist/browser/viewer/dist/errors.js +12 -0
  66. package/dist/browser/viewer/dist/index.d.ts +10 -0
  67. package/dist/browser/viewer/dist/index.js +9 -8334
  68. package/dist/browser/viewer/dist/minimap.d.ts +3 -0
  69. package/dist/browser/viewer/dist/minimap.js +63 -0
  70. package/dist/browser/viewer/dist/render.d.ts +6 -0
  71. package/dist/browser/viewer/dist/render.js +670 -0
  72. package/dist/browser/viewer/dist/runtime-3d.d.ts +19 -0
  73. package/dist/browser/viewer/dist/runtime-3d.js +494 -0
  74. package/dist/browser/viewer/dist/theme.d.ts +4 -0
  75. package/dist/browser/viewer/dist/theme.js +103 -0
  76. package/dist/browser/viewer/dist/tooltip.d.ts +3 -0
  77. package/dist/browser/viewer/dist/tooltip.js +198 -0
  78. package/dist/browser/viewer/dist/types.d.ts +292 -0
  79. package/dist/browser/viewer/dist/types.js +1 -0
  80. package/dist/browser/viewer/dist/vendor/three.module.js +53032 -0
  81. package/dist/browser/viewer/dist/viewer-state.d.ts +19 -0
  82. package/dist/browser/viewer/dist/viewer-state.js +162 -0
  83. package/dist/browser/viewer/dist/viewer.d.ts +2 -0
  84. package/dist/browser/viewer/dist/viewer.js +1662 -0
  85. package/dist/unpkg/core/dist/atlas-edit.d.ts +11 -0
  86. package/dist/unpkg/core/dist/atlas-edit.js +347 -0
  87. package/dist/unpkg/core/dist/atlas-utils.d.ts +22 -0
  88. package/dist/unpkg/core/dist/atlas-utils.js +189 -0
  89. package/dist/unpkg/core/dist/atlas-validate.d.ts +2 -0
  90. package/dist/unpkg/core/dist/atlas-validate.js +488 -0
  91. package/dist/unpkg/core/dist/diagnostics.d.ts +10 -0
  92. package/dist/unpkg/core/dist/diagnostics.js +109 -0
  93. package/dist/unpkg/core/dist/draft-parse.d.ts +3 -0
  94. package/dist/unpkg/core/dist/draft-parse.js +1654 -0
  95. package/dist/unpkg/core/dist/draft.d.ts +21 -0
  96. package/dist/unpkg/core/dist/draft.js +482 -0
  97. package/dist/unpkg/core/dist/errors.d.ts +7 -0
  98. package/dist/unpkg/core/dist/errors.js +16 -0
  99. package/dist/unpkg/core/dist/format.d.ts +4 -0
  100. package/dist/unpkg/core/dist/format.js +613 -0
  101. package/dist/unpkg/core/dist/index.d.ts +29 -0
  102. package/dist/unpkg/core/dist/index.js +35 -6614
  103. package/dist/unpkg/core/dist/load.d.ts +4 -0
  104. package/dist/unpkg/core/dist/load.js +182 -0
  105. package/dist/unpkg/core/dist/markdown.d.ts +2 -0
  106. package/dist/unpkg/core/dist/markdown.js +37 -0
  107. package/dist/unpkg/core/dist/normalize.d.ts +2 -0
  108. package/dist/unpkg/core/dist/normalize.js +312 -0
  109. package/dist/unpkg/core/dist/parse.d.ts +2 -0
  110. package/dist/unpkg/core/dist/parse.js +133 -0
  111. package/dist/unpkg/core/dist/scene.d.ts +3 -0
  112. package/dist/unpkg/core/dist/scene.js +1901 -0
  113. package/dist/unpkg/core/dist/schema.d.ts +8 -0
  114. package/dist/unpkg/core/dist/schema.js +298 -0
  115. package/dist/unpkg/core/dist/spatial-scene.d.ts +3 -0
  116. package/dist/unpkg/core/dist/spatial-scene.js +420 -0
  117. package/dist/unpkg/core/dist/tokenize.d.ts +4 -0
  118. package/dist/unpkg/core/dist/tokenize.js +68 -0
  119. package/dist/unpkg/core/dist/types.d.ts +637 -0
  120. package/dist/unpkg/core/dist/types.js +1 -0
  121. package/dist/unpkg/core/dist/validate.d.ts +2 -0
  122. package/dist/unpkg/core/dist/validate.js +56 -0
  123. package/dist/unpkg/editor/dist/editor.d.ts +2 -0
  124. package/dist/unpkg/editor/dist/editor.js +3700 -0
  125. package/dist/unpkg/editor/dist/index.d.ts +2 -0
  126. package/dist/unpkg/editor/dist/index.js +1 -12275
  127. package/dist/unpkg/editor/dist/types.d.ts +59 -0
  128. package/dist/unpkg/editor/dist/types.js +1 -0
  129. package/dist/unpkg/markdown/dist/html.d.ts +3 -0
  130. package/dist/unpkg/markdown/dist/html.js +64 -0
  131. package/dist/unpkg/markdown/dist/index.d.ts +4 -0
  132. package/dist/unpkg/markdown/dist/index.js +3 -6207
  133. package/dist/unpkg/markdown/dist/rehype.d.ts +10 -0
  134. package/dist/unpkg/markdown/dist/rehype.js +49 -0
  135. package/dist/unpkg/markdown/dist/remark.d.ts +9 -0
  136. package/dist/unpkg/markdown/dist/remark.js +28 -0
  137. package/dist/unpkg/markdown/dist/types.d.ts +11 -0
  138. package/dist/unpkg/markdown/dist/types.js +1 -0
  139. package/dist/unpkg/viewer/dist/atlas-state.d.ts +12 -0
  140. package/dist/unpkg/viewer/dist/atlas-state.js +269 -0
  141. package/dist/unpkg/viewer/dist/atlas-viewer.d.ts +2 -0
  142. package/dist/unpkg/viewer/dist/atlas-viewer.js +495 -0
  143. package/dist/unpkg/viewer/dist/custom-element.d.ts +1 -0
  144. package/dist/unpkg/viewer/dist/custom-element.js +78 -0
  145. package/dist/unpkg/viewer/dist/embed.d.ts +24 -0
  146. package/dist/unpkg/viewer/dist/embed.js +172 -0
  147. package/dist/unpkg/viewer/dist/errors.d.ts +6 -0
  148. package/dist/unpkg/viewer/dist/errors.js +12 -0
  149. package/dist/unpkg/viewer/dist/index.d.ts +10 -0
  150. package/dist/unpkg/viewer/dist/index.js +9 -8391
  151. package/dist/unpkg/viewer/dist/minimap.d.ts +3 -0
  152. package/dist/unpkg/viewer/dist/minimap.js +63 -0
  153. package/dist/unpkg/viewer/dist/render.d.ts +6 -0
  154. package/dist/unpkg/viewer/dist/render.js +670 -0
  155. package/dist/unpkg/viewer/dist/runtime-3d.d.ts +19 -0
  156. package/dist/unpkg/viewer/dist/runtime-3d.js +494 -0
  157. package/dist/unpkg/viewer/dist/theme.d.ts +4 -0
  158. package/dist/unpkg/viewer/dist/theme.js +103 -0
  159. package/dist/unpkg/viewer/dist/tooltip.d.ts +3 -0
  160. package/dist/unpkg/viewer/dist/tooltip.js +198 -0
  161. package/dist/unpkg/viewer/dist/types.d.ts +292 -0
  162. package/dist/unpkg/viewer/dist/types.js +1 -0
  163. package/dist/unpkg/viewer/dist/vendor/three.module.js +53032 -0
  164. package/dist/unpkg/viewer/dist/viewer-state.d.ts +19 -0
  165. package/dist/unpkg/viewer/dist/viewer-state.js +162 -0
  166. package/dist/unpkg/viewer/dist/viewer.d.ts +2 -0
  167. package/dist/unpkg/viewer/dist/viewer.js +1662 -0
  168. package/dist/unpkg/worldorbit-core.min.js +1 -12
  169. package/dist/unpkg/worldorbit-editor.min.js +1 -904
  170. package/dist/unpkg/worldorbit-markdown.min.js +1 -103
  171. package/dist/unpkg/worldorbit-viewer.min.js +1 -259
  172. package/dist/unpkg/worldorbit.js +2 -9704
  173. package/dist/unpkg/worldorbit.min.js +2 -263
  174. package/package.json +1 -1
  175. package/packages/core/dist/index.d.ts +1 -0
  176. package/packages/core/dist/index.js +1 -0
  177. package/packages/core/dist/spatial-scene.d.ts +3 -0
  178. package/packages/core/dist/spatial-scene.js +420 -0
  179. package/packages/core/dist/types.d.ts +105 -0
  180. package/packages/editor/dist/editor.js +25 -4
  181. package/packages/editor/dist/types.d.ts +4 -0
  182. package/packages/markdown/dist/html.js +10 -3
  183. package/packages/viewer/dist/atlas-state.js +3 -0
  184. package/packages/viewer/dist/atlas-viewer.js +1 -0
  185. package/packages/viewer/dist/custom-element.js +18 -4
  186. package/packages/viewer/dist/embed.d.ts +5 -1
  187. package/packages/viewer/dist/embed.js +58 -24
  188. package/packages/viewer/dist/errors.d.ts +6 -0
  189. package/packages/viewer/dist/errors.js +12 -0
  190. package/packages/viewer/dist/index.d.ts +1 -0
  191. package/packages/viewer/dist/index.js +1 -0
  192. package/packages/viewer/dist/runtime-3d.d.ts +19 -0
  193. package/packages/viewer/dist/runtime-3d.js +494 -0
  194. package/packages/viewer/dist/types.d.ts +21 -2
  195. package/packages/viewer/dist/vendor/three.module.js +53032 -0
  196. package/packages/viewer/dist/viewer.js +501 -41
@@ -0,0 +1,19 @@
1
+ import { type CoordinatePoint, type RenderBounds, type RenderScene } from "@worldorbit/core";
2
+ import type { ViewerState } from "./types.js";
3
+ export interface ViewerConstraints {
4
+ minScale: number;
5
+ maxScale: number;
6
+ fitPadding: number;
7
+ }
8
+ export declare const DEFAULT_VIEWER_STATE: ViewerState;
9
+ export declare function normalizeRotation(rotationDeg: number): number;
10
+ export declare function clampScale(scale: number, constraints: ViewerConstraints): number;
11
+ export declare function panViewerState(state: ViewerState, dx: number, dy: number): ViewerState;
12
+ export declare function rotateViewerState(state: ViewerState, deltaDeg: number): ViewerState;
13
+ export declare function zoomViewerStateAt(scene: RenderScene, state: ViewerState, factor: number, anchor: CoordinatePoint, constraints: ViewerConstraints): ViewerState;
14
+ export declare function fitViewerState(scene: RenderScene, state: ViewerState, constraints: ViewerConstraints): ViewerState;
15
+ export declare function focusViewerState(scene: RenderScene, state: ViewerState, objectId: string, constraints: ViewerConstraints): ViewerState;
16
+ export declare function composeViewerTransform(scene: RenderScene, state: ViewerState): string;
17
+ export declare function invertViewerPoint(scene: RenderScene, state: ViewerState, point: CoordinatePoint): CoordinatePoint;
18
+ export declare function getViewerVisibleBounds(scene: RenderScene, state: ViewerState): RenderBounds;
19
+ export declare function getSceneCenter(scene: RenderScene): CoordinatePoint;
@@ -0,0 +1,162 @@
1
+ import { rotatePoint, } from "@worldorbit/core";
2
+ export const DEFAULT_VIEWER_STATE = {
3
+ scale: 1,
4
+ rotationDeg: 0,
5
+ translateX: 0,
6
+ translateY: 0,
7
+ selectedObjectId: null,
8
+ };
9
+ export function normalizeRotation(rotationDeg) {
10
+ let normalized = rotationDeg % 360;
11
+ if (normalized > 180) {
12
+ normalized -= 360;
13
+ }
14
+ if (normalized <= -180) {
15
+ normalized += 360;
16
+ }
17
+ return normalized;
18
+ }
19
+ export function clampScale(scale, constraints) {
20
+ return Math.min(Math.max(scale, constraints.minScale), constraints.maxScale);
21
+ }
22
+ export function panViewerState(state, dx, dy) {
23
+ return {
24
+ ...state,
25
+ translateX: state.translateX + dx,
26
+ translateY: state.translateY + dy,
27
+ };
28
+ }
29
+ export function rotateViewerState(state, deltaDeg) {
30
+ return {
31
+ ...state,
32
+ rotationDeg: normalizeRotation(state.rotationDeg + deltaDeg),
33
+ };
34
+ }
35
+ export function zoomViewerStateAt(scene, state, factor, anchor, constraints) {
36
+ if (!Number.isFinite(factor) || factor <= 0) {
37
+ return state;
38
+ }
39
+ const center = getSceneCenter(scene);
40
+ const nextScale = clampScale(state.scale * factor, constraints);
41
+ if (nextScale === state.scale) {
42
+ return state;
43
+ }
44
+ const zoomRatio = nextScale / state.scale;
45
+ const anchorDx = anchor.x - center.x;
46
+ const anchorDy = anchor.y - center.y;
47
+ return {
48
+ ...state,
49
+ scale: nextScale,
50
+ translateX: (1 - zoomRatio) * anchorDx + zoomRatio * state.translateX,
51
+ translateY: (1 - zoomRatio) * anchorDy + zoomRatio * state.translateY,
52
+ };
53
+ }
54
+ export function fitViewerState(scene, state, constraints) {
55
+ const center = getSceneCenter(scene);
56
+ const rotatedBounds = rotateBounds(scene.contentBounds, center, state.rotationDeg);
57
+ const availableWidth = Math.max(scene.width - constraints.fitPadding * 2, 1);
58
+ const availableHeight = Math.max(scene.height - constraints.fitPadding * 2, 1);
59
+ const safeWidth = Math.max(rotatedBounds.width, 1);
60
+ const safeHeight = Math.max(rotatedBounds.height, 1);
61
+ const nextScale = clampScale(Math.min(availableWidth / safeWidth, availableHeight / safeHeight), constraints);
62
+ const rotatedCenter = rotatePoint({
63
+ x: scene.contentBounds.centerX,
64
+ y: scene.contentBounds.centerY,
65
+ }, center, state.rotationDeg);
66
+ return {
67
+ ...state,
68
+ scale: nextScale,
69
+ translateX: center.x - (center.x + (rotatedCenter.x - center.x) * nextScale),
70
+ translateY: center.y - (center.y + (rotatedCenter.y - center.y) * nextScale),
71
+ };
72
+ }
73
+ export function focusViewerState(scene, state, objectId, constraints) {
74
+ const target = scene.objects.find((object) => object.objectId === objectId && !object.hidden);
75
+ if (!target) {
76
+ return state;
77
+ }
78
+ const center = getSceneCenter(scene);
79
+ const nextScale = clampScale(Math.max(state.scale, 1.8), constraints);
80
+ const rotatedPoint = rotatePoint({ x: target.x, y: target.y }, center, state.rotationDeg);
81
+ return {
82
+ ...state,
83
+ scale: nextScale,
84
+ translateX: center.x - (center.x + (rotatedPoint.x - center.x) * nextScale),
85
+ translateY: center.y - (center.y + (rotatedPoint.y - center.y) * nextScale),
86
+ selectedObjectId: objectId,
87
+ };
88
+ }
89
+ export function composeViewerTransform(scene, state) {
90
+ const center = getSceneCenter(scene);
91
+ return `translate(${state.translateX} ${state.translateY}) translate(${center.x} ${center.y}) rotate(${state.rotationDeg}) scale(${state.scale}) translate(${-center.x} ${-center.y})`;
92
+ }
93
+ export function invertViewerPoint(scene, state, point) {
94
+ const center = getSceneCenter(scene);
95
+ const translated = {
96
+ x: point.x - state.translateX,
97
+ y: point.y - state.translateY,
98
+ };
99
+ const centered = {
100
+ x: translated.x - center.x,
101
+ y: translated.y - center.y,
102
+ };
103
+ const scaled = {
104
+ x: centered.x / Math.max(state.scale, 0.0001),
105
+ y: centered.y / Math.max(state.scale, 0.0001),
106
+ };
107
+ const unrotated = rotatePoint({ x: scaled.x, y: scaled.y }, { x: 0, y: 0 }, -state.rotationDeg);
108
+ return {
109
+ x: center.x + unrotated.x,
110
+ y: center.y + unrotated.y,
111
+ };
112
+ }
113
+ export function getViewerVisibleBounds(scene, state) {
114
+ const corners = [
115
+ { x: 0, y: 0 },
116
+ { x: scene.width, y: 0 },
117
+ { x: scene.width, y: scene.height },
118
+ { x: 0, y: scene.height },
119
+ ].map((point) => invertViewerPoint(scene, state, point));
120
+ const minX = Math.min(...corners.map((corner) => corner.x));
121
+ const minY = Math.min(...corners.map((corner) => corner.y));
122
+ const maxX = Math.max(...corners.map((corner) => corner.x));
123
+ const maxY = Math.max(...corners.map((corner) => corner.y));
124
+ return {
125
+ minX,
126
+ minY,
127
+ maxX,
128
+ maxY,
129
+ width: maxX - minX,
130
+ height: maxY - minY,
131
+ centerX: minX + (maxX - minX) / 2,
132
+ centerY: minY + (maxY - minY) / 2,
133
+ };
134
+ }
135
+ export function getSceneCenter(scene) {
136
+ return {
137
+ x: scene.width / 2,
138
+ y: scene.height / 2,
139
+ };
140
+ }
141
+ function rotateBounds(bounds, center, rotationDeg) {
142
+ const corners = [
143
+ { x: bounds.minX, y: bounds.minY },
144
+ { x: bounds.maxX, y: bounds.minY },
145
+ { x: bounds.maxX, y: bounds.maxY },
146
+ { x: bounds.minX, y: bounds.maxY },
147
+ ].map((corner) => rotatePoint(corner, center, rotationDeg));
148
+ const minX = Math.min(...corners.map((corner) => corner.x));
149
+ const minY = Math.min(...corners.map((corner) => corner.y));
150
+ const maxX = Math.max(...corners.map((corner) => corner.x));
151
+ const maxY = Math.max(...corners.map((corner) => corner.y));
152
+ return {
153
+ minX,
154
+ minY,
155
+ maxX,
156
+ maxY,
157
+ width: maxX - minX,
158
+ height: maxY - minY,
159
+ centerX: minX + (maxX - minX) / 2,
160
+ centerY: minY + (maxY - minY) / 2,
161
+ };
162
+ }
@@ -0,0 +1,2 @@
1
+ import type { InteractiveViewerOptions, WorldOrbitViewer } from "./types.js";
2
+ export declare function createInteractiveViewer(container: HTMLElement, options: InteractiveViewerOptions): WorldOrbitViewer;