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.
Files changed (79) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +31 -0
  3. package/dist/document.d.ts +32 -0
  4. package/dist/graph/bake-service.d.ts +84 -0
  5. package/dist/graph/channel-baker.d.ts +10 -0
  6. package/dist/graph/compiler.d.ts +36 -0
  7. package/dist/graph/nodes/color/blend.d.ts +2 -0
  8. package/dist/graph/nodes/color/bright-contrast.d.ts +2 -0
  9. package/dist/graph/nodes/color/hue-sat-val.d.ts +2 -0
  10. package/dist/graph/nodes/color/invert.d.ts +2 -0
  11. package/dist/graph/nodes/color/rgb-curves.d.ts +2 -0
  12. package/dist/graph/nodes/converter/adapters.d.ts +4 -0
  13. package/dist/graph/nodes/converter/clamp.d.ts +2 -0
  14. package/dist/graph/nodes/converter/color-ramp.d.ts +2 -0
  15. package/dist/graph/nodes/converter/height-blend.d.ts +2 -0
  16. package/dist/graph/nodes/converter/levels.d.ts +2 -0
  17. package/dist/graph/nodes/converter/math.d.ts +2 -0
  18. package/dist/graph/nodes/converter/xyz.d.ts +3 -0
  19. package/dist/graph/nodes/group/group.d.ts +4 -0
  20. package/dist/graph/nodes/input/constant.d.ts +3 -0
  21. package/dist/graph/nodes/input/tex-coordinate.d.ts +2 -0
  22. package/dist/graph/nodes/output/material-output.d.ts +2 -0
  23. package/dist/graph/nodes/shader/emission.d.ts +2 -0
  24. package/dist/graph/nodes/shader/mix-shader.d.ts +2 -0
  25. package/dist/graph/nodes/shader/principled-bsdf.d.ts +2 -0
  26. package/dist/graph/nodes/texture/anisotropic-stripes.d.ts +2 -0
  27. package/dist/graph/nodes/texture/checker.d.ts +2 -0
  28. package/dist/graph/nodes/texture/fbm.d.ts +2 -0
  29. package/dist/graph/nodes/texture/gradient.d.ts +2 -0
  30. package/dist/graph/nodes/texture/scatter.d.ts +2 -0
  31. package/dist/graph/nodes/texture/screen-noise.d.ts +2 -0
  32. package/dist/graph/nodes/texture/shape.d.ts +2 -0
  33. package/dist/graph/nodes/texture/tile.d.ts +2 -0
  34. package/dist/graph/nodes/texture/tileable-noise.d.ts +2 -0
  35. package/dist/graph/nodes/texture/voronoi.d.ts +2 -0
  36. package/dist/graph/nodes/texture/wave.d.ts +2 -0
  37. package/dist/graph/nodes/vector/domain-warp.d.ts +2 -0
  38. package/dist/graph/nodes/vector/mapping.d.ts +2 -0
  39. package/dist/graph/nodes/vector/normal-from-height.d.ts +2 -0
  40. package/dist/graph/nodes/vector/normal-map.d.ts +2 -0
  41. package/dist/graph/nodes/vector/tileable-warp.d.ts +2 -0
  42. package/dist/graph/nodes/vector/vector-math.d.ts +2 -0
  43. package/dist/graph/registry.d.ts +15 -0
  44. package/dist/graph/textured-surface.d.ts +60 -0
  45. package/dist/graph/tiling-test.d.ts +21 -0
  46. package/dist/graph/types.d.ts +153 -0
  47. package/dist/index.d.ts +9 -0
  48. package/dist/index.js +4437 -0
  49. package/dist/runtime.d.ts +36 -0
  50. package/dist/topology.d.ts +3 -0
  51. package/dist/tsl/blender-color.d.ts +5 -0
  52. package/dist/tsl/blender-gradient.d.ts +4 -0
  53. package/dist/tsl/blender-mapping.d.ts +4 -0
  54. package/dist/tsl/blender-noise.d.ts +5 -0
  55. package/dist/tsl/blender-voronoi.d.ts +13 -0
  56. package/dist/tsl/blender-wave.d.ts +14 -0
  57. package/dist/tsl/curve.d.ts +4 -0
  58. package/dist/tsl/lloyd-points.d.ts +9 -0
  59. package/dist/tsl/noise/cellular.d.ts +5 -0
  60. package/dist/tsl/noise/erosion.d.ts +4 -0
  61. package/dist/tsl/noise/fbm.d.ts +5 -0
  62. package/dist/tsl/noise/flow.d.ts +8 -0
  63. package/dist/tsl/noise/gabor.d.ts +1 -0
  64. package/dist/tsl/noise/hash.d.ts +8 -0
  65. package/dist/tsl/noise/index.d.ts +8 -0
  66. package/dist/tsl/noise/screen.d.ts +8 -0
  67. package/dist/tsl/noise/simplex.d.ts +4 -0
  68. package/dist/tsl/noise/value.d.ts +4 -0
  69. package/dist/tsl/noise/wavelet.d.ts +4 -0
  70. package/dist/tsl/parallax.d.ts +5 -0
  71. package/dist/tsl/relaxed-voronoi.d.ts +7 -0
  72. package/dist/tsl/scatter.d.ts +16 -0
  73. package/dist/tsl/shape.d.ts +13 -0
  74. package/dist/tsl/tile.d.ts +23 -0
  75. package/dist/tsl/tileable-noise.d.ts +6 -0
  76. package/dist/tsl/triplanar-normal.d.ts +5 -0
  77. package/dist/tsl/triplanar.d.ts +6 -0
  78. package/dist/tsl/uv-debug-material.d.ts +2 -0
  79. 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,3 @@
1
+ import { type NodeRegistry } from "./graph/registry";
2
+ import type { MaterialGraphDocument } from "./graph/types";
3
+ export declare function createMaterialTopologyKey(doc: MaterialGraphDocument, registry: NodeRegistry): string;
@@ -0,0 +1,5 @@
1
+ import type { MaterialValue } from "../graph/types";
2
+ type V = MaterialValue;
3
+ export declare function rgbToHsv(rgb: V): V;
4
+ export declare function hsvToRgb(hsv: V): V;
5
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { MaterialValue } from "../graph/types";
2
+ type V = MaterialValue;
3
+ export declare function blenderGradient(p: V, type: number): V;
4
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { MaterialValue } from "../graph/types";
2
+ type V = MaterialValue;
3
+ export declare function blenderMapping(v: V, location: V, rotation: V, scale: V, type: number): V;
4
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { MaterialValue } from "../graph/types";
2
+ type V = MaterialValue;
3
+ export declare const blenderSnoise: (p: V) => V;
4
+ export declare function blenderFbm(p: V, octaves: number, roughness: V, lacunarity: V): V;
5
+ export {};
@@ -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,4 @@
1
+ import type { MaterialValue } from "../graph/types";
2
+ type V = MaterialValue;
3
+ export declare function curve5(t: V, p: V[]): V;
4
+ 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 declare function worleyBase01(p: V, perX: number | V, perY: number | V): V;
4
+ export declare function voronoiSmoothBase01(p: V, perX: number | V, perY: number | V): V;
5
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { MaterialValue } from "../../graph/types";
2
+ type V = MaterialValue;
3
+ export declare function erosionBase01(p: V, per: number, _perY: number): V;
4
+ export {};
@@ -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,4 @@
1
+ import type { MaterialValue } from "../../graph/types";
2
+ type V = MaterialValue;
3
+ export declare function simplexBase01(p: V, perX: number, perY: number): V;
4
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { MaterialValue } from "../../graph/types";
2
+ type V = MaterialValue;
3
+ export declare function valueBase01(p: V, perX: number, perY: number): V;
4
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { MaterialValue } from "../../graph/types";
2
+ type V = MaterialValue;
3
+ export declare function waveletBase01(p: V, perX: number, perY: number): V;
4
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { Texture } from "three/webgpu";
2
+ import type { MaterialValue } from "../graph/types";
3
+ type V = MaterialValue;
4
+ export declare function parallaxOcclusionUV(heightMap: Texture, baseUv: V, scale: V, layers: number): V;
5
+ 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,5 @@
1
+ import type { Texture } from "three/webgpu";
2
+ import type { MaterialValue } from "../graph/types";
3
+ type V = MaterialValue;
4
+ export declare function triplanarNormalMap(map: Texture, scale: V, sharpness: V): V;
5
+ 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 {};
@@ -0,0 +1,2 @@
1
+ import { MeshBasicNodeMaterial } from "three/webgpu";
2
+ export declare function createUvDebugMaterial(): MeshBasicNodeMaterial;
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
+ }