File tree Expand file tree Collapse file tree 3 files changed +26
-4
lines changed
packages/three-vrm-materials-mtoon/src/nodes Expand file tree Collapse file tree 3 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -8,10 +8,11 @@ import {
8
8
shadingShift ,
9
9
shadingToony ,
10
10
} from './immutableNodes' ;
11
+ import { FnCompat } from './utils/FnCompat' ;
11
12
12
13
// TODO: 0% confidence about function types.
13
14
14
- const linearstep = THREE . tslFn (
15
+ const linearstep = FnCompat (
15
16
( {
16
17
a,
17
18
b,
@@ -30,7 +31,7 @@ const linearstep = THREE.tslFn(
30
31
/**
31
32
* Convert NdotL into toon shading factor using shadingShift and shadingToony
32
33
*/
33
- const getShading = THREE . tslFn ( ( { dotNL } : { dotNL : THREE . ShaderNodeObject < THREE . Node > } ) => {
34
+ const getShading = FnCompat ( ( { dotNL } : { dotNL : THREE . ShaderNodeObject < THREE . Node > } ) => {
34
35
const shadow = 1.0 ; // TODO
35
36
36
37
const feather = THREE . float ( 1.0 ) . sub ( shadingToony ) ;
@@ -48,7 +49,7 @@ const getShading = THREE.tslFn(({ dotNL }: { dotNL: THREE.ShaderNodeObject<THREE
48
49
/**
49
50
* Mix diffuseColor and shadeColor using shading factor and light color
50
51
*/
51
- const getDiffuse = THREE . tslFn (
52
+ const getDiffuse = FnCompat (
52
53
( {
53
54
shading,
54
55
lightColor,
Original file line number Diff line number Diff line change 1
1
import * as THREE from 'three/webgpu' ;
2
+ import { FnCompat } from './utils/FnCompat' ;
2
3
3
- export const mtoonParametricRim = THREE . tslFn (
4
+ export const mtoonParametricRim = FnCompat (
4
5
( {
5
6
parametricRimLift,
6
7
parametricRimFresnelPower,
Original file line number Diff line number Diff line change
1
+ import * as THREE from 'three/webgpu' ;
2
+
3
+ /**
4
+ * A compat function for `Fn()` / `tslFn()`.
5
+ * `tslFn()` has been renamed to `Fn()` in r168.
6
+ * We are going to use this compat for a while.
7
+ *
8
+ * See: https://github.com/mrdoob/three.js/pull/29064
9
+ */
10
+ // eslint-disable-next-line @typescript-eslint/naming-convention
11
+ export const FnCompat : typeof THREE . tslFn = ( jsFunc : any ) => {
12
+ // COMPAT r168: `tslFn()` has been renamed to `Fn()`
13
+ // See: https://github.com/mrdoob/three.js/pull/29064
14
+ const threeRevision = parseInt ( THREE . REVISION , 10 ) ;
15
+ if ( threeRevision >= 168 ) {
16
+ return ( THREE as any ) . Fn ( jsFunc ) ;
17
+ } else {
18
+ return ( THREE as any ) . tslFn ( jsFunc ) ;
19
+ }
20
+ } ;
You can’t perform that action at this time.
0 commit comments