Skip to content

xem/mini3Dphysics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mini3DPhysics

Tiny 3D physics engine inspired by the book "Game Physics Cookbook" by Gabor Szauer, and focused on boxes and spheres interactions.

The relevant chapters of the book are summarized in the pages below

The source code is available in the lib folder

An optional micro WebGL renderer is included in the lib folder, based on W.js

Physics engine API

  • physicsSystem.addRigidBody(body);
  • physicsSystem.addConstraint(constraint);
  • physicsSystem.update();
  • physicsSystem.render();
  • physicsSystem.clear();

Renderer API (todo)

Scene:

  • W.reset(webglContext)
  • W.light({x, y, z})
  • W.camera({x, y, z, rx, ry, rz, fov})
  • W.wclearColor("#rgb");

Shapes:

  • W.sphere(options)
  • W.box(options)
  • W.add(model_name, {vertices, uv, indices}) // register new model, then it can be rendered using W.model_name(options)

Transformations:

  • W.move(options)
  • W.delete(id)

options:

  • id (string)
  • p: position (DOMPoint)
  • r: rotation (DOMPoint)
  • size: half-width/height/depth for boxes ([w, h d]), radius for spheres (r)
  • c: color (string, optional)
  • t: texture (image, optional)
  • M: transformation matrix (DOMMatrix)
  • s: smoothing (0/1)

(contrary to W.js, this renderer does not include groups, delays, animations, planes, billboards and pyramids)

Chapters summarized

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published