Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/arturbien/3d-image

🏄 3D images on your website (just like those on Facebook!)
https://github.com/arturbien/3d-image

Last synced: 2 months ago
JSON representation

🏄 3D images on your website (just like those on Facebook!)

Awesome Lists containing this project

README

        

# 🏄 3D-image


NPM
3d-image version
R3d-image license

![car](https://user-images.githubusercontent.com/28541613/61730278-57f78c80-ad79-11e9-826e-71198a75025c.gif)

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"](https://www.youtube.com/watch?time_continue=30&v=ulsqCFMCajY) 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](https://www.youtube.com/watch?v=eeU5mUASnVI):

![car1](https://user-images.githubusercontent.com/28541613/61730337-73fb2e00-ad79-11e9-8242-fdd093e39f28.jpg)

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

```html


```

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

var car = document.getElementById("car");
image3D.process(car);

```
### 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](https://tympanus.net/codrops/2019/02/20/how-to-create-a-fake-3d-image-effect-with-webgl/) and [Keilyn Nunez](https://codepen.io/keilyn3d/full/KLVxZM).**