• Stars
    star
    10,327
  • Rank 3,348 (Top 0.07 %)
  • Language
    JavaScript
  • Created over 5 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Flat, round, designer-friendly pseudo-3D engine for canvas & SVG

Zdog

Round, flat, designer-friendly pseudo-3D engine

View complete documentation and live demos at zzz.dog.

Install

Download

CDN

Link directly to Zdog JS on unpkg.

<script src="https://unpkg.com/zdog@1/dist/zdog.dist.min.js"></script>

Package managers

npm: npm install zdog

Bower: bower install zdog

Hello world demo

Create 3D models with Zdog by adding shapes. See Getting started for a walk-through of this demo.

let isSpinning = true;

let illo = new Zdog.Illustration({
  element: '.zdog-canvas',
  zoom: 4,
  dragRotate: true,
  // stop spinning when drag starts
  onDragStart: function() {
    isSpinning = false;
  },
});

// circle
new Zdog.Ellipse({
  addTo: illo,
  diameter: 20,
  translate: { z: 10 },
  stroke: 5,
  color: '#636',
});

// square
new Zdog.Rect({
  addTo: illo,
  width: 20,
  height: 20,
  translate: { z: -10 },
  stroke: 3,
  color: '#E62',
  fill: true,
});

function animate() {
  illo.rotate.y += isSpinning ? 0.03 : 0;
  illo.updateRenderGraph();
  requestAnimationFrame( animate );
}
animate();

About Zdog

Hi, Dave here. I wanted to make a video game. I needed a 3D engine, but most engines were too powerful and complex for me. I made Zdog so I could design and display simple 3D models without a lot of overhead.

Zdog is directly inspired by Dogz, a virtual pet game by P.F. Magic released in 1995. It used flat 2D circle sprites to render the Dogz’ models, but in a 3D scene. See Dogz playthrough video here. Dogz were fully animated in real time, running, flopping, scratching (on Windows 3.1!). It was remarkable.

Zdog uses the same principle. It renders all shapes using the 2D drawing APIs in either <canvas> or <svg>. Spheres are actually dots. Toruses are actually circles. Capsules are actually thick lines. It’s a simple, but effective trick. The underlying 3D math comes from Rotating 3D Shapes by Peter Collingridge.

Zdog is pronounced "Zee-dog" in American parlance or "Zed-dog" in British.

Beta!

Zdog v1 is a beta-release, of sorts. This is my first time creating a 3D engine, so I probably got some stuff wrong. Expect lots of changes for v2. Provide input and select new features on the Zdog issue tracker on GitHub.

More Zdog resources

Other people's stuff:

My stuff:


Licensed MIT. Made by Metafizzy 🌈🐻

More Repositories

1

isotope

πŸ’ž Filter & sort magical layouts
HTML
11,040
star
2

flickity

πŸƒ Touch, responsive, flickable carousels
JavaScript
7,511
star
3

infinite-scroll

πŸ“œ Automatically add next page
HTML
7,407
star
4

packery

🍱 Gapless, draggable grid layouts
JavaScript
4,128
star
5

huebee

🐝 1-click color picker
JavaScript
402
star
6

outlayer

πŸ‘· the brains & guts of a layout library
JavaScript
163
star
7

unidragger

πŸ‘‡ Draggable base class
JavaScript
82
star
8

ev-emitter

πŸ”” Lil' event emitter
JavaScript
65
star
9

flickity-fade

Fade between Flickity slides
JavaScript
62
star
10

zdog-demos

Round, flat, designer friendly demos for Zdog
Makefile
57
star
11

fizzy-ui-utils

UI utilities & helpers
JavaScript
46
star
12

flickity-fullscreen

Enable fullscreen view for Flickity carousels
HTML
46
star
13

tap-listener

Listens to taps
JavaScript
42
star
14

isotope-packery

packery layout mode for Isotope
JavaScript
42
star
15

flickity-bg-lazyload

Flickity lazyload background images
HTML
31
star
16

flickity-as-nav-for

Enable asNavFor for Flickity
HTML
30
star
17

flickity-sync

Sync up two Flickity carousels
HTML
29
star
18

metafizzy.co

🐻 Metafizzy site!
Handlebars
29
star
19

flickity-docs

πŸ“ documentation for Flickity
Handlebars
28
star
20

unipointer

☝️ Do one thing with one pointer
JavaScript
27
star
21

flickity-imagesloaded

enables imagesLoaded option for Flickity
JavaScript
19
star
22

zdog-docs

Documentation site for Zdog
Handlebars
19
star
23

fizzy.school

πŸŽƒ Lessons for anyone writing jQuery
HTML
17
star
24

logo.pizza

πŸ• Logo Pizza site
JavaScript
16
star
25

next-project

Help us decide what to build next
16
star
26

isotope-docs

πŸ“ documentation for Isotope
Handlebars
13
star
27

isotope-masonry-horizontal

masonryHorizontal layout mode for Isotope
HTML
13
star
28

droppabilly

Drag and drop
JavaScript
11
star
29

flickity-hash

Select Flickity slides with links
HTML
11
star
30

packery-docs

πŸ“ Documentation for Packery
HTML
9
star
31

isotope-horizontal

horizontal layout mode for Isotope
JavaScript
8
star
32

isotope-fit-columns

fitColumns layout mode for Isotope
JavaScript
7
star
33

eslint-plugin-metafizzy

ESLint config and rules for Metafizzy
JavaScript
3
star
34

transfob

get a transform stream, like through2.obj()
JavaScript
3
star
35

isotope-cells-by-column

cellsByColumn layout mode for Isotope
JavaScript
3
star
36

flickity-dev

Little demos made in development of Flickity
JavaScript
3
star
37

fizzy-docs-modules

Modules used in Metafizzy documentation sites
Handlebars
3
star
38

isotope-cells-by-row

cellsByRow layout mode for Isotope
JavaScript
2
star
39

huebee-docs

Huebee documentation
Handlebars
2
star
40

infinite-scroll-docs

πŸ“ Documentation for Infinite Scroll
Handlebars
2
star
41

grunt-fizzy-docs

Grunt tasks for Masonry, Isotope, and Packery docs
JavaScript
2
star