phoria2 1.2.0 → 1.4.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 (69) hide show
  1. package/README.md +11 -9
  2. package/dist/bloom.js +4 -4
  3. package/dist/bloom.js.map +1 -1
  4. package/dist/charts.js +527 -510
  5. package/dist/charts.js.map +1 -1
  6. package/dist/core.js +1760 -1170
  7. package/dist/core.js.map +1 -1
  8. package/dist/debug.js +297 -0
  9. package/dist/debug.js.map +1 -0
  10. package/dist/edit.js +60 -60
  11. package/dist/edit.js.map +1 -1
  12. package/dist/explain.js +32 -13
  13. package/dist/explain.js.map +1 -1
  14. package/dist/gltf.js +155 -155
  15. package/dist/gltf.js.map +1 -1
  16. package/dist/keyboard.js +188 -0
  17. package/dist/keyboard.js.map +1 -0
  18. package/dist/motion.js +35 -35
  19. package/dist/motion.js.map +1 -1
  20. package/dist/particles.js +187 -114
  21. package/dist/particles.js.map +1 -1
  22. package/dist/passes.js +116 -104
  23. package/dist/passes.js.map +1 -1
  24. package/dist/phoria2.js +1 -1
  25. package/dist/picking.js +95 -62
  26. package/dist/picking.js.map +1 -1
  27. package/dist/snapshot.js +1 -1
  28. package/dist/tooltip.js +1 -1
  29. package/dist/types/View.d.ts +27 -0
  30. package/dist/types/area.d.ts +18 -0
  31. package/dist/types/debug.d.ts +74 -0
  32. package/dist/types/explain.d.ts +4 -0
  33. package/dist/types/frame.d.ts +5 -0
  34. package/dist/types/geometry/Geometry.d.ts +16 -0
  35. package/dist/types/index.d.ts +2 -0
  36. package/dist/types/material/Material.d.ts +67 -0
  37. package/dist/types/material/Texture.d.ts +18 -2
  38. package/dist/types/particles/Emitter.d.ts +39 -2
  39. package/dist/types/scene/drawables.d.ts +23 -2
  40. package/dist/types/watch.d.ts +8 -1
  41. package/dist/types/webgl/hooks.d.ts +48 -0
  42. package/dist/types/webgl/passes.d.ts +4 -0
  43. package/dist/types/webgl/programs.d.ts +15 -5
  44. package/dist/types/webgl/resources.d.ts +12 -2
  45. package/dist/types/webgl/shaders.d.ts +41 -5
  46. package/llms-full.txt +275 -1
  47. package/llms.txt +1 -1
  48. package/package.json +1 -1
  49. package/schema/scene.schema.json +75 -0
  50. package/src/View.js +121 -7
  51. package/src/area.js +131 -0
  52. package/src/charts/marks.js +29 -2
  53. package/src/debug.js +283 -0
  54. package/src/explain.js +19 -0
  55. package/src/frame.js +7 -2
  56. package/src/geometry/Geometry.js +16 -1
  57. package/src/index.js +1 -0
  58. package/src/material/Material.js +130 -4
  59. package/src/material/Texture.js +55 -2
  60. package/src/particles/Emitter.js +121 -10
  61. package/src/scene/drawables.js +89 -8
  62. package/src/watch.js +26 -3
  63. package/src/webgl/WebGLRenderer.js +55 -7
  64. package/src/webgl/hooks.js +121 -0
  65. package/src/webgl/passes.js +17 -2
  66. package/src/webgl/picking.js +45 -3
  67. package/src/webgl/programs.js +20 -9
  68. package/src/webgl/resources.js +169 -15
  69. package/src/webgl/shaders.js +545 -38
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Small, friendly 3D for the web. A WebGL 2 renderer with PBR materials, shadows, instancing, points,
4
4
  lines, labels, picking, glTF models and particles, behind an API small enough to learn in an
5
5
  afternoon - aimed at business apps: charts, labelled scenes, diagrams, dashboards, floor plans and
6
- product viewers.
6
+ product viewers. The [demo gallery](https://kevs3d.co.uk/phoria2/).
7
7
 
8
8
  - **Small**: about 70 KB gzipped for a lit, interactive scene, and about 116 KB for everything;
9
9
  charts, particles, glTF, motion and editing are separate imports, and the heavier parts (shadows,
@@ -20,6 +20,9 @@ product viewers.
20
20
  - **Tells you what to write**: every option is checked, and a mistake throws an error that names
21
21
  the fix - pass `colour` and you get `Material: use 'color'`. Written to be easy for coding
22
22
  agents too.
23
+ - **Small shader hooks, not full shaders**: a line or two of GLSL in `material.shader` waves a flag,
24
+ dissolves a part or pulses a line, and lighting, shadows, picking and outlines keep working - the
25
+ hook runs inside phoria2's own shader. A hook that doesn't compile says which of its lines is wrong.
23
26
  - **Accessible**: `keyboard: true` lets people step through bars, points and parts with the
24
27
  arrow keys while a screen reader says what each one is; motion follows the system's
25
28
  reduced-motion setting.
@@ -29,8 +32,7 @@ product viewers.
29
32
 
30
33
  **New to phoria2?** The [getting started tutorial](https://kevs3d.co.uk/phoria2/tutorial.html)
31
34
  builds a first 3D scene and then a live dashboard of 3D charts, step by step - each step running
32
- beside its code, ready to copy as one HTML file. The [demo gallery](https://kevs3d.co.uk/phoria2/)
33
- shows the rest.
35
+ beside its code, ready to copy as one HTML file.
34
36
 
35
37
  **Using a coding agent?** Point it at [llms-full.txt](https://kevs3d.co.uk/phoria2/llms-full.txt) - the whole API
36
38
  in one page ([llms.txt](https://kevs3d.co.uk/phoria2/llms.txt) is the short index). Both ship in the
@@ -70,12 +72,12 @@ own). Pin the version so a new release can't change your page:
70
72
  <script type="importmap">
71
73
  {
72
74
  "imports": {
73
- "phoria2": "https://cdn.jsdelivr.net/npm/phoria2@1.2.0/dist/phoria2.js",
74
- "phoria2/charts": "https://cdn.jsdelivr.net/npm/phoria2@1.2.0/dist/charts.js",
75
- "phoria2/particles": "https://cdn.jsdelivr.net/npm/phoria2@1.2.0/dist/particles.js",
76
- "phoria2/gltf": "https://cdn.jsdelivr.net/npm/phoria2@1.2.0/dist/gltf.js",
77
- "phoria2/motion": "https://cdn.jsdelivr.net/npm/phoria2@1.2.0/dist/motion.js",
78
- "phoria2/edit": "https://cdn.jsdelivr.net/npm/phoria2@1.2.0/dist/edit.js"
75
+ "phoria2": "https://cdn.jsdelivr.net/npm/phoria2@1.4.0/dist/phoria2.js",
76
+ "phoria2/charts": "https://cdn.jsdelivr.net/npm/phoria2@1.4.0/dist/charts.js",
77
+ "phoria2/particles": "https://cdn.jsdelivr.net/npm/phoria2@1.4.0/dist/particles.js",
78
+ "phoria2/gltf": "https://cdn.jsdelivr.net/npm/phoria2@1.4.0/dist/gltf.js",
79
+ "phoria2/motion": "https://cdn.jsdelivr.net/npm/phoria2@1.4.0/dist/motion.js",
80
+ "phoria2/edit": "https://cdn.jsdelivr.net/npm/phoria2@1.4.0/dist/edit.js"
79
81
  }
80
82
  }
81
83
  </script>
package/dist/bloom.js CHANGED
@@ -1,4 +1,4 @@
1
- import { E as e, w as t } from "./core.js";
1
+ import { D as e, k as t } from "./core.js";
2
2
  // src/webgl/bloom.js
3
3
  var n = `precision highp float;
4
4
  in vec2 vUv;
@@ -6,7 +6,7 @@ uniform sampler2D uSource;
6
6
  uniform vec2 uTexel;
7
7
  uniform float uThreshold;
8
8
  out vec4 fragColor;
9
- ${t}
9
+ ${e}
10
10
  vec3 tap(vec2 uv) {
11
11
  vec3 c = texture(uSource, uv).rgb;
12
12
  return uThreshold < 0.0 ? c : srgbToLinear(c);
@@ -29,7 +29,7 @@ uniform sampler2D uScene;
29
29
  uniform sampler2D uBloom;
30
30
  uniform float uStrength;
31
31
  out vec4 fragColor;
32
- ${t}
32
+ ${e}
33
33
  void main() {
34
34
  vec4 scene = texture(uScene, vUv);
35
35
  vec3 glow = texture(uBloom, vUv).rgb * uStrength;
@@ -37,7 +37,7 @@ vec3 c = srgbToLinear(scene.rgb) + glow;
37
37
  float a = clamp(scene.a + max(glow.r, max(glow.g, glow.b)), 0.0, 1.0);
38
38
  fragColor = vec4(linearToSrgb(c), a);
39
39
  }
40
- `, a = [e, n], o = [e, r], s = [e, i], c = 6, l = class {
40
+ `, a = [t, n], o = [t, r], s = [t, i], c = 6, l = class {
41
41
  #e = null;
42
42
  #t = !1;
43
43
  constructor(e, t) {
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","#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":""}
1
+ {"version":3,"file":"bloom.js","names":["COMMON","FULLSCREEN_VERTEX","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":""}