MCPcopy
hub / github.com/pixiv/three-vrm

github.com/pixiv/three-vrm @v3.5.4 sqlite

repository ↗ · DeepWiki ↗ · release v3.5.4 ↗
735 symbols 1,416 edges 263 files 159 documented · 22%
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

Extension points exported contracts — how you extend this code

VRMExpressionBind (Interface)
(no doc) [9 implementers]
packages/three-vrm-core/src/expressions/VRMExpressionBind.ts
ColliderShapeBufferGeometry (Interface)
(no doc) [3 implementers]
packages/three-vrm-springbone/src/helpers/utils/ColliderShapeBufferGeometry.ts
BlendShapeBind (Interface)
(no doc)
packages/types-vrm-0.0/types/BlendShapeBind.d.ts
MToonMaterialParameters (Interface)
(no doc)
packages/three-vrm-materials-mtoon/src/MToonMaterialParameters.ts
VRMNodeConstraintLoaderPluginOptions (Interface)
(no doc)
packages/three-vrm-node-constraint/src/VRMNodeConstraintLoaderPluginOptions.ts
VRMParameters (Interface)
(no doc)
packages/three-vrm/src/VRMParameters.ts
VRMCVRMAnimation (Interface)
(no doc)
packages/types-vrmc-vrm-animation-1.0/types/VRMCVRMAnimation.d.ts
VRMCSpringBoneExtendedCollider (Interface)
(no doc)
packages/types-vrmc-springbone-extended-collider-1.0/types/VRMCSpringBoneExtendedCollider.d.ts

Core symbols most depended-on inside this repo

copy
called by 92
packages/three-vrm-core/src/lookAt/VRMLookAt.ts
toBeCloseToQuaternion
called by 45
packages/three-vrm-core/src/tests/matchers/toBeCloseToQuaternion.ts
update
called by 38
packages/three-vrm-node-constraint/src/tests/VRMMockedConstraint.ts
get
called by 36
packages/three-vrm/src/VRMUtils/combineSkeletons.ts
map
called by 24
packages/three-vrm-materials-mtoon/src/MToonMaterial.ts
clone
called by 22
packages/three-vrm-core/src/lookAt/VRMLookAt.ts
map
called by 20
packages/three-vrm-core/src/lookAt/VRMLookAtRangeMap.ts
assignPrimitive
called by 16
packages/three-vrm-materials-mtoon/src/GLTFMToonMaterialParamsAssignHelper.ts

Shape

Method 410
Class 128
Function 100
Interface 97

Languages

TypeScript100%

Modules by API surface

packages/three-vrm-materials-mtoon/src/MToonMaterial.ts44 symbols
packages/three-vrm-core/src/humanoid/VRMHumanoid.ts31 symbols
packages/three-vrm-materials-mtoon/src/nodes/MToonNodeMaterial.ts22 symbols
packages/three-vrm-core/src/expressions/VRMExpressionManager.ts18 symbols
packages/three-vrm-springbone/src/VRMSpringBoneManager.ts17 symbols
packages/three-vrm-materials-mtoon/src/MToonMaterialLoaderPlugin.ts17 symbols
packages/three-vrm-core/src/lookAt/VRMLookAt.ts16 symbols
packages/three-vrm-springbone/src/VRMSpringBoneJoint.ts14 symbols
packages/three-vrm-core/src/firstPerson/VRMFirstPerson.ts13 symbols
packages/three-vrm/src/VRMUtils/combineSkeletons.ts12 symbols
packages/three-vrm-springbone/src/VRMSpringBoneLoaderPlugin.ts12 symbols
packages/three-vrm-core/src/expressions/VRMExpression.ts12 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

@eslint/eslintrc3.3.5 · 1×
@eslint/js9.39.4 · 1×
@gltf-transform/core4.2.1 · 1×
@pixiv/three-vrm-coreworkspace:* · 1×
@pixiv/three-vrm-materials-hdr-emissive-multiplierworkspace:* · 1×
@pixiv/three-vrm-materials-mtoonworkspace:* · 1×
@pixiv/three-vrm-materials-v0compatworkspace:* · 1×
@pixiv/three-vrm-node-constraintworkspace:* · 1×
@pixiv/three-vrm-springboneworkspace:* · 1×
@pixiv/types-vrm-0.0workspace:* · 1×
@pixiv/types-vrmc-materials-hdr-emissive-multiplier-1.0workspace:* · 1×
@pixiv/types-vrmc-materials-mtoon-1.0workspace:* · 1×

For agents

$ claude mcp add three-vrm \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact