phoria2 1.0.0-rc.4 → 1.0.0-rc.6

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 (54) hide show
  1. package/README.md +25 -8
  2. package/dist/bloom.js +13 -17
  3. package/dist/bloom.js.map +1 -1
  4. package/dist/charts.js +732 -672
  5. package/dist/charts.js.map +1 -1
  6. package/dist/core.js +1878 -1315
  7. package/dist/core.js.map +1 -1
  8. package/dist/edit.js +91 -77
  9. package/dist/edit.js.map +1 -1
  10. package/dist/explain.js +6 -6
  11. package/dist/explain.js.map +1 -1
  12. package/dist/gltf.js +167 -163
  13. package/dist/gltf.js.map +1 -1
  14. package/dist/motion.js +38 -43
  15. package/dist/motion.js.map +1 -1
  16. package/dist/particles.js +41 -41
  17. package/dist/particles.js.map +1 -1
  18. package/dist/passes.js +124 -74
  19. package/dist/passes.js.map +1 -1
  20. package/dist/phoria2.js +1 -1
  21. package/dist/picking.js +45 -56
  22. package/dist/picking.js.map +1 -1
  23. package/dist/snapshot.js +1 -1
  24. package/dist/tooltip.js +3 -3
  25. package/dist/tooltip.js.map +1 -1
  26. package/dist/types/OrbitControl.d.ts +13 -0
  27. package/dist/types/Raycaster.d.ts +12 -1
  28. package/dist/types/View.d.ts +2 -2
  29. package/dist/types/charts/marks.d.ts +7 -0
  30. package/dist/types/charts/network.d.ts +1 -4
  31. package/dist/types/charts/scales.d.ts +10 -3
  32. package/dist/types/ease.d.ts +4 -0
  33. package/dist/types/explain.d.ts +9 -1
  34. package/dist/types/frame.d.ts +43 -2
  35. package/dist/types/geometry/Geometry.d.ts +1 -1
  36. package/dist/types/geometry/bvh.d.ts +32 -0
  37. package/dist/types/material/Material.d.ts +32 -12
  38. package/dist/types/material/Texture.d.ts +13 -2
  39. package/dist/types/motion/ease.d.ts +3 -4
  40. package/dist/types/presets.d.ts +17 -13
  41. package/dist/types/scene/Node.d.ts +57 -10
  42. package/dist/types/scene/cameras.d.ts +7 -0
  43. package/dist/types/scene/drawables.d.ts +9 -2
  44. package/dist/types/scene/lights.d.ts +15 -1
  45. package/dist/types/shadow.d.ts +15 -0
  46. package/dist/types/validate.d.ts +22 -0
  47. package/dist/types/webgl/passes.d.ts +24 -16
  48. package/dist/types/webgl/programs.d.ts +6 -0
  49. package/dist/types/webgl/resources.d.ts +16 -0
  50. package/dist/types/webgl/shaders.d.ts +2 -2
  51. package/llms-full.txt +588 -0
  52. package/llms.txt +31 -0
  53. package/package.json +14 -4
  54. package/schema/chart.schema.json +1 -1
package/README.md CHANGED
@@ -4,8 +4,9 @@ Small, friendly 3D for the web. A WebGL 2 renderer with PBR materials, instancin
4
4
  labels, picking and particles, behind an API small enough to learn in an afternoon - aimed at
5
5
  business apps: charts, labelled scenes, diagrams, dashboards and product viewers.
6
6
 
7
- - **Small**: about 46 KB gzipped for a lit, interactive scene; charts, particles and glTF are
8
- separate imports, and the heavier parts (shadows, HDR environments, GPU picking) load only when used.
7
+ - **Small**: about 57 KB gzipped for a lit, interactive scene, and about 116 KB for everything;
8
+ charts, particles, glTF, motion and editing are separate imports, and the heavier parts (shadows,
9
+ HDR environments, GPU picking) load only when used.
9
10
  - **Idle when nothing changes**: a view draws only when something in it changed, so a dashboard of
10
11
  many views only updates when needed.
11
12
  - **Tells you what to write**: every option is checked, and a mistake throws an error that names
@@ -13,6 +14,22 @@ business apps: charts, labelled scenes, diagrams, dashboards and product viewers
13
14
  agents too.
14
15
  - **No runtime dependencies.** ES modules, with TypeScript types.
15
16
 
17
+ **Using a coding agent?** Point it at [llms-full.txt](https://kevs3d.co.uk/phoria2/llms-full.txt) - the whole API
18
+ in one page ([llms.txt](https://kevs3d.co.uk/phoria2/llms.txt) is the short index). Both ship in the
19
+ package too, at `node_modules/phoria2/llms-full.txt`.
20
+
21
+ **Claude Code**: install the phoria2 plugin, and Claude reaches for phoria2 when asked for 3D charts,
22
+ diagrams, explainers or dashboards - with the reference to hand and a check that loads the page in
23
+ Chrome and reports what's wrong:
24
+
25
+ ```text
26
+ /plugin marketplace add kevinroast/phoria2
27
+ /plugin install phoria2@phoria2
28
+ ```
29
+
30
+ The skill inside it ([claude-plugin/skills/phoria2](claude-plugin/skills/phoria2)) follows the Agent
31
+ Skills standard, so other agents that read skills can use the folder as it is.
32
+
16
33
  ## Install
17
34
 
18
35
  ```sh
@@ -35,12 +52,12 @@ own). Pin the version so a new release can't change your page:
35
52
  <script type="importmap">
36
53
  {
37
54
  "imports": {
38
- "phoria2": "https://cdn.jsdelivr.net/npm/phoria2@1.0.0-rc.4/dist/phoria2.js",
39
- "phoria2/charts": "https://cdn.jsdelivr.net/npm/phoria2@1.0.0-rc.4/dist/charts.js",
40
- "phoria2/particles": "https://cdn.jsdelivr.net/npm/phoria2@1.0.0-rc.4/dist/particles.js",
41
- "phoria2/gltf": "https://cdn.jsdelivr.net/npm/phoria2@1.0.0-rc.4/dist/gltf.js",
42
- "phoria2/motion": "https://cdn.jsdelivr.net/npm/phoria2@1.0.0-rc.4/dist/motion.js",
43
- "phoria2/edit": "https://cdn.jsdelivr.net/npm/phoria2@1.0.0-rc.4/dist/edit.js"
55
+ "phoria2": "https://cdn.jsdelivr.net/npm/phoria2@1.0.0-rc.6/dist/phoria2.js",
56
+ "phoria2/charts": "https://cdn.jsdelivr.net/npm/phoria2@1.0.0-rc.6/dist/charts.js",
57
+ "phoria2/particles": "https://cdn.jsdelivr.net/npm/phoria2@1.0.0-rc.6/dist/particles.js",
58
+ "phoria2/gltf": "https://cdn.jsdelivr.net/npm/phoria2@1.0.0-rc.6/dist/gltf.js",
59
+ "phoria2/motion": "https://cdn.jsdelivr.net/npm/phoria2@1.0.0-rc.6/dist/motion.js",
60
+ "phoria2/edit": "https://cdn.jsdelivr.net/npm/phoria2@1.0.0-rc.6/dist/edit.js"
44
61
  }
45
62
  }
46
63
  </script>
package/dist/bloom.js CHANGED
@@ -1,4 +1,4 @@
1
- import { F as e, N as t } from "./core.js";
1
+ import { I as e, P as t } from "./core.js";
2
2
  // src/webgl/bloom.js
3
3
  var n = `precision highp float;
4
4
  in vec2 vUv;
@@ -39,44 +39,43 @@ fragColor = vec4(linearToSrgb(c), a);
39
39
  }
40
40
  `, a = [e, n], o = [e, r], s = [e, i], c = 6, l = class {
41
41
  #e = null;
42
- #t = null;
43
- #n = !1;
42
+ #t = !1;
44
43
  constructor(e, t) {
45
44
  this.gl = e, this.programs = t, this.reset();
46
45
  }
47
46
  reset() {
48
- this.#e = null, this.#t = null, this.#n = !!this.gl.getExtension("EXT_color_buffer_float");
47
+ this.#e = null, this.#t = !!this.gl.getExtension("EXT_color_buffer_float");
49
48
  }
50
49
  dispose() {
51
- this.#i(), this.#e = null;
50
+ this.#r(), this.#e = null;
52
51
  }
53
52
  begin(e, t) {
54
- let n = this.gl, r = this.#r(e, t);
53
+ let n = this.gl, r = this.#n(e, t);
55
54
  n.bindFramebuffer(n.FRAMEBUFFER, r.multisampled), n.viewport(0, 0, e, t);
56
55
  }
57
56
  end(e) {
58
57
  let t = this.gl, n = this.#e, { width: r, height: i, levels: c } = n;
59
- t.bindFramebuffer(t.READ_FRAMEBUFFER, n.multisampled), t.bindFramebuffer(t.DRAW_FRAMEBUFFER, n.resolved), t.blitFramebuffer(0, 0, r, i, 0, 0, r, i, t.COLOR_BUFFER_BIT, t.NEAREST), t.bindFramebuffer(t.READ_FRAMEBUFFER, null), t.bindFramebuffer(t.DRAW_FRAMEBUFFER, null), t.disable(t.DEPTH_TEST), t.disable(t.CULL_FACE), t.disable(t.BLEND), t.depthMask(!1), t.bindVertexArray(this.#a());
58
+ t.bindFramebuffer(t.READ_FRAMEBUFFER, n.multisampled), t.bindFramebuffer(t.DRAW_FRAMEBUFFER, n.resolved), t.blitFramebuffer(0, 0, r, i, 0, 0, r, i, t.COLOR_BUFFER_BIT, t.NEAREST), t.bindFramebuffer(t.READ_FRAMEBUFFER, null), t.bindFramebuffer(t.DRAW_FRAMEBUFFER, null), t.disable(t.DEPTH_TEST), t.disable(t.CULL_FACE), t.disable(t.BLEND), t.depthMask(!1);
60
59
  let l = this.programs.ready("bloom-down", [], a);
61
60
  t.useProgram(l.program);
62
61
  let u = n.picture, d = r, f = i;
63
62
  c.forEach((n, r) => {
64
- t.bindFramebuffer(t.FRAMEBUFFER, n.framebuffer), t.viewport(0, 0, n.width, n.height), l.set("uSource", u), l.set("uTexel", [1 / d, 1 / f]), l.set("uThreshold", r === 0 ? Math.max(0, e.threshold) : -1), t.drawArrays(t.TRIANGLES, 0, 3), u = n.texture, d = n.width, f = n.height;
63
+ t.bindFramebuffer(t.FRAMEBUFFER, n.framebuffer), t.viewport(0, 0, n.width, n.height), l.set("uSource", u), l.set("uTexel", [1 / d, 1 / f]), l.set("uThreshold", r === 0 ? Math.max(0, e.threshold) : -1), this.programs.drawFullscreen(), u = n.texture, d = n.width, f = n.height;
65
64
  });
66
65
  let p = this.programs.ready("bloom-up", [], o);
67
66
  t.useProgram(p.program), t.enable(t.BLEND), t.blendFunc(t.ONE, t.ONE);
68
67
  let m = Math.min(1, Math.max(0, e.radius));
69
68
  for (let e = c.length - 1; e > 0; e--) {
70
69
  let n = c[e], r = c[e - 1];
71
- t.bindFramebuffer(t.FRAMEBUFFER, r.framebuffer), t.viewport(0, 0, r.width, r.height), p.set("uSource", n.texture), p.set("uTexel", [1 / n.width, 1 / n.height]), p.set("uWeight", m), t.drawArrays(t.TRIANGLES, 0, 3);
70
+ t.bindFramebuffer(t.FRAMEBUFFER, r.framebuffer), t.viewport(0, 0, r.width, r.height), p.set("uSource", n.texture), p.set("uTexel", [1 / n.width, 1 / n.height]), p.set("uWeight", m), this.programs.drawFullscreen();
72
71
  }
73
72
  t.disable(t.BLEND), t.bindFramebuffer(t.FRAMEBUFFER, null), t.viewport(0, 0, r, i);
74
73
  let h = this.programs.ready("bloom-composite", [], s);
75
- t.useProgram(h.program), h.set("uScene", n.picture), h.set("uBloom", c[0].texture), h.set("uStrength", Math.max(0, e.strength)), t.drawArrays(t.TRIANGLES, 0, 3), t.depthMask(!0), t.enable(t.DEPTH_TEST), t.bindVertexArray(null);
74
+ t.useProgram(h.program), h.set("uScene", n.picture), h.set("uBloom", c[0].texture), h.set("uStrength", Math.max(0, e.strength)), this.programs.drawFullscreen(), t.depthMask(!0), t.enable(t.DEPTH_TEST), t.bindVertexArray(null);
76
75
  }
77
- #r(e, t) {
76
+ #n(e, t) {
78
77
  if (this.#e && this.#e.width === e && this.#e.height === t) return this.#e;
79
- this.#i();
78
+ this.#r();
80
79
  let n = this.gl, r = Math.min(4, n.getParameter(n.MAX_SAMPLES)), i = n.createFramebuffer();
81
80
  n.bindFramebuffer(n.FRAMEBUFFER, i);
82
81
  let a = n.createRenderbuffer();
@@ -94,7 +93,7 @@ fragColor = vec4(linearToSrgb(c), a);
94
93
  height: t
95
94
  };
96
95
  }, l = s(e, t, n.RGBA8), u = [], d = e, f = t;
97
- for (let e = 0; e < c && (d = Math.max(1, d >> 1), f = Math.max(1, f >> 1), !(e > 1 && Math.min(d, f) < 8)); e++) u.push(s(d, f, this.#n ? n.RGBA16F : n.RGBA8));
96
+ for (let e = 0; e < c && (d = Math.max(1, d >> 1), f = Math.max(1, f >> 1), !(e > 1 && Math.min(d, f) < 8)); e++) u.push(s(d, f, this.#t ? n.RGBA16F : n.RGBA8));
98
97
  return n.bindFramebuffer(n.FRAMEBUFFER, null), n.bindRenderbuffer(n.RENDERBUFFER, null), this.#e = {
99
98
  width: e,
100
99
  height: t,
@@ -105,7 +104,7 @@ fragColor = vec4(linearToSrgb(c), a);
105
104
  levels: u
106
105
  }, this.#e;
107
106
  }
108
- #i() {
107
+ #r() {
109
108
  let e = this.#e;
110
109
  if (!e) return;
111
110
  let t = this.gl;
@@ -114,9 +113,6 @@ fragColor = vec4(linearToSrgb(c), a);
114
113
  t.deleteFramebuffer(e.resolved), t.deleteTexture(e.picture);
115
114
  for (let n of e.levels) t.deleteFramebuffer(n.framebuffer), t.deleteTexture(n.texture);
116
115
  }
117
- #a() {
118
- return this.#t ||= this.gl.createVertexArray(), this.#t;
119
- }
120
116
  };
121
117
  export { l as Bloom };
122
118
 
package/dist/bloom.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"bloom.js","names":["FULLSCREEN_VERTEX","COMMON","DOWN_FRAGMENT","UP_FRAGMENT","COMPOSITE_FRAGMENT","DOWN","UP","COMPOSITE","LEVELS","Bloom","gl","programs","#target","#empty","#float","#free","target","#targetFor","width","height","#emptyArray","down","source","sw","sh","level","i","settings","up","weight","levels","from","to","composite","samples","multisampled","color","depth","texture","t","format","w","h","framebuffer","picture","b"],"sources":[],"mappings":""}
1
+ {"version":3,"file":"bloom.js","names":["FULLSCREEN_VERTEX","COMMON","DOWN_FRAGMENT","UP_FRAGMENT","COMPOSITE_FRAGMENT","DOWN","UP","COMPOSITE","LEVELS","Bloom","gl","programs","#target","#float","#free","target","#targetFor","width","height","down","source","sw","sh","level","i","settings","up","weight","levels","from","to","composite","samples","multisampled","color","depth","texture","t","format","w","h","framebuffer","picture","b"],"sources":[],"mappings":""}