troncell-vue-component 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +144 -0
- package/dist/index.cjs +742 -0
- package/dist/index.mjs +10142 -0
- package/dist/troncell-vue-component.css +1 -0
- package/dist/types/components/3DCardComp/component/CardBody.vue.d.ts +21 -0
- package/dist/types/components/3DCardComp/component/CardContainer.vue.d.ts +27 -0
- package/dist/types/components/3DCardComp/component/Cardltem.vue.d.ts +89 -0
- package/dist/types/components/3DCardComp/component/card-3d.d.ts +4 -0
- package/dist/types/components/3DCardComp/component/useMouseState.d.ts +4 -0
- package/dist/types/components/3DCardComp/index.vue.d.ts +50 -0
- package/dist/types/components/AnimatedTestimonialsComp/component/AnimatedTestimonials.vue.d.ts +39 -0
- package/dist/types/components/AnimatedTestimonialsComp/index.vue.d.ts +53 -0
- package/dist/types/components/AuroraComp/component/Aurora.vue.d.ts +23 -0
- package/dist/types/components/AuroraComp/index.vue.d.ts +35 -0
- package/dist/types/components/BendingGalleryComp/component/BendingGallery.vue.d.ts +19 -0
- package/dist/types/components/BendingGalleryComp/index.vue.d.ts +35 -0
- package/dist/types/components/BentoGridComp/component/BentoGrid.vue.d.ts +21 -0
- package/dist/types/components/BentoGridComp/component/BentoGridltem.vue.d.ts +24 -0
- package/dist/types/components/BentoGridComp/index.vue.d.ts +33 -0
- package/dist/types/components/Carousel3DComp/component/Carousel3D.vue.d.ts +18 -0
- package/dist/types/components/Carousel3DComp/index.vue.d.ts +27 -0
- package/dist/types/components/ContainerScrollComp/component/ContainerScroll.vue.d.ts +22 -0
- package/dist/types/components/ContainerScrollComp/component/ContainerScrollCard.vue.d.ts +23 -0
- package/dist/types/components/ContainerScrollComp/component/ContainerScrollTitle.vue.d.ts +21 -0
- package/dist/types/components/ContainerScrollComp/index.vue.d.ts +37 -0
- package/dist/types/components/DirectionAwareHoverComp/component/DirectionAwareHover.vue.d.ts +31 -0
- package/dist/types/components/DirectionAwareHoverComp/index.vue.d.ts +42 -0
- package/dist/types/components/DockComp/component/Dock.vue.d.ts +35 -0
- package/dist/types/components/DockComp/component/DockSeparator.vue.d.ts +2 -0
- package/dist/types/components/DockComp/component/Docklcon.vue.d.ts +21 -0
- package/dist/types/components/DockComp/component/index.d.ts +3 -0
- package/dist/types/components/DockComp/component/injectionKeys.d.ts +7 -0
- package/dist/types/components/DockComp/component/types.d.ts +2 -0
- package/dist/types/components/DockComp/index.vue.d.ts +27 -0
- package/dist/types/components/DomeGalleryComp/component/DomeGallery.vue.d.ts +49 -0
- package/dist/types/components/DomeGalleryComp/index.vue.d.ts +53 -0
- package/dist/types/components/ExpandableGalleryComp/component/ExpandableGallery.vue.d.ts +7 -0
- package/dist/types/components/ExpandableGalleryComp/index.vue.d.ts +17 -0
- package/dist/types/components/FluidCursorComp/component/FluidCursor.vue.d.ts +42 -0
- package/dist/types/components/FluidCursorComp/index.vue.d.ts +23 -0
- package/dist/types/components/IButtonComp/index.vue.d.ts +55 -0
- package/dist/types/components/IInputComp/index.vue.d.ts +28 -0
- package/dist/types/components/IconCloudComp/component/IconCloud.vue.d.ts +5 -0
- package/dist/types/components/IconCloudComp/component/index.d.ts +14 -0
- package/dist/types/components/IconCloudComp/index.vue.d.ts +29 -0
- package/dist/types/components/InfiniteGridComp/component/DisposalManager.d.ts +121 -0
- package/dist/types/components/InfiniteGridComp/component/EventHandler.d.ts +126 -0
- package/dist/types/components/InfiniteGridComp/component/GridManager.d.ts +191 -0
- package/dist/types/components/InfiniteGridComp/component/InfiniteGrid.vue.d.ts +16 -0
- package/dist/types/components/InfiniteGridComp/component/InfiniteGridClass.d.ts +382 -0
- package/dist/types/components/InfiniteGridComp/component/PostProcessShader.d.ts +116 -0
- package/dist/types/components/InfiniteGridComp/component/createTexture.d.ts +99 -0
- package/dist/types/components/InfiniteGridComp/component/shaders.d.ts +4 -0
- package/dist/types/components/InfiniteGridComp/component/types.d.ts +122 -0
- package/dist/types/components/InfiniteGridComp/index.vue.d.ts +47 -0
- package/dist/types/components/InfiniteMenuComp/component/InfiniteMenu.vue.d.ts +13 -0
- package/dist/types/components/InfiniteMenuComp/index.vue.d.ts +33 -0
- package/dist/types/components/InspiraImageParticlesComp/component/inspiraImageParticles.d.ts +107 -0
- package/dist/types/components/InspiraImageParticlesComp/index.vue.d.ts +24 -0
- package/dist/types/components/InteractiveGridPatternComp/component/InteractiveGridPattern.vue.d.ts +14 -0
- package/dist/types/components/InteractiveGridPatternComp/index.vue.d.ts +29 -0
- package/dist/types/components/LightningComp/component/Lightning.vue.d.ts +17 -0
- package/dist/types/components/LightningComp/index.vue.d.ts +35 -0
- package/dist/types/components/LinkPreviewComp/component/LinkPreview.vue.d.ts +19 -0
- package/dist/types/components/LinkPreviewComp/index.vue.d.ts +11 -0
- package/dist/types/components/MagnifyingGlassComp/component/Beams.vue.d.ts +2 -0
- package/dist/types/components/MagnifyingGlassComp/component/Lens.vue.d.ts +45 -0
- package/dist/types/components/MagnifyingGlassComp/component/Rays.vue.d.ts +5 -0
- package/dist/types/components/MagnifyingGlassComp/index.vue.d.ts +41 -0
- package/dist/types/components/MarqueeComp/component/Marquee.vue.d.ts +28 -0
- package/dist/types/components/MarqueeComp/component/ReviewCard.vue.d.ts +8 -0
- package/dist/types/components/MarqueeComp/index.vue.d.ts +42 -0
- package/dist/types/components/MeteorsComp/component/Meteors.vue.d.ts +16 -0
- package/dist/types/components/MeteorsComp/index.vue.d.ts +45 -0
- package/dist/types/components/Navigation.vue.d.ts +2 -0
- package/dist/types/components/PhotoGalleryComp/component/PhotoGallery.vue.d.ts +9 -0
- package/dist/types/components/PhotoGalleryComp/index.vue.d.ts +38 -0
- package/dist/types/components/RegistrationFormComp/index.vue.d.ts +15 -0
- package/dist/types/components/RippleButtonComp/component/RippleButton.vue.d.ts +35 -0
- package/dist/types/components/RippleButtonComp/index.vue.d.ts +35 -0
- package/dist/types/components/RollingGalleryComp/component/RollingGallery.vue.d.ts +29 -0
- package/dist/types/components/RollingGalleryComp/index.vue.d.ts +45 -0
- package/dist/types/components/ScratchToRevealComp/component/ScratchToReveal.vue.d.ts +37 -0
- package/dist/types/components/ScratchToRevealComp/index.vue.d.ts +37 -0
- package/dist/types/components/ScrollIslandComp/component/AnimatedCircularProgressBar.vue.d.ts +22 -0
- package/dist/types/components/ScrollIslandComp/component/ScrollIsland.vue.d.ts +19 -0
- package/dist/types/components/ScrollIslandComp/index.vue.d.ts +41 -0
- package/dist/types/components/SparkElementComp/component/Sparkles.vue.d.ts +20 -0
- package/dist/types/components/SparkElementComp/index.vue.d.ts +13 -0
- package/dist/types/components/SparklesTextComp/component/SparklesText.vue.d.ts +17 -0
- package/dist/types/components/SparklesTextComp/index.vue.d.ts +13 -0
- package/dist/types/components/SplineComp/component/ParentSize.vue.d.ts +55 -0
- package/dist/types/components/SplineComp/component/Spline.vue.d.ts +67 -0
- package/dist/types/components/SplineComp/index.vue.d.ts +41 -0
- package/dist/types/components/StackComp/component/Stack.vue.d.ts +36 -0
- package/dist/types/components/StackComp/index.vue.d.ts +49 -0
- package/dist/types/components/TargetCursorComp/component/TargetCursor.vue.d.ts +15 -0
- package/dist/types/components/TargetCursorComp/index.vue.d.ts +50 -0
- package/dist/types/components/TestimonialSliderComp/component/TestimonialSlider.vue.d.ts +19 -0
- package/dist/types/components/TestimonialSliderComp/index.vue.d.ts +35 -0
- package/dist/types/components/Text3dComp/component/Text3d.vue.d.ts +40 -0
- package/dist/types/components/Text3dComp/index.vue.d.ts +33 -0
- package/dist/types/components/TextGenerateEffectComp/component/TextGenerateEffect.vue.d.ts +16 -0
- package/dist/types/components/TextGenerateEffectComp/index.vue.d.ts +29 -0
- package/dist/types/components/TimelineComp/component/Timeline.vue.d.ts +37 -0
- package/dist/types/components/TimelineComp/index.vue.d.ts +41 -0
- package/dist/types/components/TracingBeamComp/component/TracingBeam.vue.d.ts +27 -0
- package/dist/types/components/TracingBeamComp/index.vue.d.ts +47 -0
- package/dist/types/index.d.ts +42 -0
- package/dist/types/utils/lib/utils.d.ts +3 -0
- package/dist/types/utils/sensing-sample-sdk-quorra-1.0.d.ts +67 -0
- package/dist/types/utils/sensing-sample-sdk-webview-1.0.d.ts +45 -0
- package/dist/types/utils/useDynamicComponents.d.ts +42 -0
- package/package.json +83 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import { Renderer, Camera, Transform, Mesh, Vec2, RenderTarget, Raycast } from 'ogl';
|
|
2
|
+
import { CustomPostProcessShader } from './PostProcessShader';
|
|
3
|
+
import { EventHandler, EventHandlerHost } from './EventHandler';
|
|
4
|
+
import { DisposalManager, DisposableHost } from './DisposalManager';
|
|
5
|
+
import { GridManager, GridManagerHost } from './GridManager';
|
|
6
|
+
import { CardData, InfiniteGridOptions, Position2D, ScrollState, TileGroupData, CardTexturePair } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* InfiniteGridClass - An OGL-based infinite scrolling grid system
|
|
9
|
+
*
|
|
10
|
+
* This class creates an infinite, scrollable grid of tiles that displays card data.
|
|
11
|
+
* It uses a 3x3 grid system where tiles are repositioned as the user scrolls to
|
|
12
|
+
* create an infinite scrolling effect. Each tile can display custom content
|
|
13
|
+
* with foreground and background textures.
|
|
14
|
+
*
|
|
15
|
+
* Key Features:
|
|
16
|
+
* - Infinite scrolling in all directions using tile repositioning
|
|
17
|
+
* - Interactive hover effects with background blur transitions
|
|
18
|
+
* - Click events with custom event dispatching
|
|
19
|
+
* - Optional post-processing effects (distortion, vignette)
|
|
20
|
+
* - GSAP-powered smooth animations and inertia scrolling
|
|
21
|
+
* - Responsive design with automatic viewport calculations
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const grid = new InfiniteGridClass(
|
|
26
|
+
* containerElement,
|
|
27
|
+
* cardDataArray,
|
|
28
|
+
* {
|
|
29
|
+
* gridCols: 3,
|
|
30
|
+
* gridRows: 3,
|
|
31
|
+
* enablePostProcessing: true
|
|
32
|
+
* }
|
|
33
|
+
* );
|
|
34
|
+
* await grid.init();
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare class InfiniteGridClass implements EventHandlerHost, DisposableHost, GridManagerHost {
|
|
38
|
+
/**
|
|
39
|
+
* Core Container and Data Properties
|
|
40
|
+
*/
|
|
41
|
+
/** The HTML element that contains the OGL canvas */
|
|
42
|
+
container: HTMLElement;
|
|
43
|
+
/** Array of card data to be displayed in the grid */
|
|
44
|
+
cardData: CardData[];
|
|
45
|
+
/** Merged configuration options with defaults applied */
|
|
46
|
+
options: Required<InfiniteGridOptions>;
|
|
47
|
+
/**
|
|
48
|
+
* Grid Layout Properties (calculated once, read-only)
|
|
49
|
+
*/
|
|
50
|
+
/** Gap between tiles in OGL world units */
|
|
51
|
+
readonly GRID_GAP: number;
|
|
52
|
+
/** Size of each individual tile in OGL world units */
|
|
53
|
+
readonly TILE_SIZE: number;
|
|
54
|
+
/** Total space occupied by one tile including gap */
|
|
55
|
+
readonly TILE_SPACE: number;
|
|
56
|
+
/** Number of columns in each grid section */
|
|
57
|
+
readonly GRID_COLS: number;
|
|
58
|
+
/** Number of rows in each grid section */
|
|
59
|
+
readonly GRID_ROWS: number;
|
|
60
|
+
/** Total width of one grid section */
|
|
61
|
+
readonly GRID_WIDTH: number;
|
|
62
|
+
/** Total height of one grid section */
|
|
63
|
+
readonly GRID_HEIGHT: number;
|
|
64
|
+
/** Total width of all 3 grid sections (for infinite wrapping) */
|
|
65
|
+
private readonly TOTAL_GRID_WIDTH;
|
|
66
|
+
/** Total height of all 3 grid sections (for infinite wrapping) */
|
|
67
|
+
private readonly TOTAL_GRID_HEIGHT;
|
|
68
|
+
/**
|
|
69
|
+
* OGL Core Rendering Objects
|
|
70
|
+
*/
|
|
71
|
+
/** Main OGL scene containing all 3D objects */
|
|
72
|
+
scene: Transform;
|
|
73
|
+
/** Perspective camera for viewing the scene */
|
|
74
|
+
camera: Camera | null;
|
|
75
|
+
/** WebGL renderer for drawing to the canvas */
|
|
76
|
+
renderer: Renderer | null;
|
|
77
|
+
/** 2D pointer coordinates for interaction */
|
|
78
|
+
pointer: Vec2;
|
|
79
|
+
/** Raycast utility for mouse/touch interaction */
|
|
80
|
+
raycast: Raycast;
|
|
81
|
+
/**
|
|
82
|
+
* Post-Processing Objects
|
|
83
|
+
*/
|
|
84
|
+
/** Post-processing shader for visual effects (distortion, vignette) */
|
|
85
|
+
postProcessShader: CustomPostProcessShader | null;
|
|
86
|
+
/** Render target for capturing the scene before post-processing */
|
|
87
|
+
sceneRenderTarget: RenderTarget | null;
|
|
88
|
+
/**
|
|
89
|
+
* Scene Objects and Data Structures
|
|
90
|
+
*/
|
|
91
|
+
/** Array of OGL transforms, each containing one 3x3 section of tiles */
|
|
92
|
+
groupObjects: Transform[];
|
|
93
|
+
/** Map of tile keys to foreground mesh objects (clickable content) */
|
|
94
|
+
foregroundMeshMap: Map<string, Mesh>;
|
|
95
|
+
/** Map of tile keys to background mesh objects (blur effect on hover) */
|
|
96
|
+
backgroundMeshMap: Map<string, Mesh>;
|
|
97
|
+
/** Generated textures for all cards (foreground + background pairs) */
|
|
98
|
+
cardTextures: CardTexturePair[];
|
|
99
|
+
/** Static shader uniforms for background materials */
|
|
100
|
+
staticUniforms: Map<string, any>;
|
|
101
|
+
/**
|
|
102
|
+
* User Interaction State
|
|
103
|
+
*/
|
|
104
|
+
/** Key of the currently hovered tile (empty string if none) */
|
|
105
|
+
currentHoveredTileKey: string;
|
|
106
|
+
/** Whether the user is currently dragging/scrolling */
|
|
107
|
+
isDown: boolean;
|
|
108
|
+
isHoveringCanvas: boolean;
|
|
109
|
+
/** Whether the scene has moved significantly during this interaction */
|
|
110
|
+
hasMovedSignificantly: boolean;
|
|
111
|
+
/** Position where the current drag started */
|
|
112
|
+
startPosition: Position2D;
|
|
113
|
+
/** Scroll position when the current drag started */
|
|
114
|
+
scrollPosition: Position2D;
|
|
115
|
+
/** Current scroll state and behavior settings */
|
|
116
|
+
scroll: ScrollState;
|
|
117
|
+
/** Direction of scroll movement for infinite wrapping logic */
|
|
118
|
+
private direction;
|
|
119
|
+
/** GSAP InertiaPlugin tracker for smooth scroll transitions */
|
|
120
|
+
scrollTracker: any;
|
|
121
|
+
/**
|
|
122
|
+
* Animation Configuration Constants
|
|
123
|
+
*/
|
|
124
|
+
/** Duration of hover transition animations in seconds */
|
|
125
|
+
readonly hoverTransitionDuration: number;
|
|
126
|
+
/** GSAP easing function for hover animations */
|
|
127
|
+
readonly hoverEase: string;
|
|
128
|
+
/** Initial opacity of background blur effect (0 = transparent) */
|
|
129
|
+
readonly initialBackgroundOpacity: number;
|
|
130
|
+
/** Target opacity when background is hovered (1 = fully visible) */
|
|
131
|
+
readonly hoveredBackgroundOpacity: number;
|
|
132
|
+
/** Maximum movement distance in pixels before click is disabled */
|
|
133
|
+
readonly maxClickMovement: number;
|
|
134
|
+
/**
|
|
135
|
+
* Animation Frame Management
|
|
136
|
+
*/
|
|
137
|
+
/** RequestAnimationFrame ID for the main render loop */
|
|
138
|
+
animationFrameId: number | null;
|
|
139
|
+
/**
|
|
140
|
+
* Tile Group Data Structure
|
|
141
|
+
*/
|
|
142
|
+
/** Array containing position data for all 9 tile groups (3x3 infinite grid) */
|
|
143
|
+
tileGroupsData: TileGroupData[];
|
|
144
|
+
/**
|
|
145
|
+
* Modular System Components
|
|
146
|
+
*/
|
|
147
|
+
/** Event handler for managing user interactions */
|
|
148
|
+
eventHandler?: EventHandler;
|
|
149
|
+
/** Grid manager for handling grid creation and management */
|
|
150
|
+
gridManager: GridManager;
|
|
151
|
+
/** Disposal manager for resource cleanup */
|
|
152
|
+
private disposalManager;
|
|
153
|
+
/**
|
|
154
|
+
* Creates a new InfiniteGridClass instance
|
|
155
|
+
*
|
|
156
|
+
* @param containerElement - HTML element that will contain the OGL canvas
|
|
157
|
+
* @param cardData - Array of card data to display in the grid (defaults to empty array)
|
|
158
|
+
* @param options - Configuration options (merged with defaults)
|
|
159
|
+
*
|
|
160
|
+
* @throws {Error} Throws if containerElement is null or undefined
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* const container = document.getElementById('grid-container');
|
|
165
|
+
* const cards = [
|
|
166
|
+
* { title: 'Card 1', badge: 'NEW', description: '...', tags: ['tag1'], date: '2024' },
|
|
167
|
+
* // ... more cards
|
|
168
|
+
* ];
|
|
169
|
+
* const grid = new InfiniteGridClass(container, cards, {
|
|
170
|
+
* gridCols: 4,
|
|
171
|
+
* tileSize: 2.5,
|
|
172
|
+
* enablePostProcessing: true
|
|
173
|
+
* });
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
constructor(containerElement: HTMLElement, cardData?: CardData[], options?: Partial<InfiniteGridOptions>);
|
|
177
|
+
/**
|
|
178
|
+
* Initializes the infinite grid system asynchronously
|
|
179
|
+
*
|
|
180
|
+
* This method sets up all necessary components in the correct order:
|
|
181
|
+
* 1. WebGL renderer and camera
|
|
182
|
+
* 2. Tile group positioning structure
|
|
183
|
+
* 3. Texture generation for all card data
|
|
184
|
+
* 4. 3D mesh creation and scene setup
|
|
185
|
+
* 5. Event listeners for interaction
|
|
186
|
+
* 6. Animation systems and render loop
|
|
187
|
+
*
|
|
188
|
+
* @returns Promise that resolves when initialization is complete
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* const grid = new InfiniteGridClass(container, cardData);
|
|
193
|
+
* await grid.init(); // Wait for all textures to load and scene to be ready
|
|
194
|
+
* // Grid is now interactive and rendering
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
init(): Promise<void>;
|
|
198
|
+
/**
|
|
199
|
+
* Sets up the WebGL renderer with optimal settings
|
|
200
|
+
*
|
|
201
|
+
* Creates an OGL renderer with antialiasing and transparency,
|
|
202
|
+
* configures it for the container size, and appends the canvas
|
|
203
|
+
* to the DOM.
|
|
204
|
+
*/
|
|
205
|
+
private setupRenderer;
|
|
206
|
+
/**
|
|
207
|
+
* Sets up the perspective camera with proper positioning
|
|
208
|
+
*
|
|
209
|
+
* Creates a perspective camera with a 45-degree field of view,
|
|
210
|
+
* positions it at the configured Z distance.
|
|
211
|
+
*/
|
|
212
|
+
private setupCamera;
|
|
213
|
+
/**
|
|
214
|
+
* Sets up post-processing effects if enabled
|
|
215
|
+
*
|
|
216
|
+
* Creates a render target for capturing the scene before post-processing
|
|
217
|
+
* and initializes the post-processing shader with configured parameters.
|
|
218
|
+
*/
|
|
219
|
+
private setupPostProcessing;
|
|
220
|
+
/**
|
|
221
|
+
* Calculates the viewport dimensions in world space
|
|
222
|
+
*
|
|
223
|
+
* Uses the camera's field of view and position to determine how much
|
|
224
|
+
* world space is visible. This is essential for infinite scrolling
|
|
225
|
+
* calculations to know when tile groups need to be repositioned.
|
|
226
|
+
*
|
|
227
|
+
* @returns Viewport object with width and height in world units
|
|
228
|
+
*/
|
|
229
|
+
private get viewport();
|
|
230
|
+
updatePositions(): void;
|
|
231
|
+
animateInertiaScroll(vx?: number | string, vy?: number | string): void;
|
|
232
|
+
/**
|
|
233
|
+
* Gets all interactive meshes for raycasting
|
|
234
|
+
* @returns Array of foreground meshes that can be interacted with
|
|
235
|
+
*/
|
|
236
|
+
getInteractiveMeshes(): Mesh[];
|
|
237
|
+
/**
|
|
238
|
+
* Updates mouse/touch coordinates for raycasting
|
|
239
|
+
* @param clientX - X coordinate in client space
|
|
240
|
+
* @param clientY - Y coordinate in client space
|
|
241
|
+
*/
|
|
242
|
+
updatePointerCoordinates(clientX: number, clientY: number): void;
|
|
243
|
+
/**
|
|
244
|
+
* Performs raycasting and returns hit results
|
|
245
|
+
* @returns Array of hit meshes ordered by distance
|
|
246
|
+
*/
|
|
247
|
+
performRaycast(): Mesh[];
|
|
248
|
+
/**
|
|
249
|
+
* Extracts tile key from a mesh using its userData
|
|
250
|
+
* @param mesh - The mesh to get the tile key from
|
|
251
|
+
* @returns The tile key or empty string if not found
|
|
252
|
+
*/
|
|
253
|
+
getTileKeyFromMesh(mesh: Mesh): string;
|
|
254
|
+
fadeInBackground(mesh: Mesh): void;
|
|
255
|
+
fadeOutBackground(mesh: Mesh): void;
|
|
256
|
+
/**
|
|
257
|
+
* Gets the card data for a specific tile
|
|
258
|
+
* @param groupIndex - The group index of the tile
|
|
259
|
+
* @param tileIndex - The tile index within the group
|
|
260
|
+
* @returns The card data for the tile
|
|
261
|
+
*/
|
|
262
|
+
getCardDataForTile(groupIndex: number, tileIndex: number): CardData;
|
|
263
|
+
private render;
|
|
264
|
+
/**
|
|
265
|
+
* Animates the post-processing effects
|
|
266
|
+
*
|
|
267
|
+
* @param targetDistortion - Target distortion intensity (0 = no distortion)
|
|
268
|
+
* @param targetVignetteOffset - Target vignette offset (0.0-1.0)
|
|
269
|
+
* @param targetVignetteDarkness - Target vignette darkness (should be > offset)
|
|
270
|
+
* @param duration - Animation duration in seconds
|
|
271
|
+
* @param delay - Animation delay in seconds
|
|
272
|
+
* @param ease - GSAP ease function
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```typescript
|
|
276
|
+
* // Animate to strong distortion and vignette
|
|
277
|
+
* grid.animatePostProcessing(0.5, 0.6, 0.9, 2.0);
|
|
278
|
+
*
|
|
279
|
+
* // Reset to no effects
|
|
280
|
+
* grid.animatePostProcessing(0, 0.8, 1.0, 1.0);
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
animatePostProcessing(targetDistortion: number, targetVignetteOffset: number, targetVignetteDarkness: number, duration?: number, delay?: number, ease?: string): void;
|
|
284
|
+
/**
|
|
285
|
+
* Toggles post-processing on/off for debugging
|
|
286
|
+
* @param enabled - Whether to enable post-processing
|
|
287
|
+
*/
|
|
288
|
+
setPostProcessingEnabled(enabled: boolean): void;
|
|
289
|
+
/**
|
|
290
|
+
* Gets the current distortion intensity
|
|
291
|
+
*/
|
|
292
|
+
get distortionIntensity(): number;
|
|
293
|
+
/**
|
|
294
|
+
* Sets the distortion intensity (0 = no distortion)
|
|
295
|
+
*/
|
|
296
|
+
set distortionIntensity(value: number);
|
|
297
|
+
/**
|
|
298
|
+
* Gets the current vignette offset
|
|
299
|
+
*/
|
|
300
|
+
get vignetteOffset(): number;
|
|
301
|
+
/**
|
|
302
|
+
* Sets the vignette offset (0.0 = center, 1.0 = edges)
|
|
303
|
+
*/
|
|
304
|
+
set vignetteOffset(value: number);
|
|
305
|
+
/**
|
|
306
|
+
* Gets the current vignette darkness
|
|
307
|
+
*/
|
|
308
|
+
get vignetteDarkness(): number;
|
|
309
|
+
/**
|
|
310
|
+
* Sets the vignette darkness (should be > vignetteOffset)
|
|
311
|
+
*/
|
|
312
|
+
set vignetteDarkness(value: number);
|
|
313
|
+
/**
|
|
314
|
+
* Completely disposes of the infinite grid and cleans up all resources
|
|
315
|
+
*
|
|
316
|
+
* This method now uses the DisposalManager for systematic cleanup to prevent memory leaks.
|
|
317
|
+
* The disposal manager handles:
|
|
318
|
+
* - Cancels the animation frame loop
|
|
319
|
+
* - Removes all event listeners
|
|
320
|
+
* - Disposes all OGL geometries, materials, and textures
|
|
321
|
+
* - Clears all data structures and maps
|
|
322
|
+
* - Removes the canvas from the DOM
|
|
323
|
+
*
|
|
324
|
+
* Call this method when the grid is no longer needed, such as when
|
|
325
|
+
* navigating away from the page or unmounting the component.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```typescript
|
|
329
|
+
* // In a Vue component's onBeforeUnmount or React's useEffect cleanup
|
|
330
|
+
* onBeforeUnmount(() => {
|
|
331
|
+
* if (gridInstance) {
|
|
332
|
+
* gridInstance.dispose();
|
|
333
|
+
* gridInstance = null;
|
|
334
|
+
* }
|
|
335
|
+
* });
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
dispose(): void;
|
|
339
|
+
/**
|
|
340
|
+
* Gets the event handler instance for advanced event management
|
|
341
|
+
* @returns The EventHandler instance or undefined if not initialized
|
|
342
|
+
*/
|
|
343
|
+
getEventHandler(): EventHandler | undefined;
|
|
344
|
+
/**
|
|
345
|
+
* Gets the grid manager instance for advanced grid management
|
|
346
|
+
* @returns The GridManager instance
|
|
347
|
+
*/
|
|
348
|
+
getGridManager(): GridManager;
|
|
349
|
+
/**
|
|
350
|
+
* Gets the disposal manager instance for advanced cleanup control
|
|
351
|
+
* @returns The DisposalManager instance
|
|
352
|
+
*/
|
|
353
|
+
getDisposalManager(): DisposalManager;
|
|
354
|
+
/**
|
|
355
|
+
* Updates card data and regenerates the grid
|
|
356
|
+
* @param newCardData - The new card data to display
|
|
357
|
+
* @returns Promise that resolves when update is complete
|
|
358
|
+
*/
|
|
359
|
+
updateCardData(newCardData: CardData[]): Promise<void>;
|
|
360
|
+
/**
|
|
361
|
+
* Gets statistics about the current grid
|
|
362
|
+
* @returns Object containing grid statistics
|
|
363
|
+
*/
|
|
364
|
+
getGridStats(): {
|
|
365
|
+
totalGroups: number;
|
|
366
|
+
tilesPerGroup: number;
|
|
367
|
+
totalTiles: number;
|
|
368
|
+
totalTextures: number;
|
|
369
|
+
memoryEstimate: string;
|
|
370
|
+
};
|
|
371
|
+
/**
|
|
372
|
+
* Validates that all resources have been properly disposed
|
|
373
|
+
* Useful for debugging memory leaks
|
|
374
|
+
* @returns True if disposal was successful, false if issues were found
|
|
375
|
+
*/
|
|
376
|
+
validateDisposal(): boolean;
|
|
377
|
+
/**
|
|
378
|
+
* Performs a partial cleanup that preserves the core structure
|
|
379
|
+
* but clears dynamic content. Useful for reinitialization scenarios.
|
|
380
|
+
*/
|
|
381
|
+
partialCleanup(): void;
|
|
382
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { RenderTarget, Renderer, Texture } from 'ogl';
|
|
2
|
+
type OGLContext = WebGL2RenderingContext & {
|
|
3
|
+
renderer: Renderer;
|
|
4
|
+
canvas: HTMLCanvasElement;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* @interface CustomPostProcessShaderParameters
|
|
8
|
+
* @description Defines the initial parameters for the CustomPostProcessShader.
|
|
9
|
+
* @property {number} [distortionIntensity] - Initial intensity of the distortion effect. Defaults to 0.
|
|
10
|
+
* @property {number} [vignetteOffset] - Initial offset for the vignette effect (0.0 = center, 1.0 = edges). Defaults to 0.8.
|
|
11
|
+
* @property {number} [vignetteDarkness] - Controls vignette transition smoothness (should be > vignetteOffset). Defaults to 1.0.
|
|
12
|
+
*/
|
|
13
|
+
interface CustomPostProcessShaderParameters {
|
|
14
|
+
distortionIntensity?: number;
|
|
15
|
+
vignetteOffset?: number;
|
|
16
|
+
vignetteDarkness?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @class CustomPostProcessShader
|
|
20
|
+
* @description A custom OGL-based post-processing shader for distortion and vignette effects.
|
|
21
|
+
* It provides animatable properties for these effects via GSAP.
|
|
22
|
+
*/
|
|
23
|
+
export declare class CustomPostProcessShader {
|
|
24
|
+
private gl;
|
|
25
|
+
private program;
|
|
26
|
+
private renderTarget;
|
|
27
|
+
private mesh;
|
|
28
|
+
private geometry;
|
|
29
|
+
private scene;
|
|
30
|
+
private camera;
|
|
31
|
+
/**
|
|
32
|
+
* @private
|
|
33
|
+
* @property {number} _distortionIntensity - Internal property for distortion intensity, animated by GSAP.
|
|
34
|
+
*/
|
|
35
|
+
private _distortionIntensity;
|
|
36
|
+
/**
|
|
37
|
+
* @private
|
|
38
|
+
* @property {number} _vignetteOffset - Internal property for vignette offset (0.0-1.0 range), animated by GSAP.
|
|
39
|
+
*/
|
|
40
|
+
private _vignetteOffset;
|
|
41
|
+
/**
|
|
42
|
+
* @private
|
|
43
|
+
* @property {number} _vignetteDarkness - Internal property for vignette transition end (should be > _vignetteOffset), animated by GSAP.
|
|
44
|
+
*/
|
|
45
|
+
private _vignetteDarkness;
|
|
46
|
+
/**
|
|
47
|
+
* Creates an instance of CustomPostProcessShader.
|
|
48
|
+
* @param {OGLContext} gl - The OGL WebGL context
|
|
49
|
+
* @param {CustomPostProcessShaderParameters} [initialParams={}] - Optional initial parameters for the shader effects.
|
|
50
|
+
*/
|
|
51
|
+
constructor(gl: OGLContext, initialParams?: CustomPostProcessShaderParameters);
|
|
52
|
+
/**
|
|
53
|
+
* @property {number} distortionIntensity - Getter/Setter for the distortion intensity.
|
|
54
|
+
* When set, it updates the shader uniforms.
|
|
55
|
+
*/
|
|
56
|
+
get distortionIntensity(): number;
|
|
57
|
+
set distortionIntensity(value: number);
|
|
58
|
+
/**
|
|
59
|
+
* @property {number} vignetteOffset - Getter/Setter for the vignette offset.
|
|
60
|
+
* Controls where the vignette effect starts (0.0 = center, 1.0 = screen edges).
|
|
61
|
+
* When set, it updates the shader uniforms.
|
|
62
|
+
*/
|
|
63
|
+
get vignetteOffset(): number;
|
|
64
|
+
set vignetteOffset(value: number);
|
|
65
|
+
/**
|
|
66
|
+
* @property {number} vignetteDarkness - Getter/Setter for the vignette transition end.
|
|
67
|
+
* Controls where the vignette reaches maximum darkness (should be > vignetteOffset for smooth transition).
|
|
68
|
+
* When set, it updates the shader uniforms.
|
|
69
|
+
*/
|
|
70
|
+
get vignetteDarkness(): number;
|
|
71
|
+
set vignetteDarkness(value: number);
|
|
72
|
+
/**
|
|
73
|
+
* @method updateUniforms
|
|
74
|
+
* @description Updates all relevant uniforms of the shader material based on the current
|
|
75
|
+
* internal `_distortionIntensity`, `_vignetteOffset`, and `_vignetteDarkness` properties.
|
|
76
|
+
* This method should be called whenever the internal properties change to reflect
|
|
77
|
+
* the changes in the shader.
|
|
78
|
+
*/
|
|
79
|
+
updateUniforms(): void;
|
|
80
|
+
/**
|
|
81
|
+
* @method animate
|
|
82
|
+
* @description Animates the distortion and vignette parameters using GSAP.
|
|
83
|
+
* @param {number} targetDistortion - The target distortion intensity value.
|
|
84
|
+
* @param {number} targetVignetteOffset - The target vignette offset value.
|
|
85
|
+
* @param {number} targetVignetteDarkness - The target vignette darkness value.
|
|
86
|
+
* @param {number} [duration=1] - The duration of the animation in seconds.
|
|
87
|
+
* @param {number} [delay=0] - The delay before the animation starts in seconds.
|
|
88
|
+
* @param {string} [ease='power2.out'] - The GSAP ease function to use for the animation.
|
|
89
|
+
*/
|
|
90
|
+
animate(targetDistortion: number, targetVignetteOffset: number, targetVignetteDarkness: number, duration?: number, delay?: number, ease?: string): void;
|
|
91
|
+
/**
|
|
92
|
+
* @method setInputTexture
|
|
93
|
+
* @description Sets the input texture for post-processing
|
|
94
|
+
* @param {any} texture - The input texture (usually from a RenderTarget)
|
|
95
|
+
*/
|
|
96
|
+
setInputTexture(texture: Texture): void;
|
|
97
|
+
/**
|
|
98
|
+
* @method render
|
|
99
|
+
* @description Renders the post-processing effect to the specified target or screen
|
|
100
|
+
* @param {RenderTarget | null} target - The render target (null for screen)
|
|
101
|
+
*/
|
|
102
|
+
render(target?: RenderTarget | null): void;
|
|
103
|
+
/**
|
|
104
|
+
* @method resize
|
|
105
|
+
* @description Resizes the render target when the canvas size changes
|
|
106
|
+
* @param {number} width - New width
|
|
107
|
+
* @param {number} height - New height
|
|
108
|
+
*/
|
|
109
|
+
resize(width: number, height: number): void;
|
|
110
|
+
/**
|
|
111
|
+
* @method dispose
|
|
112
|
+
* @description Cleans up WebGL resources
|
|
113
|
+
*/
|
|
114
|
+
dispose(): void;
|
|
115
|
+
}
|
|
116
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Texture, Renderer } from 'ogl';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the data structure for a single card/tile
|
|
4
|
+
* This interface must match the CardData interface in InfiniteGridClass.ts
|
|
5
|
+
*/
|
|
6
|
+
interface CardData {
|
|
7
|
+
/** The main title text displayed prominently on the card */
|
|
8
|
+
title: string;
|
|
9
|
+
/** Badge text (currently not implemented in the rendering pipeline) */
|
|
10
|
+
badge: string;
|
|
11
|
+
/** Detailed description text for the card content (optional) */
|
|
12
|
+
description?: string;
|
|
13
|
+
/** Array of tag strings that will be displayed as styled pills */
|
|
14
|
+
tags: string[];
|
|
15
|
+
/** Date string displayed in the bottom-right corner */
|
|
16
|
+
date: string;
|
|
17
|
+
/** Optional image URL - falls back to '/photo.png' if not provided */
|
|
18
|
+
image?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Generates the foreground texture for a card using Canvas 2D API
|
|
22
|
+
*
|
|
23
|
+
* This function creates the main visible content of each card including:
|
|
24
|
+
* - Title text with automatic truncation and ellipsis
|
|
25
|
+
* - Main image with aspect ratio preservation and centering
|
|
26
|
+
* - Styled tag pills at the bottom
|
|
27
|
+
* - Date text in the bottom-right corner
|
|
28
|
+
* - Border outline around the entire card
|
|
29
|
+
*
|
|
30
|
+
* The generated texture is used for the front-facing mesh that users
|
|
31
|
+
* can interact with (hover and click).
|
|
32
|
+
*
|
|
33
|
+
* @param data - Card data containing title, image, tags, date, etc.
|
|
34
|
+
* @param renderer - OGL Renderer for texture creation
|
|
35
|
+
* @returns Promise resolving to an OGL Texture
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const cardData = {
|
|
40
|
+
* title: "Amazing Project",
|
|
41
|
+
* image: "/images/project.jpg",
|
|
42
|
+
* tags: ["web", "ogl"],
|
|
43
|
+
* date: "2024",
|
|
44
|
+
* badge: "NEW",
|
|
45
|
+
* description: "A cool project"
|
|
46
|
+
* };
|
|
47
|
+
* const texture = await generateForegroundTexture(cardData, renderer);
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function generateForegroundTexture(data: CardData, renderer: Renderer): Promise<Texture>;
|
|
51
|
+
/**
|
|
52
|
+
* Generates the background texture for a card using Canvas 2D API
|
|
53
|
+
*
|
|
54
|
+
* This function creates a blurred, darkened version of the card's image
|
|
55
|
+
* that serves as the background layer visible during hover effects.
|
|
56
|
+
* The background provides visual depth and context while maintaining
|
|
57
|
+
* readability of the foreground content.
|
|
58
|
+
*
|
|
59
|
+
* Processing steps:
|
|
60
|
+
* 1. Loads the same image used in the foreground
|
|
61
|
+
* 2. Scales it up for better blur coverage
|
|
62
|
+
* 3. Applies canvas blur filter
|
|
63
|
+
* 4. Adds a semi-transparent dark overlay
|
|
64
|
+
* 5. Falls back to solid color if image loading fails
|
|
65
|
+
*
|
|
66
|
+
* @param data - Card data containing the image URL
|
|
67
|
+
* @param renderer - OGL Renderer for texture creation
|
|
68
|
+
* @returns Promise resolving to an OGL Texture for background layer
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* const backgroundTexture = await generateBackgroundTexture(cardData, renderer);
|
|
73
|
+
* // Use this texture for the background mesh with shader material
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function generateBackgroundTexture(data: CardData, renderer: Renderer): Promise<Texture>;
|
|
77
|
+
/**
|
|
78
|
+
* Convenience function to generate both foreground and background textures
|
|
79
|
+
*
|
|
80
|
+
* This function generates both texture types in parallel for efficiency.
|
|
81
|
+
* While the individual generation functions are typically used separately
|
|
82
|
+
* in the main grid system, this function can be useful for testing or
|
|
83
|
+
* simpler use cases.
|
|
84
|
+
*
|
|
85
|
+
* @param data - Card data for texture generation
|
|
86
|
+
* @param renderer - OGL Renderer for texture creation
|
|
87
|
+
* @returns Promise resolving to an object with both texture types
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const { foreground, background } = await generateCardTextures(cardData, renderer);
|
|
92
|
+
* // Use foreground for main mesh, background for hover effect
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
export declare function generateCardTextures(data: CardData, renderer: Renderer): Promise<{
|
|
96
|
+
foreground: Texture;
|
|
97
|
+
background: Texture;
|
|
98
|
+
}>;
|
|
99
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const gaussianBlurFragmentShader = "precision highp float;\n\nuniform sampler2D map;\n// uniform float blurAmount; // Removed: Blur amount is now fixed\nuniform vec2 resolution;\nuniform float uOpacity; // New uniform for controlling opacity from JS\n\nvarying vec2 vUv;\n\nvoid main() {\n vec2 onePixel = vec2(1.0, 1.0) / resolution;\n\n // Fixed blur amount directly in the shader\n float fixedBlurAmount = 10.0; // Changed to a fixed value as requested\n\n vec4 sum = vec4(0.0);\n\n sum += texture2D(map, vUv + onePixel * vec2(-1.0, -1.0) * fixedBlurAmount) * 0.0625;\n sum += texture2D(map, vUv + onePixel * vec2( 0.0, -1.0) * fixedBlurAmount) * 0.125;\n sum += texture2D(map, vUv + onePixel * vec2( 1.0, -1.0) * fixedBlurAmount) * 0.0625;\n sum += texture2D(map, vUv + onePixel * vec2(-1.0, 0.0) * fixedBlurAmount) * 0.125;\n sum += texture2D(map, vUv + onePixel * vec2( 0.0, 0.0) * fixedBlurAmount) * 0.25;\n sum += texture2D(map, vUv + onePixel * vec2( 1.0, 0.0) * fixedBlurAmount) * 0.125;\n sum += texture2D(map, vUv + onePixel * vec2(-1.0, 1.0) * fixedBlurAmount) * 0.0625;\n sum += texture2D(map, vUv + onePixel * vec2( 0.0, 1.0) * fixedBlurAmount) * 0.125;\n sum += texture2D(map, vUv + onePixel * vec2( 1.0, 1.0) * fixedBlurAmount) * 0.0625;\n\n // Apply the opacity uniform to the alpha channel of the final color\n gl_FragColor = vec4(sum.rgb, sum.a * uOpacity); // sum.a is usually 1.0 from texture, so multiply by uOpacity\n}";
|
|
2
|
+
export declare const gaussianBlurVertexShader = "\n attribute vec2 uv;\n attribute vec3 position;\n \n uniform mat4 modelViewMatrix;\n uniform mat4 projectionMatrix;\n \n varying vec2 vUv;\n \n void main() {\n // Flip UV coordinates 180 degrees (both X and Y)\n vUv = vec2(uv.x, 1.0 - uv.y);\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n";
|
|
3
|
+
export declare const postProcessFragmentShader = "precision highp float;\n\nuniform sampler2D tDiffuse;\nuniform vec2 distortion;\nuniform float vignetteOffset;\nuniform float vignetteDarkness;\n\nvarying vec2 vUv;\n\nvoid main() {\n vec2 shiftedUv = 2.0 * (vUv - 0.5);\n float distanceToCenter = length(shiftedUv);\n\n // Lens distortion effect\n // NOTE: The original shader had 'distortion * dot(shiftedUv)'.\n // If distortion is a vec2, dot product will result in a scalar.\n // If you intend distortion to scale both X and Y independently based on distance,\n // you might need something like: shiftedUv *= (0.88 + distortion.x * abs(shiftedUv.x) + distortion.y * abs(shiftedUv.y));\n // For now, I'll keep the dot product as it was in your provided shader,\n // which applies uniform distortion based on radial distance.\n shiftedUv *= (0.88 + distortion.x * dot(shiftedUv, shiftedUv)); // Assuming distortion.x controls the scalar distortion factor\n vec2 transformedUv = shiftedUv * 0.5 + 0.5;\n\n // Vignette effect\n // Corrected 'vignetteOffset * 0.799' and '(vignetteDarkness + vignetteOffset)' if that was the intent.\n // The second parameter to smoothstep is the \"edge\" where it starts.\n // I'll interpret your intent as scaling the effect based on a combined factor.\n float vignetteIntensity = smoothstep(vignetteOffset, vignetteDarkness, distanceToCenter); // Simplified as common vignette\n // If your original intention for vignette was 'smoothstep(0.8, vignetteOffset * 0.799, (vignetteDarkness + vignetteOffset) * distanceToCenter);'\n // this would be a more complex interaction. Let's start with a standard vignette.\n\n // Sample render texture and output fragment\n vec3 color = texture2D(tDiffuse, transformedUv).rgb * (1.0 - vignetteIntensity); // Apply darkening based on intensity\n // The original '* vignetteIntensity' would brighten. Vignettes usually darken.\n // If you want a more subtle darkening, adjust the '(1.0 - vignetteIntensity)''.\n gl_FragColor = vec4(color, 1.);\n}";
|
|
4
|
+
export declare const postProcessVertexShader = "\nattribute vec2 uv;\nattribute vec3 position;\n\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\n\nvarying vec2 vUv;\n\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}";
|