Skip to content

arturbien/3D-image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

36 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ„ 3D-image

NPM 3d-image version R3d-image license

car

Small (2.5kB gzipped), dependency-free library for creating 3D image effect on your website ( just like on Facebook! ).

  • reacts to mouse move / mobile device movement! ๐Ÿคณ (in iOS Safari "motion & orientation access" has to be enabled)
  • based on WebGL shaders
  • uses IntersectionObserver to animate only the images that are currently in the viewport

How to use

First, you need 2 images: original image, and depth image:

car1

Then, prepare image slot with data-src and data-depth-src attributes containing paths to those images:

<div id="car" data-src="path to original image" data-depth-src="path to depth image"></div>

Finally, add 3D-image library and run it like so:

<script src="https://unpkg.com/3d-image"></script>
<script>
    var car = document.getElementById("car");
    image3D.process(car);
</script>

That's it! ๐Ÿฅค

Disclaimer: this library is a work-in-progress, so the API will likely change. There will be more options added like:

  • increasing and decreasing 3D effect strength
  • reacting to scroll events for devices not supporting DeviceOrientation API

Based on the work of Yuriy Artyukh and Keilyn Nunez.

About

๐Ÿ„ 3D images on your website (just like those on Facebook!)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published