tosijs-3d 0.8.2 → 0.8.3

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 (50) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/dist/b3d-cloud-deck.d.ts +4 -1
  3. package/dist/b3d-cloud-deck.d.ts.map +1 -1
  4. package/dist/b3d-cloud-deck.js +124 -16
  5. package/dist/b3d-cloud-deck.js.map +1 -1
  6. package/dist/b3d-galaxy.d.ts +66 -32
  7. package/dist/b3d-galaxy.d.ts.map +1 -1
  8. package/dist/b3d-galaxy.js +387 -329
  9. package/dist/b3d-galaxy.js.map +1 -1
  10. package/dist/b3d-skybox.d.ts +5 -0
  11. package/dist/b3d-skybox.d.ts.map +1 -1
  12. package/dist/b3d-skybox.js +124 -74
  13. package/dist/b3d-skybox.js.map +1 -1
  14. package/dist/b3d-terrain.d.ts +18 -2
  15. package/dist/b3d-terrain.d.ts.map +1 -1
  16. package/dist/b3d-terrain.js +73 -9
  17. package/dist/b3d-terrain.js.map +1 -1
  18. package/dist/biome-plugin.d.ts.map +1 -1
  19. package/dist/biome-plugin.js +5 -1
  20. package/dist/biome-plugin.js.map +1 -1
  21. package/dist/cloud-field.d.ts +3 -2
  22. package/dist/cloud-field.d.ts.map +1 -1
  23. package/dist/cloud-field.js +9 -5
  24. package/dist/cloud-field.js.map +1 -1
  25. package/dist/index.d.ts +1 -1
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +1 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/land-and-sky.d.ts +2 -0
  30. package/dist/land-and-sky.d.ts.map +1 -0
  31. package/dist/{world-sim.js → land-and-sky.js} +67 -26
  32. package/dist/land-and-sky.js.map +1 -0
  33. package/dist/landform.d.ts.map +1 -1
  34. package/dist/landform.js +29 -11
  35. package/dist/landform.js.map +1 -1
  36. package/dist/scene-schemas.d.ts.map +1 -1
  37. package/dist/scene-schemas.js +4 -0
  38. package/dist/scene-schemas.js.map +1 -1
  39. package/dist/skybox-baker.d.ts +55 -19
  40. package/dist/skybox-baker.d.ts.map +1 -1
  41. package/dist/skybox-baker.js +67 -25
  42. package/dist/skybox-baker.js.map +1 -1
  43. package/dist/starfield-codec.js +1 -1
  44. package/dist/widgets3d.js +1 -1
  45. package/package.json +1 -1
  46. package/static/attributes.json +16 -1
  47. package/static/attributes.txt +4 -1
  48. package/dist/world-sim.d.ts +0 -2
  49. package/dist/world-sim.d.ts.map +0 -1
  50. package/dist/world-sim.js.map +0 -1
@@ -2,6 +2,20 @@ import { B3dChild } from './b3d-utils.js';
2
2
  import * as BABYLON from '@babylonjs/core';
3
3
  import type { B3d } from './tosi-b3d.js';
4
4
  import { type StarData, type GalaxyData, type StarSystemData } from './galaxy-data.js';
5
+ /**
6
+ * A particle as the baker and the picker see it. The field names are the
7
+ * `SolidParticle` subset those consumers always read (`scaling`, not
8
+ * `scale`), so code written against the old particle system still reads it.
9
+ */
10
+ export interface GalaxyPoint {
11
+ /** Centre, in the mesh's own (Babylon, y-up) frame. */
12
+ position: BABYLON.Vector3;
13
+ /** The authored size multiplier — the quad is `particleSize × scaling.x`. */
14
+ scaling: {
15
+ x: number;
16
+ };
17
+ color: BABYLON.Color4;
18
+ }
5
19
  export declare class B3dGalaxy extends B3dChild {
6
20
  static preferredTagName: string;
7
21
  static shadowStyleSpec: {
@@ -35,31 +49,30 @@ export declare class B3dGalaxy extends B3dChild {
35
49
  maxStarApparentSize: number;
36
50
  owner: B3d | null;
37
51
  private rootNode;
38
- private starSps;
52
+ private starQuads;
39
53
  private starMesh;
40
- private nebulaSps;
54
+ private nebulaQuads;
41
55
  private nebulaMesh;
56
+ /** The fixed viewpoint set by `facePoint`, or null to follow the camera. */
57
+ private faceTarget;
42
58
  private blackHoleEl;
43
59
  private galaxyData;
44
60
  private originalColors;
45
61
  private registered;
46
- private _beforeRender;
47
62
  content: () => string;
48
63
  sceneReady(owner: B3d, scene: BABYLON.Scene): void;
49
64
  sceneDispose(): void;
50
65
  /**
51
- * Point every particle at THE CAMERA POSITION — a fixed world point, rather
52
- * than at the camera's view plane.
53
- *
54
- * ⚠️ THIS IS WHAT MAKES A CUBE BAKE WORK. `SolidParticleSystem.billboard`
55
- * aligns quads to the camera's VIEW PLANE, which is a different plane for
56
- * each of a cube's six faces — so every star and nebula silently re-orients
57
- * between captures, and the faces disagree at their seams.
66
+ * Face every particle at a FIXED world point instead of the live camera, and
67
+ * clamp star sizes as seen from it. `null` hands orientation back to the
68
+ * camera.
58
69
  *
59
- * A cube map is ONE viewpoint photographed six ways. All six share a camera
60
- * POSITION and differ only in rotation, so that position is what the
61
- * particles should face: do it once, and every face sees each nebula from the
62
- * same angle and as the same shape.
70
+ * The particles always face the viewpoint's POSITION — the vertex shader
71
+ * does that (see `registerShaders`) — so a cube bake's six faces, which share
72
+ * a position and differ only in rotation, already agree at their seams
73
+ * without this. What a fixed point adds is the APPARENT-SIZE CLAMP
74
+ * (`maxStarApparentSize`), which only means something from one known
75
+ * viewpoint, and a guarantee that nothing between captures can move it.
63
76
  *
64
77
  * ⚠️ NOT the galactic centre. This was first written as `faceOrigin`, which
65
78
  * named the wrong thing even though the argument was right — Tonio: "No
@@ -67,10 +80,12 @@ export declare class B3dGalaxy extends B3dChild {
67
80
  * way out from the core, so facing the core would tilt every particle away
68
81
  * from the viewer by a different amount depending where it sits.
69
82
  *
70
- * Pass `null` to hand orientation back to the live camera.
83
+ * (This used to write a rotation into every particle on the CPU, alongside
84
+ * Babylon's own per-frame billboarding — two mechanisms that COMPOSED rather
85
+ * than replaced each other, which is how a restore once left every star a
86
+ * vertical smear. One uniform cannot stack with anything.)
71
87
  */
72
88
  facePoint(target: BABYLON.Vector3 | null): void;
73
- private update;
74
89
  private disposeMeshes;
75
90
  private registerShaders;
76
91
  private createShaderMaterial;
@@ -82,31 +97,50 @@ export declare class B3dGalaxy extends B3dChild {
82
97
  getStarSystem(index: number): StarSystemData | null;
83
98
  /** Get the galaxy data */
84
99
  getGalaxyData(): GalaxyData | null;
85
- /** Get the star SPS for external picking */
86
- getStarSPS(): BABYLON.SolidParticleSystem | null;
87
- /** Get the star SPS mesh for pick comparison */
100
+ /**
101
+ * @deprecated There is no particle system any more — stars are billboarded
102
+ * in the vertex shader. Use {@link pickStar} to pick. Returns null; removed
103
+ * in 0.9.
104
+ */
105
+ getStarSPS(): null;
106
+ /** The star mesh — hide it, fade it, or compare against it. */
88
107
  getStarMesh(): BABYLON.Mesh | null;
89
108
  /**
90
- * The DISTANT STAR particles, for the skybox baker — the tail of the star
91
- * SPS, in the same order `generateGalaxy` made them (see the note in
92
- * `galaxy-data`).
109
+ * Every point in the star mesh — the disc stars in generation order, then
110
+ * the distant stars — in the mesh's own (Babylon) frame.
111
+ */
112
+ getStarPoints(): GalaxyPoint[];
113
+ /**
114
+ * The star under a screen point, or `-1`.
115
+ *
116
+ * ⚠️ NOT `scene.pick`. The mesh's CPU geometry is every quad collapsed to its
117
+ * centre — the corners only exist in the vertex shader — so a triangle pick
118
+ * finds nothing. This casts the pick ray and takes the NEAREST star whose
119
+ * drawn disc it passes through, with a few pixels of slack so a star a
120
+ * pixel wide is still clickable (the old quad pick was not that kind).
121
+ */
122
+ pickStar(x: number, y: number, camera?: BABYLON.Camera | null): number;
123
+ /**
124
+ * The DISTANT STAR points, for the skybox baker — the tail of the star
125
+ * mesh, in the same order `generateGalaxy` made them.
93
126
  */
94
- getDistantStarParticles(): BABYLON.SolidParticle[];
127
+ getDistantStarParticles(): GalaxyPoint[];
95
128
  /**
96
- * The DISTANT GALAXY particles, for the skybox baker.
129
+ * The DISTANT GALAXY points, for the skybox baker.
97
130
  *
98
- * They live inside the nebula SPS (appended last, in generation order — see
99
- * the note in `galaxy-data`), so the only code that knows which particles
100
- * they are without guessing by size or colour is the code next to the build.
101
- * That is here: the last `distantGalaxies.length` particles, in the SPS's
131
+ * They live inside the nebula mesh (appended last, in generation order — see
132
+ * the note in `galaxy-data`), so the only code that knows which points they
133
+ * are without guessing by size or colour is the code next to the build.
134
+ * That is here: the last `distantGalaxies.length` points, in the mesh's
102
135
  * own (Babylon) frame — which is the frame a baker photographs in.
103
136
  */
104
- getDistantGalaxyParticles(): BABYLON.SolidParticle[];
105
- /** Hide a star particle (e.g. to replace it with a star system) */
137
+ getDistantGalaxyParticles(): GalaxyPoint[];
138
+ private isStarIndex;
139
+ /** Hide a star (e.g. to replace it with a star system) */
106
140
  hideStarAt(index: number): void;
107
- /** Show a previously hidden star particle */
141
+ /** Show a previously hidden star */
108
142
  showStarAt(index: number): void;
109
- /** Get the world position of a star particle */
143
+ /** Get the world position of a star */
110
144
  getStarPosition(index: number): BABYLON.Vector3 | null;
111
145
  /** Filter stars: dim those that don't match criteria */
112
146
  filterStars(options?: {
@@ -1 +1 @@
1
- {"version":3,"file":"b3d-galaxy.d.ts","sourceRoot":"","sources":["../src/b3d-galaxy.ts"],"names":[],"mappings":"AA8UA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAA;AAC1C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAGL,KAAK,QAAQ,EACb,KAAK,UAAU,EACf,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAA;AAGzB,qBAAa,SAAU,SAAQ,QAAQ;IACrC,MAAM,CAAC,gBAAgB,SAAoB;IAE3C,MAAM,CAAC,eAAe;;;;MAIrB;IAED,MAAM,CAAC,cAAc;;;;;;;;;;;;MA0CpB;IAEO,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,CAAA;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM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