Giter VIP home page Giter VIP logo

pagehammer's Introduction

Smash

Smash is a breakable web page.

Running Smash locally

Clone the repo, and run npm i && npm start to start the development server. It's built with Snowpack so all the usual snowpack things work.

How Smash works

Smash uses Delaunator to create a mesh of triangles, and then it uses matter.js to simulate how the triangles would fall apart under the influence of gravity.

The lifecycle of the page is as follows;

  • The page loads and index.js runs

  • index.js creates a set of points that represent the edges of the page with some additional random points spread out across the viewport.

  • Delaunator takes these points and creates a mesh of triangles to connect them all

  • For each triangle the base div is cloned and injected in to the page body, and the div is clipped to the triangle using clip-path.

  • A matching triangle is also created in the matter.js world.

  • When the user clicks the "Smash" button the physics engine is started.

  • On each tick of the physics engine the triangle polygons move, and their position and rotation data is converted to a CSS tranform that's applied to the corresponding triangle in the page.

  • Everything falls apart.

Contributing

PRs are welcome, especially for performance fixes.

pagehammer's People

Contributors

onion2k avatar

Stargazers

 avatar Vishal Manwani avatar

Watchers

James Cloos avatar

Forkers

boyquotes

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.