0.0.6 • Published 5 months ago

oglimage v0.0.6

Weekly downloads
-
License
-
Repository
-
Last release
5 months ago

Image-OGL

⚠️ BETA ⚠️

oglimage is a concise JavaScript library based on OGL, enabling the conversion of DOM images into flat 3D images on a WebGL canvas.

Install


npm i oglimage

Basic setup


import Experience from "oglimage"

const experience = new Experience()

const myImage = document.querySelector(".my-image")

experience.addImage(myImage)

Instance setting


OptionTypeDefaultDescription
containerHTMLElementdocument.bodySpecifies the DOM element for the canvas.
alphabooleantrueEnables canvas transparency.
antialiasbooleantrueToggles antialiasing for smoother rendering.
dprnumberMath.min(window.devicePixelRatio, 2)Sets the device pixel ratio for the canvas.
scrollobjectfalse → browser scrollChange the current value to your own scroll

Instance Method: addImage(image, options)

OptionTypeDescription
imageHTMLImageElement or nullThe image to be transformed into a WebGL-renderable format.
optionsObjectConfiguration options for the transformation.
vertex (optional)Custom vertex shader.
fragment (optional)Custom fragment shader.
uniforms (optional)A function that returns custom uniforms.

Example

// ...
experience.addImage(myImage, {
    vertex: vertex,
    fragment: fragment,
    uniformes: {
      uStrength: { value: 0.5 },  
    }
})
0.0.5

5 months ago

0.0.6

5 months ago

0.0.4

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago