All Projects → pschroen → Alien.js

pschroen / Alien.js

Licence: mit
Future web pattern

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Alien.js

Taro
A lightweight 3D game engine for the web.
Stars: ✭ 345 (+144.68%)
Mutual labels:  3d, webgl, svg, webaudio, html5, canvas
Three.js
JavaScript 3D Library.
Stars: ✭ 78,237 (+55387.23%)
Mutual labels:  3d, webgl, svg, webaudio, html5, canvas
Wechart
Create all the [ch]arts by cax or three.js - Cax 和 three.js 创造一切图[表]
Stars: ✭ 152 (+7.8%)
Mutual labels:  3d, webgl, svg, html5, canvas
Melonjs
a fresh & lightweight javascript game engine
Stars: ✭ 3,721 (+2539.01%)
Mutual labels:  webgl, webaudio, html5, canvas
Earthjs
D3 Earth JS
Stars: ✭ 128 (-9.22%)
Mutual labels:  3d, webgl, svg, canvas
Hilo3d
Hilo3d, a WebGL Rendering Engine.
Stars: ✭ 123 (-12.77%)
Mutual labels:  3d, webgl, html5, canvas
Layaair discard
This is old LayaAir veriosn writetten by ActionScript 3.0 ,now LayaAir is using TypeScript as the Engine Script,Please use https://github.com/layabox/LayaAir instead.
Stars: ✭ 1,858 (+1217.73%)
Mutual labels:  3d, webgl, html5, canvas
Dynamic effect
平时练习的一些前端动效,基于HTML5,CSS3,Canvas,Svg
Stars: ✭ 264 (+87.23%)
Mutual labels:  3d, html5, canvas, css3
Curtainsjs
curtains.js is a lightweight vanilla WebGL javascript library that turns HTML DOM elements into interactive textured planes.
Stars: ✭ 1,039 (+636.88%)
Mutual labels:  3d, webgl, html5, canvas
Xsound
Web Audio API Library for Synthesizer, Effects, Visualization, Multi-Track Recording, Audio Streaming, Visual Audio Sprite ...
Stars: ✭ 123 (-12.77%)
Mutual labels:  svg, webaudio, canvas
Zrender
A lightweight graphic library providing 2d draw for Apache ECharts
Stars: ✭ 5,122 (+3532.62%)
Mutual labels:  svg, html5, canvas
Zfont
💬 Text plugin for Zdog - works with any .ttf font!
Stars: ✭ 126 (-10.64%)
Mutual labels:  3d, svg, canvas
Html5
HTML5学习、总结、实践
Stars: ✭ 493 (+249.65%)
Mutual labels:  html5, canvas, css3
Spritejs
A cross platform high-performance graphics system.
Stars: ✭ 4,712 (+3241.84%)
Mutual labels:  3d, webgl, canvas
People You Should Follow On Codepen
People You Should Follow on CodePen
Stars: ✭ 542 (+284.4%)
Mutual labels:  webgl, svg, canvas
React Force Graph
React component for 2D, 3D, VR and AR force directed graphs
Stars: ✭ 589 (+317.73%)
Mutual labels:  3d, webgl, canvas
Webworldwind
The NASA WorldWind Javascript SDK (WebWW) includes the library and examples for creating geo-browser web applications and for embedding a 3D globe in HTML5 web pages.
Stars: ✭ 628 (+345.39%)
Mutual labels:  3d, webgl, html5
Phaser3 Docs
Phaser 3 Documentation and TypeScript Defs
Stars: ✭ 339 (+140.43%)
Mutual labels:  webgl, html5, canvas
Zdog
Flat, round, designer-friendly pseudo-3D engine for canvas & SVG
Stars: ✭ 8,904 (+6214.89%)
Mutual labels:  3d, svg, canvas
Deep Viz
A React component library, providing concise and beautiful diversity charts with Canvas, SVG, E-map, WebGL, Dom, based on data visualization experience and commercial data display practice.
Stars: ✭ 55 (-60.99%)
Mutual labels:  webgl, svg, canvas

Alien.js

Alien.js

NPM Package Build Status Dependencies Dev Dependencies

Future web pattern


Alien.js is a design pattern and project structure for building SPA websites with ES modules and GSAP.

The idea is to keep it simple, with minimal abstraction, and to build websites more like a framework, which is why Rollup is used instead for bundling.

In its design, everything is an ES module, all user interfaces and components follow the same class structure, making it easy to copy-paste from examples and between projects.

Note this design pattern intentionally does not use underscores or private fields, in favour of cleaner code.

Examples

ui

logo
logo (interface)
tilt
ufo

3d

ripple
physics
audio
audio (fast)
spherical cube
penrose triangle
polyhedron (orbit camera, debug)
camera wobble
camera shake

shader

noise
fxaa
blur (Gaussian blur)
blur (Poisson disc blur)
blur (Bokeh blur)
bloom
bloom (Unreal bloom)
bloom (Unreal bloom with dither)
matcap
pbr
soft particles
dof (fake with Bokeh blur, debug)
chromatic aberration
film grain
reflection (with fast Gaussian blur)
flowmap
flowmap (RGB shift)
flowmap (view)
depth (fragment depth with dither)
hologram
text (MSDF text)
alienkitty (flowmap with RGB shift, MSDF text)

thread

canvas (noise)
physics
audio
audio (fast)
polyhedron (OBJ loader thread)
camera shake
pbr (texture loader thread)


Class structure

import gsap from 'gsap';

export class Logo {
    constructor() {
        this.element;
        this.image;

        this.initHTML();

        this.addListeners();
        this.onResize();
    }

    initHTML() {
        this.element = document.createElement('div');
        this.element.classList.add('logo');
        gsap.set(this.element, {
            top: 50,
            left: 50,
            width: 64,
            height: 64,
            cursor: 'pointer',
            opacity: 0
        });

        this.image = document.createElement('img');
        this.image.src = 'assets/images/alienkitty.svg';
        gsap.set(this.image, {
            position: 'relative',
            width: '100%'
        });
        this.element.appendChild(this.image);
    }

    addListeners() {
        window.addEventListener('resize', this.onResize);
        window.addEventListener('orientationchange', this.onResize);
        this.element.addEventListener('mouseenter', this.onHover);
        this.element.addEventListener('mouseleave', this.onHover);
        this.element.addEventListener('click', this.onClick);
    }

    removeListeners() {
        window.removeEventListener('resize', this.onResize);
        window.removeEventListener('orientationchange', this.onResize);
        this.element.removeEventListener('mouseenter', this.onHover);
        this.element.removeEventListener('mouseleave', this.onHover);
        this.element.removeEventListener('click', this.onClick);
    }

    /**
     * Event handlers
     */

    onResize = () => {
        if (window.innerWidth < window.innerHeight) {
            gsap.set(this.element, {
                top: 30,
                left: 30,
                width: 40,
                height: 40
            });
        } else {
            gsap.set(this.element, {
                top: 50,
                left: 50,
                width: 64,
                height: 64
            });
        }
    };

    onHover = ({ type }) => {
        if (type === 'mouseenter') {
            gsap.to(this.element, { opacity: 0.6, duration: 0.3, ease: 'power2.out' });
        } else {
            gsap.to(this.element, { opacity: 1, duration: 0.3, ease: 'power2.out' });
        }
    };

    onClick = () => {
        open('https://alien.js.org/');
    };

    /**
     * Public methods
     */

    animateIn = () => {
        gsap.to(this.element, { opacity: 1, duration: 0.6, ease: 'sine.inOut' });
    };

    destroy = () => {
        this.element.parentNode.removeChild(this.element);

        this.removeListeners();

        this.element = null;
        this.image = null;

        return null;
    };
}

Class hierarchy

Preloader
    \
     '--- PreloaderView
      \
       '- App
              \
               '----- World ---.
                \               \
                 '--- Views -----.
                  \               \
                   '- Controllers -.

Project structure

public
│
├── assets
│   │
│   ├── css
│   │   │
│   │   └── style.css
│   │
│   ├── data
│   │   │
│   │   └── data.json
│   │
│   ├── images
│   │
│   ├── js
│   │   │
│   │   ├── loader.js
│   │   └── main.js
│   │
│   ├── meta
│   │   │
│   │   └── share.png
│   │
│   └── textures
│
├── favicon.ico
└── index.html

src
│
├── config
│   │
│   ├── Config.js
│   ├── Device.js
│   ├── Events.js
│   └── Global.js
│
├── controllers
│   │
│   ├── audio
│   │   │
│   │   └── AudioController.js
│   │
│   ├── world
│   │   │
│   │   ├── CameraController.js
│   │   ├── InputManager.js
│   │   ├── RenderManager.js
│   │   ├── SceneController.js
│   │   └── WorldController.js
│   │
│   ├── App.js
│   ├── Preloader.js
│   └── Stage.js
│
├── data
│   │
│   ├── Data.js
│   ├── Geo.js
│   └── Socket.js
│
├── lib
│   │
│   └── CustomEase.js
│
├── partials
│   │
│   ├── icons
│   │   │
│   │   ├── arrow.svg.js
│   │   └── close.svg.js
│   │
│   └── Icons.js
│
├── loaders
│   │
│   ├── world
│   │   │
│   │   ├── EnvironmentTextureLoader.js
│   │   ├── OBJLoaderThread.js
│   │   ├── SphericalCubeTextureLoader.js
│   │   ├── SpherizeTextureLoader.js
│   │   ├── TextGeometryLoader.js
│   │   ├── TextGeometryLoaderThread.js
│   │   └── TextureLoader.js
│   │
│   ├── AssetLoader.js
│   ├── Assets.js
│   ├── FontLoader.js
│   ├── ImageBitmapLoader.js
│   ├── ImageBitmapLoaderThread.js
│   ├── Loader.js
│   └── MultiLoader.js
│
├── materials
│   │
│   ├── BasicMaterial.js
│   └── FXAAMaterial.js
│
├── shaders
│   │
│   ├── modules
│   │   │
│   │   └── noise
│   │      │
│   │      └── simplex2d.glsl.js
│   │
│   ├── BasicMaterial.frag.js
│   ├── BasicMaterial.vert.js
│   ├── FXAAPass.frag.js
│   └── FXAAPass.vert.js
│
├── utils
│   │
│   ├── audio
│   │   │
│   │   ├── Sound.js
│   │   ├── Sound3D.js
│   │   ├── WebAudio.js
│   │   ├── WebAudio3D.js
│   │   └── WebAudioParam.js
│   │
│   ├── world
│   │   │
│   │   ├── Flowmap.js
│   │   ├── Reflector.js
│   │   ├── SpherizeImage.js
│   │   ├── TextGeometry.js
│   │   ├── Utils3D.js
│   │   └── Wobble.js
│   │
│   ├── Cluster.js
│   ├── Component.js
│   ├── EventEmitter.js
│   ├── Interface.js
│   ├── LinkedList.js
│   ├── ObjectPool.js
│   ├── Thread.js
│   ├── Tween.js
│   └── Utils.js
│
├── views
│   │
│   ├── LandingView.js
│   ├── PreloaderView.js
│   └── SceneView.js
│
└── main.js

Code-splitting

public
│
└── assets
    │
    └── js
        │
        ├── loader.js (~90kb with GSAP)
        └── main.js (~700kb with three.js)

Multithreading

App (main thread)
│
└── Thread (instance thread)
    │
    ├── shared (navigator.hardwareConcurrency)
    │
    └── events
        │
        ├── on
        ├── off
        └── send

Getting started

Clone this repository template and install its dependencies:

git clone https://github.com/pschroen/alien.js
cd alien.js
npm i

# or
npx degit pschroen/alien.js my-app
cd my-app
npm i
# Serve at localhost:8080
npm run dev

# Build for production
npm run build

With three.js

Uncomment all the lines in App.js and install three:

npm i && npm i three
npm run dev

With examples

npm i && npm i three
cd examples
npm i
npm run build
npm start

Resources

See also

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].