explaingit

metafizzy/zdog

10,620JavaScriptAudience · designerComplexity · 2/5LicenseSetup · easy

TLDR

A small JavaScript library for drawing cartoon-style 3D graphics on a web page using flat 2D shapes, no heavy 3D engine needed, just a script tag and a few lines of code.

Mindmap

mindmap
  root((Zdog))
    What it does
      Flat 2D shapes as 3D
      Canvas and SVG output
      Drag to rotate
    Shapes available
      Circles and boxes
      Cones and cylinders
    Use cases
      Decorative illustrations
      Interactive 3D logos
      Animated UI elements
    Setup
      CDN script tag
      Or npm install
    Tech
      JavaScript
      Canvas API
      SVG
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Add a spinning 3D logo or decorative illustration to a website landing page with minimal code.

USE CASE 2

Create an interactive 3D model that users can drag and rotate, built entirely in the browser.

USE CASE 3

Build playful animated UI elements like loading spinners or icons with a flat cartoon 3D look.

USE CASE 4

Prototype simple 3D concepts for a web page without setting up a full 3D engine like Three.js.

Tech stack

JavaScriptCanvasSVG

Getting it running

Difficulty · easy Time to first run · 5min

Add one CDN script tag to any HTML page to get started, no build step or npm required.

MIT license, use freely for any purpose including commercial projects, with no restrictions beyond keeping the copyright notice.

In plain English

Zdog is a JavaScript library that lets you create simple 3D-looking graphics on a web page without the complexity of a full 3D engine. It works inside standard HTML elements, either a canvas element or an SVG element, and draws everything using flat 2D shapes. Spheres look like circles, tubes look like thick lines, and the depth effect comes from how those shapes are layered and rotated. The result is a clean, cartoon-like visual style rather than realistic 3D. The author built it because existing 3D engines were too large and complicated for the kinds of small interactive models he wanted to make. Zdog takes inspiration from a 1995 virtual pet game that used flat 2D circle sprites to fake a convincing 3D dog in real time, even on very old hardware. The same trick works here: simple shapes, smart math, no heavy rendering pipeline. To use it, you drop a script tag into your HTML page, then write a few lines of JavaScript to define shapes and attach them to a canvas or SVG element. You can build compositions from circles, rectangles, boxes, cones, cylinders, and other shapes, then animate them or let users drag to rotate them in 3D. The code example in the README shows how to create a spinning circle and square in under 30 lines. Installation is straightforward: link to the hosted file via a CDN, or install via npm. There are community-made plugins for text rendering and for Vue, plus a Python port. The project is in beta and the author expects significant changes in future versions. It is MIT licensed and best suited for decorative, illustrative, or playful web graphics rather than games or data visualization.

Copy-paste prompts

Prompt 1
Using Zdog, write me the code to display a spinning cartoon-style 3D cube on an HTML canvas that rotates automatically and can also be dragged by the user.
Prompt 2
I want to build a Zdog scene with a character made of basic shapes: a sphere head, cylinder body, and box arms. Show me the JavaScript code to set it up and animate it.
Prompt 3
How do I use Zdog to add a draggable 3D illustration to a plain HTML page using only a CDN script tag, no build tools?
Prompt 4
Create a Zdog animation of a simple planet orbiting a star using circles and cylinders, with a smooth looping rotation.
Open on GitHub → Explain another repo

← metafizzy on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.