@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.
- package/dist/animationsV2/ClipsRuntime.d.ts.map +1 -1
- package/dist/animationsV2/ClipsRuntime.js +9 -5
- package/dist/animationsV2/clipUtils.d.ts +9 -0
- package/dist/animationsV2/clipUtils.d.ts.map +1 -1
- package/dist/animationsV2/clipUtils.js +11 -2
- package/dist/animationsV2/normalize.d.ts.map +1 -1
- package/dist/animationsV2/normalize.js +2 -0
- package/dist/animationsV2/types.d.ts +4 -0
- package/dist/animationsV2/types.d.ts.map +1 -1
- package/dist/api/sceneHandle.d.ts +40 -3
- package/dist/api/sceneHandle.d.ts.map +1 -1
- package/dist/api/sceneHandle.js +40 -0
- package/dist/components/GalleryObject.d.ts +13 -0
- package/dist/components/GalleryObject.d.ts.map +1 -0
- package/dist/components/GalleryObject.js +46 -0
- package/dist/components/ImageObject.d.ts +9 -0
- package/dist/components/ImageObject.d.ts.map +1 -0
- package/dist/components/ImageObject.js +26 -0
- package/dist/components/ObjectNode.d.ts.map +1 -1
- package/dist/components/ObjectNode.js +11 -5
- package/dist/components/ProjectLoader.d.ts +2 -0
- package/dist/components/ProjectLoader.d.ts.map +1 -1
- package/dist/components/ProjectLoader.js +2 -2
- package/dist/components/SceneBuilder.d.ts +10 -0
- package/dist/components/SceneBuilder.d.ts.map +1 -1
- package/dist/components/SceneBuilder.js +3 -2
- package/dist/components/gallery/BasicCarouselGallery.d.ts +18 -0
- package/dist/components/gallery/BasicCarouselGallery.d.ts.map +1 -0
- package/dist/components/gallery/BasicCarouselGallery.js +9 -0
- package/dist/components/gallery/ContourLinesGallery.d.ts +18 -0
- package/dist/components/gallery/ContourLinesGallery.d.ts.map +1 -0
- package/dist/components/gallery/ContourLinesGallery.js +9 -0
- package/dist/components/gallery/DepthLayersGallery.d.ts +18 -0
- package/dist/components/gallery/DepthLayersGallery.d.ts.map +1 -0
- package/dist/components/gallery/DepthLayersGallery.js +9 -0
- package/dist/components/gallery/EngravingGallery.d.ts +18 -0
- package/dist/components/gallery/EngravingGallery.d.ts.map +1 -0
- package/dist/components/gallery/EngravingGallery.js +9 -0
- package/dist/components/gallery/FlowLinesGallery.d.ts +18 -0
- package/dist/components/gallery/FlowLinesGallery.d.ts.map +1 -0
- package/dist/components/gallery/FlowLinesGallery.js +9 -0
- package/dist/components/gallery/FoldGallery.d.ts +18 -0
- package/dist/components/gallery/FoldGallery.d.ts.map +1 -0
- package/dist/components/gallery/FoldGallery.js +9 -0
- package/dist/components/gallery/GlassPanesGallery.d.ts +18 -0
- package/dist/components/gallery/GlassPanesGallery.d.ts.map +1 -0
- package/dist/components/gallery/GlassPanesGallery.js +9 -0
- package/dist/components/gallery/HaloGallery.d.ts +18 -0
- package/dist/components/gallery/HaloGallery.d.ts.map +1 -0
- package/dist/components/gallery/HaloGallery.js +9 -0
- package/dist/components/gallery/LightThreadsGallery.d.ts +18 -0
- package/dist/components/gallery/LightThreadsGallery.d.ts.map +1 -0
- package/dist/components/gallery/LightThreadsGallery.js +9 -0
- package/dist/components/gallery/LoomGallery.d.ts +18 -0
- package/dist/components/gallery/LoomGallery.d.ts.map +1 -0
- package/dist/components/gallery/LoomGallery.js +9 -0
- package/dist/components/gallery/PaperLanternsGallery.d.ts +18 -0
- package/dist/components/gallery/PaperLanternsGallery.d.ts.map +1 -0
- package/dist/components/gallery/PaperLanternsGallery.js +9 -0
- package/dist/components/gallery/ParticleShiftGallery.d.ts +18 -0
- package/dist/components/gallery/ParticleShiftGallery.d.ts.map +1 -0
- package/dist/components/gallery/ParticleShiftGallery.js +9 -0
- package/dist/components/gallery/PinscreenGallery.d.ts +18 -0
- package/dist/components/gallery/PinscreenGallery.d.ts.map +1 -0
- package/dist/components/gallery/PinscreenGallery.js +9 -0
- package/dist/components/gallery/PopUpGallery.d.ts +18 -0
- package/dist/components/gallery/PopUpGallery.d.ts.map +1 -0
- package/dist/components/gallery/PopUpGallery.js +9 -0
- package/dist/components/gallery/PrismSplitGallery.d.ts +18 -0
- package/dist/components/gallery/PrismSplitGallery.d.ts.map +1 -0
- package/dist/components/gallery/PrismSplitGallery.js +9 -0
- package/dist/components/gallery/RidgelinesGallery.d.ts +18 -0
- package/dist/components/gallery/RidgelinesGallery.d.ts.map +1 -0
- package/dist/components/gallery/RidgelinesGallery.js +9 -0
- package/dist/components/gallery/ShadowBoxGallery.d.ts +18 -0
- package/dist/components/gallery/ShadowBoxGallery.d.ts.map +1 -0
- package/dist/components/gallery/ShadowBoxGallery.js +9 -0
- package/dist/components/gallery/SilkGallery.d.ts +18 -0
- package/dist/components/gallery/SilkGallery.d.ts.map +1 -0
- package/dist/components/gallery/SilkGallery.js +9 -0
- package/dist/components/gallery/SlatsGallery.d.ts +18 -0
- package/dist/components/gallery/SlatsGallery.d.ts.map +1 -0
- package/dist/components/gallery/SlatsGallery.js +9 -0
- package/dist/components/gallery/StrataGallery.d.ts +18 -0
- package/dist/components/gallery/StrataGallery.d.ts.map +1 -0
- package/dist/components/gallery/StrataGallery.js +9 -0
- package/dist/components/gallery/TerracesGallery.d.ts +18 -0
- package/dist/components/gallery/TerracesGallery.d.ts.map +1 -0
- package/dist/components/gallery/TerracesGallery.js +9 -0
- package/dist/components/gallery/WireReliefGallery.d.ts +18 -0
- package/dist/components/gallery/WireReliefGallery.d.ts.map +1 -0
- package/dist/components/gallery/WireReliefGallery.js +9 -0
- package/dist/components/gallery/index.d.ts +46 -0
- package/dist/components/gallery/index.d.ts.map +1 -0
- package/dist/components/gallery/index.js +22 -0
- package/dist/components/gallery/kit/GalleryVariant.d.ts +68 -0
- package/dist/components/gallery/kit/GalleryVariant.d.ts.map +1 -0
- package/dist/components/gallery/kit/GalleryVariant.js +231 -0
- package/dist/components/gallery/kit/feeds.d.ts +7 -0
- package/dist/components/gallery/kit/feeds.d.ts.map +1 -0
- package/dist/components/gallery/kit/feeds.js +83 -0
- package/dist/components/gallery/kit/galleryKit.d.ts +118 -0
- package/dist/components/gallery/kit/galleryKit.d.ts.map +1 -0
- package/dist/components/gallery/kit/galleryKit.js +298 -0
- package/dist/components/gallery/kit/lookBase.d.ts +157 -0
- package/dist/components/gallery/kit/lookBase.d.ts.map +1 -0
- package/dist/components/gallery/kit/lookBase.js +211 -0
- package/dist/components/gallery/kit/pictures.d.ts +14 -0
- package/dist/components/gallery/kit/pictures.d.ts.map +1 -0
- package/dist/components/gallery/kit/pictures.js +81 -0
- package/dist/components/gallery/looks/basicCarousel.d.ts +177 -0
- package/dist/components/gallery/looks/basicCarousel.d.ts.map +1 -0
- package/dist/components/gallery/looks/basicCarousel.js +315 -0
- package/dist/components/gallery/looks/contourLines.d.ts +153 -0
- package/dist/components/gallery/looks/contourLines.d.ts.map +1 -0
- package/dist/components/gallery/looks/contourLines.js +91 -0
- package/dist/components/gallery/looks/depthLayers.d.ts +155 -0
- package/dist/components/gallery/looks/depthLayers.d.ts.map +1 -0
- package/dist/components/gallery/looks/depthLayers.js +87 -0
- package/dist/components/gallery/looks/engraving.d.ts +162 -0
- package/dist/components/gallery/looks/engraving.d.ts.map +1 -0
- package/dist/components/gallery/looks/engraving.js +96 -0
- package/dist/components/gallery/looks/flowLines.d.ts +180 -0
- package/dist/components/gallery/looks/flowLines.d.ts.map +1 -0
- package/dist/components/gallery/looks/flowLines.js +113 -0
- package/dist/components/gallery/looks/fold.d.ts +209 -0
- package/dist/components/gallery/looks/fold.d.ts.map +1 -0
- package/dist/components/gallery/looks/fold.js +155 -0
- package/dist/components/gallery/looks/glassPanes.d.ts +133 -0
- package/dist/components/gallery/looks/glassPanes.d.ts.map +1 -0
- package/dist/components/gallery/looks/glassPanes.js +208 -0
- package/dist/components/gallery/looks/halo.d.ts +100 -0
- package/dist/components/gallery/looks/halo.d.ts.map +1 -0
- package/dist/components/gallery/looks/halo.js +119 -0
- package/dist/components/gallery/looks/lightThreads.d.ts +199 -0
- package/dist/components/gallery/looks/lightThreads.d.ts.map +1 -0
- package/dist/components/gallery/looks/lightThreads.js +246 -0
- package/dist/components/gallery/looks/loom.d.ts +238 -0
- package/dist/components/gallery/looks/loom.d.ts.map +1 -0
- package/dist/components/gallery/looks/loom.js +256 -0
- package/dist/components/gallery/looks/paperLanterns.d.ts +181 -0
- package/dist/components/gallery/looks/paperLanterns.d.ts.map +1 -0
- package/dist/components/gallery/looks/paperLanterns.js +399 -0
- package/dist/components/gallery/looks/particleShift.d.ts +193 -0
- package/dist/components/gallery/looks/particleShift.d.ts.map +1 -0
- package/dist/components/gallery/looks/particleShift.js +282 -0
- package/dist/components/gallery/looks/pinscreen.d.ts +175 -0
- package/dist/components/gallery/looks/pinscreen.d.ts.map +1 -0
- package/dist/components/gallery/looks/pinscreen.js +96 -0
- package/dist/components/gallery/looks/popUp.d.ts +206 -0
- package/dist/components/gallery/looks/popUp.d.ts.map +1 -0
- package/dist/components/gallery/looks/popUp.js +132 -0
- package/dist/components/gallery/looks/prismSplit.d.ts +151 -0
- package/dist/components/gallery/looks/prismSplit.d.ts.map +1 -0
- package/dist/components/gallery/looks/prismSplit.js +84 -0
- package/dist/components/gallery/looks/ridgelines.d.ts +179 -0
- package/dist/components/gallery/looks/ridgelines.d.ts.map +1 -0
- package/dist/components/gallery/looks/ridgelines.js +111 -0
- package/dist/components/gallery/looks/shadowBox.d.ts +152 -0
- package/dist/components/gallery/looks/shadowBox.d.ts.map +1 -0
- package/dist/components/gallery/looks/shadowBox.js +82 -0
- package/dist/components/gallery/looks/silk.d.ts +140 -0
- package/dist/components/gallery/looks/silk.d.ts.map +1 -0
- package/dist/components/gallery/looks/silk.js +346 -0
- package/dist/components/gallery/looks/slats.d.ts +176 -0
- package/dist/components/gallery/looks/slats.d.ts.map +1 -0
- package/dist/components/gallery/looks/slats.js +93 -0
- package/dist/components/gallery/looks/strata.d.ts +172 -0
- package/dist/components/gallery/looks/strata.d.ts.map +1 -0
- package/dist/components/gallery/looks/strata.js +88 -0
- package/dist/components/gallery/looks/terraces.d.ts +168 -0
- package/dist/components/gallery/looks/terraces.d.ts.map +1 -0
- package/dist/components/gallery/looks/terraces.js +91 -0
- package/dist/components/gallery/looks/wireRelief.d.ts +153 -0
- package/dist/components/gallery/looks/wireRelief.d.ts.map +1 -0
- package/dist/components/gallery/looks/wireRelief.js +128 -0
- package/dist/components/image/ContourImage.d.ts +7 -0
- package/dist/components/image/ContourImage.d.ts.map +1 -0
- package/dist/components/image/ContourImage.js +6 -0
- package/dist/components/image/EngravingImage.d.ts +7 -0
- package/dist/components/image/EngravingImage.d.ts.map +1 -0
- package/dist/components/image/EngravingImage.js +6 -0
- package/dist/components/image/FrostImage.d.ts +7 -0
- package/dist/components/image/FrostImage.d.ts.map +1 -0
- package/dist/components/image/FrostImage.js +6 -0
- package/dist/components/image/LenticularImage.d.ts +7 -0
- package/dist/components/image/LenticularImage.d.ts.map +1 -0
- package/dist/components/image/LenticularImage.js +6 -0
- package/dist/components/image/PinscreenImage.d.ts +7 -0
- package/dist/components/image/PinscreenImage.d.ts.map +1 -0
- package/dist/components/image/PinscreenImage.js +6 -0
- package/dist/components/image/PrismImage.d.ts +7 -0
- package/dist/components/image/PrismImage.d.ts.map +1 -0
- package/dist/components/image/PrismImage.js +6 -0
- package/dist/components/image/ProjectorImage.d.ts +7 -0
- package/dist/components/image/ProjectorImage.d.ts.map +1 -0
- package/dist/components/image/ProjectorImage.js +6 -0
- package/dist/components/image/ReliefImage.d.ts +7 -0
- package/dist/components/image/ReliefImage.d.ts.map +1 -0
- package/dist/components/image/ReliefImage.js +6 -0
- package/dist/components/image/RollImage.d.ts +7 -0
- package/dist/components/image/RollImage.d.ts.map +1 -0
- package/dist/components/image/RollImage.js +6 -0
- package/dist/components/image/ShardsImage.d.ts +126 -0
- package/dist/components/image/ShardsImage.d.ts.map +1 -0
- package/dist/components/image/ShardsImage.js +470 -0
- package/dist/components/image/core/contour.d.ts +126 -0
- package/dist/components/image/core/contour.d.ts.map +1 -0
- package/dist/components/image/core/contour.js +123 -0
- package/dist/components/image/core/engraving.d.ts +135 -0
- package/dist/components/image/core/engraving.d.ts.map +1 -0
- package/dist/components/image/core/engraving.js +163 -0
- package/dist/components/image/core/frost.d.ts +126 -0
- package/dist/components/image/core/frost.d.ts.map +1 -0
- package/dist/components/image/core/frost.js +156 -0
- package/dist/components/image/core/imageCore.d.ts +110 -0
- package/dist/components/image/core/imageCore.d.ts.map +1 -0
- package/dist/components/image/core/imageCore.js +269 -0
- package/dist/components/image/core/lenticular.d.ts +129 -0
- package/dist/components/image/core/lenticular.d.ts.map +1 -0
- package/dist/components/image/core/lenticular.js +132 -0
- package/dist/components/image/core/pinscreen.d.ts +126 -0
- package/dist/components/image/core/pinscreen.d.ts.map +1 -0
- package/dist/components/image/core/pinscreen.js +147 -0
- package/dist/components/image/core/prism.d.ts +120 -0
- package/dist/components/image/core/prism.d.ts.map +1 -0
- package/dist/components/image/core/prism.js +164 -0
- package/dist/components/image/core/projector.d.ts +135 -0
- package/dist/components/image/core/projector.d.ts.map +1 -0
- package/dist/components/image/core/projector.js +225 -0
- package/dist/components/image/core/relief.d.ts +111 -0
- package/dist/components/image/core/relief.d.ts.map +1 -0
- package/dist/components/image/core/relief.js +94 -0
- package/dist/components/image/core/roll.d.ts +114 -0
- package/dist/components/image/core/roll.d.ts.map +1 -0
- package/dist/components/image/core/roll.js +116 -0
- package/dist/components/image/imageVariant.d.ts +46 -0
- package/dist/components/image/imageVariant.d.ts.map +1 -0
- package/dist/components/image/imageVariant.js +128 -0
- package/dist/components/image/index.d.ts +22 -0
- package/dist/components/image/index.d.ts.map +1 -0
- package/dist/components/image/index.js +10 -0
- package/dist/components/image/pictureCycle.d.ts +15 -0
- package/dist/components/image/pictureCycle.d.ts.map +1 -0
- package/dist/components/image/pictureCycle.js +82 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +4 -0
- package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts +9 -7
- package/dist/components/volumetricClouds/VolumetricCloudsPass.d.ts.map +1 -1
- package/dist/components/volumetricClouds/VolumetricCloudsPass.js +39 -27
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -0
- package/dist/galleryRuntime.d.ts +57 -0
- package/dist/galleryRuntime.d.ts.map +1 -0
- package/dist/galleryRuntime.js +105 -0
- package/dist/hooks/useConfigLive.d.ts +1 -1
- package/dist/hooks/useConfigLive.d.ts.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/keyPad/KeyPadControls.d.ts +16 -0
- package/dist/keyPad/KeyPadControls.d.ts.map +1 -0
- package/dist/keyPad/KeyPadControls.js +176 -0
- package/dist/keyPad/index.d.ts +16 -0
- package/dist/keyPad/index.d.ts.map +1 -0
- package/dist/keyPad/index.js +8 -0
- package/dist/keyPad/keyBindings.d.ts +43 -0
- package/dist/keyPad/keyBindings.d.ts.map +1 -0
- package/dist/keyPad/keyBindings.js +92 -0
- package/dist/keyPad/keyPadAnimation.d.ts +28 -0
- package/dist/keyPad/keyPadAnimation.d.ts.map +1 -0
- package/dist/keyPad/keyPadAnimation.js +131 -0
- package/dist/keyPad/keyPadMotion.d.ts +68 -0
- package/dist/keyPad/keyPadMotion.d.ts.map +1 -0
- package/dist/keyPad/keyPadMotion.js +283 -0
- package/dist/keyPad/keyPadStore.d.ts +25 -0
- package/dist/keyPad/keyPadStore.d.ts.map +1 -0
- package/dist/keyPad/keyPadStore.js +63 -0
- package/dist/keyPad/types.d.ts +23 -0
- package/dist/keyPad/types.d.ts.map +1 -0
- package/dist/keyPad/types.js +9 -0
- package/dist/operations/catalogue/visibility.d.ts.map +1 -1
- package/dist/operations/catalogue/visibility.js +23 -1
- package/dist/shaders/clouds/CloudResolveMaterial.d.ts +2 -1
- package/dist/shaders/clouds/CloudResolveMaterial.d.ts.map +1 -1
- package/dist/shaders/clouds/CloudResolveMaterial.js +37 -12
- package/dist/shaders/clouds/CloudVolumeMaterial.d.ts +4 -0
- package/dist/shaders/clouds/CloudVolumeMaterial.d.ts.map +1 -1
- package/dist/shaders/clouds/CloudVolumeMaterial.js +15 -3
- package/dist/triggers/kinds/gallery.d.ts +2 -0
- package/dist/triggers/kinds/gallery.d.ts.map +1 -0
- package/dist/triggers/kinds/gallery.js +39 -0
- package/dist/triggers/kinds/index.d.ts +1 -0
- package/dist/triggers/kinds/index.d.ts.map +1 -1
- package/dist/triggers/kinds/index.js +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { texturesManager } from '@3driseai/3drise-core';
|
|
2
|
+
function findIn(scene, id) {
|
|
3
|
+
let found = null;
|
|
4
|
+
scene.traverse((o) => { if (!found && o.userData?.id === id)
|
|
5
|
+
found = o; });
|
|
6
|
+
return found;
|
|
7
|
+
}
|
|
8
|
+
function attached(o, scene) {
|
|
9
|
+
let p = o;
|
|
10
|
+
while (p) {
|
|
11
|
+
if (p === scene)
|
|
12
|
+
return true;
|
|
13
|
+
p = p.parent;
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
/** The target's own door: an image object's feedImage, else the first mesh material with a map slot. */
|
|
18
|
+
function doorOf(obj) {
|
|
19
|
+
let feed;
|
|
20
|
+
let mesh;
|
|
21
|
+
obj.traverse((c) => {
|
|
22
|
+
if (!feed && typeof c.userData?.feedImage === 'function')
|
|
23
|
+
feed = c.userData.feedImage;
|
|
24
|
+
const m = c.material;
|
|
25
|
+
if (!mesh && m && !Array.isArray(m) && 'map' in m)
|
|
26
|
+
mesh = c;
|
|
27
|
+
});
|
|
28
|
+
return feed ? { feed } : mesh ? { mesh } : null;
|
|
29
|
+
}
|
|
30
|
+
const loadTexture = (url) => texturesManager.loadTexture(url.split('/').pop()?.split('.')[0] || `feed-${Date.now()}`, url, 'images');
|
|
31
|
+
export function createFeeds(scene) {
|
|
32
|
+
const fed = new Map();
|
|
33
|
+
const send = (id, url) => {
|
|
34
|
+
let f = fed.get(id);
|
|
35
|
+
if (f && !attached(f.obj, scene)) {
|
|
36
|
+
fed.delete(id);
|
|
37
|
+
f = undefined;
|
|
38
|
+
} // the target remounted: start over
|
|
39
|
+
if (f && f.url === url)
|
|
40
|
+
return;
|
|
41
|
+
const obj = f?.obj ?? findIn(scene, id);
|
|
42
|
+
if (!obj)
|
|
43
|
+
return;
|
|
44
|
+
const door = doorOf(obj);
|
|
45
|
+
if (!door)
|
|
46
|
+
return;
|
|
47
|
+
if (door.feed) {
|
|
48
|
+
door.feed(url);
|
|
49
|
+
if (!f)
|
|
50
|
+
fed.set(id, { obj, url, release: () => door.feed(null) });
|
|
51
|
+
else
|
|
52
|
+
f.url = url;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const mesh = door.mesh, mat = mesh.material;
|
|
56
|
+
if (!f) {
|
|
57
|
+
const own = mat.map;
|
|
58
|
+
fed.set(id, { obj, url, release: () => { mat.map = own; mat.needsUpdate = true; } });
|
|
59
|
+
}
|
|
60
|
+
else
|
|
61
|
+
f.url = url;
|
|
62
|
+
loadTexture(url).then((t) => { if (fed.get(id)?.url === url) {
|
|
63
|
+
mat.map = t;
|
|
64
|
+
mat.needsUpdate = true;
|
|
65
|
+
} }).catch(() => { });
|
|
66
|
+
};
|
|
67
|
+
return {
|
|
68
|
+
/** Bring every target in line: `ids` fed with `url` (null = no picture: release them all). */
|
|
69
|
+
sync(ids, url) {
|
|
70
|
+
const want = new Set(url ? ids : []);
|
|
71
|
+
for (const [id, f] of fed)
|
|
72
|
+
if (!want.has(id)) {
|
|
73
|
+
f.release();
|
|
74
|
+
fed.delete(id);
|
|
75
|
+
}
|
|
76
|
+
if (url)
|
|
77
|
+
for (const id of want)
|
|
78
|
+
send(id, url);
|
|
79
|
+
},
|
|
80
|
+
dispose() { for (const f of fed.values())
|
|
81
|
+
f.release(); fed.clear(); },
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
export declare const fragHead = "\n layout(location = 0) out highp vec4 pc_fragColor;\n #define gl_FragColor pc_fragColor\n";
|
|
3
|
+
export declare const col: (c: any) => THREE.Color;
|
|
4
|
+
export declare const smooth: (a: any, b: any, x: any) => number;
|
|
5
|
+
export declare function mulberry32(a: any): () => number;
|
|
6
|
+
export declare const wrap: (d: any, n: any) => any;
|
|
7
|
+
/** The scroll: one float index on a damped spring; drag moves it, release throws, then it snaps. */
|
|
8
|
+
export declare function createScroll(cfg: any, onChange: any): {
|
|
9
|
+
st: {
|
|
10
|
+
s: number;
|
|
11
|
+
v: number;
|
|
12
|
+
target: number;
|
|
13
|
+
dragging: boolean;
|
|
14
|
+
dragS0: number;
|
|
15
|
+
dragX0: number;
|
|
16
|
+
lastDx: number;
|
|
17
|
+
count: number;
|
|
18
|
+
autoT: number;
|
|
19
|
+
pitch: number;
|
|
20
|
+
};
|
|
21
|
+
controls: {
|
|
22
|
+
next(): void;
|
|
23
|
+
prev(): void;
|
|
24
|
+
goTo(i: any): void;
|
|
25
|
+
jump(i: any): void;
|
|
26
|
+
readonly index: number;
|
|
27
|
+
readonly count: number;
|
|
28
|
+
readonly busy: boolean;
|
|
29
|
+
dragBegin(x: any): void;
|
|
30
|
+
dragMove(x: any): void;
|
|
31
|
+
dragEnd(dt: any): void;
|
|
32
|
+
readonly dragging: boolean;
|
|
33
|
+
hover(): void;
|
|
34
|
+
};
|
|
35
|
+
step: (dt: any, pointer: any) => void;
|
|
36
|
+
};
|
|
37
|
+
/** Focus of item i at scroll s: 1 at the front, 0 a full step away (continuous in s, never switches). */
|
|
38
|
+
export declare const focusAt: (i: any, s: any, n: any) => number;
|
|
39
|
+
/** Move `value` toward `target` at a constant rate (1 / seconds): a sweep that can reverse half-way, never jumps. */
|
|
40
|
+
export declare const approach: (value: any, target: any, dt: any, seconds: any) => number;
|
|
41
|
+
/** Colours blended by the items' focus, so a light follows the row without jumping. */
|
|
42
|
+
export declare function blendByFocus(colors: any, s: any, n: any, out: any): number;
|
|
43
|
+
/** One texture per picture, cut out of the array (for the standard, scene-lit materials). Returns [textures, average colours]. */
|
|
44
|
+
export declare function sliceTextures(tex: any, count: any): any[][];
|
|
45
|
+
/**
|
|
46
|
+
* The lean (every gallery): the whole gallery turns a little toward the cursor about its vertical axis and eases
|
|
47
|
+
* back when it leaves — the interaction of Halo. Wraps a built gallery: its content moves into a rig that turns;
|
|
48
|
+
* `lean` (config) is the strength, 0 = off. Pointer: { nx } in NDC (-1..1), or a plane x as a fallback.
|
|
49
|
+
*/
|
|
50
|
+
export declare function withLean(api: any, c: any): any;
|
|
51
|
+
export declare const LAYOUTS: string[];
|
|
52
|
+
export declare const LAYOUT_NAMES: {
|
|
53
|
+
row: string;
|
|
54
|
+
wave: string;
|
|
55
|
+
ring: string;
|
|
56
|
+
helix: string;
|
|
57
|
+
tunnel: string;
|
|
58
|
+
stack: string;
|
|
59
|
+
fan: string;
|
|
60
|
+
constellation: string;
|
|
61
|
+
};
|
|
62
|
+
export declare const LAYOUT_HINTS: {
|
|
63
|
+
row: string;
|
|
64
|
+
wave: string;
|
|
65
|
+
ring: string;
|
|
66
|
+
helix: string;
|
|
67
|
+
tunnel: string;
|
|
68
|
+
stack: string;
|
|
69
|
+
fan: string;
|
|
70
|
+
constellation: string;
|
|
71
|
+
};
|
|
72
|
+
/** What `shape` does on each layout (one knob, its meaning per layout). */
|
|
73
|
+
export declare const SHAPE_HINTS: {
|
|
74
|
+
row: string;
|
|
75
|
+
wave: string;
|
|
76
|
+
ring: string;
|
|
77
|
+
helix: string;
|
|
78
|
+
tunnel: string;
|
|
79
|
+
stack: string;
|
|
80
|
+
fan: string;
|
|
81
|
+
constellation: string;
|
|
82
|
+
};
|
|
83
|
+
export declare const LAYOUT_KEYS: string[];
|
|
84
|
+
export declare const LAYOUT_GUI: ({
|
|
85
|
+
key: string;
|
|
86
|
+
options: string[];
|
|
87
|
+
tip: string;
|
|
88
|
+
min?: undefined;
|
|
89
|
+
max?: undefined;
|
|
90
|
+
step?: undefined;
|
|
91
|
+
} | {
|
|
92
|
+
key: string;
|
|
93
|
+
min: number;
|
|
94
|
+
max: number;
|
|
95
|
+
step: number;
|
|
96
|
+
tip: string;
|
|
97
|
+
options?: undefined;
|
|
98
|
+
})[];
|
|
99
|
+
export declare const MAX_PICTURES = 32;
|
|
100
|
+
export declare function createLayout(W: any, H: any): {
|
|
101
|
+
place: (i: any, s: any, n: any, c: any, m: any) => {
|
|
102
|
+
d: any;
|
|
103
|
+
focus: number;
|
|
104
|
+
fade: number;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
/** For the shader looks: one matrix per picture; its last element (normally 1) carries the fade, to keep the
|
|
108
|
+
* vertex uniforms small (32 mat4 = 128 vectors). */
|
|
109
|
+
export declare function layoutUniforms(): {
|
|
110
|
+
uPlace: {
|
|
111
|
+
value: THREE.Matrix4[];
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
/** Fill uPlace for n pictures at scroll s. */
|
|
115
|
+
export declare function fillLayout(layout: any, u: any, s: any, n: any, c: any): void;
|
|
116
|
+
/** GLSL: declarations the shader looks include. */
|
|
117
|
+
export declare const layoutGlsl = "\n uniform mat4 uPlace[32];\n vec3 placeAt(float img, vec3 local){ mat4 M = uPlace[int(img + 0.5)]; M[3][3] = 1.0; return (M * vec4(local, 1.0)).xyz; }\n float fadeAt(float img){ return uPlace[int(img + 0.5)][3][3]; }\n";
|
|
118
|
+
//# sourceMappingURL=galleryKit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"galleryKit.d.ts","sourceRoot":"","sources":["../../../../src/components/gallery/kit/galleryKit.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,eAAO,MAAM,QAAQ,qGAGpB,CAAC;AACF,eAAO,MAAM,GAAG,GAAI,MAAC,gBAAuB,CAAC;AAC7C,eAAO,MAAM,MAAM,GAAI,MAAC,EAAE,MAAC,EAAE,MAAC,WAA2F,CAAC;AAC1H,wBAAgB,UAAU,CAAC,CAAC,KAAA,gBAAuM;AACnO,eAAO,MAAM,IAAI,GAAI,MAAC,EAAE,MAAC,QAAoD,CAAC;AAG9E,oGAAoG;AACpG,wBAAgB,YAAY,CAAC,GAAG,KAAA,EAAE,QAAQ,KAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqBzC;AAED,yGAAyG;AACzG,eAAO,MAAM,OAAO,GAAI,MAAC,EAAE,MAAC,EAAE,MAAC,WAA+C,CAAC;AAC/E,qHAAqH;AACrH,eAAO,MAAM,QAAQ,GAAI,UAAK,EAAE,WAAM,EAAE,OAAE,EAAE,YAAO,WAA4I,CAAC;AAChM,uFAAuF;AACvF,wBAAgB,YAAY,CAAC,MAAM,KAAA,EAAE,CAAC,KAAA,EAAE,CAAC,KAAA,EAAE,GAAG,KAAA,UAA2Q;AAEzT,kIAAkI;AAClI,wBAAgB,aAAa,CAAC,GAAG,KAAA,EAAE,KAAK,KAAA,WAOvC;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,GAAG,KAAA,EAAE,CAAC,KAAA,OAe9B;AAWD,eAAO,MAAM,OAAO,UAA8E,CAAC;AACnG,eAAO,MAAM,YAAY;;;;;;;;;CAA2I,CAAC;AACrK,eAAO,MAAM,YAAY;;;;;;;;;CASxB,CAAC;AACF,2EAA2E;AAC3E,eAAO,MAAM,WAAW;;;;;;;;;CAAkP,CAAC;AAC3Q,eAAO,MAAM,WAAW,UAAqD,CAAC;AAC9E,eAAO,MAAM,UAAU;;;;;;;;;;;;;;IAMtB,CAAC;AACF,eAAO,MAAM,YAAY,KAAK,CAAC;AAI/B,wBAAgB,YAAY,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA;;;;;;EA0FhC;AAED;qDACqD;AACrD,wBAAgB,cAAc;;;;EAE7B;AACD,8CAA8C;AAC9C,wBAAgB,UAAU,CAAC,MAAM,KAAA,EAAE,CAAC,KAAA,EAAE,CAAC,KAAA,EAAE,CAAC,KAAA,EAAE,CAAC,KAAA,QAE5C;AACD,mDAAmD;AACnD,eAAO,MAAM,UAAU,yOAItB,CAAC"}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
// The gallery lab's shared helpers and layouts, verbatim (Claude outputs/gallery-lab/labCommon.mjs +
|
|
2
|
+
// layouts.mjs). Plain JS-shaped code; typed at its one door, GalleryVariant.tsx.
|
|
3
|
+
// Shared lab helpers for the gallery ideas: images as one cover-fit array texture, a damped-spring
|
|
4
|
+
// scroll with drag / throw / snap (the navigation contract), small maths.
|
|
5
|
+
import * as THREE from 'three';
|
|
6
|
+
export const fragHead = /* glsl */ `
|
|
7
|
+
layout(location = 0) out highp vec4 pc_fragColor;
|
|
8
|
+
#define gl_FragColor pc_fragColor
|
|
9
|
+
`;
|
|
10
|
+
export const col = (c) => new THREE.Color(c);
|
|
11
|
+
export const smooth = (a, b, x) => { const t = Math.min(1, Math.max(0, (x - a) / (b - a))); return t * t * (3 - 2 * t); };
|
|
12
|
+
export function mulberry32(a) { return function () { a |= 0; a = (a + 0x6D2B79F5) | 0; let t = Math.imul(a ^ (a >>> 15), 1 | a); t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t; return ((t ^ (t >>> 14)) >>> 0) / 4294967296; }; }
|
|
13
|
+
export const wrap = (d, n) => (n > 1 ? ((d + n / 2) % n + n) % n - n / 2 : d);
|
|
14
|
+
/** The scroll: one float index on a damped spring; drag moves it, release throws, then it snaps. */
|
|
15
|
+
export function createScroll(cfg, onChange) {
|
|
16
|
+
const st = { s: 0, v: 0, target: 0, dragging: false, dragS0: 0, dragX0: 0, lastDx: 0, count: 0, autoT: 0, pitch: 1 };
|
|
17
|
+
const index = () => (st.count ? ((Math.round(st.s) % st.count) + st.count) % st.count : 0);
|
|
18
|
+
const controls = {
|
|
19
|
+
next() { st.target = Math.round(st.target) + 1; st.autoT = 0; onChange?.(+1); },
|
|
20
|
+
prev() { st.target = Math.round(st.target) - 1; st.autoT = 0; onChange?.(-1); },
|
|
21
|
+
goTo(i) { const n = st.count; if (!n)
|
|
22
|
+
return; const dd = wrap(i - index(), n); if (!dd)
|
|
23
|
+
return; st.target = Math.round(st.s) + dd; st.autoT = 0; onChange?.(Math.sign(dd)); },
|
|
24
|
+
jump(i) { st.s = st.target = i; st.v = 0; },
|
|
25
|
+
get index() { return index(); }, get count() { return st.count; },
|
|
26
|
+
get busy() { return Math.abs(st.target - st.s) > 0.02 || Math.abs(st.v) > 0.05; },
|
|
27
|
+
dragBegin(x) { st.dragging = true; st.dragS0 = st.s; st.dragX0 = x; st.v = 0; st.lastDx = 0; },
|
|
28
|
+
dragMove(x) { if (!st.dragging)
|
|
29
|
+
return; const ns = st.dragS0 - (x - st.dragX0) / st.pitch; st.lastDx = ns - st.s; st.s = ns; },
|
|
30
|
+
dragEnd(dt) { if (!st.dragging)
|
|
31
|
+
return; st.dragging = false; st.v = st.lastDx / Math.max(dt, 1 / 120); st.target = Math.round(st.s + st.v * (cfg.throwing ?? 0.15)); st.autoT = 0; onChange?.(Math.sign(st.v) || 1); },
|
|
32
|
+
get dragging() { return st.dragging; },
|
|
33
|
+
hover() { },
|
|
34
|
+
};
|
|
35
|
+
function step(dt, pointer) {
|
|
36
|
+
if (!st.dragging) {
|
|
37
|
+
const sub = 4, h = dt / sub;
|
|
38
|
+
for (let q = 0; q < sub; q++) {
|
|
39
|
+
st.v += ((cfg.stiffness ?? 40) * (st.target - st.s) - (cfg.damping ?? 9) * st.v) * h;
|
|
40
|
+
st.s += st.v * h;
|
|
41
|
+
}
|
|
42
|
+
if (Math.abs(st.target - st.s) < 1e-4 && Math.abs(st.v) < 1e-3) {
|
|
43
|
+
st.s = st.target;
|
|
44
|
+
st.v = 0;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if ((cfg.autoplay ?? 0) > 0 && st.count > 1 && !pointer && !st.dragging) {
|
|
48
|
+
st.autoT += dt;
|
|
49
|
+
if (st.autoT >= cfg.autoplay)
|
|
50
|
+
controls.next();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return { st, controls, step };
|
|
54
|
+
}
|
|
55
|
+
/** Focus of item i at scroll s: 1 at the front, 0 a full step away (continuous in s, never switches). */
|
|
56
|
+
export const focusAt = (i, s, n) => 1 - smooth(0, 1, Math.abs(wrap(i - s, n)));
|
|
57
|
+
/** Move `value` toward `target` at a constant rate (1 / seconds): a sweep that can reverse half-way, never jumps. */
|
|
58
|
+
export const approach = (value, target, dt, seconds) => { const step = dt / Math.max(0.05, seconds); return value < target ? Math.min(target, value + step) : Math.max(target, value - step); };
|
|
59
|
+
/** Colours blended by the items' focus, so a light follows the row without jumping. */
|
|
60
|
+
export function blendByFocus(colors, s, n, out) { out.setRGB(0, 0, 0); let w = 0; for (let i = 0; i < n; i++) {
|
|
61
|
+
const f = focusAt(i, s, n);
|
|
62
|
+
if (f <= 0 || !colors[i])
|
|
63
|
+
continue;
|
|
64
|
+
out.r += colors[i].r * f;
|
|
65
|
+
out.g += colors[i].g * f;
|
|
66
|
+
out.b += colors[i].b * f;
|
|
67
|
+
w += f;
|
|
68
|
+
} if (w > 0)
|
|
69
|
+
out.multiplyScalar(1 / w); return w; }
|
|
70
|
+
/** One texture per picture, cut out of the array (for the standard, scene-lit materials). Returns [textures, average colours]. */
|
|
71
|
+
export function sliceTextures(tex, count) {
|
|
72
|
+
const img = tex.image, W = img.width, H = img.height, d = img.data, per = W * H * 4, out = [], avg = [];
|
|
73
|
+
for (let i = 0; i < count; i++) {
|
|
74
|
+
const t = new THREE.DataTexture(d.slice(i * per, (i + 1) * per), W, H);
|
|
75
|
+
t.colorSpace = THREE.SRGBColorSpace;
|
|
76
|
+
t.minFilter = THREE.LinearMipmapLinearFilter;
|
|
77
|
+
t.magFilter = THREE.LinearFilter;
|
|
78
|
+
t.generateMipmaps = true;
|
|
79
|
+
t.anisotropy = 4;
|
|
80
|
+
t.needsUpdate = true;
|
|
81
|
+
out.push(t);
|
|
82
|
+
let r = 0, g = 0, b = 0, n = 0;
|
|
83
|
+
for (let p = i * per; p < (i + 1) * per; p += 4 * 101) {
|
|
84
|
+
r += d[p];
|
|
85
|
+
g += d[p + 1];
|
|
86
|
+
b += d[p + 2];
|
|
87
|
+
n++;
|
|
88
|
+
}
|
|
89
|
+
avg.push(new THREE.Color(r / n / 255, g / n / 255, b / n / 255));
|
|
90
|
+
}
|
|
91
|
+
return [out, avg];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The lean (every gallery): the whole gallery turns a little toward the cursor about its vertical axis and eases
|
|
95
|
+
* back when it leaves — the interaction of Halo. Wraps a built gallery: its content moves into a rig that turns;
|
|
96
|
+
* `lean` (config) is the strength, 0 = off. Pointer: { nx } in NDC (-1..1), or a plane x as a fallback.
|
|
97
|
+
*/
|
|
98
|
+
export function withLean(api, c) {
|
|
99
|
+
const rig = new THREE.Group();
|
|
100
|
+
for (const ch of [...api.object.children])
|
|
101
|
+
rig.add(ch);
|
|
102
|
+
api.object.add(rig);
|
|
103
|
+
let strength = c.lean ?? 1, lean = 0;
|
|
104
|
+
const apply = api.apply.bind(api), update = api.update.bind(api);
|
|
105
|
+
api.apply = (k) => { if (k.lean !== undefined)
|
|
106
|
+
strength = k.lean; apply(k); };
|
|
107
|
+
api.update = (dt, pointer, state) => {
|
|
108
|
+
const nx = pointer ? Math.max(-1, Math.min(1, pointer.nx ?? pointer.x / 3)) : 0;
|
|
109
|
+
lean += (nx * 0.18 * strength - lean) * (1 - Math.exp(-Math.min(dt, 0.05) * 3));
|
|
110
|
+
rig.rotation.y = lean;
|
|
111
|
+
update(dt, pointer, state);
|
|
112
|
+
};
|
|
113
|
+
api.rig = rig;
|
|
114
|
+
return api;
|
|
115
|
+
}
|
|
116
|
+
// layouts — where the pictures of a gallery sit, shared by every look. A layout is one function: from a picture's
|
|
117
|
+
// offset d = i − s (s = the scroll's float index, wrapped over the set) it gives the picture's place, turn and size
|
|
118
|
+
// in the gallery's frame, its focus (1 at the front, 0 a step away) and its fade. The active picture always lands
|
|
119
|
+
// at the origin facing +z, so every look keeps its framing on every layout. Continuous in s: nothing ever jumps.
|
|
120
|
+
//
|
|
121
|
+
// The looks consume it two ways: mesh looks set each picture's matrix; shader looks read the same matrices from a
|
|
122
|
+
// uniform array (uPlace[i]) and the fades from uFade[i] — computed once per frame here, in JS.
|
|
123
|
+
export const LAYOUTS = ['row', 'wave', 'ring', 'helix', 'tunnel', 'stack', 'fan', 'constellation'];
|
|
124
|
+
export const LAYOUT_NAMES = { row: 'Row', wave: 'Wave', ring: 'Ring', helix: 'Helix', tunnel: 'Tunnel', stack: 'Stack', fan: 'Fan', constellation: 'Constellation' };
|
|
125
|
+
export const LAYOUT_HINTS = {
|
|
126
|
+
row: 'a straight row; the neighbours stand back at depth.',
|
|
127
|
+
wave: 'the row snakes gently in depth; the neighbours turn along the curve.',
|
|
128
|
+
ring: 'a tilted ring facing outward; the set turns round it.',
|
|
129
|
+
helix: 'a spiral staircase around you: the pictures face inward, the set turns and rises along it.',
|
|
130
|
+
tunnel: 'a corridor into depth; the next picture comes forward through the others, the passed one flies past the camera.',
|
|
131
|
+
stack: 'a deck in depth; the front picture slides aside and the deck steps forward.',
|
|
132
|
+
fan: 'a hand of cards spread from one hinge below; the active one swings upright.',
|
|
133
|
+
constellation: 'a loose cloud in space; the whole cloud glides to bring the next picture to the front.',
|
|
134
|
+
};
|
|
135
|
+
/** What `shape` does on each layout (one knob, its meaning per layout). */
|
|
136
|
+
export const SHAPE_HINTS = { row: 'unused', wave: 'height of the wave', ring: 'tilt of the ring', helix: 'rise of the spiral', tunnel: 'drift of the corridor to the side', stack: 'offset of the deck', fan: 'spread of the fan', constellation: 'scatter of the cloud' };
|
|
137
|
+
export const LAYOUT_KEYS = ['layout', 'spacing', 'depth', 'visible', 'shape'];
|
|
138
|
+
export const LAYOUT_GUI = [
|
|
139
|
+
{ key: 'layout', options: LAYOUTS, tip: 'Where the pictures sit' },
|
|
140
|
+
{ key: 'spacing', min: 0.8, max: 2.5, step: 0.01, tip: 'Distance between neighbours, in picture widths' },
|
|
141
|
+
{ key: 'depth', min: 0, max: 3, step: 0.01, tip: 'How far the inactive pictures stand back' },
|
|
142
|
+
{ key: 'visible', min: 1, max: 6, step: 0.1, tip: 'How many neighbours show on each side' },
|
|
143
|
+
{ key: 'shape', min: 0, max: 2, step: 0.01, tip: 'The layout’s own shape (wave height, ring tilt, spiral rise, …)' },
|
|
144
|
+
];
|
|
145
|
+
export const MAX_PICTURES = 32;
|
|
146
|
+
const _q = new THREE.Quaternion(), _e = new THREE.Euler(), _p = new THREE.Vector3(), _s = new THREE.Vector3();
|
|
147
|
+
export function createLayout(W, H) {
|
|
148
|
+
let cloud = null;
|
|
149
|
+
/** Constellation: n points, no two overlapping as pictures, chained nearest-neighbour so each hop is short. */
|
|
150
|
+
function cloudPoints(n, c) {
|
|
151
|
+
const sh = c.shape ?? 1, key = `${n}|${c.spacing}|${sh}|${c.depth}`;
|
|
152
|
+
if (cloud && cloud.key === key)
|
|
153
|
+
return cloud.pts;
|
|
154
|
+
const rnd = mulberry32(17), Wp = W * c.spacing;
|
|
155
|
+
let spanX = Wp * Math.sqrt(n) * (1.0 + 0.5 * sh), spanY = H * Math.sqrt(n) * (0.9 + 0.45 * sh), pts = [];
|
|
156
|
+
for (let grow = 0; grow < 8 && pts.length < n; grow++, spanX *= 1.15, spanY *= 1.15) {
|
|
157
|
+
pts = [];
|
|
158
|
+
for (let k = 0; k < 6000 && pts.length < n; k++) {
|
|
159
|
+
const p = [(rnd() - 0.5) * spanX, (rnd() - 0.5) * spanY, (rnd() - 0.5) * 1.6 * c.depth * sh, rnd() - 0.5];
|
|
160
|
+
if (pts.every(q => Math.abs(q[0] - p[0]) > Wp * 0.95 || Math.abs(q[1] - p[1]) > H * 1.12))
|
|
161
|
+
pts.push(p);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
while (pts.length < n)
|
|
165
|
+
pts.push([pts.length * Wp, 0, 0, 0]);
|
|
166
|
+
// chain: start nearest the centre, then always the nearest unvisited
|
|
167
|
+
const order = [], left = pts.slice();
|
|
168
|
+
let cur = left.reduce((b, p) => (Math.hypot(p[0], p[1]) < Math.hypot(b[0], b[1]) ? p : b), left[0]);
|
|
169
|
+
while (left.length) {
|
|
170
|
+
left.splice(left.indexOf(cur), 1);
|
|
171
|
+
order.push(cur);
|
|
172
|
+
if (!left.length)
|
|
173
|
+
break;
|
|
174
|
+
cur = left.reduce((b, p) => (Math.hypot(p[0] - cur[0], p[1] - cur[1]) < Math.hypot(b[0] - cur[0], b[1] - cur[1]) ? p : b), left[0]);
|
|
175
|
+
}
|
|
176
|
+
cloud = { key, pts: order };
|
|
177
|
+
return order;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Place picture i of n at scroll s. Writes its matrix (gallery frame) into m; returns { d, focus, fade }.
|
|
181
|
+
* c: { layout, spacing, depth, visible, shape }.
|
|
182
|
+
*/
|
|
183
|
+
function place(i, s, n, c, m) {
|
|
184
|
+
const d = wrap(i - s, n), ad = Math.abs(d), focus = 1 - smooth(0, 1, ad);
|
|
185
|
+
const Wp = W * c.spacing, sh = c.shape ?? 1, vis = c.visible ?? 2.4, back = 1 - focus;
|
|
186
|
+
let x = 0, y = 0, z = 0, yaw = 0, pitch = 0, roll = 0, sc = 1;
|
|
187
|
+
let fade = 1 - smooth(vis - 0.6, vis, ad);
|
|
188
|
+
switch (c.layout) {
|
|
189
|
+
case 'wave': {
|
|
190
|
+
const A = sh * W * 0.32, k = 1.25;
|
|
191
|
+
x = d * Wp;
|
|
192
|
+
z = -c.depth * back + A * Math.sin(d * k);
|
|
193
|
+
yaw = -Math.atan2(A * k * Math.cos(d * k), Wp) * 0.8;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
case 'ring': {
|
|
197
|
+
const R = Math.max(Wp * n / (2 * Math.PI), W * 0.8), a = d * 2 * Math.PI / Math.max(n, 1), t = sh * 8 * Math.PI / 180;
|
|
198
|
+
const ca = Math.cos(a), sa = Math.sin(a), r = R - c.depth * 0.35 * back;
|
|
199
|
+
x = r * sa;
|
|
200
|
+
y = R * Math.sin(t) * (1 - ca);
|
|
201
|
+
z = (r * ca - R) * Math.cos(t);
|
|
202
|
+
yaw = a;
|
|
203
|
+
sc = 1 - 0.25 * (0.5 - 0.5 * ca);
|
|
204
|
+
fade = 1; // the whole ring shows
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
case 'helix': {
|
|
208
|
+
// a spiral staircase around the viewer: the pictures face inward, the neighbours come round at the sides
|
|
209
|
+
const R = Wp * 2.2, a = d * Wp / R, r = R + c.depth * 0.5 * back;
|
|
210
|
+
x = r * Math.sin(a);
|
|
211
|
+
z = R - r * Math.cos(a);
|
|
212
|
+
y = d * H * 0.45 * sh;
|
|
213
|
+
yaw = -a;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
case 'tunnel': {
|
|
217
|
+
const step = Wp * 0.95;
|
|
218
|
+
if (d >= 0) {
|
|
219
|
+
x = sh * 0.45 * W * d;
|
|
220
|
+
y = sh * 0.12 * H * d;
|
|
221
|
+
z = -d * step;
|
|
222
|
+
fade = 1 - smooth(vis * 1.4 - 0.8, vis * 1.4, d);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
x = d * W * 0.15;
|
|
226
|
+
z = -d * step * 1.2;
|
|
227
|
+
fade = 1 - smooth(0.05, 0.45, -d);
|
|
228
|
+
}
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
case 'stack': {
|
|
232
|
+
if (d >= 0) {
|
|
233
|
+
x = d * W * 0.1 * sh;
|
|
234
|
+
y = d * H * 0.09 * sh;
|
|
235
|
+
z = -d * (0.25 + c.depth * 0.4);
|
|
236
|
+
sc = 1 - 0.04 * d;
|
|
237
|
+
fade = 1 - smooth(vis - 0.6, vis, d);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
const e = -d;
|
|
241
|
+
x = -e * Wp * 1.05;
|
|
242
|
+
z = -e * 0.25;
|
|
243
|
+
yaw = -e * 0.45;
|
|
244
|
+
fade = 1 - smooth(0.7, 1.4, e);
|
|
245
|
+
}
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
case 'fan': {
|
|
249
|
+
const piv = H * 1.35, a = -d * 0.2 * (0.4 + 0.6 * sh) * c.spacing;
|
|
250
|
+
x = piv * Math.sin(-a);
|
|
251
|
+
y = piv * (Math.cos(a) - 1);
|
|
252
|
+
z = -c.depth * 0.45 * back - ad * 0.04;
|
|
253
|
+
roll = a;
|
|
254
|
+
break;
|
|
255
|
+
}
|
|
256
|
+
case 'constellation': {
|
|
257
|
+
const pts = cloudPoints(n, c), fl = Math.floor(s), t = s - fl;
|
|
258
|
+
const A = pts[((fl % n) + n) % n], B = pts[(((fl + 1) % n) + n) % n], P = pts[((i % n) + n) % n];
|
|
259
|
+
const e = t * t * (3 - 2 * t);
|
|
260
|
+
x = P[0] - (A[0] + (B[0] - A[0]) * e);
|
|
261
|
+
y = P[1] - (A[1] + (B[1] - A[1]) * e);
|
|
262
|
+
z = P[2] - (A[2] + (B[2] - A[2]) * e) - c.depth * 0.5 * back;
|
|
263
|
+
yaw = P[3] * 0.6 * back;
|
|
264
|
+
const dist = Math.hypot(x, y);
|
|
265
|
+
fade = 1 - smooth(Wp * vis * 0.9, Wp * vis * 1.25, dist);
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
default: { // row
|
|
269
|
+
x = d * Wp;
|
|
270
|
+
z = -c.depth * back;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
_e.set(pitch, yaw, roll, 'YXZ');
|
|
274
|
+
_q.setFromEuler(_e);
|
|
275
|
+
m.compose(_p.set(x, y, z), _q, _s.setScalar(sc));
|
|
276
|
+
return { d, focus, fade };
|
|
277
|
+
}
|
|
278
|
+
return { place };
|
|
279
|
+
}
|
|
280
|
+
/** For the shader looks: one matrix per picture; its last element (normally 1) carries the fade, to keep the
|
|
281
|
+
* vertex uniforms small (32 mat4 = 128 vectors). */
|
|
282
|
+
export function layoutUniforms() {
|
|
283
|
+
return { uPlace: { value: Array.from({ length: MAX_PICTURES }, () => new THREE.Matrix4()) } };
|
|
284
|
+
}
|
|
285
|
+
/** Fill uPlace for n pictures at scroll s. */
|
|
286
|
+
export function fillLayout(layout, u, s, n, c) {
|
|
287
|
+
for (let i = 0; i < n; i++) {
|
|
288
|
+
const m = u.uPlace.value[i];
|
|
289
|
+
const r = layout.place(i, s, n, c, m);
|
|
290
|
+
m.elements[15] = r.fade;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
/** GLSL: declarations the shader looks include. */
|
|
294
|
+
export const layoutGlsl = /* glsl */ `
|
|
295
|
+
uniform mat4 uPlace[${MAX_PICTURES}];
|
|
296
|
+
vec3 placeAt(float img, vec3 local){ mat4 M = uPlace[int(img + 0.5)]; M[3][3] = 1.0; return (M * vec4(local, 1.0)).xyz; }
|
|
297
|
+
float fadeAt(float img){ return uPlace[int(img + 0.5)][3][3]; }
|
|
298
|
+
`;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import * as THREE from 'three';
|
|
2
|
+
import { fragHead, withLean } from './galleryKit';
|
|
3
|
+
import { LAYOUT_GUI } from './galleryKit';
|
|
4
|
+
export { fragHead, LAYOUT_GUI, withLean };
|
|
5
|
+
export declare const MAXI = 32;
|
|
6
|
+
export declare const BASE_DEFAULTS: {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
lean: number;
|
|
9
|
+
imageUrls: any[];
|
|
10
|
+
autoplay: number;
|
|
11
|
+
intensity: number;
|
|
12
|
+
opacity: number;
|
|
13
|
+
layout: string;
|
|
14
|
+
spacing: number;
|
|
15
|
+
depth: number;
|
|
16
|
+
visible: number;
|
|
17
|
+
shape: number;
|
|
18
|
+
stiffness: number;
|
|
19
|
+
damping: number;
|
|
20
|
+
throwing: number;
|
|
21
|
+
changeTime: number;
|
|
22
|
+
wave: number;
|
|
23
|
+
slant: number;
|
|
24
|
+
dim: number;
|
|
25
|
+
pointerStrength: number;
|
|
26
|
+
pointerRadius: number;
|
|
27
|
+
};
|
|
28
|
+
export declare const BASE_GUI_MOTION: ({
|
|
29
|
+
key: string;
|
|
30
|
+
min: number;
|
|
31
|
+
max: number;
|
|
32
|
+
step: number;
|
|
33
|
+
tip?: undefined;
|
|
34
|
+
} | {
|
|
35
|
+
key: string;
|
|
36
|
+
min: number;
|
|
37
|
+
max: number;
|
|
38
|
+
step: number;
|
|
39
|
+
tip: string;
|
|
40
|
+
})[];
|
|
41
|
+
export declare const BASE_GUI_TAIL: {
|
|
42
|
+
key: string;
|
|
43
|
+
min: number;
|
|
44
|
+
max: number;
|
|
45
|
+
step: number;
|
|
46
|
+
}[];
|
|
47
|
+
export declare function baseUniforms(): {
|
|
48
|
+
uTex: {
|
|
49
|
+
value: any;
|
|
50
|
+
};
|
|
51
|
+
uS: {
|
|
52
|
+
value: number;
|
|
53
|
+
};
|
|
54
|
+
uCount: {
|
|
55
|
+
value: number;
|
|
56
|
+
};
|
|
57
|
+
uTime: {
|
|
58
|
+
value: number;
|
|
59
|
+
};
|
|
60
|
+
uAct: {
|
|
61
|
+
value: Float32Array<ArrayBuffer>;
|
|
62
|
+
};
|
|
63
|
+
uW: {
|
|
64
|
+
value: number;
|
|
65
|
+
};
|
|
66
|
+
uH: {
|
|
67
|
+
value: number;
|
|
68
|
+
};
|
|
69
|
+
uWave: {
|
|
70
|
+
value: number;
|
|
71
|
+
};
|
|
72
|
+
uSlant: {
|
|
73
|
+
value: number;
|
|
74
|
+
};
|
|
75
|
+
uDim: {
|
|
76
|
+
value: number;
|
|
77
|
+
};
|
|
78
|
+
uIntensity: {
|
|
79
|
+
value: number;
|
|
80
|
+
};
|
|
81
|
+
uOpacity: {
|
|
82
|
+
value: number;
|
|
83
|
+
};
|
|
84
|
+
uPointer: {
|
|
85
|
+
value: THREE.Vector3;
|
|
86
|
+
};
|
|
87
|
+
uPointerActive: {
|
|
88
|
+
value: number;
|
|
89
|
+
};
|
|
90
|
+
uPointerMode: {
|
|
91
|
+
value: number;
|
|
92
|
+
};
|
|
93
|
+
uPointerStrength: {
|
|
94
|
+
value: number;
|
|
95
|
+
};
|
|
96
|
+
uPointerRadius: {
|
|
97
|
+
value: number;
|
|
98
|
+
};
|
|
99
|
+
uPlace: {
|
|
100
|
+
value: THREE.Matrix4[];
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
export declare function applyBase(u: any, c: any, modes: any): (k: any, v: any) => void;
|
|
104
|
+
/** GLSL shared by every shader of the batch (vertex and fragment). */
|
|
105
|
+
export declare const baseGlsl = "\n uniform float uS, uCount, uTime, uW, uH, uWave, uSlant, uDim, uIntensity, uOpacity;\n uniform float uAct[32];\n uniform vec3 uPointer; uniform float uPointerActive, uPointerMode, uPointerStrength, uPointerRadius;\n \n uniform mat4 uPlace[32];\n vec3 placeAt(float img, vec3 local){ mat4 M = uPlace[int(img + 0.5)]; M[3][3] = 1.0; return (M * vec4(local, 1.0)).xyz; }\n float fadeAt(float img){ return uPlace[int(img + 0.5)][3][3]; }\n\n float actOf(float img){ return uAct[int(img + 0.5)]; }\n float waveAt(float act, vec2 g){\n float pos = mix(g.x, 1.0 - g.y, uSlant * 0.5);\n float front = act * (1.0 + uWave) - uWave * 0.5;\n float w = smoothstep(front + uWave * 0.5, front - uWave * 0.5, pos);\n return w * w * (3.0 - 2.0 * w);\n }\n float maskAt(vec2 p){ if (uPointerMode < -0.5) return 0.0; float d = length(p - uPointer.xy); return uPointerActive * uPointerStrength * (1.0 - smoothstep(uPointerRadius * 0.4, uPointerRadius, d)); }\n float lumOf(vec3 c){ return dot(c, vec3(0.299, 0.587, 0.114)); }\n // the inactive look: the picture's own luminance, grey and dim\n vec3 fadedOf(vec3 pic){ return vec3(0.1 + 0.9 * lumOf(pic)) * uDim; }\n";
|
|
106
|
+
/** An instanced geometry: `base` repeated `per` times for each of the 32 pictures; aI = (picture, index, u, v). */
|
|
107
|
+
export declare function instanced(base: any, per: any, cell: any): THREE.InstancedBufferGeometry;
|
|
108
|
+
/** A self-coloured ShaderMaterial of the batch (premultiplied). */
|
|
109
|
+
export declare function shaderMaterial(u: any, vertexShader: any, fragmentShader: any, opts?: {}): THREE.ShaderMaterial;
|
|
110
|
+
/**
|
|
111
|
+
* A scene-lit standard material whose geometry and colour come from the look's own GLSL:
|
|
112
|
+
* vertex.head / vertex.body — body sets `gPos` (local position, before the layout) and `gNrm` (local normal);
|
|
113
|
+
* the layout's matrix is applied here.
|
|
114
|
+
* fragment.head / fragment.body — body sets `diffuseColor.rgb` (and may scale `diffuseColor.a`).
|
|
115
|
+
* It lights with the scene's lights like any standard material (the gallery adds none).
|
|
116
|
+
*/
|
|
117
|
+
export declare function litMaterial(u: any, key: any, vertex: any, fragment: any, opts?: {}): THREE.MeshStandardMaterial;
|
|
118
|
+
/**
|
|
119
|
+
* The shadow twin of a litMaterial: the same geometry (vertex.body + the layout) and the same cut-out
|
|
120
|
+
* (cutout.head / cutout.body, which may `discard`), so the look casts true shadows of its own shape.
|
|
121
|
+
* Set as mesh.customDepthMaterial (directional and spot lights).
|
|
122
|
+
*/
|
|
123
|
+
export declare function litDepthMaterial(u: any, key: any, vertex: any, cutout?: {
|
|
124
|
+
head: string;
|
|
125
|
+
body: string;
|
|
126
|
+
}): THREE.MeshDepthMaterial;
|
|
127
|
+
/**
|
|
128
|
+
* The gallery shell: navigation, layout, act, cursor, texture. `meshes` are added under the object; `setCount(n)`
|
|
129
|
+
* is called when the pictures change (set instance counts); `extra(dt, pointer, state)` runs every frame after
|
|
130
|
+
* the shared state is up to date.
|
|
131
|
+
*/
|
|
132
|
+
export declare function makeGallery(u: any, c: any, opts: any): {
|
|
133
|
+
object: THREE.Group<THREE.Object3DEventMap>;
|
|
134
|
+
controls: {
|
|
135
|
+
next(): void;
|
|
136
|
+
prev(): void;
|
|
137
|
+
goTo(i: any): void;
|
|
138
|
+
jump(i: any): void;
|
|
139
|
+
readonly index: number;
|
|
140
|
+
readonly count: number;
|
|
141
|
+
readonly busy: boolean;
|
|
142
|
+
dragBegin(x: any): void;
|
|
143
|
+
dragMove(x: any): void;
|
|
144
|
+
dragEnd(dt: any): void;
|
|
145
|
+
readonly dragging: boolean;
|
|
146
|
+
hover(): void;
|
|
147
|
+
} & {
|
|
148
|
+
setTexture(tex: any, count: any): void;
|
|
149
|
+
};
|
|
150
|
+
pickMesh: THREE.Mesh<THREE.PlaneGeometry, THREE.MeshBasicMaterial, THREE.Object3DEventMap>;
|
|
151
|
+
materials: any;
|
|
152
|
+
cfg: any;
|
|
153
|
+
apply(k: any): void;
|
|
154
|
+
update(dt: any, pointer: any, state: any): void;
|
|
155
|
+
dispose(): void;
|
|
156
|
+
};
|
|
157
|
+
//# sourceMappingURL=lookBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lookBase.d.ts","sourceRoot":"","sources":["../../../../src/components/gallery/kit/lookBase.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAmC,QAAQ,EAAE,MAAM,cAAc,CAAC;AACnF,OAAO,EAAwD,UAAU,EAAE,MAAM,cAAc,CAAC;AAEhG,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;AAC1C,eAAO,MAAM,IAAI,KAAK,CAAC;AAEvB,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;CAMzB,CAAC;AACF,eAAO,MAAM,eAAe;;;;;;;;;;;;IAM3B,CAAC;AACF,eAAO,MAAM,aAAa;;;;;GAGzB,CAAC;AAEF,wBAAgB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQ3B;AACD,wBAAgB,SAAS,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA,EAAE,KAAK,KAAA,4BAMpC;AAED,sEAAsE;AACtE,eAAO,MAAM,QAAQ,ssCAgBpB,CAAC;AAEF,mHAAmH;AACnH,wBAAgB,SAAS,CAAC,IAAI,KAAA,EAAE,GAAG,KAAA,EAAE,IAAI,KAAA,iCASxC;AAED,mEAAmE;AACnE,wBAAgB,cAAc,CAAC,CAAC,KAAA,EAAE,YAAY,KAAA,EAAE,cAAc,KAAA,EAAE,IAAI,KAAK,wBAExE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,KAAA,EAAE,GAAG,KAAA,EAAE,MAAM,KAAA,EAAE,QAAQ,KAAA,EAAE,IAAI,KAAK,8BAc9D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,KAAA,EAAE,GAAG,KAAA,EAAE,MAAM,KAAA,EAAE,MAAM;;;CAAyB,2BAa/E;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA,EAAE,IAAI,KAAA;;;;;;;;;;;;;;;;;;;;;;;;EAoCrC"}
|