material-designer-runtime 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +31 -0
- package/dist/document.d.ts +32 -0
- package/dist/graph/bake-service.d.ts +84 -0
- package/dist/graph/channel-baker.d.ts +10 -0
- package/dist/graph/compiler.d.ts +36 -0
- package/dist/graph/nodes/color/blend.d.ts +2 -0
- package/dist/graph/nodes/color/bright-contrast.d.ts +2 -0
- package/dist/graph/nodes/color/hue-sat-val.d.ts +2 -0
- package/dist/graph/nodes/color/invert.d.ts +2 -0
- package/dist/graph/nodes/color/rgb-curves.d.ts +2 -0
- package/dist/graph/nodes/converter/adapters.d.ts +4 -0
- package/dist/graph/nodes/converter/clamp.d.ts +2 -0
- package/dist/graph/nodes/converter/color-ramp.d.ts +2 -0
- package/dist/graph/nodes/converter/height-blend.d.ts +2 -0
- package/dist/graph/nodes/converter/levels.d.ts +2 -0
- package/dist/graph/nodes/converter/math.d.ts +2 -0
- package/dist/graph/nodes/converter/xyz.d.ts +3 -0
- package/dist/graph/nodes/group/group.d.ts +4 -0
- package/dist/graph/nodes/input/constant.d.ts +3 -0
- package/dist/graph/nodes/input/tex-coordinate.d.ts +2 -0
- package/dist/graph/nodes/output/material-output.d.ts +2 -0
- package/dist/graph/nodes/shader/emission.d.ts +2 -0
- package/dist/graph/nodes/shader/mix-shader.d.ts +2 -0
- package/dist/graph/nodes/shader/principled-bsdf.d.ts +2 -0
- package/dist/graph/nodes/texture/anisotropic-stripes.d.ts +2 -0
- package/dist/graph/nodes/texture/checker.d.ts +2 -0
- package/dist/graph/nodes/texture/fbm.d.ts +2 -0
- package/dist/graph/nodes/texture/gradient.d.ts +2 -0
- package/dist/graph/nodes/texture/scatter.d.ts +2 -0
- package/dist/graph/nodes/texture/screen-noise.d.ts +2 -0
- package/dist/graph/nodes/texture/shape.d.ts +2 -0
- package/dist/graph/nodes/texture/tile.d.ts +2 -0
- package/dist/graph/nodes/texture/tileable-noise.d.ts +2 -0
- package/dist/graph/nodes/texture/voronoi.d.ts +2 -0
- package/dist/graph/nodes/texture/wave.d.ts +2 -0
- package/dist/graph/nodes/vector/domain-warp.d.ts +2 -0
- package/dist/graph/nodes/vector/mapping.d.ts +2 -0
- package/dist/graph/nodes/vector/normal-from-height.d.ts +2 -0
- package/dist/graph/nodes/vector/normal-map.d.ts +2 -0
- package/dist/graph/nodes/vector/tileable-warp.d.ts +2 -0
- package/dist/graph/nodes/vector/vector-math.d.ts +2 -0
- package/dist/graph/registry.d.ts +15 -0
- package/dist/graph/textured-surface.d.ts +60 -0
- package/dist/graph/tiling-test.d.ts +21 -0
- package/dist/graph/types.d.ts +153 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +4437 -0
- package/dist/runtime.d.ts +36 -0
- package/dist/topology.d.ts +3 -0
- package/dist/tsl/blender-color.d.ts +5 -0
- package/dist/tsl/blender-gradient.d.ts +4 -0
- package/dist/tsl/blender-mapping.d.ts +4 -0
- package/dist/tsl/blender-noise.d.ts +5 -0
- package/dist/tsl/blender-voronoi.d.ts +13 -0
- package/dist/tsl/blender-wave.d.ts +14 -0
- package/dist/tsl/curve.d.ts +4 -0
- package/dist/tsl/lloyd-points.d.ts +9 -0
- package/dist/tsl/noise/cellular.d.ts +5 -0
- package/dist/tsl/noise/erosion.d.ts +4 -0
- package/dist/tsl/noise/fbm.d.ts +5 -0
- package/dist/tsl/noise/flow.d.ts +8 -0
- package/dist/tsl/noise/gabor.d.ts +1 -0
- package/dist/tsl/noise/hash.d.ts +8 -0
- package/dist/tsl/noise/index.d.ts +8 -0
- package/dist/tsl/noise/screen.d.ts +8 -0
- package/dist/tsl/noise/simplex.d.ts +4 -0
- package/dist/tsl/noise/value.d.ts +4 -0
- package/dist/tsl/noise/wavelet.d.ts +4 -0
- package/dist/tsl/parallax.d.ts +5 -0
- package/dist/tsl/relaxed-voronoi.d.ts +7 -0
- package/dist/tsl/scatter.d.ts +16 -0
- package/dist/tsl/shape.d.ts +13 -0
- package/dist/tsl/tile.d.ts +23 -0
- package/dist/tsl/tileable-noise.d.ts +6 -0
- package/dist/tsl/triplanar-normal.d.ts +5 -0
- package/dist/tsl/triplanar.d.ts +6 -0
- package/dist/tsl/uv-debug-material.d.ts +2 -0
- package/package.json +63 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { WebGPURenderer } from "three/webgpu";
|
|
2
|
+
import { MaterialGraphSession } from "./document";
|
|
3
|
+
import { MaterialBakeService } from "./graph/bake-service";
|
|
4
|
+
import { TexturedSurface } from "./graph/textured-surface";
|
|
5
|
+
import type { MaterialBackend, MaterialGraphDocument } from "./graph/types";
|
|
6
|
+
import { type NodeRegistry } from "./graph/registry";
|
|
7
|
+
export interface MaterialGraphRuntimeOptions {
|
|
8
|
+
document?: MaterialGraphDocument;
|
|
9
|
+
registry?: NodeRegistry;
|
|
10
|
+
bakeService?: MaterialBakeService;
|
|
11
|
+
source?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class MaterialGraphRuntime {
|
|
14
|
+
readonly graph: MaterialGraphSession;
|
|
15
|
+
readonly surface: TexturedSurface;
|
|
16
|
+
readonly service: MaterialBakeService;
|
|
17
|
+
constructor(options?: MaterialGraphRuntimeOptions);
|
|
18
|
+
get material(): import("three/webgpu").MeshStandardNodeMaterial;
|
|
19
|
+
get lastError(): string | null;
|
|
20
|
+
setRenderer(renderer: WebGPURenderer): this;
|
|
21
|
+
setBackend(backend: MaterialBackend): this;
|
|
22
|
+
getBackend(): MaterialBackend;
|
|
23
|
+
fromDocument(document: MaterialGraphDocument): this;
|
|
24
|
+
setDocument(document: MaterialGraphDocument): this;
|
|
25
|
+
getDocument(): MaterialGraphDocument;
|
|
26
|
+
setOutputResolution(size: number): this;
|
|
27
|
+
setOutputTargets(targets: {
|
|
28
|
+
resolution?: number;
|
|
29
|
+
size?: number;
|
|
30
|
+
}): this;
|
|
31
|
+
setNodeParam(nodeId: string, key: string, value: unknown): this;
|
|
32
|
+
updateNodeParams(nodeId: string, patch: Record<string, unknown>): this;
|
|
33
|
+
refresh(): Promise<void>;
|
|
34
|
+
regenerate(): this;
|
|
35
|
+
dispose(): void;
|
|
36
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MaterialValue } from "../graph/types";
|
|
2
|
+
type V = MaterialValue;
|
|
3
|
+
export declare const blenderVoronoiF1: (c: V, r: V, m: number, e: V, period?: number | V) => V;
|
|
4
|
+
export declare const blenderVoronoiF1Color: (c: V, r: V, m: number, e: V, period?: number | V) => V;
|
|
5
|
+
export declare const blenderVoronoiF1Pos: (c: V, r: V, m: number, e: V, period?: number | V) => V;
|
|
6
|
+
export declare const blenderVoronoiF2: (c: V, r: V, m: number, e: V, period?: number | V) => V;
|
|
7
|
+
export declare const blenderVoronoiF2Color: (c: V, r: V, m: number, e: V, period?: number | V) => V;
|
|
8
|
+
export declare const blenderVoronoiF2Pos: (c: V, r: V, m: number, e: V, period?: number | V) => V;
|
|
9
|
+
export declare const blenderVoronoiSmoothF1: (c: V, r: V, m: number, e: V, s: V, period?: number | V) => V;
|
|
10
|
+
export declare const blenderVoronoiSmoothF1Color: (c: V, r: V, m: number, e: V, s: V, period?: number | V) => V;
|
|
11
|
+
export declare const blenderVoronoiSmoothF1Pos: (c: V, r: V, m: number, e: V, s: V, period?: number | V) => V;
|
|
12
|
+
export declare function blenderVoronoiDistanceToEdge(coord: V, randomness: V, period?: number | V): V;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MaterialValue } from "../graph/types";
|
|
2
|
+
type V = MaterialValue;
|
|
3
|
+
export interface WaveOpts {
|
|
4
|
+
waveType: number;
|
|
5
|
+
dir: number;
|
|
6
|
+
profile: number;
|
|
7
|
+
withDistortion: boolean;
|
|
8
|
+
detail: number;
|
|
9
|
+
tileable: boolean;
|
|
10
|
+
scaleNum: number;
|
|
11
|
+
detailScaleNum: number;
|
|
12
|
+
}
|
|
13
|
+
export declare function blenderWave(coord: V, scale: V, phase: V, distortion: V, detailScale: V, detailRoughness: V, opts: WaveOpts): V;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relaxed seed offsets for a P×P periodic Voronoi grid.
|
|
3
|
+
* @param P integer period (= round(scale)); tile spans [0,P) cells.
|
|
4
|
+
* @param randomness initial jitter amount (0..1), matches the Voronoi `randomness` look.
|
|
5
|
+
* @param iterations Lloyd iterations (0 = raw jitter, 2–4 = strongly relaxed/CVT).
|
|
6
|
+
* @param seed jitter seed.
|
|
7
|
+
* @returns Float32Array of length P*P*3 — [ox,oy,0] per cell, index = iy*P + ix.
|
|
8
|
+
*/
|
|
9
|
+
export declare function relaxedCellOffsets(P: number, randomness: number, iterations: number, seed?: number): Float32Array;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MaterialValue } from "../../graph/types";
|
|
2
|
+
type V = MaterialValue;
|
|
3
|
+
export type NoiseBase01 = (p: V, perX: number, perY: number) => V;
|
|
4
|
+
export declare function periodicFbm01(uv2: V, periodX: number | V, periodY: number | V, octaves: number, gain: V, base: NoiseBase01, aa?: V, lacunarity?: number): V;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MaterialValue } from "../../graph/types";
|
|
2
|
+
type V = MaterialValue;
|
|
3
|
+
export declare const curlVec2: import("three/src/nodes/TSL.js").FnNode<any[], any>;
|
|
4
|
+
export declare function curlVec(p: V, per: number, _perY: number): V;
|
|
5
|
+
export declare function paperBase01(p: V, per: number, _perY: number): V;
|
|
6
|
+
export declare function woolBase01(p: V, per: number, _perY: number): V;
|
|
7
|
+
export declare function stoneBase01(p: V, per: number, _perY: number): V;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const gaborValue2D: import("three/src/nodes/TSL.js").FnNode<any[], any>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MaterialValue } from "../../graph/types";
|
|
2
|
+
type V = MaterialValue;
|
|
3
|
+
export declare const hashInt3ToVec3: import("three/src/nodes/TSL.js").FnNode<any[], any>;
|
|
4
|
+
export declare function hashCell2(ix: V, iy: V, perX: number | V, perY: number | V): V;
|
|
5
|
+
export declare function hashCell2ToVec2(ix: V, iy: V, perX: number | V, perY: number | V): V;
|
|
6
|
+
export declare function hashCell2ToVec3(ix: V, iy: V, perX: number | V, perY: number | V): V;
|
|
7
|
+
export declare function hashCell2ToVec3Seed(ix: V, iy: V, seed: number, perX: number | V, perY: number | V): V;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { periodicFbm01, type NoiseBase01 } from "./fbm";
|
|
2
|
+
export { valueBase01 } from "./value";
|
|
3
|
+
export { worleyBase01, voronoiSmoothBase01 } from "./cellular";
|
|
4
|
+
export { curlVec, paperBase01, woolBase01, stoneBase01 } from "./flow";
|
|
5
|
+
export { gaborValue2D } from "./gabor";
|
|
6
|
+
export { simplexBase01 } from "./simplex";
|
|
7
|
+
export { waveletBase01 } from "./wavelet";
|
|
8
|
+
export { erosionBase01 } from "./erosion";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MaterialValue } from "../../graph/types";
|
|
2
|
+
type V = MaterialValue;
|
|
3
|
+
export declare function ign12(p: V): V;
|
|
4
|
+
export declare function goldenIgn12(p: V): V;
|
|
5
|
+
export declare function blue12(p: V): V;
|
|
6
|
+
export declare function hilbertBlue12(p: V): V;
|
|
7
|
+
export declare function scratches12(uv0: V, thinness: V): V;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MaterialValue } from "../graph/types";
|
|
2
|
+
type V = MaterialValue;
|
|
3
|
+
type SeedFn = (ix: V, iy: V) => V;
|
|
4
|
+
export declare function relaxedVoronoiDistanceToEdge(coord: V, seed: SeedFn): V;
|
|
5
|
+
type ValueFn = (ix: V, iy: V) => V;
|
|
6
|
+
export declare function relaxedVoronoiCellValue(coord: V, seed: SeedFn, value: ValueFn): V;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MaterialValue } from "../graph/types";
|
|
2
|
+
type V = MaterialValue;
|
|
3
|
+
export interface ScatterUniforms {
|
|
4
|
+
amount: V;
|
|
5
|
+
radius: V;
|
|
6
|
+
sizeRandom: V;
|
|
7
|
+
posRandom: V;
|
|
8
|
+
rotRandom: V;
|
|
9
|
+
}
|
|
10
|
+
export interface ScatterResult {
|
|
11
|
+
coord: V;
|
|
12
|
+
value: V;
|
|
13
|
+
size: V;
|
|
14
|
+
}
|
|
15
|
+
export declare function scatterPattern(coord: V, cells: number, u: ScatterUniforms): ScatterResult;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MaterialValue } from "../graph/types";
|
|
2
|
+
type V = MaterialValue;
|
|
3
|
+
export interface ShapeUniforms {
|
|
4
|
+
irregularity: V;
|
|
5
|
+
dome: V;
|
|
6
|
+
edge: V;
|
|
7
|
+
}
|
|
8
|
+
export interface ShapeResult {
|
|
9
|
+
mask: V;
|
|
10
|
+
height: V;
|
|
11
|
+
}
|
|
12
|
+
export declare function shapeField(coord: V, type: string, sides: number, seedIn: V | null, u: ShapeUniforms): ShapeResult;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { MaterialValue } from "../graph/types";
|
|
2
|
+
type V = MaterialValue;
|
|
3
|
+
export interface TileGrid {
|
|
4
|
+
columns: number;
|
|
5
|
+
rows: number;
|
|
6
|
+
offsetFreq: number;
|
|
7
|
+
}
|
|
8
|
+
export interface TileUniforms {
|
|
9
|
+
rowOffset: V;
|
|
10
|
+
gap: V;
|
|
11
|
+
roundness: V;
|
|
12
|
+
edge: V;
|
|
13
|
+
sizeRandom: V;
|
|
14
|
+
posRandom: V;
|
|
15
|
+
rotRandom: V;
|
|
16
|
+
}
|
|
17
|
+
export interface TileResult {
|
|
18
|
+
mask: V;
|
|
19
|
+
value: V;
|
|
20
|
+
}
|
|
21
|
+
export declare function tilePattern(coord: V, grid: TileGrid, u: TileUniforms): TileResult;
|
|
22
|
+
export declare function hexPattern(coord: V, columns: number, rows: number, gap: V, edge: V): TileResult;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { MaterialValue } from "../graph/types";
|
|
2
|
+
type V = MaterialValue;
|
|
3
|
+
export declare const pnoise2: import("three/src/nodes/TSL.js").FnNode<any[], any>;
|
|
4
|
+
export declare function tileableFbm(uv2: V, // the 2D coordinate (uv tile)
|
|
5
|
+
periodX: number | V, periodY: number | V, octaves: number, gain: V, aa?: V, lacunarity?: number): V;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Texture } from "three/webgpu";
|
|
2
|
+
import type { MaterialValue } from "../graph/types";
|
|
3
|
+
type V = MaterialValue;
|
|
4
|
+
export declare function triplanarBlendWeights(sharpness: V): V;
|
|
5
|
+
export declare function triplanarColor(map: Texture, scale: V, sharpness: V): V;
|
|
6
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "material-designer-runtime",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Lightweight runtime for loading and rendering Material Designer node graph documents.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Ivan Juarez",
|
|
8
|
+
"homepage": "https://github.com/vanrez-nez/material-designer-runtime#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/vanrez-nez/material-designer-runtime.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/vanrez-nez/material-designer-runtime/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"three",
|
|
18
|
+
"threejs",
|
|
19
|
+
"webgpu",
|
|
20
|
+
"tsl",
|
|
21
|
+
"material",
|
|
22
|
+
"pbr",
|
|
23
|
+
"node-graph",
|
|
24
|
+
"procedural",
|
|
25
|
+
"textures",
|
|
26
|
+
"shader"
|
|
27
|
+
],
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=18"
|
|
30
|
+
},
|
|
31
|
+
"main": "./dist/index.js",
|
|
32
|
+
"module": "./dist/index.js",
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"import": "./dist/index.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"README.md",
|
|
43
|
+
"LICENSE"
|
|
44
|
+
],
|
|
45
|
+
"sideEffects": [
|
|
46
|
+
"./dist/index.js"
|
|
47
|
+
],
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
50
|
+
"pack:dry-run": "npm pack --dry-run",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"prepublishOnly": "npm run test && npm run build && npm run pack:dry-run"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"three": "0.184.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@types/three": "^0.184.1",
|
|
59
|
+
"typescript": "6.0.3",
|
|
60
|
+
"vite": "8.0.16",
|
|
61
|
+
"vitest": "^4.0.0"
|
|
62
|
+
}
|
|
63
|
+
}
|