Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.0] Bump Three.js to r137 #913

Merged
merged 4 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/three-vrm-core/examples/expressions.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
</head>

<body>
<script src="https://unpkg.com/three@0.136.0/build/three.js"></script>
<script src="https://unpkg.com/three@0.136.0/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://unpkg.com/three@0.136.0/examples/js/controls/OrbitControls.js"></script>
<script src="https://unpkg.com/three@0.137.4/build/three.js"></script>
<script src="https://unpkg.com/three@0.137.4/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://unpkg.com/three@0.137.4/examples/js/controls/OrbitControls.js"></script>
<script src="../lib/three-vrm-core.js"></script>
<script>
// renderer
Expand Down
6 changes: 3 additions & 3 deletions packages/three-vrm-core/examples/firstPerson.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

<body>
<span id="info"></span>
<script src="https://unpkg.com/three@0.136.0/build/three.js"></script>
<script src="https://unpkg.com/three@0.136.0/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://unpkg.com/three@0.136.0/examples/js/controls/OrbitControls.js"></script>
<script src="https://unpkg.com/three@0.137.4/build/three.js"></script>
<script src="https://unpkg.com/three@0.137.4/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://unpkg.com/three@0.137.4/examples/js/controls/OrbitControls.js"></script>
<script src="../lib/three-vrm-core.js"></script>
<script>
// renderer
Expand Down
6 changes: 3 additions & 3 deletions packages/three-vrm-core/examples/humanoid.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
</head>

<body>
<script src="https://unpkg.com/three@0.136.0/build/three.js"></script>
<script src="https://unpkg.com/three@0.136.0/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://unpkg.com/three@0.136.0/examples/js/controls/OrbitControls.js"></script>
<script src="https://unpkg.com/three@0.137.4/build/three.js"></script>
<script src="https://unpkg.com/three@0.137.4/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://unpkg.com/three@0.137.4/examples/js/controls/OrbitControls.js"></script>
<script src="../lib/three-vrm-core.js"></script>
<script>
// renderer
Expand Down
6 changes: 3 additions & 3 deletions packages/three-vrm-core/examples/lookAt.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

<body>
<span id="info"></span>
<script src="https://unpkg.com/three@0.136.0/build/three.js"></script>
<script src="https://unpkg.com/three@0.136.0/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://unpkg.com/three@0.136.0/examples/js/controls/OrbitControls.js"></script>
<script src="https://unpkg.com/three@0.137.4/build/three.js"></script>
<script src="https://unpkg.com/three@0.137.4/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://unpkg.com/three@0.137.4/examples/js/controls/OrbitControls.js"></script>
<script src="../lib/three-vrm-core.js"></script>
<script>
// renderer
Expand Down
6 changes: 3 additions & 3 deletions packages/three-vrm-core/examples/meta.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
<body>
<span id="meta"></span>
<img id="thumbnail" alt="thumbnail" />
<script src="https://unpkg.com/three@0.136.0/build/three.js"></script>
<script src="https://unpkg.com/three@0.136.0/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://unpkg.com/three@0.136.0/examples/js/controls/OrbitControls.js"></script>
<script src="https://unpkg.com/three@0.137.4/build/three.js"></script>
<script src="https://unpkg.com/three@0.137.4/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://unpkg.com/three@0.137.4/examples/js/controls/OrbitControls.js"></script>
<script src="../lib/three-vrm-core.js"></script>
<script>
// renderer
Expand Down
8 changes: 4 additions & 4 deletions packages/three-vrm-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
"@pixiv/types-vrmc-vrm-1.0": "1.0.0-beta.8"
},
"devDependencies": {
"@types/three": "^0.136.1",
"@types/three": "^0.137.0",
"lint-staged": "10.5.3",
"three": "^0.136.0"
"three": "^0.137.4"
},
"peerDependencies": {
"@types/three": "^0.136.1",
"three": "^0.136.0"
"@types/three": "^0.137.0",
"three": "^0.137.4"
}
}
2 changes: 1 addition & 1 deletion packages/three-vrm-core/src/VRMCoreLoaderPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GLTF, GLTFLoaderPlugin, GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader';
import { GLTF, GLTFLoaderPlugin, GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { VRMCoreLoaderPluginOptions } from './VRMCoreLoaderPluginOptions';
import { VRMCore } from './VRMCore';
import { VRMExpressionLoaderPlugin } from './expressions/VRMExpressionLoaderPlugin';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type * as V0VRM from '@pixiv/types-vrm-0.0';
import type * as V1VRMSchema from '@pixiv/types-vrmc-vrm-1.0';
import * as THREE from 'three';
import { GLTF, GLTFLoaderPlugin, GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader';
import { GLTF, GLTFLoaderPlugin, GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { gltfExtractPrimitivesFromNode } from '../utils/gltfExtractPrimitivesFromNode';
import { gltfGetAssociatedMaterialIndex } from '../utils/gltfGetAssociatedMaterialIndex';
import { VRMExpression } from './VRMExpression';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type * as V0VRM from '@pixiv/types-vrm-0.0';
import type * as V1VRMSchema from '@pixiv/types-vrmc-vrm-1.0';
import type { GLTF, GLTFLoaderPlugin, GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader';
import type { GLTF, GLTFLoaderPlugin, GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader.js';
import type { VRMHumanoid } from '../humanoid/VRMHumanoid';
import { gltfExtractPrimitivesFromNodes } from '../utils/gltfExtractPrimitivesFromNode';
import { VRMFirstPerson } from './VRMFirstPerson';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type * as V0VRM from '@pixiv/types-vrm-0.0';
import type * as V1VRMSchema from '@pixiv/types-vrmc-vrm-1.0';
import type { GLTF, GLTFLoaderPlugin, GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader';
import type { GLTF, GLTFLoaderPlugin, GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { VRMHumanoid } from './VRMHumanoid';
import type { VRMHumanBones } from './VRMHumanBones';
import { VRMRequiredHumanBoneName } from './VRMRequiredHumanBoneName';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type * as V0VRM from '@pixiv/types-vrm-0.0';
import type * as V1VRMSchema from '@pixiv/types-vrmc-vrm-1.0';
import type { GLTF, GLTFLoaderPlugin, GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader';
import type { GLTF, GLTFLoaderPlugin, GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader.js';
import type { VRMExpressionManager } from '../expressions/VRMExpressionManager';
import type { VRMHumanoid } from '../humanoid/VRMHumanoid';
import { VRMLookAtHelper } from './helpers/VRMLookAtHelper';
Expand Down
2 changes: 1 addition & 1 deletion packages/three-vrm-core/src/meta/VRMMetaLoaderPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { GLTF, GLTFLoaderPlugin, GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader';
import type { GLTF, GLTFLoaderPlugin, GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader.js';
import type { VRM0Meta } from './VRM0Meta';
import type { VRM1Meta } from './VRM1Meta';
import type { VRMMeta } from './VRMMeta';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { GLTF } from 'three/examples/jsm/loaders/GLTFLoader';
import type { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { GLTF as GLTFSchema } from '@gltf-transform/core';

function extractPrimitivesInternal(gltf: GLTF, nodeIndex: number, node: THREE.Object3D): THREE.Mesh[] | null {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as THREE from 'three';
import { GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader';
import { GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader.js';

/**
* Get a material definition index of glTF from associated material.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
</head>

<body>
<script src="https://unpkg.com/three@0.136.0/build/three.js"></script>
<script src="https://unpkg.com/three@0.136.0/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://unpkg.com/three@0.136.0/examples/js/controls/OrbitControls.js"></script>
<script src="https://unpkg.com/three@0.137.4/build/three.js"></script>
<script src="https://unpkg.com/three@0.137.4/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://unpkg.com/three@0.137.4/examples/js/controls/OrbitControls.js"></script>
<script src="../lib/three-vrm-materials-hdr-emissive-multiplier.js"></script>
<script>
// renderer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@
"@pixiv/types-vrmc-materials-hdr-emissive-multiplier-1.0": "1.0.0-beta.8"
},
"devDependencies": {
"@types/three": "^0.136.1",
"three": "^0.136.0"
"@types/three": "^0.137.0",
"three": "^0.137.4"
},
"peerDependencies": {
"@types/three": "^0.136.1",
"three": "^0.136.0"
"@types/three": "^0.137.0",
"three": "^0.137.4"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as THREE from 'three';
import { GLTF, GLTFLoaderPlugin, GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader';
import { GLTF, GLTFLoaderPlugin, GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader.js';
import * as HDREmissiveMultiplierSchema from '@pixiv/types-vrmc-materials-hdr-emissive-multiplier-1.0';
import { gltfGetAssociatedMaterialIndex } from './utils/gltfGetAssociatedMaterialIndex';
import { GLTF as GLTFSchema } from '@gltf-transform/core';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as THREE from 'three';
import { GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader';
import { GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader.js';

/**
* Get a material definition index of glTF from associated material.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
</head>

<body>
<script src="https://unpkg.com/three@0.136.0/build/three.js"></script>
<script src="https://unpkg.com/three@0.136.0/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://unpkg.com/three@0.136.0/examples/js/controls/OrbitControls.js"></script>
<script src="https://unpkg.com/three@0.137.4/build/three.js"></script>
<script src="https://unpkg.com/three@0.137.4/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://unpkg.com/three@0.137.4/examples/js/controls/OrbitControls.js"></script>
<script src="../lib/three-vrm-materials-mtoon.js"></script>
<script>
// renderer
Expand Down
8 changes: 4 additions & 4 deletions packages/three-vrm-materials-mtoon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
"@pixiv/types-vrmc-materials-mtoon-1.0": "1.0.0-beta.8"
},
"devDependencies": {
"@types/three": "^0.136.1",
"three": "^0.136.0"
"@types/three": "^0.137.0",
"three": "^0.137.4"
},
"peerDependencies": {
"@types/three": "^0.136.1",
"three": "^0.136.0"
"@types/three": "^0.137.0",
"three": "^0.137.4"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as THREE from 'three';
import { GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader';
import { GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { MToonMaterialParameters } from './MToonMaterialParameters';

/**
Expand Down
45 changes: 25 additions & 20 deletions packages/three-vrm-materials-mtoon/src/MToonMaterial.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* tslint:disable:member-ordering */

import * as THREE from 'three';
import { getTexelDecodingFunction } from './utils/getTexelDecodingFunction';
import vertexShader from './shaders/mtoon.vert';
import fragmentShader from './shaders/mtoon.frag';
import { MToonMaterialDebugMode } from './MToonMaterialDebugMode';
import { MToonMaterialOutlineWidthMode } from './MToonMaterialOutlineWidthMode';
import type { MToonMaterialParameters } from './MToonMaterialParameters';
import { getTexelDecodingFunction } from './utils/getTexelDecodingFunction';
import { getTextureEncodingFromMap } from './utils/getTextureEncodingFromMap';

/**
Expand Down Expand Up @@ -470,25 +470,30 @@ export class MToonMaterial extends THREE.ShaderMaterial {
.join('\n') + '\n';

// -- texture encodings ----------------------------------------------------------------------
const encodings =
(this.matcapTexture !== null
? getTexelDecodingFunction(
'matcapTextureTexelToLinear',
getTextureEncodingFromMap(this.matcapTexture, isWebGL2),
) + '\n'
: '') +
(this.shadeMultiplyTexture !== null
? getTexelDecodingFunction(
'shadeMultiplyTextureTexelToLinear',
getTextureEncodingFromMap(this.shadeMultiplyTexture, isWebGL2),
) + '\n'
: '') +
(this.rimMultiplyTexture !== null
? getTexelDecodingFunction(
'rimMultiplyTextureTexelToLinear',
getTextureEncodingFromMap(this.rimMultiplyTexture, isWebGL2),
) + '\n'
: '');
// COMPAT: pre-r137
let encodings = '';

if (parseInt(THREE.REVISION, 10) < 137) {
encodings =
(this.matcapTexture !== null
? getTexelDecodingFunction(
'matcapTextureTexelToLinear',
getTextureEncodingFromMap(this.matcapTexture, isWebGL2),
) + '\n'
: '') +
(this.shadeMultiplyTexture !== null
? getTexelDecodingFunction(
'shadeMultiplyTextureTexelToLinear',
getTextureEncodingFromMap(this.shadeMultiplyTexture, isWebGL2),
) + '\n'
: '') +
(this.rimMultiplyTexture !== null
? getTexelDecodingFunction(
'rimMultiplyTextureTexelToLinear',
getTextureEncodingFromMap(this.rimMultiplyTexture, isWebGL2),
) + '\n'
: '');
}

// -- generate shader code -------------------------------------------------------------------
shader.vertexShader = defines + shader.vertexShader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as THREE from 'three';
import * as V1MToonSchema from '@pixiv/types-vrmc-materials-mtoon-1.0';
import type { GLTF, GLTFLoaderPlugin, GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader';
import type { GLTF, GLTFLoaderPlugin, GLTFParser } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { MToonMaterial } from './MToonMaterial';
import type { MToonMaterialParameters } from './MToonMaterialParameters';
import { MToonMaterialOutlineWidthMode } from './MToonMaterialOutlineWidthMode';
Expand Down
43 changes: 36 additions & 7 deletions packages/three-vrm-materials-mtoon/src/shaders/mtoon.frag
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,18 @@ void main() {
// #include <map_fragment>
#ifdef USE_MAP
vec2 mapUv = ( mapUvTransform * vec3( uv, 1 ) ).xy;
vec4 texelColor = texture2D( map, mapUv );
texelColor = mapTexelToLinear( texelColor );
diffuseColor *= texelColor;
#if THREE_VRM_THREE_REVISION >= 137
vec4 sampledDiffuseColor = texture2D( map, mapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
#endif
diffuseColor *= sampledDiffuseColor;
#else
// COMPAT: pre-r137
vec4 texelColor = texture2D( map, mapUv );
texelColor = mapTexelToLinear( texelColor );
diffuseColor *= texelColor;
#endif
#endif

// #include <color_fragment>
Expand Down Expand Up @@ -432,7 +441,12 @@ void main() {
// #include <emissivemap_fragment>
#ifdef USE_EMISSIVEMAP
vec2 emissiveMapUv = ( emissiveMapUvTransform * vec3( uv, 1 ) ).xy;
totalEmissiveRadiance *= emissiveMapTexelToLinear( texture2D( emissiveMap, emissiveMapUv ) ).rgb;
#if THREE_VRM_THREE_REVISION >= 137
totalEmissiveRadiance *= texture2D( emissiveMap, emissiveMapUv ).rgb;
#else
// COMPAT: pre-r137
totalEmissiveRadiance *= emissiveMapTexelToLinear( texture2D( emissiveMap, emissiveMapUv ) ).rgb;
#endif
#endif

#ifdef DEBUG_NORMAL
Expand All @@ -449,7 +463,12 @@ void main() {

material.shadeColor = shadeColorFactor;
#ifdef USE_SHADEMULTIPLYTEXTURE
material.shadeColor *= shadeMultiplyTextureTexelToLinear( texture2D( shadeMultiplyTexture, uv ) ).rgb;
#if THREE_VRM_THREE_REVISION >= 137
material.shadeColor *= texture2D( shadeMultiplyTexture, uv ).rgb;
#else
// COMPAT: pre-r137
material.shadeColor *= shadeMultiplyTextureTexelToLinear( texture2D( shadeMultiplyTexture, uv ) ).rgb;
#endif
#endif

#if ( defined( USE_COLOR ) && !defined( IGNORE_VERTEX_COLOR ) )
Expand Down Expand Up @@ -665,14 +684,24 @@ void main() {
vec3 y = cross( viewDir, x ); // guaranteed to be normalized
vec2 sphereUv = 0.5 + 0.5 * vec2( dot( x, normal ), -dot( y, normal ) );
sphereUv = ( matcapTextureUvTransform * vec3( sphereUv, 1 ) ).xy;
vec3 matcap = matcapTextureTexelToLinear( texture2D( matcapTexture, sphereUv ) ).rgb;
#if THREE_VRM_THREE_REVISION >= 137
vec3 matcap = texture2D( matcapTexture, sphereUv ).rgb;
#else
// COMPAT: pre-r137
vec3 matcap = matcapTextureTexelToLinear( texture2D( matcapTexture, sphereUv ) ).rgb;
#endif
rim += matcapFactor * matcap;
}
#endif

#ifdef USE_RIMMULTIPLYTEXTURE
vec2 rimMultiplyTextureUv = ( rimMultiplyTextureUvTransform * vec3( uv, 1 ) ).xy;
rim *= rimMultiplyTextureTexelToLinear( texture2D( rimMultiplyTexture, rimMultiplyTextureUv ) ).rgb;
#if THREE_VRM_THREE_REVISION >= 137
rim *= texture2D( rimMultiplyTexture, rimMultiplyTextureUv ).rgb;
#else
// COMPAT: pre-r137
rim *= rimMultiplyTextureTexelToLinear( texture2D( rimMultiplyTexture, rimMultiplyTextureUv ) ).rgb;
#endif
#endif

col += rimMix * rim;
Expand Down
Loading