-
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
135 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
import CodeNode from './CodeNode'; | ||
import CodeNode, { CodeNodeInclude } from './CodeNode'; | ||
import FunctionCallNode from './FunctionCallNode'; | ||
import NodeBuilder from './NodeBuilder'; | ||
import NodeFunction from './NodeFunction'; | ||
import NodeFunctionInput from './NodeFunctionInput'; | ||
import Node from './Node'; | ||
|
||
export default class FunctionNode extends CodeNode { | ||
export type FunctionNodeParameters = Node[] | { [name: string]: Node }; | ||
|
||
export default class FunctionNode<P extends Node[] | { [name: string]: Node }> extends CodeNode { | ||
keywords: { [key: string]: Node }; | ||
constructor(code?: string); | ||
constructor(code?: string, includes?: CodeNodeInclude[]); | ||
|
||
getInputs(builder: NodeBuilder): NodeFunctionInput[]; | ||
getNodeFunction(builder: NodeBuilder): NodeFunction; | ||
call(parameters: { [name: string]: Node }): FunctionCallNode; | ||
call(parameters: P): FunctionCallNode<P>; | ||
} |
4 changes: 4 additions & 0 deletions
4
types/three/examples/jsm/nodes/materialx/functions/lib/mx_hsv.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { FnParameters, Node, Swizzable } from '../../../Nodes'; | ||
|
||
export function mx_hsvtorgb(...params: FnParameters<[Node]>): Swizzable; | ||
export function mx_rgbtohsv(...params: FnParameters<[Node]>): Swizzable; |
6 changes: 6 additions & 0 deletions
6
types/three/examples/jsm/nodes/materialx/functions/lib/mx_noise.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { FnParameters, Node, Swizzable } from '../../../Nodes'; | ||
|
||
export function mx_perlin_noise_float(...params: FnParameters<[Node]>): Swizzable; | ||
export function mx_cell_noise_float(...params: FnParameters<[Node]>): Swizzable; | ||
export function mx_worley_noise_float(...params: FnParameters<[Node]>): Swizzable; | ||
export function mx_fractal_noise_float(...params: FnParameters<[Node, Node, Node, Node]>): Swizzable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* Various tests of func, fn and call | ||
*/ | ||
|
||
import { | ||
code, | ||
fn, | ||
uv, | ||
func, | ||
Node, | ||
FunctionNode, | ||
call, | ||
Swizzable, | ||
FunctionCallNode, | ||
} from 'three/examples/jsm/nodes/Nodes'; | ||
|
||
import { ProxiedObject } from 'three/examples/jsm/nodes/shadernode/ShaderNode'; | ||
|
||
export const mx_noise = code('whatever'); | ||
const includes = [mx_noise]; | ||
|
||
const someFunc1 = new FunctionNode<[a: Node]>(); | ||
const someFunc2 = new FunctionNode<{ a: Node }>(); | ||
|
||
// tslint:disable-next-line:no-unnecessary-generics | ||
function assertSwizzable<T extends Node>(_s: Swizzable<T>) {} | ||
|
||
type a = ProxiedObject<readonly [Node]>; | ||
|
||
assertSwizzable<FunctionCallNode<[Node]>>(call(someFunc1, [1])); | ||
assertSwizzable<FunctionCallNode<[Node]>>(call(someFunc1, [uv()])); | ||
assertSwizzable<FunctionCallNode<[Node]>>(call(someFunc1, [uv().xy])); | ||
assertSwizzable<FunctionCallNode<{ a: Node }>>(call(someFunc2, { a: 1 })); | ||
assertSwizzable<FunctionCallNode<{ a: Node }>>(call(someFunc2, { a: uv() })); | ||
assertSwizzable<FunctionCallNode<{ a: Node }>>(call(someFunc2, { a: uv().xy })); | ||
|
||
export const mx_cell_noise_float_call = func<[Node]>('float mx_cell_noise_float( vec3 p )', includes); | ||
export const mx_worley_noise_float_call = func<[Node, Node, Node]>( | ||
'float mx_worley_noise_float( vec3 p, float jitter, int metric )', | ||
includes, | ||
); | ||
export const ab_call = func<{ a: Node; b: Node }>('float mx_cell_noise_float( vec3 p )', includes); | ||
|
||
assertSwizzable<Node>(mx_cell_noise_float_call.call(uv())); | ||
assertSwizzable<Node>(mx_worley_noise_float_call.call(uv(), 1, 1)); | ||
assertSwizzable<Node>(ab_call.call({ a: 1, b: uv() })); | ||
|
||
export const mx_cell_noise_float = fn<[Node]>('float mx_cell_noise_float( vec3 p )', includes); | ||
export const mx_worley_noise_float = fn<[Node, Node, Node]>( | ||
'float mx_worley_noise_float( vec3 p, float jitter, int metric )', | ||
includes, | ||
); | ||
export const ab = fn<{ a: Node; b: Node }>('float mx_cell_noise_float( vec3 p )', includes); | ||
|
||
assertSwizzable<Node>(mx_cell_noise_float(uv())); | ||
assertSwizzable<Node>(mx_worley_noise_float(uv(), 1, 1)); | ||
assertSwizzable<Node>(ab({ a: 1, b: uv() })); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { | ||
mx_perlin_noise_float, | ||
mx_cell_noise_float, | ||
mx_worley_noise_float, | ||
mx_fractal_noise_float, | ||
} from 'three/examples/jsm/nodes/materialx/functions/lib/mx_noise'; | ||
|
||
import { mx_hsvtorgb, mx_rgbtohsv } from 'three/examples/jsm/nodes/materialx/functions/lib/mx_hsv'; | ||
|
||
mx_perlin_noise_float(1); | ||
mx_cell_noise_float(1); | ||
mx_worley_noise_float(1); | ||
mx_fractal_noise_float(1, 1, 1, 1); | ||
mx_hsvtorgb(1); | ||
mx_rgbtohsv(1); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters