@3driseai/3drise-viewer 0.1.40 → 0.1.41

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 (297) hide show
  1. package/dist/animationsV2/ClipsRuntime.d.ts.map +1 -1
  2. package/dist/animationsV2/ClipsRuntime.js +9 -5
  3. package/dist/animationsV2/clipUtils.d.ts +9 -0
  4. package/dist/animationsV2/clipUtils.d.ts.map +1 -1
  5. package/dist/animationsV2/clipUtils.js +11 -2
  6. package/dist/animationsV2/normalize.d.ts.map +1 -1
  7. package/dist/animationsV2/normalize.js +2 -0
  8. package/dist/animationsV2/types.d.ts +4 -0
  9. package/dist/animationsV2/types.d.ts.map +1 -1
  10. package/dist/api/sceneHandle.d.ts +40 -3
  11. package/dist/api/sceneHandle.d.ts.map +1 -1
  12. package/dist/api/sceneHandle.js +40 -0
  13. package/dist/components/GalleryObject.d.ts +13 -0
  14. package/dist/components/GalleryObject.d.ts.map +1 -0
  15. package/dist/components/GalleryObject.js +46 -0
  16. package/dist/components/ImageObject.d.ts +9 -0
  17. package/dist/components/ImageObject.d.ts.map +1 -0
  18. package/dist/components/ImageObject.js +26 -0
  19. package/dist/components/ObjectNode.d.ts.map +1 -1
  20. package/dist/components/ObjectNode.js +11 -5
  21. package/dist/components/ProjectLoader.d.ts +2 -0
  22. package/dist/components/ProjectLoader.d.ts.map +1 -1
  23. package/dist/components/ProjectLoader.js +2 -2
  24. package/dist/components/SceneBuilder.d.ts +10 -0
  25. package/dist/components/SceneBuilder.d.ts.map +1 -1
  26. package/dist/components/SceneBuilder.js +3 -2
  27. package/dist/components/gallery/BasicCarouselGallery.d.ts +18 -0
  28. package/dist/components/gallery/BasicCarouselGallery.d.ts.map +1 -0
  29. package/dist/components/gallery/BasicCarouselGallery.js +9 -0
  30. package/dist/components/gallery/ContourLinesGallery.d.ts +18 -0
  31. package/dist/components/gallery/ContourLinesGallery.d.ts.map +1 -0
  32. package/dist/components/gallery/ContourLinesGallery.js +9 -0
  33. package/dist/components/gallery/DepthLayersGallery.d.ts +18 -0
  34. package/dist/components/gallery/DepthLayersGallery.d.ts.map +1 -0
  35. package/dist/components/gallery/DepthLayersGallery.js +9 -0
  36. package/dist/components/gallery/EngravingGallery.d.ts +18 -0
  37. package/dist/components/gallery/EngravingGallery.d.ts.map +1 -0
  38. package/dist/components/gallery/EngravingGallery.js +9 -0
  39. package/dist/components/gallery/FlowLinesGallery.d.ts +18 -0
  40. package/dist/components/gallery/FlowLinesGallery.d.ts.map +1 -0
  41. package/dist/components/gallery/FlowLinesGallery.js +9 -0
  42. package/dist/components/gallery/FoldGallery.d.ts +18 -0
  43. package/dist/components/gallery/FoldGallery.d.ts.map +1 -0
  44. package/dist/components/gallery/FoldGallery.js +9 -0
  45. package/dist/components/gallery/GlassPanesGallery.d.ts +18 -0
  46. package/dist/components/gallery/GlassPanesGallery.d.ts.map +1 -0
  47. package/dist/components/gallery/GlassPanesGallery.js +9 -0
  48. package/dist/components/gallery/HaloGallery.d.ts +18 -0
  49. package/dist/components/gallery/HaloGallery.d.ts.map +1 -0
  50. package/dist/components/gallery/HaloGallery.js +9 -0
  51. package/dist/components/gallery/LightThreadsGallery.d.ts +18 -0
  52. package/dist/components/gallery/LightThreadsGallery.d.ts.map +1 -0
  53. package/dist/components/gallery/LightThreadsGallery.js +9 -0
  54. package/dist/components/gallery/LoomGallery.d.ts +18 -0
  55. package/dist/components/gallery/LoomGallery.d.ts.map +1 -0
  56. package/dist/components/gallery/LoomGallery.js +9 -0
  57. package/dist/components/gallery/PaperLanternsGallery.d.ts +18 -0
  58. package/dist/components/gallery/PaperLanternsGallery.d.ts.map +1 -0
  59. package/dist/components/gallery/PaperLanternsGallery.js +9 -0
  60. package/dist/components/gallery/ParticleShiftGallery.d.ts +18 -0
  61. package/dist/components/gallery/ParticleShiftGallery.d.ts.map +1 -0
  62. package/dist/components/gallery/ParticleShiftGallery.js +9 -0
  63. package/dist/components/gallery/PinscreenGallery.d.ts +18 -0
  64. package/dist/components/gallery/PinscreenGallery.d.ts.map +1 -0
  65. package/dist/components/gallery/PinscreenGallery.js +9 -0
  66. package/dist/components/gallery/PopUpGallery.d.ts +18 -0
  67. package/dist/components/gallery/PopUpGallery.d.ts.map +1 -0
  68. package/dist/components/gallery/PopUpGallery.js +9 -0
  69. package/dist/components/gallery/PrismSplitGallery.d.ts +18 -0
  70. package/dist/components/gallery/PrismSplitGallery.d.ts.map +1 -0
  71. package/dist/components/gallery/PrismSplitGallery.js +9 -0
  72. package/dist/components/gallery/RidgelinesGallery.d.ts +18 -0
  73. package/dist/components/gallery/RidgelinesGallery.d.ts.map +1 -0
  74. package/dist/components/gallery/RidgelinesGallery.js +9 -0
  75. package/dist/components/gallery/ShadowBoxGallery.d.ts +18 -0
  76. package/dist/components/gallery/ShadowBoxGallery.d.ts.map +1 -0
  77. package/dist/components/gallery/ShadowBoxGallery.js +9 -0
  78. package/dist/components/gallery/SilkGallery.d.ts +18 -0
  79. package/dist/components/gallery/SilkGallery.d.ts.map +1 -0
  80. package/dist/components/gallery/SilkGallery.js +9 -0
  81. package/dist/components/gallery/SlatsGallery.d.ts +18 -0
  82. package/dist/components/gallery/SlatsGallery.d.ts.map +1 -0
  83. package/dist/components/gallery/SlatsGallery.js +9 -0
  84. package/dist/components/gallery/StrataGallery.d.ts +18 -0
  85. package/dist/components/gallery/StrataGallery.d.ts.map +1 -0
  86. package/dist/components/gallery/StrataGallery.js +9 -0
  87. package/dist/components/gallery/TerracesGallery.d.ts +18 -0
  88. package/dist/components/gallery/TerracesGallery.d.ts.map +1 -0
  89. package/dist/components/gallery/TerracesGallery.js +9 -0
  90. package/dist/components/gallery/WireReliefGallery.d.ts +18 -0
  91. package/dist/components/gallery/WireReliefGallery.d.ts.map +1 -0
  92. package/dist/components/gallery/WireReliefGallery.js +9 -0
  93. package/dist/components/gallery/index.d.ts +46 -0
  94. package/dist/components/gallery/index.d.ts.map +1 -0
  95. package/dist/components/gallery/index.js +22 -0
  96. package/dist/components/gallery/kit/GalleryVariant.d.ts +68 -0
  97. package/dist/components/gallery/kit/GalleryVariant.d.ts.map +1 -0
  98. package/dist/components/gallery/kit/GalleryVariant.js +231 -0
  99. package/dist/components/gallery/kit/feeds.d.ts +7 -0
  100. package/dist/components/gallery/kit/feeds.d.ts.map +1 -0
  101. package/dist/components/gallery/kit/feeds.js +83 -0
  102. package/dist/components/gallery/kit/galleryKit.d.ts +118 -0
  103. package/dist/components/gallery/kit/galleryKit.d.ts.map +1 -0
  104. package/dist/components/gallery/kit/galleryKit.js +298 -0
  105. package/dist/components/gallery/kit/lookBase.d.ts +157 -0
  106. package/dist/components/gallery/kit/lookBase.d.ts.map +1 -0
  107. package/dist/components/gallery/kit/lookBase.js +211 -0
  108. package/dist/components/gallery/kit/pictures.d.ts +14 -0
  109. package/dist/components/gallery/kit/pictures.d.ts.map +1 -0
  110. package/dist/components/gallery/kit/pictures.js +81 -0
  111. package/dist/components/gallery/looks/basicCarousel.d.ts +177 -0
  112. package/dist/components/gallery/looks/basicCarousel.d.ts.map +1 -0
  113. package/dist/components/gallery/looks/basicCarousel.js +315 -0
  114. package/dist/components/gallery/looks/contourLines.d.ts +153 -0
  115. package/dist/components/gallery/looks/contourLines.d.ts.map +1 -0
  116. package/dist/components/gallery/looks/contourLines.js +91 -0
  117. package/dist/components/gallery/looks/depthLayers.d.ts +155 -0
  118. package/dist/components/gallery/looks/depthLayers.d.ts.map +1 -0
  119. package/dist/components/gallery/looks/depthLayers.js +87 -0
  120. package/dist/components/gallery/looks/engraving.d.ts +162 -0
  121. package/dist/components/gallery/looks/engraving.d.ts.map +1 -0
  122. package/dist/components/gallery/looks/engraving.js +96 -0
  123. package/dist/components/gallery/looks/flowLines.d.ts +180 -0
  124. package/dist/components/gallery/looks/flowLines.d.ts.map +1 -0
  125. package/dist/components/gallery/looks/flowLines.js +113 -0
  126. package/dist/components/gallery/looks/fold.d.ts +209 -0
  127. package/dist/components/gallery/looks/fold.d.ts.map +1 -0
  128. package/dist/components/gallery/looks/fold.js +155 -0
  129. package/dist/components/gallery/looks/glassPanes.d.ts +133 -0
  130. package/dist/components/gallery/looks/glassPanes.d.ts.map +1 -0
  131. package/dist/components/gallery/looks/glassPanes.js +208 -0
  132. package/dist/components/gallery/looks/halo.d.ts +100 -0
  133. package/dist/components/gallery/looks/halo.d.ts.map +1 -0
  134. package/dist/components/gallery/looks/halo.js +119 -0
  135. package/dist/components/gallery/looks/lightThreads.d.ts +199 -0
  136. package/dist/components/gallery/looks/lightThreads.d.ts.map +1 -0
  137. package/dist/components/gallery/looks/lightThreads.js +246 -0
  138. package/dist/components/gallery/looks/loom.d.ts +238 -0
  139. package/dist/components/gallery/looks/loom.d.ts.map +1 -0
  140. package/dist/components/gallery/looks/loom.js +256 -0
  141. package/dist/components/gallery/looks/paperLanterns.d.ts +181 -0
  142. package/dist/components/gallery/looks/paperLanterns.d.ts.map +1 -0
  143. package/dist/components/gallery/looks/paperLanterns.js +399 -0
  144. package/dist/components/gallery/looks/particleShift.d.ts +193 -0
  145. package/dist/components/gallery/looks/particleShift.d.ts.map +1 -0
  146. package/dist/components/gallery/looks/particleShift.js +282 -0
  147. package/dist/components/gallery/looks/pinscreen.d.ts +175 -0
  148. package/dist/components/gallery/looks/pinscreen.d.ts.map +1 -0
  149. package/dist/components/gallery/looks/pinscreen.js +96 -0
  150. package/dist/components/gallery/looks/popUp.d.ts +206 -0
  151. package/dist/components/gallery/looks/popUp.d.ts.map +1 -0
  152. package/dist/components/gallery/looks/popUp.js +132 -0
  153. package/dist/components/gallery/looks/prismSplit.d.ts +151 -0
  154. package/dist/components/gallery/looks/prismSplit.d.ts.map +1 -0
  155. package/dist/components/gallery/looks/prismSplit.js +84 -0
  156. package/dist/components/gallery/looks/ridgelines.d.ts +179 -0
  157. package/dist/components/gallery/looks/ridgelines.d.ts.map +1 -0
  158. package/dist/components/gallery/looks/ridgelines.js +111 -0
  159. package/dist/components/gallery/looks/shadowBox.d.ts +152 -0
  160. package/dist/components/gallery/looks/shadowBox.d.ts.map +1 -0
  161. package/dist/components/gallery/looks/shadowBox.js +82 -0
  162. package/dist/components/gallery/looks/silk.d.ts +140 -0
  163. package/dist/components/gallery/looks/silk.d.ts.map +1 -0
  164. package/dist/components/gallery/looks/silk.js +346 -0
  165. package/dist/components/gallery/looks/slats.d.ts +176 -0
  166. package/dist/components/gallery/looks/slats.d.ts.map +1 -0
  167. package/dist/components/gallery/looks/slats.js +93 -0
  168. package/dist/components/gallery/looks/strata.d.ts +172 -0
  169. package/dist/components/gallery/looks/strata.d.ts.map +1 -0
  170. package/dist/components/gallery/looks/strata.js +88 -0
  171. package/dist/components/gallery/looks/terraces.d.ts +168 -0
  172. package/dist/components/gallery/looks/terraces.d.ts.map +1 -0
  173. package/dist/components/gallery/looks/terraces.js +91 -0
  174. package/dist/components/gallery/looks/wireRelief.d.ts +153 -0
  175. package/dist/components/gallery/looks/wireRelief.d.ts.map +1 -0
  176. package/dist/components/gallery/looks/wireRelief.js +128 -0
  177. package/dist/components/image/ContourImage.d.ts +7 -0
  178. package/dist/components/image/ContourImage.d.ts.map +1 -0
  179. package/dist/components/image/ContourImage.js +6 -0
  180. package/dist/components/image/EngravingImage.d.ts +7 -0
  181. package/dist/components/image/EngravingImage.d.ts.map +1 -0
  182. package/dist/components/image/EngravingImage.js +6 -0
  183. package/dist/components/image/FrostImage.d.ts +7 -0
  184. package/dist/components/image/FrostImage.d.ts.map +1 -0
  185. package/dist/components/image/FrostImage.js +6 -0
  186. package/dist/components/image/LenticularImage.d.ts +7 -0
  187. package/dist/components/image/LenticularImage.d.ts.map +1 -0
  188. package/dist/components/image/LenticularImage.js +6 -0
  189. package/dist/components/image/PinscreenImage.d.ts +7 -0
  190. package/dist/components/image/PinscreenImage.d.ts.map +1 -0
  191. package/dist/components/image/PinscreenImage.js +6 -0
  192. package/dist/components/image/PrismImage.d.ts +7 -0
  193. package/dist/components/image/PrismImage.d.ts.map +1 -0
  194. package/dist/components/image/PrismImage.js +6 -0
  195. package/dist/components/image/ProjectorImage.d.ts +7 -0
  196. package/dist/components/image/ProjectorImage.d.ts.map +1 -0
  197. package/dist/components/image/ProjectorImage.js +6 -0
  198. package/dist/components/image/ReliefImage.d.ts +7 -0
  199. package/dist/components/image/ReliefImage.d.ts.map +1 -0
  200. package/dist/components/image/ReliefImage.js +6 -0
  201. package/dist/components/image/RollImage.d.ts +7 -0
  202. package/dist/components/image/RollImage.d.ts.map +1 -0
  203. package/dist/components/image/RollImage.js +6 -0
  204. package/dist/components/image/ShardsImage.d.ts +126 -0
  205. package/dist/components/image/ShardsImage.d.ts.map +1 -0
  206. package/dist/components/image/ShardsImage.js +470 -0
  207. package/dist/components/image/core/contour.d.ts +126 -0
  208. package/dist/components/image/core/contour.d.ts.map +1 -0
  209. package/dist/components/image/core/contour.js +123 -0
  210. package/dist/components/image/core/engraving.d.ts +135 -0
  211. package/dist/components/image/core/engraving.d.ts.map +1 -0
  212. package/dist/components/image/core/engraving.js +163 -0
  213. package/dist/components/image/core/frost.d.ts +126 -0
  214. package/dist/components/image/core/frost.d.ts.map +1 -0
  215. package/dist/components/image/core/frost.js +156 -0
  216. package/dist/components/image/core/imageCore.d.ts +110 -0
  217. package/dist/components/image/core/imageCore.d.ts.map +1 -0
  218. package/dist/components/image/core/imageCore.js +269 -0
  219. package/dist/components/image/core/lenticular.d.ts +129 -0
  220. package/dist/components/image/core/lenticular.d.ts.map +1 -0
  221. package/dist/components/image/core/lenticular.js +132 -0
  222. package/dist/components/image/core/pinscreen.d.ts +126 -0
  223. package/dist/components/image/core/pinscreen.d.ts.map +1 -0
  224. package/dist/components/image/core/pinscreen.js +147 -0
  225. package/dist/components/image/core/prism.d.ts +120 -0
  226. package/dist/components/image/core/prism.d.ts.map +1 -0
  227. package/dist/components/image/core/prism.js +164 -0
  228. package/dist/components/image/core/projector.d.ts +135 -0
  229. package/dist/components/image/core/projector.d.ts.map +1 -0
  230. package/dist/components/image/core/projector.js +225 -0
  231. package/dist/components/image/core/relief.d.ts +111 -0
  232. package/dist/components/image/core/relief.d.ts.map +1 -0
  233. package/dist/components/image/core/relief.js +94 -0
  234. package/dist/components/image/core/roll.d.ts +114 -0
  235. package/dist/components/image/core/roll.d.ts.map +1 -0
  236. package/dist/components/image/core/roll.js +116 -0
  237. package/dist/components/image/imageVariant.d.ts +46 -0
  238. package/dist/components/image/imageVariant.d.ts.map +1 -0
  239. package/dist/components/image/imageVariant.js +128 -0
  240. package/dist/components/image/index.d.ts +22 -0
  241. package/dist/components/image/index.d.ts.map +1 -0
  242. package/dist/components/image/index.js +10 -0
  243. package/dist/components/image/pictureCycle.d.ts +15 -0
  244. package/dist/components/image/pictureCycle.d.ts.map +1 -0
  245. package/dist/components/image/pictureCycle.js +82 -0
  246. package/dist/components/index.d.ts +4 -0
  247. package/dist/components/index.d.ts.map +1 -1
  248. package/dist/components/index.js +4 -0
  249. package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts +9 -7
  250. package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts.map +1 -1
  251. package/dist/components/volumetricClouds/VolumetricCloudsPass.js +39 -27
  252. package/dist/constants.d.ts.map +1 -1
  253. package/dist/constants.js +2 -0
  254. package/dist/galleryRuntime.d.ts +57 -0
  255. package/dist/galleryRuntime.d.ts.map +1 -0
  256. package/dist/galleryRuntime.js +105 -0
  257. package/dist/hooks/useConfigLive.d.ts +1 -1
  258. package/dist/hooks/useConfigLive.d.ts.map +1 -1
  259. package/dist/index.d.ts +4 -1
  260. package/dist/index.d.ts.map +1 -1
  261. package/dist/index.js +4 -0
  262. package/dist/keyPad/KeyPadControls.d.ts +16 -0
  263. package/dist/keyPad/KeyPadControls.d.ts.map +1 -0
  264. package/dist/keyPad/KeyPadControls.js +176 -0
  265. package/dist/keyPad/index.d.ts +16 -0
  266. package/dist/keyPad/index.d.ts.map +1 -0
  267. package/dist/keyPad/index.js +8 -0
  268. package/dist/keyPad/keyBindings.d.ts +43 -0
  269. package/dist/keyPad/keyBindings.d.ts.map +1 -0
  270. package/dist/keyPad/keyBindings.js +92 -0
  271. package/dist/keyPad/keyPadAnimation.d.ts +28 -0
  272. package/dist/keyPad/keyPadAnimation.d.ts.map +1 -0
  273. package/dist/keyPad/keyPadAnimation.js +131 -0
  274. package/dist/keyPad/keyPadMotion.d.ts +68 -0
  275. package/dist/keyPad/keyPadMotion.d.ts.map +1 -0
  276. package/dist/keyPad/keyPadMotion.js +283 -0
  277. package/dist/keyPad/keyPadStore.d.ts +25 -0
  278. package/dist/keyPad/keyPadStore.d.ts.map +1 -0
  279. package/dist/keyPad/keyPadStore.js +63 -0
  280. package/dist/keyPad/types.d.ts +23 -0
  281. package/dist/keyPad/types.d.ts.map +1 -0
  282. package/dist/keyPad/types.js +9 -0
  283. package/dist/operations/catalogue/visibility.d.ts.map +1 -1
  284. package/dist/operations/catalogue/visibility.js +23 -1
  285. package/dist/shaders/clouds/CloudResolveMaterial.d.ts +2 -1
  286. package/dist/shaders/clouds/CloudResolveMaterial.d.ts.map +1 -1
  287. package/dist/shaders/clouds/CloudResolveMaterial.js +37 -12
  288. package/dist/shaders/clouds/CloudVolumeMaterial.d.ts +4 -0
  289. package/dist/shaders/clouds/CloudVolumeMaterial.d.ts.map +1 -1
  290. package/dist/shaders/clouds/CloudVolumeMaterial.js +15 -3
  291. package/dist/triggers/kinds/gallery.d.ts +2 -0
  292. package/dist/triggers/kinds/gallery.d.ts.map +1 -0
  293. package/dist/triggers/kinds/gallery.js +39 -0
  294. package/dist/triggers/kinds/index.d.ts +1 -0
  295. package/dist/triggers/kinds/index.d.ts.map +1 -1
  296. package/dist/triggers/kinds/index.js +1 -0
  297. package/package.json +2 -2
@@ -0,0 +1,94 @@
1
+ // GENERATED from the lab (Claude outputs/gallery-lab/image/relief.mjs) by emit_image.mjs — change the lab and re-emit.
2
+ // relief — an image variant (type 'image', config.type 'relief'). Material: MeshStandardMaterial (lit by the scene;
3
+ // object effects attach).
4
+ //
5
+ // The picture is pressed into a sheet of paper: the surface is displaced by the picture's own local contrast — a
6
+ // band-pass of its luminance (fine mip minus a coarse one), so edges and textures stand up as a low emboss and flat
7
+ // areas stay flat (a plain luminance height would lift every sky). The scene's light rakes across the relief.
8
+ // A change is a press travelling across the sheet: a soft crest lifts the paper along the front, the old
9
+ // impression is pressed flat under it, the new one rises behind; the ink of the new picture lays down darks
10
+ // first, then mids, then lights (it follows the crest, never a flat crossfade). The first picture is printed into
11
+ // blank paper the same way. Idle: the sheet breathes — two slow, very low waves that move the highlights.
12
+ // Cursor: `press` dents the paper under the cursor, `rake` deepens the relief around it (a loupe for texture).
13
+ import * as THREE from 'three';
14
+ import { baseUniforms, applyBase, setU, createPicture, stepPointer, patchMaterial, depthTwin } from './imageCore.js';
15
+ export const POINTER_MODES = ['press', 'rake'];
16
+ export const STRUCTURAL = ['imageUrls', 'detail'];
17
+ export function createUniforms() {
18
+ return { ...baseUniforms(), uDepth: { value: 0.6 }, uCrest: { value: 0.6 }, uSelf: { value: 0.12 } };
19
+ }
20
+ export function applyConfig(u, c) {
21
+ applyBase(u, c, POINTER_MODES);
22
+ setU(u, 'uDepth', c.depth);
23
+ setU(u, 'uCrest', c.crest);
24
+ setU(u, 'uSelf', c.selfLight);
25
+ setU(u, 'uBlank', c.paperColor);
26
+ }
27
+ const pars = /* glsl */ `
28
+ uniform float uDepth, uCrest, uSelf;
29
+ varying vec2 vPic; varying float vL;
30
+ // band-passed luminance: what stands up in the paper
31
+ float bandA(vec2 uv){ return luma(picAL(uv, 1.0)) - luma(picAL(uv, 4.5)); }
32
+ float bandB(vec2 uv){ return luma(picBL(uv, 1.0)) - luma(picBL(uv, 4.5)); }
33
+ float heightAt(vec2 uv){
34
+ float l = localP(uv); float s = sstep(l); float bump = sin(PI * l);
35
+ vec2 xy = (uv - 0.5) * uSize;
36
+ float press = 1.0 - 0.85 * bump; // the old impression is pressed flat under the crest
37
+ float h = mix(bandA(uv), bandB(uv), s) * press * uDepth * 0.12 * (1.0 + 0.04 * uBreathe * sin(uTime * 0.45));
38
+ h += uCrest * 0.09 * bump * bump * bump; // the crest
39
+ h += uBreathe * 0.004 * sin(xy.x * 1.3 + uTime * 0.37) * sin(xy.y * 1.9 - uTime * 0.29 + 1.0);
40
+ float pb = pointerBump(xy);
41
+ if (uPointerMode > -0.5 && uPointerMode < 0.5) h -= 0.07 * pb; // press
42
+ else if (uPointerMode > 0.5) h += mix(bandA(uv), bandB(uv), s) * uDepth * 0.12 * 2.5 * pb; // rake
43
+ return h;
44
+ }
45
+ `;
46
+ const vertex = /* glsl */ `
47
+ vec2 uv0 = position.xy + 0.5;
48
+ float e = 1.5 / 256.0;
49
+ float h0 = heightAt(uv0), hx = heightAt(uv0 + vec2(e, 0.0)), hy = heightAt(uv0 + vec2(0.0, e));
50
+ fxP = vec3(position.xy * uSize, h0);
51
+ fxN = normalize(vec3(-(hx - h0) / (e * uSize.x), -(hy - h0) / (e * uSize.y), 1.0));
52
+ vPic = uv0; vL = localP(uv0);
53
+ `;
54
+ const diffuse = /* glsl */ `
55
+ vec3 ca = picA(vPic), cb = picB(vPic);
56
+ float lb = luma(cb);
57
+ float crest = sin(PI * vL); crest *= crest;
58
+ vec3 pressed = mix(ca, uBlank, 0.55 * crest); // the old ink is lifted off under the crest
59
+ float inkB = smoothstep(lb * 0.45 + 0.3, lb * 0.45 + 0.55, vL); // the new ink: darks first, lights last
60
+ vec3 pic = mix(pressed, cb, inkB);
61
+ diffuseColor.rgb = pic * uIntensity;
62
+ diffuseColor.a *= uOpacity;
63
+ `;
64
+ const emissive = /* glsl */ `
65
+ totalEmissiveRadiance += diffuseColor.rgb * uSelf;
66
+ `;
67
+ export function build(u, c) {
68
+ const object = new THREE.Group();
69
+ const segX = Math.max(16, c.detail | 0), segY = Math.round(segX * 0.65);
70
+ const geo = new THREE.PlaneGeometry(1, 1, segX, segY);
71
+ const P = { key: 'relief', uniforms: u, pars, vertex, diffuse, emissive };
72
+ const mat = patchMaterial(new THREE.MeshStandardMaterial({ roughness: c.roughness, metalness: 0, side: THREE.DoubleSide }), P);
73
+ const mesh = new THREE.Mesh(geo, mat);
74
+ mesh.castShadow = true;
75
+ mesh.receiveShadow = true;
76
+ mesh.frustumCulled = false;
77
+ mesh.customDepthMaterial = depthTwin(P);
78
+ object.add(mesh);
79
+ const cfg = { ...c };
80
+ const pic = createPicture(u, cfg);
81
+ const pst = {};
82
+ const api = {
83
+ object, materials: [mat, mesh.customDepthMaterial],
84
+ controls: { show: (t) => pic.show(t), get busy() { return pic.busy; }, pic },
85
+ apply(k) { Object.assign(cfg, k); applyConfig(u, k); if (k.roughness !== undefined)
86
+ mat.roughness = k.roughness; if (k.opacity !== undefined) {
87
+ mat.transparent = k.opacity < 1;
88
+ mat.depthWrite = k.opacity >= 1;
89
+ } },
90
+ update(dt, pointer) { dt = Math.min(dt, 0.1); u.uTime.value += dt; pic.step(dt); stepPointer(u, pointer, dt, pst); },
91
+ dispose() { geo.dispose(); mat.dispose(); mesh.customDepthMaterial.dispose(); pic.dispose(); },
92
+ };
93
+ return api;
94
+ }
@@ -0,0 +1,114 @@
1
+ import * as THREE from 'three';
2
+ export declare const POINTER_MODES: string[];
3
+ export declare const STRUCTURAL: string[];
4
+ export declare function createUniforms(): {
5
+ uRoll: {
6
+ value: number;
7
+ };
8
+ uSkew: {
9
+ value: number;
10
+ };
11
+ uBack: {
12
+ value: THREE.Color;
13
+ };
14
+ uSelf: {
15
+ value: number;
16
+ };
17
+ uTexA: {
18
+ value: any;
19
+ };
20
+ uTexB: {
21
+ value: any;
22
+ };
23
+ uFitA: {
24
+ value: THREE.Vector2;
25
+ };
26
+ uFitB: {
27
+ value: THREE.Vector2;
28
+ };
29
+ uP: {
30
+ value: number;
31
+ };
32
+ uHasA: {
33
+ value: number;
34
+ };
35
+ uSeq: {
36
+ value: number;
37
+ };
38
+ uSize: {
39
+ value: THREE.Vector2;
40
+ };
41
+ uTime: {
42
+ value: number;
43
+ };
44
+ uDir: {
45
+ value: THREE.Vector2;
46
+ };
47
+ uSpread: {
48
+ value: number;
49
+ };
50
+ uBlank: {
51
+ value: THREE.Color;
52
+ };
53
+ uIntensity: {
54
+ value: number;
55
+ };
56
+ uOpacity: {
57
+ value: number;
58
+ };
59
+ uBreathe: {
60
+ value: number;
61
+ };
62
+ uPointer: {
63
+ value: THREE.Vector3;
64
+ };
65
+ uPointerVel: {
66
+ value: THREE.Vector2;
67
+ };
68
+ uPointerActive: {
69
+ value: number;
70
+ };
71
+ uPointerMode: {
72
+ value: number;
73
+ };
74
+ uPointerStrength: {
75
+ value: number;
76
+ };
77
+ uPointerRadius: {
78
+ value: number;
79
+ };
80
+ uPointerColor: {
81
+ value: THREE.Color;
82
+ };
83
+ };
84
+ export declare function applyConfig(u: any, c: any): void;
85
+ export declare function build(u: any, c: any): {
86
+ object: THREE.Group<THREE.Object3DEventMap>;
87
+ materials: any[];
88
+ controls: {
89
+ show: (t: any) => void;
90
+ readonly busy: boolean;
91
+ pic: {
92
+ st: {
93
+ A: any;
94
+ B: any;
95
+ aspA: number;
96
+ aspB: number;
97
+ p: number;
98
+ dir: number;
99
+ pending: any;
100
+ seq: number;
101
+ frame: number;
102
+ };
103
+ show: (tex: any) => void;
104
+ jump: (tex: any) => void;
105
+ step: (dt: any) => void;
106
+ readonly busy: boolean;
107
+ dispose(): void;
108
+ };
109
+ };
110
+ apply(k: any): void;
111
+ update(dt: any, pointer: any): void;
112
+ dispose(): void;
113
+ };
114
+ //# sourceMappingURL=roll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roll.d.ts","sourceRoot":"","sources":["../../../../src/components/image/core/roll.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,eAAO,MAAM,aAAa,UAAoB,CAAC;AAC/C,eAAO,MAAM,UAAU,UAA0B,CAAC;AAElD,wBAAgB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAE7B;AACD,wBAAgB,WAAW,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA,QAG/B;AAsDD,wBAAgB,KAAK,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwBzB"}
@@ -0,0 +1,116 @@
1
+ // GENERATED from the lab (Claude outputs/gallery-lab/image/roll.mjs) by emit_image.mjs — change the lab and re-emit.
2
+ // roll — an image variant (type 'image', config.type 'roll'). Material: MeshStandardMaterial (double-sided; lit by
3
+ // the scene; object effects attach).
4
+ //
5
+ // The picture is a print on paper, and a change is a slim paper roll travelling across it: ahead of the roll lies
6
+ // the old print, which curls up around the roll's back and winds in; behind it the new print unwinds off the
7
+ // roll's front and lies flat. Both sheets are the same subdivided plane bent in the vertex shader around a cylinder
8
+ // of radius r at the roll position F (arc length preserved, tangent-continuous at the contact line), with material
9
+ // past half a turn folded onto the roll's crest — so the picture never stretches and nothing pops. The printed
10
+ // sides face inward on the roll, so from outside it is a clean paper tube catching the scene's light and casting a
11
+ // soft shadow on the print. r grows from zero and returns to zero, so the roll appears and disappears in place.
12
+ // Idle: the paper breathes (a very low swell). Cursor: `lift` — the paper lifts softly toward the cursor (air
13
+ // under the sheet), `press` — it dents under it.
14
+ import * as THREE from 'three';
15
+ import { baseUniforms, applyBase, setU, createPicture, stepPointer, patchMaterial, depthTwin } from './imageCore.js';
16
+ export const POINTER_MODES = ['lift', 'press'];
17
+ export const STRUCTURAL = ['imageUrls', 'detail'];
18
+ export function createUniforms() {
19
+ return { ...baseUniforms(), uRoll: { value: 1 }, uSkew: { value: 0.12 }, uBack: { value: new THREE.Color('#efebe3') }, uSelf: { value: 0.1 } };
20
+ }
21
+ export function applyConfig(u, c) {
22
+ applyBase(u, c, POINTER_MODES);
23
+ setU(u, 'uRoll', c.rollSize);
24
+ setU(u, 'uSkew', c.skew);
25
+ setU(u, 'uBack', c.paperColor);
26
+ setU(u, 'uSelf', c.selfLight);
27
+ }
28
+ const pars = /* glsl */ `
29
+ uniform float uRoll, uSkew, uSelf, uWhich; uniform vec3 uBack;
30
+ varying vec2 vPic; varying float vShade;
31
+ float sheetH(vec2 xy){
32
+ float h = uBreathe * 0.005 * sin(xy.x * 1.4 + uTime * 0.33) * sin(xy.y * 1.8 - uTime * 0.27 + 0.7);
33
+ float pb = pointerBump(xy);
34
+ if (uPointerMode > -0.5 && uPointerMode < 0.5) h += 0.06 * pb; else if (uPointerMode > 0.5) h -= 0.05 * pb;
35
+ return h;
36
+ }
37
+ `;
38
+ // s = coordinate along the travel; the roll line is s = F + skew * (coordinate across); A ahead (s > F), B behind.
39
+ const vertex = /* glsl */ `
40
+ vec2 uv0 = position.xy + 0.5;
41
+ vec2 xy = position.xy * uSize;
42
+ vec2 dir = uDir, crossD = vec2(-uDir.y, uDir.x);
43
+ float ext = 0.5 * (abs(dir.x) * uSize.x + abs(dir.y) * uSize.y);
44
+ float extC = 0.5 * (abs(crossD.x) * uSize.x + abs(crossD.y) * uSize.y);
45
+ float s = dot(xy, dir), w = dot(xy, crossD);
46
+ float e = sstep(uP);
47
+ float skew = uSkew * ext * 0.5;
48
+ float F = mix(-ext - abs(skew), ext + abs(skew), e) + skew * (w / max(extC, 1e-3));
49
+ float r = max(uRoll * 0.07 * pow(sin(PI * uP), 0.6), 1e-4);
50
+ // which part of this sheet is wound: A behind the line (s < F), B ahead of it (s > F)
51
+ float d = uWhich < 0.5 ? (F - s) : (s - F);
52
+ float h = sheetH(xy);
53
+ if (d <= 0.0) {
54
+ float ee = 0.01;
55
+ float hx = sheetH(xy + vec2(ee, 0.0)), hy = sheetH(xy + vec2(0.0, ee));
56
+ fxP = vec3(xy, h);
57
+ fxN = normalize(vec3(-(hx - h) / ee, -(hy - h) / ee, 1.0));
58
+ vShade = 1.0 - 0.35 * exp(-abs(s - F) / (r * 1.2 + 1e-3)) * smoothstep(0.0, 0.02, r); // contact shade at the roll
59
+ } else {
60
+ float th = min(d / r, PI);
61
+ float side = uWhich < 0.5 ? -1.0 : 1.0; // A winds up the back, B off the front
62
+ float ss = F + side * r * sin(th);
63
+ float zz = r - r * cos(th);
64
+ fxP = vec3(xy + dir * (ss - s), zz);
65
+ vec2 n = -vec2(side * sin(th), -cos(th)); // printed side faces the roll's axis
66
+ fxN = normalize(vec3(dir * n.x, n.y));
67
+ vShade = 1.0;
68
+ }
69
+ vPic = uv0;
70
+ `;
71
+ const diffuse = /* glsl */ `
72
+ vec3 c = gl_FrontFacing ? (uWhich < 0.5 ? picA(vPic) : picB(vPic)) * uIntensity : uBack;
73
+ diffuseColor.rgb = c * vShade;
74
+ diffuseColor.a *= uOpacity;
75
+ `;
76
+ const emissive = /* glsl */ `
77
+ totalEmissiveRadiance += gl_FrontFacing ? diffuseColor.rgb * uSelf : vec3(0.0);
78
+ `;
79
+ export function build(u, c) {
80
+ const object = new THREE.Group();
81
+ const seg = Math.max(30, c.detail | 0);
82
+ const geo = new THREE.PlaneGeometry(1, 1, seg, Math.round(seg * 0.7));
83
+ const meshes = [], mats = [];
84
+ for (const which of [0, 1]) {
85
+ const uu = { ...u, uWhich: { value: which } };
86
+ const P = { key: 'roll', uniforms: uu, pars, vertex, diffuse, emissive };
87
+ const mat = patchMaterial(new THREE.MeshStandardMaterial({ roughness: c.roughness, metalness: 0, side: THREE.DoubleSide }), P);
88
+ const m = new THREE.Mesh(geo, mat);
89
+ m.castShadow = true;
90
+ m.receiveShadow = true;
91
+ m.frustumCulled = false;
92
+ m.customDepthMaterial = depthTwin(P);
93
+ meshes.push(m);
94
+ mats.push(mat);
95
+ object.add(m);
96
+ }
97
+ const cfg = { ...c };
98
+ const pic = createPicture(u, cfg);
99
+ const pst = {};
100
+ const api = {
101
+ object, materials: mats,
102
+ controls: { show: (t) => pic.show(t), get busy() { return pic.busy; }, pic },
103
+ apply(k) { Object.assign(cfg, k); applyConfig(u, k); for (const m of mats) {
104
+ if (k.roughness !== undefined)
105
+ m.roughness = k.roughness;
106
+ if (k.opacity !== undefined)
107
+ m.transparent = k.opacity < 1;
108
+ } },
109
+ update(dt, pointer) { dt = Math.min(dt, 0.1); u.uTime.value += dt; pic.step(dt); stepPointer(u, pointer, dt, pst); },
110
+ dispose() { geo.dispose(); for (const m of meshes) {
111
+ m.material.dispose();
112
+ m.customDepthMaterial.dispose();
113
+ } pic.dispose(); },
114
+ };
115
+ return api;
116
+ }
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import * as THREE from 'three';
3
+ import type { AnimationOptions, MouseMoveDomain } from '@3driseai/3drise-core';
4
+ import type { ObjectReadyProps } from '../../types/objectReady';
5
+ export interface ImageVariantInstance {
6
+ object: THREE.Object3D;
7
+ apply(config: Record<string, unknown>): void;
8
+ update(dt: number, pointer: {
9
+ x: number;
10
+ y: number;
11
+ nx: number;
12
+ ny: number;
13
+ } | null, state?: unknown): void;
14
+ dispose(): void;
15
+ controls: {
16
+ show(tex: THREE.Texture): void;
17
+ readonly busy: boolean;
18
+ pic: {
19
+ jump(tex: THREE.Texture): void;
20
+ };
21
+ };
22
+ }
23
+ export interface ImageVariantModule {
24
+ POINTER_MODES: string[];
25
+ STRUCTURAL: string[];
26
+ createUniforms(): Record<string, THREE.IUniform>;
27
+ applyConfig(u: Record<string, THREE.IUniform>, c: Record<string, unknown>): void;
28
+ build(u: Record<string, THREE.IUniform>, c: Record<string, unknown>): ImageVariantInstance;
29
+ }
30
+ export interface ImageVariantProps<C> extends ObjectReadyProps {
31
+ config: C;
32
+ /** Scene object id: the live-edit handle is found by it. */
33
+ id?: string;
34
+ /** Keyframes on the config knobs (animations.image.animations). */
35
+ keyframes?: AnimationOptions[];
36
+ /** Pointer bindings on the config knobs (mouseMove.image). */
37
+ mouseMove?: MouseMoveDomain;
38
+ }
39
+ export declare function makeImageVariant<C extends {
40
+ imageUrls: string[];
41
+ interval: number;
42
+ enabled: boolean;
43
+ }>(mod: ImageVariantModule, defaults: C, animatable: {
44
+ value: string;
45
+ }[]): React.FC<ImageVariantProps<C>>;
46
+ //# sourceMappingURL=imageVariant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imageVariant.d.ts","sourceRoot":"","sources":["../../../src/components/image/imageVariant.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmE,MAAM,OAAO,CAAC;AACxF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAyBhE,MAAM,WAAW,oBAAoB;IACjC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC;IACvB,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC7C,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5G,OAAO,IAAI,IAAI,CAAC;IAChB,QAAQ,EAAE;QAAE,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;QAAC,GAAG,EAAE;YAAE,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,GAAG,IAAI,CAAA;SAAE,CAAA;KAAE,CAAC;CACjH;AACD,MAAM,WAAW,kBAAkB;IAC/B,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACjD,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACjF,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,oBAAoB,CAAC;CAC9F;AACD,MAAM,WAAW,iBAAiB,CAAC,CAAC,CAAE,SAAQ,gBAAgB;IAC1D,MAAM,EAAE,CAAC,CAAC;IACV,4DAA4D;IAC5D,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,mEAAmE;IACnE,SAAS,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC/B,8DAA8D;IAC9D,SAAS,CAAC,EAAE,eAAe,CAAC;CAC/B;AAqBD,wBAAgB,gBAAgB,CAAC,CAAC,SAAS;IAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,EAClG,GAAG,EAAE,kBAAkB,EAAE,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,GACtE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAmGhC"}
@@ -0,0 +1,128 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef } from 'react';
3
+ import * as THREE from 'three';
4
+ import { useFrame } from '@react-three/fiber';
5
+ import { withConfigDefaults } from '../../utils/configAnimations.js';
6
+ import { useObjectReady } from '../../hooks/useObjectReady.js';
7
+ import { useConfigDriver } from '../../hooks/useConfigDriver.js';
8
+ import { usePointerField } from '../../utils/pointerField.js';
9
+ import { usePictureCycle } from './pictureCycle.js';
10
+ const loader = new THREE.TextureLoader();
11
+ loader.setCrossOrigin('anonymous');
12
+ function loadPicture(url) {
13
+ return new Promise((resolve, reject) => loader.load(url, (t) => {
14
+ t.colorSpace = THREE.SRGBColorSpace;
15
+ t.wrapS = t.wrapT = THREE.ClampToEdgeWrapping;
16
+ t.minFilter = THREE.LinearMipmapLinearFilter;
17
+ t.generateMipmaps = true; // the variants read soft mips (relief, focus, frost, flow fields)
18
+ t.anisotropy = 8;
19
+ resolve(t);
20
+ }, undefined, reject));
21
+ }
22
+ const _plane = new THREE.Plane();
23
+ const _ray = new THREE.Raycaster();
24
+ const _hit = new THREE.Vector3();
25
+ const _n = new THREE.Vector3();
26
+ const _o = new THREE.Vector3();
27
+ export function makeImageVariant(mod, defaults, animatable) {
28
+ const STRUCTURAL = mod.STRUCTURAL;
29
+ const REBUILD = STRUCTURAL.filter((k) => k !== 'imageUrls');
30
+ const ANIMATABLE = new Set(animatable.map((p) => p.value));
31
+ const ImageVariant = ({ config, id, keyframes, mouseMove, onObjectReady, onObjectDispose }) => {
32
+ const rootRef = useRef(null);
33
+ useObjectReady(rootRef, config, onObjectReady, onObjectDispose);
34
+ const cfg = useMemo(() => withConfigDefaults(defaults, config), [config]);
35
+ const rebuildKey = REBUILD.map((k) => String(cfg[k])).join('|');
36
+ const shown = useRef(null); // the newest picture handed to the variant
37
+ const cache = useRef(new Map());
38
+ const loading = useRef('');
39
+ const built = useMemo(() => {
40
+ const u = mod.createUniforms();
41
+ mod.applyConfig(u, cfg);
42
+ const inst = mod.build(u, cfg);
43
+ inst.apply(cfg);
44
+ if (shown.current)
45
+ inst.controls.pic.jump(shown.current); // a rebuild lands on the current picture
46
+ inst.object.traverse((o) => { if (o.isMesh)
47
+ o.raycast = () => { }; });
48
+ const pick = new THREE.Mesh(new THREE.PlaneGeometry(1, 1), new THREE.MeshBasicMaterial({ visible: false }));
49
+ pick.name = 'imagePick';
50
+ inst.object.add(pick);
51
+ return { u, inst, pick };
52
+ }, [rebuildKey]); // eslint-disable-line react-hooks/exhaustive-deps
53
+ useEffect(() => () => {
54
+ built.inst.dispose();
55
+ built.pick.geometry.dispose();
56
+ built.pick.material.dispose();
57
+ }, [built]);
58
+ const instRef = useRef(built.inst);
59
+ instRef.current = built.inst;
60
+ /** Load a picture once (cached); a failed load is forgotten so it can be tried again. */
61
+ const load = useCallback((url) => {
62
+ let p = cache.current.get(url);
63
+ if (!p) {
64
+ p = loadPicture(url);
65
+ cache.current.set(url, p);
66
+ p.catch(() => cache.current.delete(url));
67
+ }
68
+ return p;
69
+ }, []);
70
+ /** The one door for a picture change: load, then the variant plays its change. A missing picture leaves the current one. */
71
+ const show = useCallback((url) => {
72
+ if (!url || url === loading.current)
73
+ return;
74
+ loading.current = url;
75
+ load(url).then((tex) => {
76
+ if (loading.current !== url)
77
+ return; // superseded by a newer url
78
+ loading.current = '';
79
+ shown.current = tex;
80
+ instRef.current.controls.show(tex);
81
+ }).catch(() => { if (loading.current === url)
82
+ loading.current = ''; });
83
+ }, [load]);
84
+ const preload = useCallback((url) => { load(url).catch(() => { }); }, [load]);
85
+ const busy = useCallback(() => !!loading.current || instRef.current.controls.busy, []);
86
+ const { showExternal, feed } = usePictureCycle({ urls: cfg.imageUrls, interval: cfg.interval, show, preload, busy });
87
+ useEffect(() => {
88
+ const root = rootRef.current;
89
+ if (!root)
90
+ return;
91
+ root.userData.applyTexture = (url) => showExternal(url);
92
+ root.userData.feedImage = feed; // a gallery's feeds (gallery/kit/feeds.ts)
93
+ return () => { delete root.userData.applyTexture; delete root.userData.feedImage; };
94
+ }, [showExternal, feed]);
95
+ useEffect(() => () => { for (const p of cache.current.values())
96
+ p.then((t) => t.dispose(), () => { }); cache.current.clear(); }, []);
97
+ useLayoutEffect(() => { built.inst.apply(cfg); }, [built, cfg]);
98
+ const push = useCallback((merged) => { instRef.current.apply(merged); }, []);
99
+ useConfigDriver({ rootRef, id, family: 'image', base: cfg, structural: STRUCTURAL, allowed: ANIMATABLE, keyframes, mouseMove, push });
100
+ const pf = usePointerField();
101
+ useFrame((state, delta) => {
102
+ const dt = Math.min(delta, 0.1);
103
+ const { inst, u, pick } = built;
104
+ // the cursor on the picture's plane (the variant's object space)
105
+ let pointer = null;
106
+ if (pf.inside) {
107
+ const o = inst.object;
108
+ o.updateWorldMatrix(true, false);
109
+ _n.set(0, 0, 1).transformDirection(o.matrixWorld);
110
+ _o.setFromMatrixPosition(o.matrixWorld);
111
+ _plane.setFromNormalAndCoplanarPoint(_n, _o);
112
+ _ray.setFromCamera(pf.ndc, state.camera);
113
+ if (_ray.ray.intersectPlane(_plane, _hit)) {
114
+ o.worldToLocal(_hit);
115
+ pointer = { x: _hit.x, y: _hit.y, nx: pf.ndc.x, ny: pf.ndc.y };
116
+ }
117
+ }
118
+ inst.update(dt, pointer, state);
119
+ const size = u.uSize?.value;
120
+ if (size)
121
+ pick.scale.set(size.x, size.y, 1);
122
+ });
123
+ if (!cfg.enabled)
124
+ return null;
125
+ return (_jsx("group", { ref: rootRef, children: _jsx("primitive", { object: built.inst.object }) }));
126
+ };
127
+ return ImageVariant;
128
+ }
@@ -0,0 +1,22 @@
1
+ export {};
2
+ export type { ShardsImageProps } from './ShardsImage';
3
+ export { default as ShardsImage } from './ShardsImage';
4
+ export type { ProjectorImageProps } from './ProjectorImage';
5
+ export { default as ProjectorImage } from './ProjectorImage';
6
+ export type { ReliefImageProps } from './ReliefImage';
7
+ export { default as ReliefImage } from './ReliefImage';
8
+ export type { PinscreenImageProps } from './PinscreenImage';
9
+ export { default as PinscreenImage } from './PinscreenImage';
10
+ export type { PrismImageProps } from './PrismImage';
11
+ export { default as PrismImage } from './PrismImage';
12
+ export type { LenticularImageProps } from './LenticularImage';
13
+ export { default as LenticularImage } from './LenticularImage';
14
+ export type { FrostImageProps } from './FrostImage';
15
+ export { default as FrostImage } from './FrostImage';
16
+ export type { RollImageProps } from './RollImage';
17
+ export { default as RollImage } from './RollImage';
18
+ export type { ContourImageProps } from './ContourImage';
19
+ export { default as ContourImage } from './ContourImage';
20
+ export type { EngravingImageProps } from './EngravingImage';
21
+ export { default as EngravingImage } from './EngravingImage';
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/image/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC;AACV,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7D,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,10 @@
1
+ export { default as ShardsImage } from './ShardsImage.js';
2
+ export { default as ProjectorImage } from './ProjectorImage.js';
3
+ export { default as ReliefImage } from './ReliefImage.js';
4
+ export { default as PinscreenImage } from './PinscreenImage.js';
5
+ export { default as PrismImage } from './PrismImage.js';
6
+ export { default as LenticularImage } from './LenticularImage.js';
7
+ export { default as FrostImage } from './FrostImage.js';
8
+ export { default as RollImage } from './RollImage.js';
9
+ export { default as ContourImage } from './ContourImage.js';
10
+ export { default as EngravingImage } from './EngravingImage.js';
@@ -0,0 +1,15 @@
1
+ export interface PictureCycleOptions {
2
+ urls: string[] | undefined;
3
+ interval: number;
4
+ /** Start the change to this picture (the variant's one door). */
5
+ show(url: string): void;
6
+ /** Load a picture ahead of time, without showing it. */
7
+ preload?(url: string): void;
8
+ /** True while a change plays or a picture loads: the clock waits. */
9
+ busy(): boolean;
10
+ }
11
+ export declare function usePictureCycle({ urls, interval, show, preload, busy }: PictureCycleOptions): {
12
+ showExternal: (url: string) => void;
13
+ feed: (url: string | null) => void;
14
+ };
15
+ //# sourceMappingURL=pictureCycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pictureCycle.d.ts","sourceRoot":"","sources":["../../../src/components/image/pictureCycle.ts"],"names":[],"mappings":"AAqBA,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,wDAAwD;IACxD,OAAO,CAAC,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,qEAAqE;IACrE,IAAI,IAAI,OAAO,CAAC;CACnB;AAED,wBAAgB,eAAe,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,mBAAmB;wBA+BjD,MAAM;gBAQd,MAAM,GAAG,IAAI;EAgB/C"}
@@ -0,0 +1,82 @@
1
+ import { useCallback, useEffect, useRef } from 'react';
2
+ import { useFrame } from '@react-three/fiber';
3
+ export function usePictureCycle({ urls, interval, show, preload, busy }) {
4
+ const list = urls ?? [];
5
+ const key = list.join('\n');
6
+ const st = useRef({ idx: 0, t: 0, current: '', preloaded: '', held: false });
7
+ const live = useRef({ list, interval, show, preload, busy });
8
+ live.current = { list, interval, show, preload, busy };
9
+ // the list changed: keep the picture shown if it is still there, else go to the first
10
+ useEffect(() => {
11
+ const s = st.current, L = live.current.list;
12
+ if (!L.length || s.held)
13
+ return;
14
+ const at = s.current ? L.indexOf(s.current) : -1;
15
+ if (at >= 0) {
16
+ s.idx = at;
17
+ return;
18
+ }
19
+ s.idx = 0;
20
+ s.t = 0;
21
+ s.current = L[0];
22
+ live.current.show(L[0]);
23
+ }, [key]);
24
+ useFrame((_, delta) => {
25
+ const s = st.current, { list: L, interval: iv, preload: pre, busy: isBusy } = live.current;
26
+ const n = L.length;
27
+ if (s.held)
28
+ return;
29
+ if (n < 2 || !(iv > 0) || isBusy()) {
30
+ s.t = 0;
31
+ return;
32
+ }
33
+ const next = L[(s.idx + 1) % n];
34
+ if (pre && s.preloaded !== next) {
35
+ s.preloaded = next;
36
+ pre(next);
37
+ }
38
+ s.t += Math.min(delta, 0.1);
39
+ if (s.t < iv)
40
+ return;
41
+ s.t = 0;
42
+ s.idx = (s.idx + 1) % n;
43
+ s.current = L[s.idx];
44
+ live.current.show(s.current);
45
+ });
46
+ /** A picture sent from outside (displayImage): change to it, the cycle carries on from it. */
47
+ const showExternal = useCallback((url) => {
48
+ if (!url)
49
+ return;
50
+ const s = st.current, at = live.current.list.indexOf(url);
51
+ if (at >= 0)
52
+ s.idx = at;
53
+ s.t = 0;
54
+ s.current = url;
55
+ live.current.show(url);
56
+ }, []);
57
+ /** A gallery feeding this object (userData.feedImage): show its picture and hold the own cycle; null ends the feed. */
58
+ const feed = useCallback((url) => {
59
+ const s = st.current;
60
+ if (url) {
61
+ s.held = true;
62
+ s.t = 0;
63
+ if (s.current !== url) {
64
+ s.current = url;
65
+ live.current.show(url);
66
+ }
67
+ return;
68
+ }
69
+ if (!s.held)
70
+ return;
71
+ s.held = false;
72
+ s.t = 0;
73
+ const L = live.current.list;
74
+ if (!L.length)
75
+ return;
76
+ const own = L[Math.min(s.idx, L.length - 1)];
77
+ s.idx = L.indexOf(own);
78
+ s.current = own;
79
+ live.current.show(own);
80
+ }, []);
81
+ return { showExternal, feed };
82
+ }
@@ -76,6 +76,8 @@ export { default as EnvironmentManager } from './EnvironmentManager';
76
76
  export { default as HdrEnvironment, isHdrActive } from './HdrEnvironment';
77
77
  export { default as EnvironmentObject } from './EnvironmentObject';
78
78
  export { default as TextGenerator } from './TextGenerator';
79
+ export { default as ImageObject } from './ImageObject';
80
+ export { default as GalleryObject } from './GalleryObject';
79
81
  export { default as Frame } from './Frame';
80
82
  export { FrameGeometry } from './FrameGeometry';
81
83
  export { FrameImage } from './FrameImage';
@@ -166,6 +168,8 @@ export { default as AdaptiveResolution } from './AdaptiveResolution';
166
168
  export { default as LandObject } from './LandObject';
167
169
  export * from './space';
168
170
  export * from './text';
171
+ export * from './image';
172
+ export * from './gallery';
169
173
  export * from './spotBeam';
170
174
  export * from './ledArray';
171
175
  export * from './fluorescentTube';