@3driseai/3drise-viewer 0.1.16 → 0.1.18

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 (145) hide show
  1. package/README.md +4 -3
  2. package/dist/components/ChladniGrid.d.ts +15 -0
  3. package/dist/components/ChladniGrid.d.ts.map +1 -0
  4. package/dist/components/ChladniGrid.js +62 -0
  5. package/dist/components/CustomPrimitive.d.ts +2 -0
  6. package/dist/components/CustomPrimitive.d.ts.map +1 -1
  7. package/dist/components/CustomPrimitive.js +2 -2
  8. package/dist/components/EffectsGenerator.d.ts.map +1 -1
  9. package/dist/components/EffectsGenerator.js +26 -2
  10. package/dist/components/FlowNetGrid.d.ts +15 -0
  11. package/dist/components/FlowNetGrid.d.ts.map +1 -0
  12. package/dist/components/FlowNetGrid.js +61 -0
  13. package/dist/components/Galaxy.d.ts.map +1 -1
  14. package/dist/components/Galaxy.js +2 -0
  15. package/dist/components/GirihGrid.d.ts +15 -0
  16. package/dist/components/GirihGrid.d.ts.map +1 -0
  17. package/dist/components/GirihGrid.js +62 -0
  18. package/dist/components/GravWaveGrid.d.ts +15 -0
  19. package/dist/components/GravWaveGrid.d.ts.map +1 -0
  20. package/dist/components/GravWaveGrid.js +62 -0
  21. package/dist/components/GridsGenerator.d.ts +2 -2
  22. package/dist/components/GridsGenerator.d.ts.map +1 -1
  23. package/dist/components/GridsGenerator.js +21 -0
  24. package/dist/components/HyperbolicGrid.d.ts +15 -0
  25. package/dist/components/HyperbolicGrid.d.ts.map +1 -0
  26. package/dist/components/HyperbolicGrid.js +61 -0
  27. package/dist/components/LayoutInstances.d.ts +13 -0
  28. package/dist/components/LayoutInstances.d.ts.map +1 -0
  29. package/dist/components/LayoutInstances.js +39 -0
  30. package/dist/components/ModelPrimitive.d.ts +2 -0
  31. package/dist/components/ModelPrimitive.d.ts.map +1 -1
  32. package/dist/components/ModelPrimitive.js +3 -3
  33. package/dist/components/ObjectNode.d.ts.map +1 -1
  34. package/dist/components/ObjectNode.js +44 -9
  35. package/dist/components/ParticlesGenerator.d.ts +10 -0
  36. package/dist/components/ParticlesGenerator.d.ts.map +1 -0
  37. package/dist/components/ParticlesGenerator.js +23 -0
  38. package/dist/components/ReactionDiffusionGrid.d.ts +15 -0
  39. package/dist/components/ReactionDiffusionGrid.d.ts.map +1 -0
  40. package/dist/components/ReactionDiffusionGrid.js +376 -0
  41. package/dist/components/WallpaperGrid.d.ts +15 -0
  42. package/dist/components/WallpaperGrid.d.ts.map +1 -0
  43. package/dist/components/WallpaperGrid.js +555 -0
  44. package/dist/components/cursor/CursorController.d.ts.map +1 -1
  45. package/dist/components/effects/BlackHoleEffect.d.ts +3 -3
  46. package/dist/components/effects/BlackHoleEffect.d.ts.map +1 -1
  47. package/dist/components/effects/BlackHoleEffect.js +293 -163
  48. package/dist/components/effects/DandelionSeedsEffect.d.ts +13 -0
  49. package/dist/components/effects/DandelionSeedsEffect.d.ts.map +1 -0
  50. package/dist/components/effects/DandelionSeedsEffect.js +510 -0
  51. package/dist/components/effects/FallingLeavesEffect.d.ts +13 -0
  52. package/dist/components/effects/FallingLeavesEffect.d.ts.map +1 -0
  53. package/dist/components/effects/FallingLeavesEffect.js +446 -0
  54. package/dist/components/effects/FieldLinesEffect.d.ts +11 -0
  55. package/dist/components/effects/FieldLinesEffect.d.ts.map +1 -0
  56. package/dist/components/effects/FieldLinesEffect.js +260 -0
  57. package/dist/components/effects/FireflySwarmEffect.d.ts +13 -0
  58. package/dist/components/effects/FireflySwarmEffect.d.ts.map +1 -0
  59. package/dist/components/effects/FireflySwarmEffect.js +408 -0
  60. package/dist/components/effects/GalaxyEffect.d.ts +13 -0
  61. package/dist/components/effects/GalaxyEffect.d.ts.map +1 -0
  62. package/dist/components/effects/GalaxyEffect.js +374 -0
  63. package/dist/components/effects/HarmonicShellEffect.d.ts +11 -0
  64. package/dist/components/effects/HarmonicShellEffect.d.ts.map +1 -0
  65. package/dist/components/effects/HarmonicShellEffect.js +209 -0
  66. package/dist/components/effects/IceCrystalsEffect.d.ts +3 -3
  67. package/dist/components/effects/IceCrystalsEffect.d.ts.map +1 -1
  68. package/dist/components/effects/IceCrystalsEffect.js +286 -166
  69. package/dist/components/effects/IceHaloEffect.d.ts +13 -0
  70. package/dist/components/effects/IceHaloEffect.d.ts.map +1 -0
  71. package/dist/components/effects/IceHaloEffect.js +306 -0
  72. package/dist/components/effects/LichtenbergEffect.d.ts +13 -0
  73. package/dist/components/effects/LichtenbergEffect.d.ts.map +1 -0
  74. package/dist/components/effects/LichtenbergEffect.js +517 -0
  75. package/dist/components/effects/MoleculesEffect.d.ts +3 -3
  76. package/dist/components/effects/MoleculesEffect.d.ts.map +1 -1
  77. package/dist/components/effects/MoleculesEffect.js +322 -164
  78. package/dist/components/effects/MurmurationEffect.d.ts +13 -0
  79. package/dist/components/effects/MurmurationEffect.d.ts.map +1 -0
  80. package/dist/components/effects/MurmurationEffect.js +539 -0
  81. package/dist/components/effects/PlanetaryRingsEffect.d.ts +13 -0
  82. package/dist/components/effects/PlanetaryRingsEffect.d.ts.map +1 -0
  83. package/dist/components/effects/PlanetaryRingsEffect.js +458 -0
  84. package/dist/components/effects/PortalEffect.d.ts +3 -3
  85. package/dist/components/effects/PortalEffect.d.ts.map +1 -1
  86. package/dist/components/effects/PortalEffect.js +240 -163
  87. package/dist/components/effects/ShockwaveEffect.d.ts +5 -3
  88. package/dist/components/effects/ShockwaveEffect.d.ts.map +1 -1
  89. package/dist/components/effects/ShockwaveEffect.js +538 -142
  90. package/dist/components/effects/SmokePlumeEffect.d.ts +3 -3
  91. package/dist/components/effects/SmokePlumeEffect.d.ts.map +1 -1
  92. package/dist/components/effects/SmokePlumeEffect.js +180 -116
  93. package/dist/components/effects/SmokeRingEffect.d.ts +3 -3
  94. package/dist/components/effects/SmokeRingEffect.d.ts.map +1 -1
  95. package/dist/components/effects/SmokeRingEffect.js +260 -135
  96. package/dist/components/effects/StrangeAttractorEffect.d.ts +11 -0
  97. package/dist/components/effects/StrangeAttractorEffect.d.ts.map +1 -0
  98. package/dist/components/effects/StrangeAttractorEffect.js +229 -0
  99. package/dist/components/effects/VolumetricFogEffect.d.ts +5 -3
  100. package/dist/components/effects/VolumetricFogEffect.d.ts.map +1 -1
  101. package/dist/components/effects/VolumetricFogEffect.js +211 -93
  102. package/dist/components/effects/WaterCausticsEffect.d.ts +13 -0
  103. package/dist/components/effects/WaterCausticsEffect.d.ts.map +1 -0
  104. package/dist/components/effects/WaterCausticsEffect.js +308 -0
  105. package/dist/components/effects/index.d.ts +9 -0
  106. package/dist/components/effects/index.d.ts.map +1 -1
  107. package/dist/components/effects/index.js +9 -0
  108. package/dist/components/index.d.ts +19 -0
  109. package/dist/components/index.d.ts.map +1 -1
  110. package/dist/components/index.js +10 -0
  111. package/dist/components/particles/BioluminescentWakeParticles.d.ts +12 -0
  112. package/dist/components/particles/BioluminescentWakeParticles.d.ts.map +1 -0
  113. package/dist/components/particles/BioluminescentWakeParticles.js +1123 -0
  114. package/dist/components/particles/BrownianDustParticles.d.ts +12 -0
  115. package/dist/components/particles/BrownianDustParticles.d.ts.map +1 -0
  116. package/dist/components/particles/BrownianDustParticles.js +757 -0
  117. package/dist/components/particles/ElectronOrbitalsParticles.d.ts +12 -0
  118. package/dist/components/particles/ElectronOrbitalsParticles.d.ts.map +1 -0
  119. package/dist/components/particles/ElectronOrbitalsParticles.js +944 -0
  120. package/dist/components/particles/GrinderSparksParticles.d.ts +12 -0
  121. package/dist/components/particles/GrinderSparksParticles.d.ts.map +1 -0
  122. package/dist/components/particles/GrinderSparksParticles.js +744 -0
  123. package/dist/components/particles/TidalStreamParticles.d.ts +12 -0
  124. package/dist/components/particles/TidalStreamParticles.d.ts.map +1 -0
  125. package/dist/components/particles/TidalStreamParticles.js +788 -0
  126. package/dist/components/particles/index.d.ts +11 -0
  127. package/dist/components/particles/index.d.ts.map +1 -0
  128. package/dist/components/particles/index.js +6 -0
  129. package/dist/constants.d.ts +1 -1
  130. package/dist/constants.d.ts.map +1 -1
  131. package/dist/constants.js +1 -1
  132. package/dist/hooks/useModelObject.d.ts +6 -1
  133. package/dist/hooks/useModelObject.d.ts.map +1 -1
  134. package/dist/hooks/useModelObject.js +19 -6
  135. package/dist/types/gridConfigs.d.ts +98 -0
  136. package/dist/types/gridConfigs.d.ts.map +1 -1
  137. package/dist/types/index.d.ts +1 -1
  138. package/dist/types/index.d.ts.map +1 -1
  139. package/dist/utils/particleTrails.d.ts +70 -0
  140. package/dist/utils/particleTrails.d.ts.map +1 -0
  141. package/dist/utils/particleTrails.js +369 -0
  142. package/dist/utils/pointerField.d.ts +28 -0
  143. package/dist/utils/pointerField.d.ts.map +1 -0
  144. package/dist/utils/pointerField.js +103 -0
  145. package/package.json +2 -2
@@ -0,0 +1,555 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useRef } from 'react';
3
+ import * as THREE from 'three';
4
+ import { useFrame } from '@react-three/fiber';
5
+ import { useObjectReady } from '../hooks/useObjectReady.js';
6
+ import { useGridSurface } from '../hooks/useGridSurface.js';
7
+ import { WallpaperGridMaterial } from '@3driseai/3drise-core';
8
+ // Side-effect import registers <wallpaperGridMaterial> via extend().
9
+ void WallpaperGridMaterial;
10
+ /** WallpaperGridConfig defaults. Must match the catalog entry in grid-defaults.json exactly. */
11
+ export const defaultWallpaperGridConfig = {
12
+ cellSize: 10,
13
+ size: 50,
14
+ flat: true,
15
+ segments: undefined,
16
+ lineMode: 2,
17
+ cellMode: 2,
18
+ lineWidth: 2,
19
+ sectionSize: 0,
20
+ sectionWidth: 1.4,
21
+ animSpeed: 1,
22
+ animScale: 0.6,
23
+ animIntensity: 0.55,
24
+ fadeDistance: undefined,
25
+ fadeStrength: 0.7,
26
+ displace: 0,
27
+ group: -1,
28
+ cycleTime: 12,
29
+ motif: 0.5,
30
+ levels: 11,
31
+ lineColor: '#f3d79b',
32
+ sectionColor: '#7fd6ff',
33
+ cellColor: '#101c50',
34
+ glowColor: '#ff9ec7',
35
+ bgColor: '#05070a',
36
+ bgOpacity: 0,
37
+ followMouse: false,
38
+ reveal: 1,
39
+ revealDuration: 0,
40
+ };
41
+ const gridFragHeader = /* glsl */ `
42
+ precision highp float;
43
+
44
+ uniform float u_time;
45
+ uniform float u_cellSize;
46
+ uniform float u_lineWidth;
47
+ uniform float u_sectionSize;
48
+ uniform float u_sectionWidth;
49
+ uniform vec3 u_lineColor;
50
+ uniform vec3 u_sectionColor;
51
+ uniform vec3 u_cellColor;
52
+ uniform vec3 u_glowColor;
53
+ uniform vec3 u_bgColor;
54
+ uniform float u_bgOpacity;
55
+ uniform float u_lineMode;
56
+ uniform float u_cellMode;
57
+ uniform float u_animSpeed;
58
+ uniform float u_animScale;
59
+ uniform float u_animIntensity;
60
+ uniform float u_fadeDistance;
61
+ uniform float u_fadeStrength;
62
+ uniform vec2 u_focus;
63
+ uniform float u_reveal;
64
+
65
+ varying vec2 vGridPos;
66
+
67
+ float lineAt(float c, float width, float fp){
68
+ float d = abs(fract(c - 0.5) - 0.5);
69
+ return 1.0 - clamp(d / max(fp * max(width, 0.05), 1e-6), 0.0, 1.0);
70
+ }
71
+ `;
72
+ const gridCommon = /* glsl */ `
73
+ const float PI = 3.14159265359;
74
+ const float TAU = 6.28318530718;
75
+
76
+ float hash21(vec2 p){
77
+ p = fract(p * vec2(123.34, 456.21));
78
+ p += dot(p, p + 45.32);
79
+ return fract(p.x * p.y);
80
+ }
81
+ `;
82
+ const gridTail = /* glsl */ `
83
+ // ---- line animation --------------------------------------------------
84
+ float lineAnim = 1.0;
85
+ if (u_lineMode > 0.5){
86
+ if (u_lineMode < 1.5){
87
+ lineAnim = 0.5 + 0.5 * sin(cellDist * u_animScale - t);
88
+ } else if (u_lineMode < 2.5){
89
+ lineAnim = 0.5 + 0.5 * sin(flowCoord * u_animScale - t);
90
+ } else if (u_lineMode < 3.5){
91
+ float s = fract(scanCoord * 0.05 * u_animScale - t * 0.15);
92
+ lineAnim = 0.25 + smoothstep(0.0, 0.15, s) * (1.0 - smoothstep(0.15, 0.35, s));
93
+ } else {
94
+ lineAnim = 0.5 + 0.5 * sin(t);
95
+ }
96
+ }
97
+ lineAnim = mix(1.0, lineAnim, u_animIntensity);
98
+
99
+ // ---- cell fill -------------------------------------------------------
100
+ float cell = 0.0;
101
+ if (u_cellMode > 0.5){
102
+ if (u_cellMode < 1.5){
103
+ cell = 0.5 + 0.5 * sin(flowCoord * 0.5 * u_animScale - t);
104
+ } else if (u_cellMode < 2.5){
105
+ cell = 0.5 + 0.5 * sin(t * (0.6 + cellH) + cellH * TAU);
106
+ } else if (u_cellMode < 3.5){
107
+ cell = smoothstep(0.6, 1.0, sin(cellDist * u_animScale - t));
108
+ } else {
109
+ cell = step(0.5, cellH) * (0.5 + 0.5 * sin(t));
110
+ }
111
+ }
112
+ cell *= u_animIntensity * edgeKeep;
113
+
114
+ float tone = step(0.55, cellH);
115
+
116
+ vec3 col = u_bgColor * u_bgOpacity;
117
+ float a = u_bgOpacity;
118
+
119
+ col += mix(u_cellColor, u_cellColor * 2.2, tone) * cell;
120
+ a = max(a, cell * 0.9);
121
+ float linesI = lines * lineAnim;
122
+ col += u_lineColor * linesI; a = max(a, linesI);
123
+ float accentI = accent * lineAnim;
124
+ col += u_sectionColor * accentI; a = max(a, accentI);
125
+ col += u_glowColor * (linesI * 0.2 + cell * 0.35) * u_animIntensity;
126
+
127
+ col = col * regionMask + extraCol;
128
+ a = max(a * regionMask, extraA);
129
+
130
+ float fade = 1.0 - smoothstep(1.0 - u_fadeStrength, 1.0, fadeR);
131
+ col *= fade;
132
+ a *= fade;
133
+
134
+ // ---- reveal ----------------------------------------------------------
135
+ // The build boundary sweeps outward from the focus point with a bright
136
+ // leading edge, so the grid reads as assembling itself.
137
+ if (u_reveal < 0.999){
138
+ float rd = length(vGridPos - u_focus) / max(u_fadeDistance, 1e-4);
139
+ float edge = u_reveal * 1.1;
140
+ float mask = 1.0 - smoothstep(edge - 0.05, edge, rd);
141
+ float front = mask * smoothstep(edge - 0.22, edge - 0.05, rd);
142
+ col = col * mask + u_glowColor * front * (a * 1.8 + 0.08);
143
+ a = max(a * mask, front * 0.10);
144
+ }
145
+
146
+ if (a < 0.002) discard;
147
+ gl_FragColor = vec4(col, a);
148
+ }
149
+ `;
150
+ const gridVertexHead = /* glsl */ `
151
+ uniform float u_time;
152
+ uniform float u_cellSize;
153
+ uniform float u_displace;
154
+ uniform float u_animSpeed;
155
+ uniform float u_animScale;
156
+
157
+ varying vec2 vGridPos;
158
+ `;
159
+ // ---------------------------------------------------------------------------
160
+ // The 17 wallpaper groups (Farris, "Creating Symmetry").
161
+ // Each group is listed by its ITA general positions in lattice coordinates:
162
+ // [a, b, c, d, tx, ty] maps (x, y) to (a x + b y + tx, c x + d y + ty).
163
+ // These are the coset representatives of the group modulo the lattice;
164
+ // centred groups (cm, cmm) use the conventional rectangular cell and carry
165
+ // the centring translation (1/2, 1/2) as extra representatives. Glide
166
+ // reflections are reflections with half-lattice translations.
167
+ // Lattices: 0 oblique, 1 rectangular, 2 centred rectangular (conventional),
168
+ // 3 square, 4 hexagonal (ITA setting, 120 degrees between a and b).
169
+ // ---------------------------------------------------------------------------
170
+ const WP_NAMES = ['p1', 'p2', 'pm', 'pg', 'cm', 'pmm', 'pmg', 'pgg', 'cmm', 'p4', 'p4m', 'p4g', 'p3', 'p3m1', 'p31m', 'p6', 'p6m'];
171
+ const WP_LATTICE = [0, 0, 1, 1, 2, 1, 1, 1, 2, 3, 3, 3, 4, 4, 4, 4, 4];
172
+ // lattice basis, columns e1 = (m[0], m[1]), e2 = (m[2], m[3]), cell units; unit-cell area ~1
173
+ const WP_BASIS = [
174
+ [1.05, 0, 0.287, 0.884],
175
+ [1.2, 0, 0, 0.84],
176
+ [1.5, 0, 0, 1.3],
177
+ [1, 0, 0, 1],
178
+ [1.07, 0, -0.535, 0.535 * Math.sqrt(3)],
179
+ ];
180
+ const WP_I = [1, 0, 0, 1, 0, 0];
181
+ const WP_OPS = [
182
+ [WP_I],
183
+ [WP_I, [-1, 0, 0, -1, 0, 0]],
184
+ [WP_I, [-1, 0, 0, 1, 0, 0]],
185
+ [WP_I, [-1, 0, 0, 1, 0, 0.5]],
186
+ [WP_I, [-1, 0, 0, 1, 0, 0], [1, 0, 0, 1, 0.5, 0.5], [-1, 0, 0, 1, 0.5, 0.5]],
187
+ [WP_I, [-1, 0, 0, -1, 0, 0], [-1, 0, 0, 1, 0, 0], [1, 0, 0, -1, 0, 0]],
188
+ [WP_I, [-1, 0, 0, -1, 0, 0], [-1, 0, 0, 1, 0.5, 0], [1, 0, 0, -1, 0.5, 0]],
189
+ [WP_I, [-1, 0, 0, -1, 0, 0], [-1, 0, 0, 1, 0.5, 0.5], [1, 0, 0, -1, 0.5, 0.5]],
190
+ [WP_I, [-1, 0, 0, -1, 0, 0], [-1, 0, 0, 1, 0, 0], [1, 0, 0, -1, 0, 0],
191
+ [1, 0, 0, 1, 0.5, 0.5], [-1, 0, 0, -1, 0.5, 0.5], [-1, 0, 0, 1, 0.5, 0.5], [1, 0, 0, -1, 0.5, 0.5]],
192
+ [WP_I, [-1, 0, 0, -1, 0, 0], [0, -1, 1, 0, 0, 0], [0, 1, -1, 0, 0, 0]],
193
+ [WP_I, [-1, 0, 0, -1, 0, 0], [0, -1, 1, 0, 0, 0], [0, 1, -1, 0, 0, 0],
194
+ [-1, 0, 0, 1, 0, 0], [1, 0, 0, -1, 0, 0], [0, 1, 1, 0, 0, 0], [0, -1, -1, 0, 0, 0]],
195
+ [WP_I, [-1, 0, 0, -1, 0, 0], [0, -1, 1, 0, 0, 0], [0, 1, -1, 0, 0, 0],
196
+ [-1, 0, 0, 1, 0.5, 0.5], [1, 0, 0, -1, 0.5, 0.5], [0, 1, 1, 0, 0.5, 0.5], [0, -1, -1, 0, 0.5, 0.5]],
197
+ [WP_I, [0, -1, 1, -1, 0, 0], [-1, 1, -1, 0, 0, 0]],
198
+ [WP_I, [0, -1, 1, -1, 0, 0], [-1, 1, -1, 0, 0, 0],
199
+ [0, -1, -1, 0, 0, 0], [-1, 1, 0, 1, 0, 0], [1, 0, 1, -1, 0, 0]],
200
+ [WP_I, [0, -1, 1, -1, 0, 0], [-1, 1, -1, 0, 0, 0],
201
+ [0, 1, 1, 0, 0, 0], [1, -1, 0, -1, 0, 0], [-1, 0, -1, 1, 0, 0]],
202
+ [WP_I, [0, -1, 1, -1, 0, 0], [-1, 1, -1, 0, 0, 0],
203
+ [-1, 0, 0, -1, 0, 0], [0, 1, -1, 1, 0, 0], [1, -1, 1, 0, 0, 0]],
204
+ [WP_I, [0, -1, 1, -1, 0, 0], [-1, 1, -1, 0, 0, 0],
205
+ [-1, 0, 0, -1, 0, 0], [0, 1, -1, 1, 0, 0], [1, -1, 1, 0, 0, 0],
206
+ [0, -1, -1, 0, 0, 0], [-1, 1, 0, 1, 0, 0], [1, 0, 1, -1, 0, 0],
207
+ [0, 1, 1, 0, 0, 0], [1, -1, 0, -1, 0, 0], [-1, 0, -1, 1, 0, 0]],
208
+ ];
209
+ // Motif wave-vectors (integer, dual-lattice coordinates) and their base amplitudes.
210
+ // (1,1) comes first because it survives every extinction rule (centring, glides).
211
+ const WP_K = [1, 1, 2, 0, 1, -2, 2, 1, 3, 1, 1, 3];
212
+ const WP_AMP = [1, 0.8, 0.62, 0.5, 0.4, 0.33];
213
+ const WP_PHASE0 = [0.3, 1.9, 4.1, 2.7, 5.3, 0.9];
214
+ const WP_OMEGA = [0.11, -0.083, 0.067, -0.052, 0.043, -0.037];
215
+ /** Pure: the uniform tables for wallpaper group `index` (0..16, standard order). */
216
+ function wallpaperTables(index) {
217
+ const gi = Math.min(16, Math.max(0, Math.round(index)));
218
+ const ops = WP_OPS[gi];
219
+ const b = WP_BASIS[WP_LATTICE[gi]];
220
+ const R = new Float32Array(48);
221
+ const T = new Float32Array(24);
222
+ const ops6 = new Float64Array(72);
223
+ for (let i = 0; i < ops.length; i++) {
224
+ const o = ops[i];
225
+ // GLSL mat2 is column-major: (a, c, b, d)
226
+ R[i * 4] = o[0];
227
+ R[i * 4 + 1] = o[2];
228
+ R[i * 4 + 2] = o[1];
229
+ R[i * 4 + 3] = o[3];
230
+ T[i * 2] = o[4];
231
+ T[i * 2 + 1] = o[5];
232
+ for (let j = 0; j < 6; j++)
233
+ ops6[i * 6 + j] = o[j];
234
+ }
235
+ const det = b[0] * b[3] - b[2] * b[1];
236
+ // inverse basis, column-major
237
+ const basisInv = new Float32Array([b[3] / det, -b[1] / det, -b[2] / det, b[0] / det]);
238
+ // Symmetry axes. A reflection with Cartesian normal n and translation t
239
+ // fixes (up to a translation tau of the group) the lines n.p = n.(t + tau)/2.
240
+ // Those lines are mirrors when some tau cancels the component along the
241
+ // axis, and glide axes otherwise.
242
+ const axes = new Float32Array(24);
243
+ const axesKind = new Float32Array(18);
244
+ let axisCount = 0;
245
+ const tx = [];
246
+ const ty = [];
247
+ for (let i = 0; i < ops.length; i++) {
248
+ const o = ops[i];
249
+ if (o[0] !== 1 || o[1] !== 0 || o[2] !== 0 || o[3] !== 1)
250
+ continue;
251
+ for (let m = -4; m <= 4; m++)
252
+ for (let n = -4; n <= 4; n++) {
253
+ const lx = m + o[4], ly = n + o[5];
254
+ tx.push(b[0] * lx + b[2] * ly);
255
+ ty.push(b[1] * lx + b[3] * ly);
256
+ }
257
+ }
258
+ for (let i = 0; i < ops.length; i++) {
259
+ const o = ops[i];
260
+ if (o[0] * o[3] - o[1] * o[2] > -0.5)
261
+ continue;
262
+ // Cartesian linear part C = B M B^-1
263
+ const m00 = o[0] * b[0] + o[2] * b[2], m01 = o[1] * b[0] + o[3] * b[2];
264
+ const m10 = o[0] * b[1] + o[2] * b[3], m11 = o[1] * b[1] + o[3] * b[3];
265
+ const c00 = (m00 * b[3] - m01 * b[1]) / det, c01 = (-m00 * b[2] + m01 * b[0]) / det;
266
+ const c10 = (m10 * b[3] - m11 * b[1]) / det, c11 = (-m10 * b[2] + m11 * b[0]) / det;
267
+ // I - C = 2 n n^T
268
+ let nx = 1 - c00, ny = -c10;
269
+ if (nx * nx + ny * ny < 1e-6) {
270
+ nx = -c01;
271
+ ny = 1 - c11;
272
+ }
273
+ const nl = Math.hypot(nx, ny);
274
+ nx /= nl;
275
+ ny /= nl;
276
+ if (ny < -1e-6 || (Math.abs(ny) <= 1e-6 && nx < 0)) {
277
+ nx = -nx;
278
+ ny = -ny;
279
+ }
280
+ let dup = false;
281
+ for (let a = 0; a < axisCount; a++)
282
+ if (Math.abs(axes[a * 4] * nx + axes[a * 4 + 1] * ny) > 0.999)
283
+ dup = true;
284
+ if (dup || axisCount >= 6)
285
+ continue;
286
+ const ux = -ny, uy = nx;
287
+ const cx = b[0] * o[4] + b[2] * o[5], cy = b[1] * o[4] + b[3] * o[5];
288
+ let delta = 1e9, period = 1e9;
289
+ for (let k = 0; k < tx.length; k++) {
290
+ const dn = Math.abs(nx * tx[k] + ny * ty[k]);
291
+ const du = Math.abs(ux * tx[k] + uy * ty[k]);
292
+ if (dn > 1e-5)
293
+ delta = Math.min(delta, dn);
294
+ else if (du > 1e-5)
295
+ period = Math.min(period, du);
296
+ }
297
+ const h = delta * 0.5;
298
+ const on = nx * cx + ny * cy;
299
+ const o0 = on * 0.5 - Math.floor(on * 0.5 / delta) * delta;
300
+ const kind = [0.5, 0.5];
301
+ for (let k = 0; k < tx.length; k++) {
302
+ const mm = (nx * (cx + tx[k]) + ny * (cy + ty[k])) * 0.5;
303
+ const j = Math.round((mm - o0) / h);
304
+ if (Math.abs(mm - o0 - j * h) > 1e-4)
305
+ continue;
306
+ const g = ux * (cx + tx[k]) + uy * (cy + ty[k]);
307
+ const r = g - Math.round(g / period) * period;
308
+ if (Math.abs(r) < 1e-4)
309
+ kind[((j % 2) + 2) % 2] = 1;
310
+ }
311
+ axes[axisCount * 4] = nx;
312
+ axes[axisCount * 4 + 1] = ny;
313
+ axes[axisCount * 4 + 2] = o0;
314
+ axes[axisCount * 4 + 3] = h;
315
+ axesKind[axisCount * 3] = kind[0];
316
+ axesKind[axisCount * 3 + 1] = kind[1];
317
+ axesKind[axisCount * 3 + 2] = period;
318
+ axisCount++;
319
+ }
320
+ return { name: WP_NAMES[gi], lattice: WP_LATTICE[gi], count: ops.length, ops: ops6, R, T, basisInv, axes, axesKind, axisCount };
321
+ }
322
+ // RMS of the symmetrised field for the current motif terms. Every term
323
+ // cos(2 pi k.(M q + s) + phi) is a plane wave with vector M^T k; waves with the
324
+ // same vector (up to sign) add as complex amplitudes, and the mean square of a
325
+ // sum of distinct plane waves is half the sum of their squared amplitudes.
326
+ function wallpaperRms(tab, wave, sk, sre, sim) {
327
+ let n = 0;
328
+ for (let g = 0; g < tab.count; g++) {
329
+ const a = tab.ops[g * 6], b = tab.ops[g * 6 + 1], c = tab.ops[g * 6 + 2], d = tab.ops[g * 6 + 3];
330
+ const sx = tab.ops[g * 6 + 4], sy = tab.ops[g * 6 + 5];
331
+ for (let j = 0; j < 6; j++) {
332
+ const amp = wave[j * 2];
333
+ if (amp <= 0)
334
+ continue;
335
+ const kx = WP_K[j * 2], ky = WP_K[j * 2 + 1];
336
+ let px = a * kx + c * ky, py = b * kx + d * ky;
337
+ let ph = wave[j * 2 + 1] + 2 * Math.PI * (kx * sx + ky * sy);
338
+ if (px < 0 || (px === 0 && py < 0)) {
339
+ px = -px;
340
+ py = -py;
341
+ ph = -ph;
342
+ }
343
+ let slot = -1;
344
+ for (let s = 0; s < n; s++)
345
+ if (sk[s * 2] === px && sk[s * 2 + 1] === py) {
346
+ slot = s;
347
+ break;
348
+ }
349
+ if (slot < 0) {
350
+ slot = n;
351
+ n++;
352
+ sk[slot * 2] = px;
353
+ sk[slot * 2 + 1] = py;
354
+ sre[slot] = 0;
355
+ sim[slot] = 0;
356
+ }
357
+ sre[slot] += amp * Math.cos(ph);
358
+ sim[slot] += amp * Math.sin(ph);
359
+ }
360
+ }
361
+ let sum = 0;
362
+ for (let s = 0; s < n; s++)
363
+ sum += sre[s] * sre[s] + sim[s] * sim[s];
364
+ return Math.sqrt(sum * 0.5);
365
+ }
366
+ function createExtraUniforms() {
367
+ return {
368
+ u_wave: { value: new Float32Array(12) },
369
+ u_RA: { value: new Float32Array(48) },
370
+ u_TA: { value: new Float32Array(24) },
371
+ u_countA: { value: 1 },
372
+ u_basisA: { value: new Float32Array([1, 0, 0, 1]) },
373
+ u_normA: { value: 1 },
374
+ u_axA: { value: new Float32Array(24) },
375
+ u_axKA: { value: new Float32Array(18) },
376
+ u_axNA: { value: 0 },
377
+ u_RB: { value: new Float32Array(48) },
378
+ u_TB: { value: new Float32Array(24) },
379
+ u_countB: { value: 1 },
380
+ u_basisB: { value: new Float32Array([1, 0, 0, 1]) },
381
+ u_normB: { value: 1 },
382
+ u_axB: { value: new Float32Array(24) },
383
+ u_axKB: { value: new Float32Array(18) },
384
+ u_axNB: { value: 0 },
385
+ u_mix: { value: 0 },
386
+ u_mixGain: { value: 1 },
387
+ };
388
+ }
389
+ function createRuntime(u, renderer, c) {
390
+ const tables = [];
391
+ for (let i = 0; i < 17; i++)
392
+ tables.push(wallpaperTables(i));
393
+ return {
394
+ tables,
395
+ clock: 0,
396
+ motion: 0,
397
+ shownA: -1,
398
+ shownB: -1,
399
+ sk: new Int32Array(160),
400
+ sre: new Float64Array(80),
401
+ sim: new Float64Array(80),
402
+ };
403
+ }
404
+ function wallpaperLoad(tab, R, T, basis, ax, axK) {
405
+ R.set(tab.R);
406
+ T.set(tab.T);
407
+ basis.set(tab.basisInv);
408
+ ax.set(tab.axes);
409
+ axK.set(tab.axesKind);
410
+ }
411
+ function updateRuntime(rt, u, c, dt, renderer) {
412
+ const speed = u.u_animSpeed ? u.u_animSpeed.value : c.animSpeed;
413
+ const group = u.u_group ? u.u_group.value : c.group;
414
+ const cycle = Math.max(0.5, u.u_cycleTime ? u.u_cycleTime.value : c.cycleTime);
415
+ const motif = Math.min(1, Math.max(0, u.u_motif ? u.u_motif.value : c.motif));
416
+ rt.clock += dt;
417
+ rt.motion += dt * speed;
418
+ // which groups are showing: a fixed one, or the cycle (starting at p6m)
419
+ let ga = 0, gb = 0, mix = 0;
420
+ if (group >= -0.5) {
421
+ ga = Math.min(16, Math.max(0, Math.round(group)));
422
+ gb = ga;
423
+ }
424
+ else {
425
+ const s = rt.clock / cycle + 16;
426
+ const i = Math.floor(s);
427
+ const f = s - i;
428
+ ga = i % 17;
429
+ gb = (i + 1) % 17;
430
+ const x = Math.min(1, Math.max(0, (f - 0.62) / 0.38));
431
+ mix = x * x * (3 - 2 * x);
432
+ }
433
+ const A = rt.tables[ga], B = rt.tables[gb];
434
+ if (ga !== rt.shownA) {
435
+ rt.shownA = ga;
436
+ wallpaperLoad(A, u.u_RA.value, u.u_TA.value, u.u_basisA.value, u.u_axA.value, u.u_axKA.value);
437
+ u.u_countA.value = A.count;
438
+ u.u_axNA.value = A.axisCount;
439
+ }
440
+ if (gb !== rt.shownB) {
441
+ rt.shownB = gb;
442
+ wallpaperLoad(B, u.u_RB.value, u.u_TB.value, u.u_basisB.value, u.u_axB.value, u.u_axKB.value);
443
+ u.u_countB.value = B.count;
444
+ u.u_axNB.value = B.axisCount;
445
+ }
446
+ // motif: wave-vectors fade in one after another as motif grows; phases drift slowly
447
+ const wave = u.u_wave.value;
448
+ const reach = 1 + motif * 5;
449
+ for (let j = 0; j < 6; j++) {
450
+ wave[j * 2] = WP_AMP[j] * Math.min(1, Math.max(0, reach - j));
451
+ wave[j * 2 + 1] = WP_PHASE0[j] + WP_OMEGA[j] * rt.motion;
452
+ }
453
+ const floorRms = 0.08;
454
+ u.u_normA.value = 1 / Math.max(wallpaperRms(A, wave, rt.sk, rt.sre, rt.sim), floorRms);
455
+ u.u_normB.value = mix > 0 ? 1 / Math.max(wallpaperRms(B, wave, rt.sk, rt.sre, rt.sim), floorRms) : 1;
456
+ u.u_mix.value = mix;
457
+ // two independent unit-RMS fields mixed by (1-x, x) have RMS sqrt((1-x)^2 + x^2)
458
+ u.u_mixGain.value = 1 / Math.sqrt((1 - mix) * (1 - mix) + mix * mix);
459
+ }
460
+ function disposeRuntime(rt) {
461
+ rt.tables.length = 0;
462
+ }
463
+ // ---------------------------------------------------------------------------
464
+ // Farris' recipe: a lattice-periodic motif m(q) summed over the coset
465
+ // representatives g of a wallpaper group, F(p) = sum_g m(g.q), q = B^-1 p.
466
+ // For any h in the group, {g h} runs over the same cosets, and m ignores
467
+ // lattice translations, so F(h.p) = F(p) exactly: the picture has precisely
468
+ // the group's mirrors, glides and rotation centres, and tiles seamlessly.
469
+ // Level sets of F are the lines; its value bands are the cells.
470
+ // ---------------------------------------------------------------------------
471
+ const wallpaperField = /* glsl */ `
472
+ uniform vec2 u_wave[6];
473
+ uniform mat2 u_RA[12];
474
+ uniform vec2 u_TA[12];
475
+ uniform float u_countA;
476
+ uniform mat2 u_basisA;
477
+ uniform float u_normA;
478
+ uniform mat2 u_RB[12];
479
+ uniform vec2 u_TB[12];
480
+ uniform float u_countB;
481
+ uniform mat2 u_basisB;
482
+ uniform float u_normB;
483
+ uniform float u_mix;
484
+ uniform float u_mixGain;
485
+
486
+ float wpMotif(vec2 q){
487
+ vec2 a = TAU * q;
488
+ return u_wave[0].x * cos(dot(a, vec2(1.0, 1.0)) + u_wave[0].y)
489
+ + u_wave[1].x * cos(dot(a, vec2(2.0, 0.0)) + u_wave[1].y)
490
+ + u_wave[2].x * cos(dot(a, vec2(1.0, -2.0)) + u_wave[2].y)
491
+ + u_wave[3].x * cos(dot(a, vec2(2.0, 1.0)) + u_wave[3].y)
492
+ + u_wave[4].x * cos(dot(a, vec2(3.0, 1.0)) + u_wave[4].y)
493
+ + u_wave[5].x * cos(dot(a, vec2(1.0, 3.0)) + u_wave[5].y);
494
+ }
495
+
496
+ float wpSym(vec2 p, mat2 Bi, mat2 R[12], vec2 T[12], float n){
497
+ vec2 q = Bi * p;
498
+ q -= floor(q);
499
+ float s = 0.0;
500
+ for (int i = 0; i < 12; i++){
501
+ if (float(i) >= n) break;
502
+ s += wpMotif(R[i] * q + T[i]);
503
+ }
504
+ return s;
505
+ }
506
+
507
+ // unit-RMS field, crossfaded between group A and group B
508
+ float wpField(vec2 p){
509
+ float f = wpSym(p, u_basisA, u_RA, u_TA, u_countA) * u_normA;
510
+ if (u_mix > 0.001){
511
+ float g = wpSym(p, u_basisB, u_RB, u_TB, u_countB) * u_normB;
512
+ f = mix(f, g, u_mix) * u_mixGain;
513
+ }
514
+ return f;
515
+ }
516
+ `;
517
+ /**
518
+ * Wallpaper-group kaleidoscope: a drifting lattice-periodic Fourier motif summed over the coset representatives of one of the 17 plane crystallographic groups. The runtime builds the group tables and crossfades from group to group.
519
+ */
520
+ export function WallpaperGrid({ config = defaultWallpaperGridConfig, groupProps, onObjectReady, onObjectDispose }) {
521
+ const matRef = useRef(null);
522
+ const rootRef = useRef(null);
523
+ const meshRef = useRef(null);
524
+ useObjectReady(rootRef, config, onObjectReady, onObjectDispose);
525
+ const { cellSize, size, segments, flat, lineMode, cellMode, lineWidth, sectionSize, sectionWidth, animSpeed, animScale, animIntensity, fadeDistance, fadeStrength, displace, group, cycleTime, motif, levels, lineColor, sectionColor, cellColor, glowColor, bgColor, bgOpacity, followMouse, reveal, revealDuration, } = config;
526
+ // the motif has up to ~3 waves per unit cell, so 16 vertices per cell keep the displaced relief smooth
527
+ const segs = segments ?? (displace > 0 ? Math.min(512, Math.max(96, Math.ceil(size / Math.max(cellSize, 1e-4)) * 16)) : 1);
528
+ const fade = fadeDistance ?? size * 0.5;
529
+ const colors = useMemo(() => ({
530
+ line: new THREE.Color(lineColor),
531
+ section: new THREE.Color(sectionColor),
532
+ cell: new THREE.Color(cellColor),
533
+ glow: new THREE.Color(glowColor),
534
+ bg: new THREE.Color(bgColor),
535
+ }), [lineColor, sectionColor, cellColor, glowColor, bgColor]);
536
+ useGridSurface(matRef, meshRef, { followMouse, reveal, revealDuration });
537
+ // the simulation behind this grid: created on mount, stepped every frame
538
+ const runtimeRef = useRef(null);
539
+ useFrame((state, delta) => {
540
+ const mat = matRef.current;
541
+ if (!mat)
542
+ return;
543
+ if (!runtimeRef.current)
544
+ runtimeRef.current = createRuntime(mat.uniforms, state.gl, config);
545
+ updateRuntime(runtimeRef.current, mat.uniforms, config, Math.min(delta, 0.1), state.gl);
546
+ });
547
+ useEffect(() => () => {
548
+ if (runtimeRef.current) {
549
+ disposeRuntime(runtimeRef.current);
550
+ runtimeRef.current = null;
551
+ }
552
+ }, []);
553
+ return (_jsx("group", { ref: rootRef, ...groupProps, children: _jsxs("mesh", { ref: meshRef, rotation: flat ? [-Math.PI / 2, 0, 0] : [0, 0, 0], children: [_jsx("planeGeometry", { args: [size, size, segs, segs] }), _jsx("wallpaperGridMaterial", { ref: matRef, transparent: true, depthWrite: false, blending: THREE.AdditiveBlending, side: THREE.DoubleSide, u_cellSize: cellSize, u_lineWidth: lineWidth, u_sectionSize: sectionSize, u_sectionWidth: sectionWidth, u_lineMode: lineMode, u_cellMode: cellMode, u_animSpeed: animSpeed, u_animScale: animScale, u_animIntensity: animIntensity, u_fadeDistance: fade, u_fadeStrength: fadeStrength, u_displace: displace, u_group: group, u_cycleTime: cycleTime, u_motif: motif, u_levels: levels, u_lineColor: colors.line, u_sectionColor: colors.section, u_cellColor: colors.cell, u_glowColor: colors.glow, u_bgColor: colors.bg, u_bgOpacity: bgOpacity }, WallpaperGridMaterial.key)] }) }));
554
+ }
555
+ export default WallpaperGrid;
@@ -1 +1 @@
1
- {"version":3,"file":"CursorController.d.ts","sourceRoot":"","sources":["../../../src/components/cursor/CursorController.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC3D,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACnC,kBAAkB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;CACjD;AAGD,QAAA,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAAiW,CAAC;AACxZ,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"CursorController.d.ts","sourceRoot":"","sources":["../../../src/components/cursor/CursorController.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC7E,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC3D,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACnC,kBAAkB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;CACjD;AAGD,QAAA,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAK1C,CAAC;AACb,eAAe,gBAAgB,CAAC"}
@@ -1,7 +1,7 @@
1
- import React from "react";
2
- import type { BlackHoleConfig, AnimationOptions } from "@3driseai/3drise-core";
1
+ import React from 'react';
2
+ import type { AnimationOptions, BlackHoleConfig } from '@3driseai/3drise-core';
3
3
  import type { ObjectReadyProps } from '../../types/objectReady';
4
- interface BlackHoleEffectProps extends ObjectReadyProps {
4
+ export interface BlackHoleEffectProps extends ObjectReadyProps {
5
5
  boundingRadius: number;
6
6
  config: BlackHoleConfig;
7
7
  animations?: AnimationOptions[];
@@ -1 +1 @@
1
- {"version":3,"file":"BlackHoleEffect.d.ts","sourceRoot":"","sources":["../../../src/components/effects/BlackHoleEffect.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChE,UAAU,oBAAqB,SAAQ,gBAAgB;IACnD,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACnC;AAsHD,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAwEnD,CAAC;AACF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"BlackHoleEffect.d.ts","sourceRoot":"","sources":["../../../src/components/effects/BlackHoleEffect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsD,MAAM,OAAO,CAAC;AAG3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC1D,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,eAAe,CAAC;IACxB,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;CACnC;AA2PD,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA6FnD,CAAC;AAEF,eAAe,eAAe,CAAC"}