pixiv/three-vrm

TypeScript

Use VRM on Three.js

gltfthreejsvrm3davatarwebgl
스타 성장
스타
2.2k
포크
189
주간 성장
+16
이슈
24
1k2k
2019년 9월2022년 1월2024년 5월2026년 9월
아티팩트npm
README

@pixiv/three-vrm

@pixiv/three-vrm on npm

Use VRM on three.js

three-vrm

GitHub Repository

Examples

Guides

API Reference

How to Use

from HTML

You will need:

  • Three.js build
  • GLTFLoader
  • A build of @pixiv/three-vrm
    • .module ones are ESM, otherwise it's UMD and injects its modules into global THREE
    • .min ones are minified (for production), otherwise it's not minified and it comes with source maps

You can import all the dependencies via CDN like jsDelivr.

<script type="importmap">
  {
    "imports": {
      "three": "https://cdn.jsdelivr.net/npm/three@0.180.0/build/three.module.js",
      "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.180.0/examples/jsm/",
      "@pixiv/three-vrm": "https://cdn.jsdelivr.net/npm/@pixiv/three-vrm@3/lib/three-vrm.module.min.js"
    }
  }
</script>

<script type="module">
  import * as THREE from 'three';
  import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
  import { VRMLoaderPlugin } from '@pixiv/three-vrm';

  // ... Setup renderer, camera, scene ...

  // Create a GLTFLoader - The loader for loading VRM models
  const loader = new GLTFLoader();

  // Install a GLTFLoader plugin that enables VRM support
  loader.register((parser) => {
    return new VRMLoaderPlugin(parser);
  });

  loader.load(
    // URL of the VRM you want to load
    '/models/VRM1_Constraint_Twist_Sample.vrm',

    // called when the resource is loaded
    (gltf) => {
      // retrieve a VRM instance from gltf
      const vrm = gltf.userData.vrm;

      // add the loaded vrm to the scene
      scene.add(vrm.scene);

      // deal with vrm features
      console.log(vrm);
    },

    // called while loading is progressing
    (progress) => console.log('Loading model...', 100.0 * (progress.loaded / progress.total), '%'),

    // called when loading has errors
    (error) => console.error(error),
  );

  // ... Perform the render loop ...
</script>

See the Three.js document if you are not familiar with Three.js yet: https://threejs.org/docs/#manual/en/introduction/Creating-a-scene

See the example for the complete code: https://github.com/pixiv/three-vrm/blob/release/packages/three-vrm/examples/basic.html

via npm

Install three and @pixiv/three-vrm :

npm install three @pixiv/three-vrm

Use with WebGPURenderer

Starting from v3, we provide WebGPURenderer compatibility. To use three-vrm with WebGPURenderer, specify the WebGPU-compatible MToonNodeMaterial for the materialType option of MToonMaterialLoaderPlugin.

MToonNodeMaterial only supports Three.js r167 or later. The NodeMaterial system of Three.js is still under development, so we may break compatibility with older versions of Three.js more frequently than other parts of three-vrm.

import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { MToonMaterialLoaderPlugin, VRMLoaderPlugin } from '@pixiv/three-vrm';
import { MToonNodeMaterial } from '@pixiv/three-vrm/nodes';

// ... Setup renderer, camera, scene ...

// Create a GLTFLoader
const loader = new GLTFLoader();

// Register a VRMLoaderPlugin
loader.register((parser) => {

  // create a WebGPU compatible MToonMaterialLoaderPlugin
  const mtoonMaterialPlugin = new MToonMaterialLoaderPlugin(parser, {

    // set the material type to MToonNodeMaterial
    materialType: MToonNodeMaterial,

  });

  return new VRMLoaderPlugin(parser, {

    // Specify the MToonMaterialLoaderPlugin to use in the VRMLoaderPlugin instance
    mtoonMaterialPlugin,

  });

});

// ... Load the VRM and perform the render loop ...

See the example for the complete code: https://github.com/pixiv/three-vrm/blob/release/packages/three-vrm/examples/webgpu-dnd.html

Contributing

See: CONTRIBUTING.md

LICENSE

MIT

관련 저장소
google/filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2

C++libraryApache License 2.0pbrgraphics
google.github.io/filament/
20.5k2.3k
playcanvas/engine

Powerful web graphics runtime built on WebGL, WebGPU, WebXR and glTF

JavaScriptnpmMIT Licensewebglwebgl2
playcanvas.com
16.7k2k
CesiumGS/cesium

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:

JavaScriptnpmlibraryApache License 2.03dgeospatial
cesium.com/cesiumjs/
15.7k3.9k
assimp/assimp

The official Open-Asset-Importer-Library Repository. Loads 40+ 3D-file-formats into one unified and clean data structure.

C++Otherasset-pipelineassets
assimp.org
13.2k3.2k
zeux/meshoptimizer

Mesh optimization library that makes meshes smaller and faster to render

C++libraryMIT Licensegpumesh-processing
meshoptimizer.org
8.3k749
google/model-viewer

Easily display interactive 3D models on the web and in AR!

TypeScriptnpmlibraryApache License 2.03d-modelsgltf
modelviewer.dev
8.2k945
turanszkij/WickedEngine

3D engine with modern graphics

C++MIT Licensedirectx12vulkan
wickedengine.net
7.2k772
f3d-app/f3d

Fast and minimalist 3D viewer.

C++cliBSD 3-Clause "New" or "Revised" Licensestl-viewergltf-viewer
f3d.app
4.7k445
vrm-c/UniVRM

UniVRM is a gltf-based VRM format implementation for Unity. English is here https://vrm.dev/en/ . 日本語 はこちら https://vrm.dev/

C#libraryMIT Licenseunity3dgltf
vrm.dev/en
3.4k490
xelatihy/yocto-gl

Yocto/GL: Tiny C++ Libraries for Data-Driven Physically-based Graphics

C++librarypath-tracergltf
xelatihy.github.io/yocto-gl
2.9k216
gildor2/UEViewer

Viewer and exporter for Unreal Engine 1-4 assets (UE Viewer).

C++appMIT Licenseumodelunreal
gildor.org/en/projects/umodel
2.9k573
pissang/claygl

A WebGL graphic library for building scalable Web3D applications

JavaScriptnpmlibraryBSD 2-Clause "Simplified" Licensewebglgltf
2.9k297