Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pixiv/three-vrm
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.0.10
Choose a base ref
...
head repository: pixiv/three-vrm
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v2.1.0
Choose a head ref
  • 18 commits
  • 46 files changed
  • 3 contributors

Commits on Dec 4, 2023

  1. Revert "Revert "feature: VRMAnimation""

    This reverts commit 2f09d71.
    0b5vr committed Dec 4, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    trivialfis Jiaming Yuan
    Copy the full SHA
    ebec9fd View commit details
  2. v2.1.0-beta.0

    0b5vr committed Dec 4, 2023
    Copy the full SHA
    5ae801b View commit details
  3. fix: Fix the issue that hips translation goes infinity

    I was probably quite sleepy when working on the restHipsPosition procedure last time
    
    See: c11d6e9
    0b5vr committed Dec 4, 2023
    Copy the full SHA
    47b07a1 View commit details

Commits on Dec 5, 2023

  1. Merge pull request #1342 from pixiv/fix-animation-hips

    fix: Fix the issue that hips translation goes infinity
    0b5vr authored Dec 5, 2023
    Copy the full SHA
    14b0d82 View commit details
  2. v2.1.0-beta.1

    0b5vr committed Dec 5, 2023
    Copy the full SHA
    9d428fd View commit details

Commits on Jan 17, 2024

  1. Copy the full SHA
    867e703 View commit details
  2. Copy the full SHA
    048962d View commit details
  3. fix (MToon): Workaround typing of UniformsUtils.merge

    not a proper typing, might want to fix from three-ts-types side
    0b5vr committed Jan 17, 2024
    Copy the full SHA
    8a89449 View commit details
  4. v2.1.0-beta.2

    0b5vr committed Jan 17, 2024
    Copy the full SHA
    22f562d View commit details

Commits on Feb 13, 2024

  1. examples: Apply suggestions from code review

    - Bump three-vrm to v2.0.8
    - Set light intensity to PI
    
    Co-authored-by: ke456-png <108649297+ke456-png@users.noreply.github.com>
    0b5vr and ke456-png authored Feb 13, 2024
    Copy the full SHA
    726941c View commit details
  2. Copy the full SHA
    13aacff View commit details
  3. chore: align package version with 2.0.10 for now

    0b5vr committed Feb 13, 2024
    Copy the full SHA
    17598a6 View commit details
  4. ci: publish workflow, remove dev branch pin

    0b5vr committed Feb 13, 2024
    Copy the full SHA
    24a97d7 View commit details
  5. fix: Fix repository field of package.json for vrm animation packages

    GitHub provenance failed because of this
    0b5vr committed Feb 13, 2024
    Copy the full SHA
    d8b3127 View commit details

Commits on Feb 14, 2024

  1. fix: Fix parsing animation from VRMA with scales

    setFromRotationMatrix don't work with world matrices with scales
    replaced with decompose
    0b5vr committed Feb 14, 2024
    Copy the full SHA
    155382e View commit details

Commits on Feb 15, 2024

  1. feature: Promote VRM Animation to the ratified version

    Also add a specVersion gate which only passes "1.0" and "1.0-draft"
    0b5vr committed Feb 15, 2024
    Copy the full SHA
    1d5977b View commit details
  2. Merge pull request #1341 from pixiv/animation-beta

    Animation beta
    0b5vr authored Feb 15, 2024
    Copy the full SHA
    5567cc1 View commit details
  3. v2.1.0

    actions-user committed Feb 15, 2024
    Copy the full SHA
    0d96aea View commit details
Showing with 1,519 additions and 43 deletions.
  1. +0 −3 .github/workflows/publish.yml
  2. +1 −1 lerna.json
  3. +9 −0 packages/three-vrm-animation/README.md
  4. +2 −0 packages/three-vrm-animation/examples/.editorconfig
  5. +11 −0 packages/three-vrm-animation/examples/.eslintrc
  6. +281 −0 packages/three-vrm-animation/examples/dnd.html
  7. +24 −0 packages/three-vrm-animation/examples/index.html
  8. +151 −0 packages/three-vrm-animation/examples/loader-plugin.html
  9. BIN packages/three-vrm-animation/examples/models/VRM1_Constraint_Twist_Sample.vrm
  10. BIN packages/three-vrm-animation/examples/models/test.vrma
  11. +62 −0 packages/three-vrm-animation/package.json
  12. +96 −0 packages/three-vrm-animation/rollup.config.js
  13. +40 −0 packages/three-vrm-animation/src/VRMAnimation.ts
  14. +271 −0 packages/three-vrm-animation/src/VRMAnimationLoaderPlugin.ts
  15. +7 −0 packages/three-vrm-animation/src/VRMAnimationLoaderPluginOptions.ts
  16. +39 −0 packages/three-vrm-animation/src/VRMLookAtQuaternionProxy.ts
  17. +150 −0 packages/three-vrm-animation/src/createVRMAnimationClip.ts
  18. +9 −0 packages/three-vrm-animation/src/index.ts
  19. +30 −0 packages/three-vrm-animation/src/utils/arrayChunk.ts
  20. +4 −0 packages/three-vrm-animation/tsconfig.json
  21. +3 −3 packages/three-vrm-core/package.json
  22. +2 −2 packages/three-vrm-materials-hdr-emissive-multiplier/package.json
  23. +3 −3 packages/three-vrm-materials-mtoon/package.json
  24. +1 −1 packages/three-vrm-materials-mtoon/src/MToonMaterial.ts
  25. +3 −3 packages/three-vrm-materials-v0compat/package.json
  26. +2 −2 packages/three-vrm-node-constraint/package.json
  27. +3 −3 packages/three-vrm-springbone/package.json
  28. +7 −7 packages/three-vrm/package.json
  29. +1 −1 packages/types-vrm-0.0/package.json
  30. +1 −1 packages/types-vrmc-materials-hdr-emissive-multiplier-1.0/package.json
  31. +1 −1 packages/types-vrmc-materials-mtoon-1.0/package.json
  32. +1 −1 packages/types-vrmc-node-constraint-1.0/package.json
  33. +1 −1 packages/types-vrmc-springbone-1.0/package.json
  34. +1 −1 packages/types-vrmc-vrm-1.0/package.json
  35. +13 −0 packages/types-vrmc-vrm-animation-1.0/README.md
  36. +44 −0 packages/types-vrmc-vrm-animation-1.0/package.json
  37. +12 −0 packages/types-vrmc-vrm-animation-1.0/src/Expression.ts
  38. +21 −0 packages/types-vrmc-vrm-animation-1.0/src/Expressions.ts
  39. +11 −0 packages/types-vrmc-vrm-animation-1.0/src/Humanoid.ts
  40. +12 −0 packages/types-vrmc-vrm-animation-1.0/src/HumanoidHumanBone.ts
  41. +9 −0 packages/types-vrmc-vrm-animation-1.0/src/HumanoidHumanBones.ts
  42. +12 −0 packages/types-vrmc-vrm-animation-1.0/src/LookAt.ts
  43. +31 −0 packages/types-vrmc-vrm-animation-1.0/src/VRMCVRMAnimation.ts
  44. +7 −0 packages/types-vrmc-vrm-animation-1.0/src/index.ts
  45. +6 −0 packages/types-vrmc-vrm-animation-1.0/tsconfig.json
  46. +124 −9 yarn.lock
3 changes: 0 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -24,9 +24,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# checkout is pinned to dev branch here
ref: dev
- name: Setup Node
uses: actions/setup-node@v3
with:
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -2,5 +2,5 @@
"npmClient": "yarn",
"useWorkspaces": true,
"packages": ["packages/*"],
"version": "2.0.10"
"version": "2.1.0"
}
9 changes: 9 additions & 0 deletions packages/three-vrm-animation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @pixiv/three-vrm-animation

The implementation of VRM Animation

[GitHub Repository](https://github.com/pixiv/three-vrm/tree/dev/packages/three-vrm-animation)

[Examples](https://pixiv.github.io/three-vrm/packages/three-vrm-animation/examples)

[Documentation](https://pixiv.github.io/three-vrm/packages/three-vrm-animation/docs)
2 changes: 2 additions & 0 deletions packages/three-vrm-animation/examples/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[*]
indent_style = tab
11 changes: 11 additions & 0 deletions packages/three-vrm-animation/examples/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"root": true,
"plugins": [
"html"
],
"extends": "mdcs",
"rules": {
"padded-blocks":"off",
"no-unused-vars": "off"
}
}
281 changes: 281 additions & 0 deletions packages/three-vrm-animation/examples/dnd.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8" />
<title>three-vrm-animation example</title>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<style>
body {
margin: 0;
}
canvas {
display: block;
}
</style>
</head>

<body>
<!-- Import maps polyfill -->
<!-- Remove this when import maps will be widely supported -->
<script async src="https://unpkg.com/es-module-shims@1.3.6/dist/es-module-shims.js"></script>

<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three@0.160.0/build/three.module.js",
"three/addons/": "https://unpkg.com/three@0.160.0/examples/jsm/",
"@pixiv/three-vrm": "https://unpkg.com/@pixiv/three-vrm@2.0.8/lib/three-vrm.module.js",
"@pixiv/three-vrm-animation": "../lib/three-vrm-animation.module.js"
}
}
</script>

<script type="module">
import * as THREE from 'three';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import GUI from 'three/addons/libs/lil-gui.module.min.js';
import { VRMLoaderPlugin, VRMUtils } from '@pixiv/three-vrm';
import { createVRMAnimationClip, VRMAnimationLoaderPlugin, VRMLookAtQuaternionProxy } from '@pixiv/three-vrm-animation';

// renderer
const renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setPixelRatio( window.devicePixelRatio );
document.body.appendChild( renderer.domElement );

// camera
const camera = new THREE.PerspectiveCamera( 30.0, window.innerWidth / window.innerHeight, 0.1, 20.0 );
camera.position.set( 0.0, 1.0, 5.0 );

// camera controls
const controls = new OrbitControls( camera, renderer.domElement );
controls.screenSpacePanning = true;
controls.target.set( 0.0, 1.0, 0.0 );
controls.update();

// scene
const scene = new THREE.Scene();

// light
const light = new THREE.DirectionalLight( 0xffffff, Math.PI );
light.position.set( 1.0, 1.0, 1.0 ).normalize();
scene.add( light );

// gltf, vrm, and vrma
let currentVrm = undefined;
let currentVrmAnimation = undefined;
let currentMixer = undefined;

const loader = new GLTFLoader();
loader.crossOrigin = 'anonymous';

loader.register( ( parser ) => {

return new VRMLoaderPlugin( parser );

} );

loader.register( ( parser ) => {

return new VRMAnimationLoaderPlugin( parser );

} );

function tryInitVRM( gltf ) {

const vrm = gltf.userData.vrm;

if ( vrm == null ) {

return;

}

// calling these functions greatly improves the performance
VRMUtils.removeUnnecessaryVertices( gltf.scene );
VRMUtils.removeUnnecessaryJoints( gltf.scene );

if ( currentVrm ) {

scene.remove( currentVrm.scene );
VRMUtils.deepDispose( currentVrm.scene );

}

// Add look at quaternion proxy to the VRM; which is needed to play the look at animation
const lookAtQuatProxy = new VRMLookAtQuaternionProxy( vrm.lookAt );
lookAtQuatProxy.name = 'lookAtQuaternionProxy';
vrm.scene.add( lookAtQuatProxy );

// Disable frustum culling
vrm.scene.traverse( ( obj ) => {

obj.frustumCulled = false;

} );

currentVrm = vrm;
scene.add( vrm.scene );

// rotate if the VRM is VRM0.0
VRMUtils.rotateVRM0( vrm );

initAnimationClip();

console.log( vrm );

}

function tryInitVRMA( gltf ) {

const vrmAnimations = gltf.userData.vrmAnimations;

if ( vrmAnimations == null ) {

return;

}

currentVrmAnimation = vrmAnimations[ 0 ] ?? null;
initAnimationClip();

console.log( vrmAnimations );

}

function initAnimationClip() {

if ( currentVrm && currentVrmAnimation ) {

currentMixer = new THREE.AnimationMixer( currentVrm.scene );

const clip = createVRMAnimationClip( currentVrmAnimation, currentVrm );
currentMixer.clipAction( clip ).play();
currentMixer.timeScale = params.timeScale;

currentVrm.humanoid.resetNormalizedPose();
// currentVrm.expressions.resetAll(); // will implement later
currentVrm.lookAt.reset();
currentVrm.lookAt.autoUpdate = currentVrmAnimation.lookAtTrack != null;

}

}

function load( url ) {

loader.load(

url,

( gltf ) => {

tryInitVRM( gltf );
tryInitVRMA( gltf );

},

( progress ) => console.log( 'Loading model...', 100.0 * ( progress.loaded / progress.total ), '%' ),

( error ) => console.error( error )

);

}

load( './models/VRM1_Constraint_Twist_Sample.vrm' );
load( './models/test.vrma' );

// helpers
const gridHelper = new THREE.GridHelper( 10, 10 );
scene.add( gridHelper );

const axesHelper = new THREE.AxesHelper( 5 );
scene.add( axesHelper );

// animate
const clock = new THREE.Clock();
clock.start();

function animate() {

requestAnimationFrame( animate );

const deltaTime = clock.getDelta();

if ( currentMixer ) {

currentMixer.update( deltaTime );

}

if ( currentVrm ) {

currentVrm.update( deltaTime );

}

renderer.render( scene, camera );

}

animate();

// gui
const gui = new GUI();

const params = {

timeScale: 1.0,

};

gui.add( params, 'timeScale', 0.0, 2.0, 0.001 ).onChange( ( value ) => {

if ( currentMixer ) {

currentMixer.timeScale = value;

}

} );

// dnd handler
window.addEventListener( 'dragover', function ( event ) {

event.preventDefault();

} );

window.addEventListener( 'drop', function ( event ) {

event.preventDefault();

// read given file then convert it to blob url
const files = event.dataTransfer.files;
if ( ! files ) {

return;

}

const file = files[ 0 ];
if ( ! file ) {

return;

}

const blob = new Blob( [ file ], { type: "application/octet-stream" } );
const url = URL.createObjectURL( blob );
load( url );

} );
</script>
</body>
</html>
24 changes: 24 additions & 0 deletions packages/three-vrm-animation/examples/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>

<html>
<head>
<meta charset="utf-8" />
<title>three-vrm-animation examples</title>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
</head>

<body>
<h1>examples of <a href="https://github.com/pixiv/three-vrm/tree/dev/packages/three-vrm-animation">@pixiv/three-vrm-animation</a></h1>
<p>
<a href="loader-plugin.html">loader-plugin.html</a><br />
Import a VRM Animation from gltf
</p>
<p>
<a href="dnd.html">dnd.html</a><br />
A slightly advanced example with a drag-and-drop capability
</p>
</body>
</html>
Loading