npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wg-displacement

v1.0.1

Published

Webgl image displacement

Downloads

2

Readme

Generate displacement effect

Usage

To use this module, simply create a new Scene instance with your desired configuration. Here's an example of how to initialize a scene with a custom image and displacement effect, including a GUI for real-time adjustments:

new Scene({
  el: '.scene__1',
  image: './img/face3.png',
  displacement: './img/ai3.png',
  GUI: true,
})

Configuration Options

  • el: A string selector that matches the DOM element where the scene will be rendered.
  • image: The path to the main image file you want to apply the shader effect to.
  • displacement: The path to the displacement image that will drive the shader effect.
  • GUI: A boolean to enable or disable the lil-gui interface for real-time effect tweaking.

Integrating wg-displacement into Framer

Step 1: Install the Package

First, you need to add wg-displacement to your Framer project. Open your project's directory in the terminal, and run:

npm install wg-displacement

This command adds the wg-displacement package to your project, making the Scene module available for use.

Step 2: Create a New Code Component

Framer allows you to create custom code components that you can use alongside the visual design tools. To create a new code component:

  1. Open your Framer project.
  2. Navigate to the "Code" tab on the left sidebar.
  3. Click the "+" button to create a new code file. Name it appropriately (e.g., CustomScene.tsx for a TypeScript project or CustomScene.jsx for JavaScript).

Step 3: Use the Scene Module in Your Component

In the code component file you just created, import the Scene module from the wg-displacement package and set it up according to your needs. Below is a sample implementation:

import * as React from 'react'
import Scene from 'wg-displacement'

export default class CustomScene extends React.Component {
  componentDidMount() {
    // Assuming you have a div in your Framer project with the class 'scene__1'
    // You might need to adjust the selector based on your actual setup
    new Scene({
      el: '.scene__1',
      image: './path/to/your/image.png', // Adjust the path to your image
      displacement: './path/to/your/displacement/image.png', // Adjust the path to your displacement image
      GUI: false,
    })
  }

  render() {
    // Render a container for your scene. Adjust the className as needed.
    return (
      <div className="scene__1">
        <canvas></canvas>
      </div>
    )
  }
}

Step 4: Add Your Component to the Canvas

Drag your new code component from the "Code" tab onto the Framer canvas. Adjust its size and position as needed.

Configuration Options

Remember, the Scene module accepts several options for customization:

  • el: A string selector that matches the DOM element where the scene will be rendered.
  • image: The path to the main image file you want to apply the shader effect to.
  • displacement: The path to the displacement image that will drive the shader effect.
  • GUI: A boolean to enable or disable the lil-gui interface for real-time effect tweaking.

Notes

  • Ensure the images and other assets used by the Scene component are accessible within your Framer project's public directory or hosted online.
  • Adjust the paths to your images and displacement maps according to where they are stored.

By following these steps, you can seamlessly integrate custom WebGL shaders created with the wg-displacement module into your Framer prototypes, enhancing your designs with dynamic, interactive elements.