All Projects → shrekshao → gltf-avatar-threejs

shrekshao / gltf-avatar-threejs

Licence: MIT license
A glTF-based 3d avatar system

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to gltf-avatar-threejs

3dtilesrendererjs
Renderer for 3D Tiles in Javascript using three.js
Stars: ✭ 333 (+70.77%)
Mutual labels:  threejs, gltf
model-browser
model-browser is a command line tool available on npm, for browsing local 3D models via a web browser. It currently only supports GLB files.
Stars: ✭ 19 (-90.26%)
Mutual labels:  threejs, gltf
Egjs View3d
Fast & customizable 3D model viewer for everyone
Stars: ✭ 34 (-82.56%)
Mutual labels:  threejs, gltf
Spoke
Easily create custom 3D environments
Stars: ✭ 321 (+64.62%)
Mutual labels:  threejs, gltf
glAvatar
a glTF extension (extra?) for avatar with switchable skeletons, skins, clothes, etc.
Stars: ✭ 30 (-84.62%)
Mutual labels:  avatar, gltf
mine.js
🌏 A voxel engine built with JS/TS/RS. (formerly mc.js) (maybe mine.ts? or even mine.rs?)
Stars: ✭ 282 (+44.62%)
Mutual labels:  threejs
3d-earth
🌏🌎🌍 3D Earth with Mapbox GL, D3.js and Three.js
Stars: ✭ 68 (-65.13%)
Mutual labels:  threejs
cannon-es-debugger
Wireframe debugger for use with cannon-es https://github.com/react-spring/cannon-es
Stars: ✭ 69 (-64.62%)
Mutual labels:  threejs
encounter
Remaking the classic C64 game in WebGL.
Stars: ✭ 45 (-76.92%)
Mutual labels:  threejs
Hypeometry2
空间错觉游戏引擎
Stars: ✭ 24 (-87.69%)
Mutual labels:  threejs
glTF-Blender-IO-materials-variants
Blender3D addon for glTF KHR_materials_variants extension
Stars: ✭ 56 (-71.28%)
Mutual labels:  gltf
spider
🕸️ 3D interactive analysis in your browser mostly written around the Three.js JavaScript library
Stars: ✭ 41 (-78.97%)
Mutual labels:  threejs
three-js-fundamentals-r3f
Examples from the Three.js Fundamentals website recreated in react-three-fiber renderer.
Stars: ✭ 84 (-56.92%)
Mutual labels:  threejs
identicon-api
A simple API to retrieve SVG identicons
Stars: ✭ 15 (-92.31%)
Mutual labels:  avatar
annihilate
js action game
Stars: ✭ 49 (-74.87%)
Mutual labels:  threejs
xQube
Boilerplate for realtime 3D rendering and server-side physics in HTML5 and NodeJS
Stars: ✭ 1 (-99.49%)
Mutual labels:  threejs
android-3d-model-viewer
Android app to load 3D models in obj, stl, dae & gltf format using pure OpenGL ES 2.0. Published on Play Store https://play.google.com/store/apps/details?id=org.andresoviedo.dddmodel2
Stars: ✭ 150 (-23.08%)
Mutual labels:  gltf
react-three-arjs
AR.js with react-three-fiber
Stars: ✭ 88 (-54.87%)
Mutual labels:  threejs
interfaces
A diverse set of royalty-free user avatars to be used for marketing graphics and application screenshots.
Stars: ✭ 50 (-74.36%)
Mutual labels:  avatar
github-avatar-generator
Generate github-style avatar with java awt
Stars: ✭ 37 (-81.03%)
Mutual labels:  avatar

gltf-avatar-threejs loader, viewer, exporter

Live Demo

Brief feature intro

A dynamic avatar system based on glTF which supports:

  • switchable skin (clothes, hair, accessory) sharing a skeleton
  • pixel-granuality skin visibility control
    • threejs real time render
    • bake to merged glTF/glb
  • sub-skeleton and animations in skin file (hair skeleton, face expression rigging)
  • node rigid bind
  • merge and output as valid standard glTF (without need for extension support loader)
    • nodejs
    • browser export glb
  • TODO: hair, clothes physics (MMD?)

Feature examples

  • combination of skins with shared skeleton or rigid bind

  • visibility control of skin, in real time renderer or baked
with visibility control without visibility control
  • sub skeleton and animation ins skin (hair) file

  • mixamo animation

  • merge and export as glb, able to get loaded on facebook, sketchfab, Godot, ...

glTF Avatar Spec v0.2

Skeleton (Base / Main / Character) file

  • An example of glTF avatar features in a skeleton file
{
    "extensionsUsed": [
        "gl_avatar"
    ],
    "extensions": {
        "gl_avatar": {
            "type": "skeleton",
            "skins": {
                "main": 2
            },
            "nodes": {
                "head": 8,
                "head-end": 9
            }
        }
    },
    "materials": [
        {
            "name": "saber-pure-body",
            "...": "...",
            "extensions": {
                "gl_avatar": {
                    "bodyIdLUT": 2
                }
            }
        },
        "..."
    ],
    "nodes": [
        {
            "mesh": 0,
            "name": "F010_Saber_Body",
            "skin": 0,
            "extensions": {
                "gl_avatar": {
                    "skin": 2
                }
            }
        },
        "..."
    ],
    "...": "..."
}
  • extensions.gl_avatar
    • type: skeleton or skin. Theoretically skeleton file can contain no mesh but only joints. However usually glTF exporters will ignore joints not used by any skinned mesh. So does the threejs glTF loader. So the literal skin of a character is ususally included in a skeleton file. We currently recommend standard 65 joints from mixamo as the general skeleton for the character.
    • skin: a dictionary mapping skeleton name to skin id. Other clothes files will use skeleton name to reference a joint list of the skeleton file.
    • nodes: a dictionary mapping node name to node id. Similiar to the skin map. This can be used by sub-skeleton or rigid bind, that needs to attach to certain node as a child.
  • materials[i].extensions.gl_avatar.bodyIdLUT : bodyIdLUT is the texture id of a body id look up table texture. This texture is now a normal png file. Of which the red channel value indicates the body id.
  • node[i].extensions.gl_avatar.skin : this is used for threejs gltf loader to pick up this skin, if this skin is not used by this skeleton file

Skin (Clothes / Accessory) file

  • An example of glTF avatar features in a skin file
{
    "extensionsUsed": [
        "gl_avatar"
    ],
    "extensions": {
        "gl_avatar": {
            "visibility": [
                0, 
                1, 1, 1, 0, 0, 
                0, 0, 1, 1, 1, 
                1, 1, 1, 1, 1,
                1, 1, 1, 1, 1,
                1, 1, 1, 0, 0,
                0, 0, 0, 0, 0,
                0, 0, 0, 1, 1,
                0, 0, 1, 1, 1,
                0, 0, 0, 0, 0,
                0, 0, 0, 0, 0,
                0, 0, 0, 0, 0,
                0, 0, 0, 0
            ],
            "type": "skin",
            "linkedSkeletons": [
                {
                    "inverseBindMatrices": 174,
                    "name": "Saber_maid_dress",
                    "skeleton": "main"
                }
            ]
        }
    },
    "meshes": [
        {
            "name": "F010_Saber.003",
            "primitives": [
                {
                    "...": "...",
                    "extensions": {
                        "gl_avatar": {
                            "attributes": {
                                "JOINTS_0": 159,
                                "WEIGHTS_0": 173
                            }
                        }
                    }
                }
            ]
        }
    ],
    "nodes": [
        {
            "name": "Saber_maid_dress",
            "...": "...",
            "extensions": {
                "gl_avatar": {
                    "skin": 0
                }
            }
        },
        {
            "name": "Hair_bone",
            "...": "...",
            "extensions": {
                "gl_avatar": {
                    "root": "head-end"
                }
            }
        }
    ],
    "...": "..."
}
  • extensions.gl_avatar
    • type: skeleton or skin.
    • visibility: It's an array of visiblity status of this clothes. 0 means invisible for this body id. For real time renderer, this visibility array will be sent to gpu via a texture or a uniform buffer. The shader of the main character skeleton will discard fragments whose visibility[bodyId] == 0. For baked glTF file, this array will affect the output texture of main character skeleton. Those fragments with visibility[bodyId] == 0 will have a zero alpha channel. With alphaMode set to MASK and a alphaCutoff of 0.5, these fragments on the character skin will be invisible.
    • linkedSkin: corresponds to the shared skins in skeleton file.
  • meshes[i].primitives[i].extensions.gl_avatar.attributes: store JOINT and WEIGHT of skinnedmesh here.
  • nodes[i].extensions.gl_avatar.skin: refers to skin id in extensions.gl_avatar.linkedSkin.
  • nodes[i].extensions.gl_avatar.root: rigid-bind/sub-skeleton

Blender art asset tutorial

Thanks @zen85 for pushing me forward to finish this part (which should be done at very first but I was too lazy... -_-).

gltf exporter we use: https://github.com/Kupoman/blendergltf (master)

Prepare the base skeleton glTF file

  • First you should have a base skeleton rigged in blender in T-pose. Save a separate file (We will call it base.blend later) for this before adding any animations. You will use this file to rig other skins (clothing, hair, shoes, etc.)
  • To have skin visibility control, you need to have an extra texture called body id map, which labels an id number in R channel (0-255) for each part of the skeleton mesh. You can generate this by texture painting in blender, or export uv snapshot and paint in Photoshop, GIMP etc.
  • To add animation and export, you can follow the awesome tutorial by @donmccurdy: https://www.donmccurdy.com/2017/11/06/creating-animated-gltf-characters-with-mixamo-and-blender/
  • At this point you should have an exported glTF base skeleton with animations. It will be in a folder, together with .bin and texture images (We will call it skeleton.gltf).
  • Run node tools/glavatar-pipeline.js path/to/skeleton.gltf --skeleton -o path/to/skeleton-avatar.gltf (This tool is crappy and needs handcraft at this moment... Sorry. Consider using https://github.com/Microsoft/glTF-SDK in the future)
    • Replace skeleton.gltf with skeleton-avatar.gltf (Save a copy of original)
    • TODO: handcraft visibility information

Prepare the clothing (skin) glTF file

  • Rig your clothes in base.blend.
  • Export as gltf (We will call it clothing.gltf).
  • Run node tools/glavatar-pipeline.js path/to/clothing.gltf --skin -o path/to/clothing-avatar.gltf
    • Replace clothing.gltf with clothing-avatar.gltf (Save a copy of original)
  • Handcraft (Sorry):
    • Copy the {...} under extensions.gl_avatar.linkedSkeletons into skeleton-avatar.gltf, inside skins array.
      • This is because blender and the exporter only write joints that has non-zero weight of cur mesh. So the skeletons could be different even you have only one set of bones.
      • The node id could be different as well. Usually it will just be an offset for every node id under joints
      • VScode gltf debug plugin by microsoft is highly recommended
    • TODO

Credit

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].