Saturday, May 24, 2025
News PouroverAI
Visit PourOver.AI
No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
News PouroverAI
No Result
View All Result

On-Scroll Revealing WebGL Images | Codrops

February 7, 2024
in Front-Tech
Reading Time: 2 mins read
0 0
A A
0
Share on FacebookShare on Twitter



Having objects appear on scroll is a common feature in web development. However, the options in HTML are limited. To add some excitement, you can incorporate WebGL effects. Let’s start with a simple PlaneGeometry object with a ShaderMaterial. This combination offers various possibilities. You can explore pixelated effects by rounding the UVs to the nearest pixel. To achieve this effect, you can use the following code:

“`html
vec2 uv = floor(vUv * 10.0) / 10.0;
“`

By sampling the texture with these UVs, you will get the pixelated effect. To highlight the effect, you can add borders to each pixel. Keep in mind that if the image is not a square, the pixels won’t be squares either. To solve this, you can use the following code:

“`html
vec2 gridSize = vec2(20., floor(20./ASPECT_RATIO));
vec2 uv = floor(vUv * gridSize) / gridSize;
“`

Next, you can add a background curtain and a changing amount of pixillation for additional effects. To connect HTML and the WebGL effect, you can use React Three Fiber and its Drei library, which provides a `` component. This component allows you to insert parts of your 3D scene into your HTML. You can control these objects using native HTML events. Here is an example:

“`html

Html content here







// this is where our Views will be in 3D world


“`

To animate the objects on scroll, you can use the native IntersectionObserver API along with GSAP, a popular animation library. The useGSAP hook provided by GSAP allows you to trigger animations based on the isIntersecting parameter from IntersectionObserver. Here is an example:

“`html
import { useGSAP } from “@gsap/react”;
import gsap from “gsap”;
…
useGSAP(() => {
gsap.to(material, { uProgress: isIntersecting ? 1 : 0, duration: 1.5 });
}, [isIntersecting]);
“`

To synchronize the scrolling between HTML and WebGL, you need to use a custom scroll solution like Lenis or Locomotive scroll. In this example, Lenis is used as a global effect inside React Three Fiber:

“`html
import { addEffect } from “@react-three/fiber”;
import Lenis from “@studio-freight/lenis”;
const lenis = new Lenis();
addEffect((t) => lenis.raf(t));
“`

Finally, it’s important to note that HTML and WebGL are separate worlds. Although they can be mixed declaratively, certain React Three Fiber hooks may not work with `` components. Keep this in mind when developing your integration. Despite the complexities involved, React simplifies the integration process. Consider using React for animated scrollable landings when the integration is straightforward.



Source link

Tags: CodropsImageson-scroll webgl effectOnScrollreact three fiberRevealingthree.jswebglwebgl image effect
Previous Post

Skyline Digital makes TradFi accessible on Web3 – Blockchain News, Opinion, TV and Jobs

Next Post

Ondo Finance Brings Real-World Assets and Yield-Bearing Stablecoin-Alternative, USDY, to Sui – Blockchain News, Opinion, TV and Jobs

Related Posts

The essential principles of a good homepage
Front-Tech

The essential principles of a good homepage

June 7, 2024
How to measure and improve user retention
Front-Tech

How to measure and improve user retention

June 6, 2024
Push Animation on Grid Items
Front-Tech

Push Animation on Grid Items

June 5, 2024
How to build a Rails API with rate limiting
Front-Tech

How to build a Rails API with rate limiting

June 4, 2024
Introduction to the B.I.A.S. framework
Front-Tech

Introduction to the B.I.A.S. framework

June 3, 2024
Blue Ridge Ruby is exactly what we need
Front-Tech

Blue Ridge Ruby is exactly what we need

June 3, 2024
Next Post
Ondo Finance Brings Real-World Assets and Yield-Bearing Stablecoin-Alternative, USDY, to Sui – Blockchain News, Opinion, TV and Jobs

Ondo Finance Brings Real-World Assets and Yield-Bearing Stablecoin-Alternative, USDY, to Sui – Blockchain News, Opinion, TV and Jobs

Enphase Energy upgraded to outperform by Oppenheimer By Investing.com

Enphase Energy upgraded to outperform by Oppenheimer By Investing.com

Coinbase-Backed DeSo SocialFi App Focus Raises $75 Million in One Week – Blockchain News, Opinion, TV and Jobs

Coinbase-Backed DeSo SocialFi App Focus Raises $75 Million in One Week – Blockchain News, Opinion, TV and Jobs

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Trending
  • Comments
  • Latest
Is C.AI Down? Here Is What To Do Now

Is C.AI Down? Here Is What To Do Now

January 10, 2024
23 Plagiarism Facts and Statistics to Analyze Latest Trends

23 Plagiarism Facts and Statistics to Analyze Latest Trends

June 4, 2024
A faster, better way to prevent an AI chatbot from giving toxic responses | MIT News

A faster, better way to prevent an AI chatbot from giving toxic responses | MIT News

April 10, 2024
Porfo: Revolutionizing the Crypto Wallet Landscape

Porfo: Revolutionizing the Crypto Wallet Landscape

October 9, 2023
NousResearch Released Nous-Hermes-2-Mixtral-8x7B: An Open-Source LLM with SFT and DPO Versions

NousResearch Released Nous-Hermes-2-Mixtral-8x7B: An Open-Source LLM with SFT and DPO Versions

January 25, 2024
Reshoring manufacturing to the US: The role of AI, automation and digital labor

Reshoring manufacturing to the US: The role of AI, automation and digital labor

December 21, 2023
Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

June 10, 2024
AI Compared: Which Assistant Is the Best?

AI Compared: Which Assistant Is the Best?

June 10, 2024
How insurance companies can use synthetic data to fight bias

How insurance companies can use synthetic data to fight bias

June 10, 2024
5 SLA metrics you should be monitoring

5 SLA metrics you should be monitoring

June 10, 2024
From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

June 10, 2024
UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

June 10, 2024
Facebook Twitter LinkedIn Pinterest RSS
News PouroverAI

The latest news and updates about the AI Technology and Latest Tech Updates around the world... PouroverAI keeps you in the loop.

CATEGORIES

  • AI Technology
  • Automation
  • Blockchain
  • Business
  • Cloud & Programming
  • Data Science & ML
  • Digital Marketing
  • Front-Tech
  • Uncategorized

SITEMAP

  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2023 PouroverAI News.
PouroverAI News

No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing

Copyright © 2023 PouroverAI News.
PouroverAI News

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In