@3driseai/3drise-core 1.0.20 → 1.0.22

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 (185) hide show
  1. package/dist/autoAnimate/composer.d.ts +6 -0
  2. package/dist/autoAnimate/composer.d.ts.map +1 -1
  3. package/dist/autoAnimate/composer.js +4 -3
  4. package/dist/autoAnimate/describeScene.js +1 -1
  5. package/dist/catalog/catalogInfo.d.ts +22 -0
  6. package/dist/catalog/catalogInfo.d.ts.map +1 -0
  7. package/dist/catalog/catalogInfo.js +204 -0
  8. package/dist/catalog/index.d.ts +3 -0
  9. package/dist/catalog/index.d.ts.map +1 -0
  10. package/dist/catalog/index.js +2 -0
  11. package/dist/catalog/objectCatalog.d.ts +33 -0
  12. package/dist/catalog/objectCatalog.d.ts.map +1 -0
  13. package/dist/catalog/objectCatalog.js +99 -0
  14. package/dist/data/allMaterials.js +2 -2
  15. package/dist/data/environmentDefaults.d.ts +10 -0
  16. package/dist/data/environmentDefaults.d.ts.map +1 -0
  17. package/dist/data/environmentDefaults.js +126 -0
  18. package/dist/data/gridsDefaults.d.ts +2 -0
  19. package/dist/data/gridsDefaults.d.ts.map +1 -1
  20. package/dist/data/gridsDefaults.js +186 -0
  21. package/dist/data/index.d.ts +4 -0
  22. package/dist/data/index.d.ts.map +1 -1
  23. package/dist/data/index.js +4 -0
  24. package/dist/data/landDefaults.d.ts +26 -0
  25. package/dist/data/landDefaults.d.ts.map +1 -0
  26. package/dist/data/landDefaults.js +76 -0
  27. package/dist/data/spaceDefaults.d.ts +10 -0
  28. package/dist/data/spaceDefaults.d.ts.map +1 -0
  29. package/dist/data/spaceDefaults.js +46 -0
  30. package/dist/data/textDefaults.d.ts +16 -0
  31. package/dist/data/textDefaults.d.ts.map +1 -0
  32. package/dist/data/textDefaults.js +199 -0
  33. package/dist/environment/oceanConfigs.d.ts +5 -4
  34. package/dist/environment/oceanConfigs.d.ts.map +1 -1
  35. package/dist/environment/oceanConfigs.js +2 -2
  36. package/dist/environment/terrainConfigs.d.ts +78 -0
  37. package/dist/environment/terrainConfigs.d.ts.map +1 -1
  38. package/dist/environment/terrainConfigs.js +72 -2
  39. package/dist/index.d.ts +3 -1
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +3 -1
  42. package/dist/properties/registry.d.ts +10 -1
  43. package/dist/properties/registry.d.ts.map +1 -1
  44. package/dist/properties/registry.js +60 -9
  45. package/dist/properties/tables/environmentProperties.d.ts +9 -0
  46. package/dist/properties/tables/environmentProperties.d.ts.map +1 -0
  47. package/dist/properties/tables/environmentProperties.js +127 -0
  48. package/dist/properties/tables/gridProperties.d.ts.map +1 -1
  49. package/dist/properties/tables/gridProperties.js +184 -82
  50. package/dist/properties/tables/index.d.ts +4 -1
  51. package/dist/properties/tables/index.d.ts.map +1 -1
  52. package/dist/properties/tables/index.js +4 -1
  53. package/dist/properties/tables/landProperties.d.ts +5 -0
  54. package/dist/properties/tables/landProperties.d.ts.map +1 -0
  55. package/dist/properties/tables/landProperties.js +24 -0
  56. package/dist/properties/tables/lightProperties.js +1 -1
  57. package/dist/properties/tables/materialBounds.js +1 -1
  58. package/dist/properties/tables/optionalProperties.d.ts +1 -2
  59. package/dist/properties/tables/optionalProperties.d.ts.map +1 -1
  60. package/dist/properties/tables/optionalProperties.js +21 -0
  61. package/dist/properties/tables/spaceProperties.d.ts +8 -0
  62. package/dist/properties/tables/spaceProperties.d.ts.map +1 -0
  63. package/dist/properties/tables/spaceProperties.js +42 -0
  64. package/dist/properties/tables/textProperties.d.ts +4 -0
  65. package/dist/properties/tables/textProperties.d.ts.map +1 -0
  66. package/dist/properties/tables/textProperties.js +361 -0
  67. package/dist/properties/types.d.ts +1 -1
  68. package/dist/properties/types.d.ts.map +1 -1
  69. package/dist/services/MaterialRegistry.d.ts.map +1 -1
  70. package/dist/services/MaterialRegistry.js +2 -0
  71. package/dist/services/SkySystemManager.d.ts +22 -0
  72. package/dist/services/SkySystemManager.d.ts.map +1 -1
  73. package/dist/services/SkySystemManager.js +50 -18
  74. package/dist/services/TextureResolver.d.ts.map +1 -1
  75. package/dist/services/TextureResolver.js +22 -0
  76. package/dist/services/index.d.ts +1 -1
  77. package/dist/services/index.d.ts.map +1 -1
  78. package/dist/services/index.js +1 -1
  79. package/dist/shaders/ApollonianGridMaterial.d.ts +70 -0
  80. package/dist/shaders/ApollonianGridMaterial.d.ts.map +1 -0
  81. package/dist/shaders/ApollonianGridMaterial.js +289 -0
  82. package/dist/shaders/ConformalGridMaterial.d.ts +91 -0
  83. package/dist/shaders/ConformalGridMaterial.d.ts.map +1 -0
  84. package/dist/shaders/ConformalGridMaterial.js +335 -0
  85. package/dist/shaders/HilbertGridMaterial.d.ts +79 -0
  86. package/dist/shaders/HilbertGridMaterial.d.ts.map +1 -0
  87. package/dist/shaders/HilbertGridMaterial.js +329 -0
  88. package/dist/shaders/LensingGridMaterial.d.ts +73 -0
  89. package/dist/shaders/LensingGridMaterial.d.ts.map +1 -0
  90. package/dist/shaders/LensingGridMaterial.js +253 -0
  91. package/dist/shaders/ParastichyGridMaterial.d.ts +76 -0
  92. package/dist/shaders/ParastichyGridMaterial.d.ts.map +1 -0
  93. package/dist/shaders/ParastichyGridMaterial.js +282 -0
  94. package/dist/shaders/PhyllotaxisGridMaterial.d.ts +85 -0
  95. package/dist/shaders/PhyllotaxisGridMaterial.d.ts.map +1 -0
  96. package/dist/shaders/PhyllotaxisGridMaterial.js +532 -0
  97. package/dist/shaders/SkyboxMaterial.js +3 -3
  98. package/dist/shaders/StarsMaterial.d.ts +5 -0
  99. package/dist/shaders/StarsMaterial.d.ts.map +1 -1
  100. package/dist/shaders/StarsMaterial.js +59 -57
  101. package/dist/shaders/TruchetGridMaterial.d.ts +76 -0
  102. package/dist/shaders/TruchetGridMaterial.d.ts.map +1 -0
  103. package/dist/shaders/TruchetGridMaterial.js +290 -0
  104. package/dist/shaders/index.d.ts +7 -0
  105. package/dist/shaders/index.d.ts.map +1 -1
  106. package/dist/shaders/index.js +7 -0
  107. package/dist/types/actions.d.ts +6 -5
  108. package/dist/types/actions.d.ts.map +1 -1
  109. package/dist/types/commands.d.ts +61 -0
  110. package/dist/types/commands.d.ts.map +1 -0
  111. package/dist/types/commands.js +1 -0
  112. package/dist/types/environment.d.ts +34 -1
  113. package/dist/types/environment.d.ts.map +1 -1
  114. package/dist/types/environment.js +15 -0
  115. package/dist/types/environmentObjects.d.ts +152 -0
  116. package/dist/types/environmentObjects.d.ts.map +1 -0
  117. package/dist/types/environmentObjects.js +10 -0
  118. package/dist/types/index.d.ts +5 -1
  119. package/dist/types/index.d.ts.map +1 -1
  120. package/dist/types/landObjects.d.ts +15 -0
  121. package/dist/types/landObjects.d.ts.map +1 -0
  122. package/dist/types/landObjects.js +1 -0
  123. package/dist/types/objectSettings.d.ts +187 -16
  124. package/dist/types/objectSettings.d.ts.map +1 -1
  125. package/dist/types/objectsConfigs.d.ts +0 -3
  126. package/dist/types/objectsConfigs.d.ts.map +1 -1
  127. package/dist/types/scene3d.d.ts +8 -5
  128. package/dist/types/scene3d.d.ts.map +1 -1
  129. package/dist/types/spaceObjects.d.ts +65 -0
  130. package/dist/types/spaceObjects.d.ts.map +1 -0
  131. package/dist/types/spaceObjects.js +11 -0
  132. package/dist/types/textObjects.d.ts +352 -0
  133. package/dist/types/textObjects.d.ts.map +1 -0
  134. package/dist/types/textObjects.js +14 -0
  135. package/dist/types/types.d.ts +3 -6
  136. package/dist/types/types.d.ts.map +1 -1
  137. package/dist/types/users.d.ts +3 -1
  138. package/dist/types/users.d.ts.map +1 -1
  139. package/dist/types/users.js +2 -0
  140. package/dist/ui/index.d.ts +5 -0
  141. package/dist/ui/index.d.ts.map +1 -0
  142. package/dist/ui/index.js +4 -0
  143. package/dist/ui/uiBindings.d.ts +45 -0
  144. package/dist/ui/uiBindings.d.ts.map +1 -0
  145. package/dist/ui/uiBindings.js +172 -0
  146. package/dist/ui/uiKeys.d.ts +14 -0
  147. package/dist/ui/uiKeys.d.ts.map +1 -0
  148. package/dist/ui/uiKeys.js +22 -0
  149. package/dist/ui/uiSanitize.d.ts +18 -0
  150. package/dist/ui/uiSanitize.d.ts.map +1 -0
  151. package/dist/ui/uiSanitize.js +251 -0
  152. package/dist/ui/uiSpec.d.ts +116 -0
  153. package/dist/ui/uiSpec.d.ts.map +1 -0
  154. package/dist/ui/uiSpec.js +173 -0
  155. package/dist/utils/environmentMigration.d.ts +3 -0
  156. package/dist/utils/environmentMigration.d.ts.map +1 -0
  157. package/dist/utils/environmentMigration.js +50 -0
  158. package/dist/utils/generativeAnimatable.d.ts +1 -1
  159. package/dist/utils/generativeAnimatable.d.ts.map +1 -1
  160. package/dist/utils/generativeAnimatable.js +12 -0
  161. package/dist/utils/getAnimatableProperties.d.ts +1 -1
  162. package/dist/utils/getAnimatableProperties.d.ts.map +1 -1
  163. package/dist/utils/getAnimatableProperties.js +1 -1
  164. package/dist/utils/gridMigration.d.ts +3 -0
  165. package/dist/utils/gridMigration.d.ts.map +1 -0
  166. package/dist/utils/gridMigration.js +34 -0
  167. package/dist/utils/index.d.ts +5 -0
  168. package/dist/utils/index.d.ts.map +1 -1
  169. package/dist/utils/index.js +5 -0
  170. package/dist/utils/objectEffects.d.ts +24 -2
  171. package/dist/utils/objectEffects.d.ts.map +1 -1
  172. package/dist/utils/objectEffects.js +29 -2
  173. package/dist/utils/objectMigration.d.ts +9 -0
  174. package/dist/utils/objectMigration.d.ts.map +1 -0
  175. package/dist/utils/objectMigration.js +12 -0
  176. package/dist/utils/skyPhase.d.ts +61 -0
  177. package/dist/utils/skyPhase.d.ts.map +1 -0
  178. package/dist/utils/skyPhase.js +93 -0
  179. package/dist/utils/spaceMigration.d.ts +3 -0
  180. package/dist/utils/spaceMigration.d.ts.map +1 -0
  181. package/dist/utils/spaceMigration.js +46 -0
  182. package/dist/utils/sunUtils.d.ts +26 -1
  183. package/dist/utils/sunUtils.d.ts.map +1 -1
  184. package/dist/utils/sunUtils.js +37 -6
  185. package/package.json +1 -1
@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AG,CAAC,CAAC;IACnC,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,aAAa,CAAC,EAAE;QACZ,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC1C,CAAC;IACF,MAAM,CAAC,EAAE,CAAC;QACN,IAAI,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IACzB,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,SAAS,CAAC,EAAE,qBAAqB,GAAG,oBAAoB,CAAC;CAC5D;AAmBD,4CAA4C;AAC5C,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKrD;AAUD,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,gBAAgB,GAAG,kBAAkB,EAAE,CAMlH;AAKD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAUhH"}
@@ -41,7 +41,7 @@ export function getAnimatableProperties(settings, domain) {
41
41
  .map(toAnimatable);
42
42
  }
43
43
  /** Domain priority when a name exists in more than one (edges before material: an edges key shadows the mesh's). */
44
- const DETECT_ORDER = ['edges', 'light', 'effect', 'grid', 'particles', 'clouds', 'rain', 'material'];
44
+ const DETECT_ORDER = ['edges', 'light', 'effect', 'grid', 'environment', 'space', 'land', 'text', 'particles', 'clouds', 'rain', 'sky', 'ocean', 'terrain', 'material'];
45
45
  /**
46
46
  * Detect which domain a property name belongs to, for a given target. Used by
47
47
  * the runtime + UI to migrate flat MouseMove arrays into the new per-domain
@@ -0,0 +1,3 @@
1
+ import type { CreatedObjectSettings } from '../types/scene3d';
2
+ export declare function migrateGridObject<T extends CreatedObjectSettings>(obj: T): T;
3
+ //# sourceMappingURL=gridMigration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gridMigration.d.ts","sourceRoot":"","sources":["../../src/utils/gridMigration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAoB9D,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,qBAAqB,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAgB5E"}
@@ -0,0 +1,34 @@
1
+ import { Euler, Quaternion } from 'three';
2
+ // =============================================================================
3
+ // Grids — load-time migration of the legacy surface knobs
4
+ // =============================================================================
5
+ //
6
+ // Every grid now lies flat in its own frame (the plane on local XZ, facing +Y);
7
+ // standing it up is the parent object's rotation, and pointer behaviour is a
8
+ // Pointer-tab binding. Older grids carried two knobs for that:
9
+ // flat: false the plane stood upright on local XY. Kept as it looked by
10
+ // turning the object +90° about its own X axis, so the now-flat
11
+ // plane ends up exactly where the upright one was.
12
+ // followMouse the ripple focus tracked the cursor. Dropped: the focus stays
13
+ // at the grid's centre.
14
+ // Both keys are removed. Pure and idempotent: returns the same object when there
15
+ // is nothing to migrate, so it can run on every load without marking anything dirty.
16
+ //
17
+ const UPRIGHT = new Quaternion().setFromEuler(new Euler(Math.PI / 2, 0, 0));
18
+ export function migrateGridObject(obj) {
19
+ if (!obj || obj.type !== 'grid')
20
+ return obj;
21
+ const config = obj.config;
22
+ if (!config || (!('flat' in config) && !('followMouse' in config)))
23
+ return obj;
24
+ const { flat, followMouse: _followMouse, ...rest } = config;
25
+ const next = { ...obj, config: rest };
26
+ if (flat === false) {
27
+ const mesh = obj.meshSettings ?? {};
28
+ const r = Array.isArray(mesh.rotation) ? mesh.rotation : [0, 0, 0];
29
+ const q = new Quaternion().setFromEuler(new Euler(r[0] ?? 0, r[1] ?? 0, r[2] ?? 0)).multiply(UPRIGHT);
30
+ const e = new Euler().setFromQuaternion(q);
31
+ next.meshSettings = { ...mesh, rotation: [e.x, e.y, e.z] };
32
+ }
33
+ return next;
34
+ }
@@ -16,6 +16,7 @@ export * from './meshUtils';
16
16
  export * from './pathUtils';
17
17
  export * from './positionsCreatorUtils';
18
18
  export * from './sunUtils';
19
+ export * from './skyPhase';
19
20
  export * from './utils';
20
21
  export * from './edgeUtils';
21
22
  export * from './surfaceUtils';
@@ -33,6 +34,10 @@ export * from './handleEdgesMouseMove';
33
34
  export * from './handleLightMouseMove';
34
35
  export * from './sceneQuery';
35
36
  export * from './shootingStarHelpers';
37
+ export * from './spaceMigration';
38
+ export * from './gridMigration';
39
+ export * from './environmentMigration';
40
+ export * from './objectMigration';
36
41
  export * from './environmentUtils';
37
42
  export * from './MaterialCompiler';
38
43
  export * from './nodeOverrides';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,iBAAiB,CAAC;AAChC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc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wB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC"}
@@ -16,6 +16,7 @@ export * from './meshUtils.js';
16
16
  export * from './pathUtils.js';
17
17
  export * from './positionsCreatorUtils.js';
18
18
  export * from './sunUtils.js';
19
+ export * from './skyPhase.js';
19
20
  export * from './utils.js';
20
21
  export * from './edgeUtils.js';
21
22
  export * from './surfaceUtils.js';
@@ -33,6 +34,10 @@ export * from './handleEdgesMouseMove.js';
33
34
  export * from './handleLightMouseMove.js';
34
35
  export * from './sceneQuery.js';
35
36
  export * from './shootingStarHelpers.js';
37
+ export * from './spaceMigration.js';
38
+ export * from './gridMigration.js';
39
+ export * from './environmentMigration.js';
40
+ export * from './objectMigration.js';
36
41
  export * from './environmentUtils.js';
37
42
  export * from './MaterialCompiler.js';
38
43
  export * from './nodeOverrides.js';
@@ -1,6 +1,28 @@
1
- import type { ObjectEffect } from '../types/objectSettings';
2
- /** The object effects of a stored object — entries of any older shape (generative effects) are dropped. */
1
+ import type { EffectSpread, EffectSteps, ObjectEffect, ObjectEffectClip } from '../types/objectSettings';
2
+ /**
3
+ * Visual effects layer GLSL onto three's standard materials, so they take only objects drawn with
4
+ * them: meshes, models and the legacy 2d / 3d text. Every other scene object (particles, grids, text
5
+ * looks, lights, weather, space, generative effects…) takes physical (transform) effects only, for now —
6
+ * they move the object's group, whatever draws inside it.
7
+ */
8
+ export declare function objectTakesVisualEffects(o: {
9
+ type?: string;
10
+ config?: unknown;
11
+ } | null | undefined): boolean;
12
+ /** A group's stagger when its clip sets none (see EffectSpread). */
13
+ export declare const DEFAULT_EFFECT_SPREAD: Required<EffectSpread>;
14
+ /** An object's effect clip (`effects`), or an empty one. The stored value itself — identity stays stable. */
15
+ export declare function objectEffectClipOf(settings: {
16
+ effects?: unknown;
17
+ } | null | undefined): ObjectEffectClip;
18
+ /** The object's Base effects (well-formed entries only). */
3
19
  export declare function objectEffectsOf(settings: {
4
20
  effects?: unknown;
5
21
  } | null | undefined): ObjectEffect[];
22
+ /** The steps of an effect clip as the effects controller takes them, or null when it has none. */
23
+ export declare function objectEffectStepsOf(clip: ObjectEffectClip | null | undefined): EffectSteps | null;
24
+ /** The object with its effect clip changed (Base effects normalised, the rest kept). */
25
+ export declare function withObjectEffectClip<T extends {
26
+ effects?: unknown;
27
+ }>(settings: T, patch: Partial<ObjectEffectClip>): T;
6
28
  //# sourceMappingURL=objectEffects.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"objectEffects.d.ts","sourceRoot":"","sources":["../../src/utils/objectEffects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,2GAA2G;AAC3G,wBAAgB,eAAe,CAAC,QAAQ,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,EAAE,CAGlG"}
1
+ {"version":3,"file":"objectEffects.d.ts","sourceRoot":"","sources":["../../src/utils/objectEffects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGzG;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAG3G;AAED,oEAAoE;AACpE,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,YAAY,CAAiD,CAAC;AAI3G,6GAA6G;AAC7G,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,GAAG,gBAAgB,CAGvG;AAED,4DAA4D;AAC5D,wBAAgB,eAAe,CAAC,QAAQ,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,GAAG,YAAY,EAAE,CAGlG;AAED,kGAAkG;AAClG,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,gBAAgB,GAAG,IAAI,GAAG,SAAS,GAAG,WAAW,GAAG,IAAI,CAEjG;AAED,wFAAwF;AACxF,wBAAgB,oBAAoB,CAAC,CAAC,SAAS;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAEtH"}
@@ -1,5 +1,32 @@
1
- /** The object effects of a stored object — entries of any older shape (generative effects) are dropped. */
1
+ import { isTextObjectConfig } from '../data/textDefaults.js';
2
+ /**
3
+ * Visual effects layer GLSL onto three's standard materials, so they take only objects drawn with
4
+ * them: meshes, models and the legacy 2d / 3d text. Every other scene object (particles, grids, text
5
+ * looks, lights, weather, space, generative effects…) takes physical (transform) effects only, for now —
6
+ * they move the object's group, whatever draws inside it.
7
+ */
8
+ export function objectTakesVisualEffects(o) {
9
+ // a group never draws an effect itself: its visual effects go to each child that takes them
10
+ return o?.type === 'mesh' || o?.type === 'model' || o?.type === 'group' || (o?.type === 'text' && !isTextObjectConfig(o.config));
11
+ }
12
+ /** A group's stagger when its clip sets none (see EffectSpread). */
13
+ export const DEFAULT_EFFECT_SPREAD = { order: 'tree', total: 0.6, out: 'reverse' };
14
+ const EMPTY = Object.freeze({ effects: [] });
15
+ /** An object's effect clip (`effects`), or an empty one. The stored value itself — identity stays stable. */
16
+ export function objectEffectClipOf(settings) {
17
+ const c = settings?.effects;
18
+ return c && typeof c === 'object' && !Array.isArray(c) ? c : EMPTY;
19
+ }
20
+ /** The object's Base effects (well-formed entries only). */
2
21
  export function objectEffectsOf(settings) {
3
- const list = settings?.effects;
22
+ const list = objectEffectClipOf(settings).effects;
4
23
  return Array.isArray(list) ? list.filter((e) => e && typeof e.operation === 'string' && typeof e.id === 'string') : [];
5
24
  }
25
+ /** The steps of an effect clip as the effects controller takes them, or null when it has none. */
26
+ export function objectEffectStepsOf(clip) {
27
+ return clip?.steps?.length ? { steps: clip.steps, loop: clip.loop, yoyo: clip.yoyo } : null;
28
+ }
29
+ /** The object with its effect clip changed (Base effects normalised, the rest kept). */
30
+ export function withObjectEffectClip(settings, patch) {
31
+ return { ...settings, effects: { ...objectEffectClipOf(settings), effects: objectEffectsOf(settings), ...patch } };
32
+ }
@@ -0,0 +1,9 @@
1
+ import type { CreatedObjectSettings } from '../types/scene3d';
2
+ /**
3
+ * Every load-time migration of saved scene objects, in one pass. Each step is
4
+ * pure, idempotent and returns the same object when there is nothing to change,
5
+ * so this runs on every load (objectsSlice, the viewer ProjectLoader). A family
6
+ * whose saved shape changes adds its step here.
7
+ */
8
+ export declare function migrateObject<T extends CreatedObjectSettings>(obj: T): T;
9
+ //# sourceMappingURL=objectMigration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"objectMigration.d.ts","sourceRoot":"","sources":["../../src/utils/objectMigration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAK9D;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,qBAAqB,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAExE"}
@@ -0,0 +1,12 @@
1
+ import { migrateSpaceObject } from './spaceMigration.js';
2
+ import { migrateGridObject } from './gridMigration.js';
3
+ import { migrateEnvironmentObject } from './environmentMigration.js';
4
+ /**
5
+ * Every load-time migration of saved scene objects, in one pass. Each step is
6
+ * pure, idempotent and returns the same object when there is nothing to change,
7
+ * so this runs on every load (objectsSlice, the viewer ProjectLoader). A family
8
+ * whose saved shape changes adds its step here.
9
+ */
10
+ export function migrateObject(obj) {
11
+ return migrateEnvironmentObject(migrateGridObject(migrateSpaceObject(obj)));
12
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Time-of-day phases, keyed by SUN ELEVATION — never by the clock.
3
+ *
4
+ * Everything that changes with the time of day (the Preetham atmosphere, star
5
+ * visibility, labels) reads these, so they all turn at the moment the sun
6
+ * actually crosses the horizon, whatever sunrise/sunset hours or sun model is in
7
+ * use. There used to be six hour tables that disagreed by up to 1.5 h.
8
+ *
9
+ * Keys, in degrees of sun elevation:
10
+ * night ≤ −12 (astronomical-ish: sky fully dark)
11
+ * twilight −4 (blue hour, sun just below the horizon)
12
+ * golden 3 (sun on the horizon: reddest, haziest)
13
+ * day ≥ 15
14
+ * Between two keys the weights cross-fade with a smoothstep; they always sum to 1.
15
+ */
16
+ export interface SkyPhaseWeights {
17
+ night: number;
18
+ twilight: number;
19
+ golden: number;
20
+ day: number;
21
+ }
22
+ export interface SkyAtmosphere {
23
+ turbidity: number;
24
+ rayleigh: number;
25
+ mieCoefficient: number;
26
+ mieDirectionalG: number;
27
+ }
28
+ export declare const SKY_PHASE_ELEVATIONS: {
29
+ readonly night: -12;
30
+ readonly twilight: -4;
31
+ readonly golden: 3;
32
+ readonly day: 15;
33
+ };
34
+ /** Built-in atmospheres for the non-day phases. The day look is the user's own
35
+ * sky settings (see atmosphereForSunElevation). */
36
+ export declare const SKY_PHASE_ATMOSPHERES: Record<'night' | 'twilight' | 'golden', SkyAtmosphere>;
37
+ /** Phase weights for a sun elevation in degrees. Sum to 1. */
38
+ export declare function skyPhaseWeights(sunElevation: number, out?: SkyPhaseWeights): SkyPhaseWeights;
39
+ /**
40
+ * The Preetham atmosphere for a sun elevation: the user's `day` look by day,
41
+ * blended through golden hour and twilight into night as the sun goes down.
42
+ * The user's sliders, keyframes and pointer bindings keep working with the clock
43
+ * on — they shape the day, and time of day adds the evening around it.
44
+ */
45
+ export declare function atmosphereForSunElevation(sunElevation: number, day: SkyAtmosphere, out?: SkyAtmosphere): SkyAtmosphere;
46
+ /** How visible the night sky is (stars, moon halo): 0 by day, 1 once the sun is
47
+ * 12° down. */
48
+ export declare function nightAmount(sunElevation: number): number;
49
+ /**
50
+ * How bright the sky dome is drawn, 1 by day. Preetham alone never gets darker
51
+ * than a flat grey after sunset (its constant 0.1 base term), so the night reads
52
+ * as overcast dusk instead of night. SkyMesh multiplies its output by this.
53
+ */
54
+ export declare const SKY_PHASE_BRIGHTNESS: {
55
+ readonly night: 0.08;
56
+ readonly twilight: 0.5;
57
+ readonly golden: 1;
58
+ readonly day: 1;
59
+ };
60
+ export declare function skyBrightnessForSunElevation(sunElevation: number): number;
61
+ //# sourceMappingURL=skyPhase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skyPhase.d.ts","sourceRoot":"","sources":["../../src/utils/skyPhase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,eAAe;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,oBAAoB;;;;;CAA4D,CAAC;AAE9F;oDACoD;AACpD,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,OAAO,GAAG,UAAU,GAAG,QAAQ,EAAE,aAAa,CAIxF,CAAC;AAOF,8DAA8D;AAC9D,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,eAAe,GAAG,eAAe,CAmB5F;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,GAAG,CAAC,EAAE,aAAa,GAAG,aAAa,CAStH;AAED;gBACgB;AAChB,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;CAA6D,CAAC;AAE/F,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAIzE"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Time-of-day phases, keyed by SUN ELEVATION — never by the clock.
3
+ *
4
+ * Everything that changes with the time of day (the Preetham atmosphere, star
5
+ * visibility, labels) reads these, so they all turn at the moment the sun
6
+ * actually crosses the horizon, whatever sunrise/sunset hours or sun model is in
7
+ * use. There used to be six hour tables that disagreed by up to 1.5 h.
8
+ *
9
+ * Keys, in degrees of sun elevation:
10
+ * night ≤ −12 (astronomical-ish: sky fully dark)
11
+ * twilight −4 (blue hour, sun just below the horizon)
12
+ * golden 3 (sun on the horizon: reddest, haziest)
13
+ * day ≥ 15
14
+ * Between two keys the weights cross-fade with a smoothstep; they always sum to 1.
15
+ */
16
+ export const SKY_PHASE_ELEVATIONS = { night: -12, twilight: -4, golden: 3, day: 15 };
17
+ /** Built-in atmospheres for the non-day phases. The day look is the user's own
18
+ * sky settings (see atmosphereForSunElevation). */
19
+ export const SKY_PHASE_ATMOSPHERES = {
20
+ night: { turbidity: 0.5, rayleigh: 0.1, mieCoefficient: 0.001, mieDirectionalG: 0.8 },
21
+ twilight: { turbidity: 2.5, rayleigh: 2.0, mieCoefficient: 0.008, mieDirectionalG: 0.86 },
22
+ golden: { turbidity: 4.5, rayleigh: 3.5, mieCoefficient: 0.012, mieDirectionalG: 0.92 },
23
+ };
24
+ const smooth = (t) => {
25
+ const c = Math.max(0, Math.min(1, t));
26
+ return c * c * (3 - 2 * c);
27
+ };
28
+ /** Phase weights for a sun elevation in degrees. Sum to 1. */
29
+ export function skyPhaseWeights(sunElevation, out) {
30
+ const w = out ?? { night: 0, twilight: 0, golden: 0, day: 0 };
31
+ w.night = 0;
32
+ w.twilight = 0;
33
+ w.golden = 0;
34
+ w.day = 0;
35
+ const { night, twilight, golden, day } = SKY_PHASE_ELEVATIONS;
36
+ if (sunElevation <= night) {
37
+ w.night = 1;
38
+ return w;
39
+ }
40
+ if (sunElevation >= day) {
41
+ w.day = 1;
42
+ return w;
43
+ }
44
+ if (sunElevation < twilight) {
45
+ const t = smooth((sunElevation - night) / (twilight - night));
46
+ w.night = 1 - t;
47
+ w.twilight = t;
48
+ }
49
+ else if (sunElevation < golden) {
50
+ const t = smooth((sunElevation - twilight) / (golden - twilight));
51
+ w.twilight = 1 - t;
52
+ w.golden = t;
53
+ }
54
+ else {
55
+ const t = smooth((sunElevation - golden) / (day - golden));
56
+ w.golden = 1 - t;
57
+ w.day = t;
58
+ }
59
+ return w;
60
+ }
61
+ /**
62
+ * The Preetham atmosphere for a sun elevation: the user's `day` look by day,
63
+ * blended through golden hour and twilight into night as the sun goes down.
64
+ * The user's sliders, keyframes and pointer bindings keep working with the clock
65
+ * on — they shape the day, and time of day adds the evening around it.
66
+ */
67
+ export function atmosphereForSunElevation(sunElevation, day, out) {
68
+ const w = skyPhaseWeights(sunElevation);
69
+ const { night: n, twilight: t, golden: g } = SKY_PHASE_ATMOSPHERES;
70
+ const o = out ?? { turbidity: 0, rayleigh: 0, mieCoefficient: 0, mieDirectionalG: 0 };
71
+ o.turbidity = w.night * n.turbidity + w.twilight * t.turbidity + w.golden * g.turbidity + w.day * day.turbidity;
72
+ o.rayleigh = w.night * n.rayleigh + w.twilight * t.rayleigh + w.golden * g.rayleigh + w.day * day.rayleigh;
73
+ o.mieCoefficient = w.night * n.mieCoefficient + w.twilight * t.mieCoefficient + w.golden * g.mieCoefficient + w.day * day.mieCoefficient;
74
+ o.mieDirectionalG = w.night * n.mieDirectionalG + w.twilight * t.mieDirectionalG + w.golden * g.mieDirectionalG + w.day * day.mieDirectionalG;
75
+ return o;
76
+ }
77
+ /** How visible the night sky is (stars, moon halo): 0 by day, 1 once the sun is
78
+ * 12° down. */
79
+ export function nightAmount(sunElevation) {
80
+ const w = skyPhaseWeights(sunElevation);
81
+ return w.night + w.twilight * 0.5;
82
+ }
83
+ /**
84
+ * How bright the sky dome is drawn, 1 by day. Preetham alone never gets darker
85
+ * than a flat grey after sunset (its constant 0.1 base term), so the night reads
86
+ * as overcast dusk instead of night. SkyMesh multiplies its output by this.
87
+ */
88
+ export const SKY_PHASE_BRIGHTNESS = { night: 0.08, twilight: 0.5, golden: 1, day: 1 };
89
+ export function skyBrightnessForSunElevation(sunElevation) {
90
+ const w = skyPhaseWeights(sunElevation);
91
+ const b = SKY_PHASE_BRIGHTNESS;
92
+ return w.night * b.night + w.twilight * b.twilight + w.golden * b.golden + w.day * b.day;
93
+ }
@@ -0,0 +1,3 @@
1
+ import type { CreatedObjectSettings } from '../types/scene3d';
2
+ export declare function migrateSpaceObject<T extends CreatedObjectSettings>(obj: T): T;
3
+ //# sourceMappingURL=spaceMigration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spaceMigration.d.ts","sourceRoot":"","sources":["../../src/utils/spaceMigration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAsB9D,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,qBAAqB,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CA2B7E"}
@@ -0,0 +1,46 @@
1
+ // =============================================================================
2
+ // Space objects — load-time migration of the legacy config
3
+ // =============================================================================
4
+ //
5
+ // The old starfield spun itself through a `rotateSpeed` knob (rotation.y +=
6
+ // rotateSpeed * 0.01 every frame). Spinning the whole object is the parent's
7
+ // transform, so the knob is gone from the space family; a saved starfield that
8
+ // had it gets the equivalent transform 'spin' effect instead (rad/s at 60 fps),
9
+ // unless it already animates its transform (a rotation effect, or keyframes: an
10
+ // enabled transform effect would switch those off). The dead `size` / `sep` keys (never
11
+ // read by the renderer) are dropped too.
12
+ //
13
+ // Pure and idempotent: returns the same object when there is nothing to migrate,
14
+ // so it can run on every load without marking anything dirty.
15
+ //
16
+ const ROTATION_EFFECTS = new Set(['rotate3d', 'spin', 'sway', 'flip']);
17
+ /** The old per-frame step (0.01 rad per unit) at 60 frames per second. */
18
+ const LEGACY_FRAMES_PER_SECOND = 60;
19
+ export function migrateSpaceObject(obj) {
20
+ if (!obj || obj.type !== 'space')
21
+ return obj;
22
+ const config = obj.config;
23
+ if (!config || config.type !== 'stars')
24
+ return obj;
25
+ if (!('rotateSpeed' in config) && !('size' in config) && !('sep' in config))
26
+ return obj;
27
+ const { rotateSpeed, size: _size, sep: _sep, ...rest } = config;
28
+ const next = { ...obj, config: rest };
29
+ const speed = typeof rotateSpeed === 'number' ? rotateSpeed * 0.01 * LEGACY_FRAMES_PER_SECOND : 0;
30
+ if (speed > 0) {
31
+ const animations = obj.animations ?? {};
32
+ const transform = animations.transform ?? {};
33
+ const effects = transform.effects ?? [];
34
+ const keyframed = (transform.animations?.length ?? 0) > 0;
35
+ if (!keyframed && !effects.some(e => ROTATION_EFFECTS.has(e?.type))) {
36
+ const hasOther = Object.entries(animations).some(([k, v]) => k !== 'enabled' && v && ((v.animations?.length ?? 0) > 0 || (v.effects?.length ?? 0) > 0));
37
+ next.animations = {
38
+ ...animations,
39
+ // Switch the animations on only when nothing else is there that the user may have turned off.
40
+ enabled: hasOther ? (animations.enabled ?? true) : true,
41
+ transform: { ...transform, effects: [...effects, { type: 'spin', enabled: true, speed, options: { axis: 'y' } }] },
42
+ };
43
+ }
44
+ }
45
+ return next;
46
+ }
@@ -1,6 +1,31 @@
1
- export declare function createSunPosition(elevation: number, azimuth: number): {
1
+ /**
2
+ * THE sun direction convention for 3drise. Every piece that turns an
3
+ * elevation/azimuth pair into a direction — the Preetham sky, the key light,
4
+ * the day-cycle clock, the clouds, the ocean, the terrain, the lighting rig —
5
+ * goes through `sunDirectionFromAngles`, so the sun that is drawn and the sun
6
+ * that lights the scene cannot disagree.
7
+ *
8
+ * elevation degrees above the horizon (90 = straight up, negative = below)
9
+ * azimuth degrees around +Y, measured from +X towards +Z
10
+ * (0 → +X, 90 → +Z, 180 → −X, −90 → −Z)
11
+ *
12
+ * There used to be two conventions: this one (Preetham sky, LightsManager) and
13
+ * x = sin(az), z = cos(az) (the clock, the skybox shader, useCloudSun), which
14
+ * mirrored the lit sun across the x = z plane — up to 137° away from the disc.
15
+ */
16
+ export interface Vec3Like {
2
17
  x: number;
3
18
  y: number;
4
19
  z: number;
20
+ }
21
+ /** Unit vector toward the sun. Writes into `out` when given (a THREE.Vector3
22
+ * works), so per-frame callers allocate nothing. */
23
+ export declare function sunDirectionFromAngles<T extends Vec3Like = Vec3Like>(elevation: number, azimuth: number, out?: T): T;
24
+ /** Inverse of `sunDirectionFromAngles`. The vector need not be normalised. */
25
+ export declare function sunAnglesFromDirection(dir: Vec3Like): {
26
+ elevation: number;
27
+ azimuth: number;
5
28
  };
29
+ /** Kept for existing callers; same convention. */
30
+ export declare function createSunPosition(elevation: number, azimuth: number): Vec3Like;
6
31
  //# sourceMappingURL=sunUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sunUtils.d.ts","sourceRoot":"","sources":["../../src/utils/sunUtils.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG;IAC/D,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACb,CAQJ"}
1
+ {"version":3,"file":"sunUtils.d.ts","sourceRoot":"","sources":["../../src/utils/sunUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,QAAQ;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACb;AAID;qDACqD;AACrD,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CASpH;AAED,8EAA8E;AAC9E,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,QAAQ,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAM5F;AAED,kDAAkD;AAClD,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,QAAQ,CAE9E"}
@@ -1,9 +1,40 @@
1
- export function createSunPosition(elevation, azimuth) {
2
- const phi = (90 - elevation) * (Math.PI / 180);
3
- const theta = azimuth * (Math.PI / 180);
1
+ /**
2
+ * THE sun direction convention for 3drise. Every piece that turns an
3
+ * elevation/azimuth pair into a direction — the Preetham sky, the key light,
4
+ * the day-cycle clock, the clouds, the ocean, the terrain, the lighting rig —
5
+ * goes through `sunDirectionFromAngles`, so the sun that is drawn and the sun
6
+ * that lights the scene cannot disagree.
7
+ *
8
+ * elevation degrees above the horizon (90 = straight up, negative = below)
9
+ * azimuth degrees around +Y, measured from +X towards +Z
10
+ * (0 → +X, 90 → +Z, 180 → −X, −90 → −Z)
11
+ *
12
+ * There used to be two conventions: this one (Preetham sky, LightsManager) and
13
+ * x = sin(az), z = cos(az) (the clock, the skybox shader, useCloudSun), which
14
+ * mirrored the lit sun across the x = z plane — up to 137° away from the disc.
15
+ */
16
+ const DEG = Math.PI / 180;
17
+ /** Unit vector toward the sun. Writes into `out` when given (a THREE.Vector3
18
+ * works), so per-frame callers allocate nothing. */
19
+ export function sunDirectionFromAngles(elevation, azimuth, out) {
20
+ const el = elevation * DEG;
21
+ const az = azimuth * DEG;
22
+ const c = Math.cos(el);
23
+ const target = (out ?? { x: 0, y: 0, z: 0 });
24
+ target.x = c * Math.cos(az);
25
+ target.y = Math.sin(el);
26
+ target.z = c * Math.sin(az);
27
+ return target;
28
+ }
29
+ /** Inverse of `sunDirectionFromAngles`. The vector need not be normalised. */
30
+ export function sunAnglesFromDirection(dir) {
31
+ const r = Math.sqrt(dir.x * dir.x + dir.y * dir.y + dir.z * dir.z) || 1;
4
32
  return {
5
- x: Math.sin(phi) * Math.cos(theta),
6
- y: Math.cos(phi),
7
- z: Math.sin(phi) * Math.sin(theta),
33
+ elevation: Math.asin(Math.max(-1, Math.min(1, dir.y / r))) / DEG,
34
+ azimuth: Math.atan2(dir.z, dir.x) / DEG,
8
35
  };
9
36
  }
37
+ /** Kept for existing callers; same convention. */
38
+ export function createSunPosition(elevation, azimuth) {
39
+ return sunDirectionFromAngles(elevation, azimuth);
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3driseai/3drise-core",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",