@shaderfrog/core 1.3.0 → 1.3.2

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 (155) hide show
  1. package/package.json +10 -7
  2. package/cjs/engine.js +0 -218
  3. package/cjs/graph/base-node.js +0 -13
  4. package/cjs/graph/code-nodes.js +0 -23
  5. package/cjs/graph/context.js +0 -253
  6. package/cjs/graph/data-nodes.js +0 -146
  7. package/cjs/graph/edge.js +0 -12
  8. package/cjs/graph/evaluate.js +0 -32
  9. package/cjs/graph/graph-node.js +0 -143
  10. package/cjs/graph/graph-types.js +0 -25
  11. package/cjs/graph/graph.js +0 -533
  12. package/cjs/graph/graph.test.js +0 -173
  13. package/cjs/graph/index.js +0 -27
  14. package/cjs/graph/parsers.js +0 -219
  15. package/cjs/graph/shader-sections.js +0 -268
  16. package/cjs/index.js +0 -19
  17. package/cjs/package.json +0 -1
  18. package/cjs/plugins/babylon/bablyengine.js +0 -597
  19. package/cjs/plugins/babylon/importers.js +0 -66
  20. package/cjs/plugins/babylon/index.js +0 -5
  21. package/cjs/plugins/playcanvas/importers.js +0 -30
  22. package/cjs/plugins/playcanvas/index.js +0 -5
  23. package/cjs/plugins/playcanvas/playengine.js +0 -549
  24. package/cjs/plugins/three/importers.js +0 -17
  25. package/cjs/plugins/three/index.js +0 -6
  26. package/cjs/plugins/three/threngine.js +0 -619
  27. package/cjs/strategy/assignemntTo.js +0 -31
  28. package/cjs/strategy/declarationOf.js +0 -28
  29. package/cjs/strategy/hardCode.js +0 -28
  30. package/cjs/strategy/index.js +0 -25
  31. package/cjs/strategy/inject.js +0 -127
  32. package/cjs/strategy/namedAttribute.js +0 -53
  33. package/cjs/strategy/strategy.js +0 -35
  34. package/cjs/strategy/stratgies.test.js +0 -192
  35. package/cjs/strategy/texture2D.js +0 -88
  36. package/cjs/strategy/uniform.js +0 -195
  37. package/cjs/strategy/variable.js +0 -85
  38. package/cjs/util/ast.js +0 -351
  39. package/cjs/util/ensure.js +0 -11
  40. package/cjs/util/id.js +0 -6
  41. package/esm/engine.d.ts +0 -69
  42. package/esm/graph/base-node.d.ts +0 -36
  43. package/esm/graph/code-nodes.d.ts +0 -44
  44. package/esm/graph/context.d.ts +0 -37
  45. package/esm/graph/data-nodes.d.ts +0 -83
  46. package/esm/graph/edge.d.ts +0 -13
  47. package/esm/graph/evaluate.d.ts +0 -9
  48. package/esm/graph/graph-node.d.ts +0 -8
  49. package/esm/graph/graph-types.d.ts +0 -38
  50. package/esm/graph/graph.d.ts +0 -89
  51. package/esm/graph/graph.test.d.ts +0 -1
  52. package/esm/graph/index.d.ts +0 -11
  53. package/esm/graph/parsers.d.ts +0 -39
  54. package/esm/graph/shader-sections.d.ts +0 -47
  55. package/esm/index.d.ts +0 -3
  56. package/esm/package.json +0 -1
  57. package/esm/plugins/babylon/bablyengine.d.ts +0 -28
  58. package/esm/plugins/babylon/importers.d.ts +0 -3
  59. package/esm/plugins/babylon/index.d.ts +0 -2
  60. package/esm/plugins/playcanvas/importers.d.ts +0 -3
  61. package/esm/plugins/playcanvas/index.d.ts +0 -2
  62. package/esm/plugins/playcanvas/playengine.d.ts +0 -39
  63. package/esm/plugins/three/importers.d.ts +0 -3
  64. package/esm/plugins/three/index.d.ts +0 -2
  65. package/esm/plugins/three/threngine.d.ts +0 -34
  66. package/esm/strategy/assignemntTo.d.ts +0 -9
  67. package/esm/strategy/declarationOf.d.ts +0 -9
  68. package/esm/strategy/hardCode.d.ts +0 -15
  69. package/esm/strategy/index.d.ts +0 -9
  70. package/esm/strategy/inject.d.ts +0 -15
  71. package/esm/strategy/namedAttribute.d.ts +0 -9
  72. package/esm/strategy/strategy.d.ts +0 -28
  73. package/esm/strategy/stratgies.test.d.ts +0 -1
  74. package/esm/strategy/texture2D.d.ts +0 -6
  75. package/esm/strategy/uniform.d.ts +0 -6
  76. package/esm/strategy/variable.d.ts +0 -6
  77. package/esm/util/ast.d.ts +0 -30
  78. package/esm/util/ensure.d.ts +0 -1
  79. package/esm/util/id.d.ts +0 -1
  80. /package/{cjs/engine.d.ts → engine.d.ts} +0 -0
  81. /package/{esm/engine.js → engine.js} +0 -0
  82. /package/{cjs/graph → graph}/base-node.d.ts +0 -0
  83. /package/{esm/graph → graph}/base-node.js +0 -0
  84. /package/{cjs/graph → graph}/code-nodes.d.ts +0 -0
  85. /package/{esm/graph → graph}/code-nodes.js +0 -0
  86. /package/{cjs/graph → graph}/context.d.ts +0 -0
  87. /package/{esm/graph → graph}/context.js +0 -0
  88. /package/{cjs/graph → graph}/data-nodes.d.ts +0 -0
  89. /package/{esm/graph → graph}/data-nodes.js +0 -0
  90. /package/{cjs/graph → graph}/edge.d.ts +0 -0
  91. /package/{esm/graph → graph}/edge.js +0 -0
  92. /package/{cjs/graph → graph}/evaluate.d.ts +0 -0
  93. /package/{esm/graph → graph}/evaluate.js +0 -0
  94. /package/{cjs/graph → graph}/graph-node.d.ts +0 -0
  95. /package/{esm/graph → graph}/graph-node.js +0 -0
  96. /package/{cjs/graph → graph}/graph-types.d.ts +0 -0
  97. /package/{esm/graph → graph}/graph-types.js +0 -0
  98. /package/{cjs/graph → graph}/graph.d.ts +0 -0
  99. /package/{esm/graph → graph}/graph.js +0 -0
  100. /package/{cjs/graph → graph}/graph.test.d.ts +0 -0
  101. /package/{esm/graph → graph}/graph.test.js +0 -0
  102. /package/{cjs/graph → graph}/index.d.ts +0 -0
  103. /package/{esm/graph → graph}/index.js +0 -0
  104. /package/{cjs/graph → graph}/parsers.d.ts +0 -0
  105. /package/{esm/graph → graph}/parsers.js +0 -0
  106. /package/{cjs/graph → graph}/shader-sections.d.ts +0 -0
  107. /package/{esm/graph → graph}/shader-sections.js +0 -0
  108. /package/{cjs/index.d.ts → index.d.ts} +0 -0
  109. /package/{esm/index.js → index.js} +0 -0
  110. /package/{cjs/plugins → plugins}/babylon/bablyengine.d.ts +0 -0
  111. /package/{esm/plugins → plugins}/babylon/bablyengine.js +0 -0
  112. /package/{cjs/plugins → plugins}/babylon/importers.d.ts +0 -0
  113. /package/{esm/plugins → plugins}/babylon/importers.js +0 -0
  114. /package/{cjs/plugins → plugins}/babylon/index.d.ts +0 -0
  115. /package/{esm/plugins → plugins}/babylon/index.js +0 -0
  116. /package/{cjs/plugins → plugins}/playcanvas/importers.d.ts +0 -0
  117. /package/{esm/plugins → plugins}/playcanvas/importers.js +0 -0
  118. /package/{cjs/plugins → plugins}/playcanvas/index.d.ts +0 -0
  119. /package/{esm/plugins → plugins}/playcanvas/index.js +0 -0
  120. /package/{cjs/plugins → plugins}/playcanvas/playengine.d.ts +0 -0
  121. /package/{esm/plugins → plugins}/playcanvas/playengine.js +0 -0
  122. /package/{cjs/plugins → plugins}/three/importers.d.ts +0 -0
  123. /package/{esm/plugins → plugins}/three/importers.js +0 -0
  124. /package/{cjs/plugins → plugins}/three/index.d.ts +0 -0
  125. /package/{esm/plugins → plugins}/three/index.js +0 -0
  126. /package/{cjs/plugins → plugins}/three/threngine.d.ts +0 -0
  127. /package/{esm/plugins → plugins}/three/threngine.js +0 -0
  128. /package/{cjs/strategy → strategy}/assignemntTo.d.ts +0 -0
  129. /package/{esm/strategy → strategy}/assignemntTo.js +0 -0
  130. /package/{cjs/strategy → strategy}/declarationOf.d.ts +0 -0
  131. /package/{esm/strategy → strategy}/declarationOf.js +0 -0
  132. /package/{cjs/strategy → strategy}/hardCode.d.ts +0 -0
  133. /package/{esm/strategy → strategy}/hardCode.js +0 -0
  134. /package/{cjs/strategy → strategy}/index.d.ts +0 -0
  135. /package/{esm/strategy → strategy}/index.js +0 -0
  136. /package/{cjs/strategy → strategy}/inject.d.ts +0 -0
  137. /package/{esm/strategy → strategy}/inject.js +0 -0
  138. /package/{cjs/strategy → strategy}/namedAttribute.d.ts +0 -0
  139. /package/{esm/strategy → strategy}/namedAttribute.js +0 -0
  140. /package/{cjs/strategy → strategy}/strategy.d.ts +0 -0
  141. /package/{esm/strategy → strategy}/strategy.js +0 -0
  142. /package/{cjs/strategy → strategy}/stratgies.test.d.ts +0 -0
  143. /package/{esm/strategy → strategy}/stratgies.test.js +0 -0
  144. /package/{cjs/strategy → strategy}/texture2D.d.ts +0 -0
  145. /package/{esm/strategy → strategy}/texture2D.js +0 -0
  146. /package/{cjs/strategy → strategy}/uniform.d.ts +0 -0
  147. /package/{esm/strategy → strategy}/uniform.js +0 -0
  148. /package/{cjs/strategy → strategy}/variable.d.ts +0 -0
  149. /package/{esm/strategy → strategy}/variable.js +0 -0
  150. /package/{cjs/util → util}/ast.d.ts +0 -0
  151. /package/{esm/util → util}/ast.js +0 -0
  152. /package/{cjs/util → util}/ensure.d.ts +0 -0
  153. /package/{esm/util → util}/ensure.js +0 -0
  154. /package/{cjs/util → util}/id.d.ts +0 -0
  155. /package/{esm/util → util}/id.js +0 -0
package/esm/engine.d.ts DELETED
@@ -1,69 +0,0 @@
1
- import { Program } from '@shaderfrog/glsl-parser/ast';
2
- import { MergeOptions } from './graph/shader-sections';
3
- import { Graph, ShaderStage } from './graph/graph-types';
4
- import { NodePosition } from './graph/base-node';
5
- import { DataNode, UniformDataType } from './graph/data-nodes';
6
- import { CodeNode, NodeProperty, SourceNode } from './graph/code-nodes';
7
- import { NodeContext } from './graph/context';
8
- import { NodeParser } from './graph/parsers';
9
- export declare enum EngineNodeType {
10
- toon = "toon",
11
- phong = "phong",
12
- physical = "physical",
13
- shader = "shader",
14
- binary = "binary"
15
- }
16
- export type PhongNodeConstructor = (id: string, name: string, position: NodePosition, uniforms: UniformDataType[], stage: ShaderStage | undefined) => CodeNode;
17
- export type PhysicalNodeConstructor = (id: string, name: string, position: NodePosition, uniforms: UniformDataType[], stage: ShaderStage | undefined) => CodeNode;
18
- export type ToonNodeConstructor = (id: string, name: string, position: NodePosition, uniforms: UniformDataType[], stage: ShaderStage | undefined) => CodeNode;
19
- export interface Engine {
20
- name: 'three' | 'babylon' | 'playcanvas';
21
- displayName: string;
22
- preserve: Set<string>;
23
- mergeOptions: MergeOptions;
24
- parsers: Record<string, NodeParser>;
25
- importers: EngineImporters;
26
- evaluateNode: (node: DataNode) => any;
27
- constructors: {
28
- [EngineNodeType.phong]?: PhongNodeConstructor;
29
- [EngineNodeType.physical]?: PhysicalNodeConstructor;
30
- [EngineNodeType.toon]?: ToonNodeConstructor;
31
- };
32
- }
33
- export type EngineContext = {
34
- engine: string;
35
- nodes: Record<string, NodeContext>;
36
- runtime: any;
37
- debuggingNonsense: {
38
- vertexSource?: string;
39
- vertexPreprocessed?: string;
40
- fragmentPreprocessed?: string;
41
- fragmentSource?: string;
42
- };
43
- };
44
- export type EngineImporter = {
45
- convertAst(ast: Program, type?: ShaderStage): void;
46
- nodeInputMap: Partial<Record<EngineNodeType, Record<string, string | null>>>;
47
- edgeMap: {
48
- [oldInput: string]: string;
49
- };
50
- };
51
- export type EngineImporters = {
52
- [engine: string]: EngineImporter;
53
- };
54
- export declare const convertNode: (node: SourceNode, converter: EngineImporter) => SourceNode;
55
- export declare const convertToEngine: (oldEngine: Engine, newEngine: Engine, graph: Graph) => Graph;
56
- export type DefaultPropertySetter = (p: NodeProperty) => any;
57
- /**
58
- * Create the initial engine node properties for a plugin to create its initial
59
- * material with. This finds all engine nodes in the graph, finds all their
60
- * properties, evalutes them, and returns an object with initial properties to
61
- * set on the new plugin material, like a three.RawShaderMaterial().
62
- *
63
- * Currently only PlayCanvas uses this. It's at odds with the compileResult.dataInputs
64
- * code path. That path uses isDataNode() to check for inputs, which excludes
65
- * baked inputs. PlayCanvas requires (at least diffusesMap?) baked input properties
66
- * to be set to a pc.Texture() at runtime, otherwise there's an error about
67
- * vertex_texCoord0.
68
- */
69
- export declare const collectInitialEvaluatedGraphProperties: (engine: Engine, graph: Graph, defaultPropertySetting: DefaultPropertySetter) => Record<string, any>;
@@ -1,36 +0,0 @@
1
- /**
2
- * Base node stuff, used across all nodes
3
- */
4
- import { GraphDataType } from './data-nodes';
5
- export type InputCategory = 'data' | 'code';
6
- export type InputType = 'uniform' | 'property' | 'filler';
7
- export interface NodeInput {
8
- displayName: string;
9
- id: string;
10
- type: InputType;
11
- dataType?: GraphDataType;
12
- accepts: InputCategory[];
13
- baked?: boolean;
14
- bakeable: boolean;
15
- property?: string;
16
- }
17
- export declare const nodeInput: (displayName: string, id: string, type: InputType, dataType: GraphDataType | undefined, accepts: InputCategory[], bakeable: boolean, property?: string) => NodeInput;
18
- export interface NodeOutput {
19
- name: string;
20
- id: string;
21
- dataType?: GraphDataType;
22
- category: InputCategory;
23
- }
24
- export type NodePosition = {
25
- x: number;
26
- y: number;
27
- };
28
- export interface BaseNode {
29
- id: string;
30
- parentId?: string;
31
- name: string;
32
- type: string;
33
- inputs: NodeInput[];
34
- outputs: NodeOutput[];
35
- position: NodePosition;
36
- }
@@ -1,44 +0,0 @@
1
- import { ShaderStage } from './graph-types';
2
- import { Strategy } from '../strategy';
3
- import { GraphDataType, UniformDataType } from './data-nodes';
4
- import { BaseNode, NodeInput } from './base-node';
5
- export declare const mapInputName: (node: CodeNode, { id, displayName }: NodeInput) => string;
6
- export type InputMapping = {
7
- [original: string]: string;
8
- };
9
- export type NodeConfig = {
10
- version: 2 | 3;
11
- mangle?: boolean;
12
- preprocess: boolean;
13
- inputMapping?: InputMapping;
14
- strategies: Strategy[];
15
- uniforms: UniformDataType[];
16
- properties?: NodeProperty[];
17
- hardCodedProperties?: Record<string, any>;
18
- };
19
- export interface NodeProperty {
20
- displayName: string;
21
- type: GraphDataType;
22
- property: string;
23
- fillerName?: string;
24
- defaultValue?: any;
25
- }
26
- export declare const property: (displayName: string, property: string, type: GraphDataType, fillerName?: string, defaultValue?: any) => NodeProperty;
27
- export declare enum SourceType {
28
- SHADER_PROGRAM = "Shader Program",
29
- EXPRESSION = "Expression",
30
- FN_BODY_FRAGMENT = "Function Body Fragment"
31
- }
32
- export interface CodeNode extends BaseNode {
33
- config: NodeConfig;
34
- engine: boolean;
35
- source: string;
36
- sourceType?: SourceType;
37
- stage?: ShaderStage;
38
- biStage?: boolean;
39
- originalEngine?: string;
40
- }
41
- export interface BinaryNode extends CodeNode {
42
- operator: string;
43
- }
44
- export type SourceNode = BinaryNode | CodeNode;
@@ -1,37 +0,0 @@
1
- import type { GlslSyntaxError } from '@shaderfrog/glsl-parser';
2
- import { AstNode, Program } from '@shaderfrog/glsl-parser/ast';
3
- import { Engine, EngineContext } from '../engine';
4
- import { NodeInput } from './base-node';
5
- import { Graph, GraphNode } from './graph-types';
6
- import { InputFillers } from './parsers';
7
- /**
8
- * A node's context is the runtime / in-memory computed data associated with a
9
- * graph node. It includes the parsed AST representation of the node, as well as
10
- * the inputs found in that AST. It's not currently saved to the database.
11
- */
12
- export type NodeContext = {
13
- id?: string;
14
- name?: string;
15
- source?: string;
16
- ast: AstNode | Program;
17
- inputs?: NodeInput[];
18
- inputFillers: InputFillers;
19
- errors?: NodeErrors;
20
- };
21
- export type NodeErrors = {
22
- type: 'errors';
23
- nodeId: string;
24
- errors: (GlslSyntaxError | string)[];
25
- };
26
- export declare const isError: (test: any) => test is NodeErrors;
27
- export declare const computeContextForNodes: (engineContext: EngineContext, engine: Engine, graph: Graph, nodes: GraphNode[]) => Promise<NodeErrors | Record<string, NodeContext>>;
28
- /**
29
- * Compute the context for every node in the graph, done on initial graph load
30
- * to compute the inputs/outputs for every node
31
- */
32
- export declare const computeAllContexts: (engineContext: EngineContext, engine: Engine, graph: Graph) => Promise<NodeErrors>;
33
- /**
34
- * Compute the contexts for nodes starting from the outputs, working backwards.
35
- * Used to only (re)-compute context for any actively used nodes
36
- */
37
- export declare const computeGraphContext: (engineContext: EngineContext, engine: Engine, graph: Graph) => Promise<NodeErrors>;
@@ -1,83 +0,0 @@
1
- import { BaseNode, NodeInput, NodeOutput, NodePosition } from './base-node';
2
- type ArrayType = 'array';
3
- type Vector = 'vector2' | 'vector3' | 'vector4';
4
- type Color = 'rgb' | 'rgba';
5
- type Mat = 'mat2' | 'mat3' | 'mat4' | 'mat2x2' | 'mat2x3' | 'mat2x4' | 'mat3x2' | 'mat3x3' | 'mat3x4' | 'mat4x2' | 'mat4x3' | 'mat4x4';
6
- export type GraphDataType = Vector | Color | Mat | 'texture' | 'samplerCube' | 'number' | ArrayType;
7
- export interface NumberNode extends BaseNode {
8
- type: 'number';
9
- value: string;
10
- range?: [number, number];
11
- stepper?: number;
12
- }
13
- export declare const numberNode: (id: string, name: string, position: NodePosition, value: string, optionals?: {
14
- range?: [number, number];
15
- stepper?: number;
16
- inputs?: NodeInput[];
17
- outputs?: NodeOutput[];
18
- }) => NumberNode;
19
- export type NumberDataUniform = Pick<NumberNode, 'type' | 'value' | 'name' | 'range' | 'stepper'>;
20
- export declare const numberUniformData: (name: string, value: string, range?: [number, number], stepper?: number) => NumberDataUniform;
21
- export interface TextureNode extends BaseNode {
22
- type: 'texture';
23
- value: string | number;
24
- }
25
- export declare const textureNode: (id: string, name: string, position: NodePosition, value: string | number) => TextureNode;
26
- export type TextureDataUniform = Pick<TextureNode, 'type' | 'value' | 'name'>;
27
- export declare const textureUniformData: (name: string, value: string | number) => TextureDataUniform;
28
- export interface SamplerCubeNode extends BaseNode {
29
- type: 'samplerCube';
30
- value: string;
31
- }
32
- export declare const samplerCubeNode: (id: string, name: string, position: NodePosition, value: string) => SamplerCubeNode;
33
- export type SamplerCubeDataUniform = Pick<SamplerCubeNode, 'type' | 'value' | 'name'>;
34
- export declare const samplerCubeUniformData: (name: string, value: string) => SamplerCubeDataUniform;
35
- export type ArrayValue = string[];
36
- export interface ArrayNode extends BaseNode {
37
- type: 'array';
38
- dimensions: number;
39
- value: ArrayValue;
40
- }
41
- export declare function arrayNode(id: string, name: string, position: NodePosition, value: ArrayValue): ArrayNode;
42
- export type Vector2 = [string, string];
43
- export type Vector3 = [string, string, string];
44
- export type Vector4 = [string, string, string, string];
45
- export interface Vector2Node extends BaseNode {
46
- type: 'vector2';
47
- dimensions: 2;
48
- value: Vector2;
49
- }
50
- export interface Vector3Node extends BaseNode {
51
- type: 'vector3';
52
- dimensions: 3;
53
- value: Vector3;
54
- }
55
- export interface Vector4Node extends BaseNode {
56
- type: 'vector4';
57
- dimensions: 4;
58
- value: Vector4;
59
- }
60
- export declare function vectorNode(id: string, name: string, position: NodePosition, value: Vector2 | Vector3 | Vector4): Vector2Node | Vector3Node | Vector4Node;
61
- export type ArrayDataUniform = Pick<ArrayNode, 'type' | 'value' | 'name' | 'dimensions'>;
62
- export declare const arrayUniformData: (name: string, value: ArrayValue) => ArrayDataUniform;
63
- export type Vector2DataUniform = Pick<Vector2Node, 'type' | 'value' | 'name' | 'dimensions'>;
64
- export type Vector3DataUniform = Pick<Vector3Node, 'type' | 'value' | 'name' | 'dimensions'>;
65
- export type Vector4DataUniform = Pick<Vector4Node, 'type' | 'value' | 'name' | 'dimensions'>;
66
- export declare const vectorUniformData: (name: string, value: Vector2 | Vector3 | Vector4) => Vector2DataUniform | Vector3DataUniform | Vector4DataUniform;
67
- export interface RgbNode extends BaseNode {
68
- type: 'rgb';
69
- dimensions: 3;
70
- value: Vector3;
71
- }
72
- export interface RgbaNode extends BaseNode {
73
- type: 'rgba';
74
- dimensions: 4;
75
- value: Vector4;
76
- }
77
- export declare function colorNode(id: string, name: string, position: NodePosition, value: Vector3 | Vector4): RgbNode | RgbaNode;
78
- export type RgbDataUniform = Omit<RgbNode, 'id' | 'inputs' | 'outputs' | 'position' | 'parentId'>;
79
- export type RgbaDataUniform = Omit<RgbaNode, 'id' | 'inputs' | 'outputs' | 'position' | 'parentId'>;
80
- export declare const colorUniformData: (name: string, value: Vector3 | Vector4) => RgbDataUniform | RgbaDataUniform;
81
- export type UniformDataType = TextureDataUniform | SamplerCubeDataUniform | NumberDataUniform | Vector2DataUniform | Vector3DataUniform | Vector4DataUniform | RgbDataUniform | RgbaDataUniform;
82
- export type DataNode = TextureNode | SamplerCubeNode | NumberNode | Vector2Node | Vector3Node | Vector4Node | ArrayNode | RgbNode | RgbaNode;
83
- export {};
@@ -1,13 +0,0 @@
1
- import { EdgeLink, ShaderStage } from './graph-types';
2
- import { GraphDataType } from './data-nodes';
3
- export type EdgeType = ShaderStage | GraphDataType | EdgeLink;
4
- export type Edge = {
5
- id: string;
6
- from: string;
7
- to: string;
8
- output: string;
9
- input: string;
10
- type?: EdgeType;
11
- };
12
- export declare const makeEdge: (id: string, from: string, to: string, output: string, input: string, type?: EdgeType) => Edge;
13
- export declare const linkFromVertToFrag: (id: string, vertId: string, fragId: string) => Edge;
@@ -1,9 +0,0 @@
1
- import { Engine } from '../engine';
2
- import { Edge } from './edge';
3
- import { SourceNode } from './code-nodes';
4
- import { Graph, GraphNode } from './graph-types';
5
- import { DataNode } from './data-nodes';
6
- export type Evaluator = (node: GraphNode) => any;
7
- export type Evaluate = (node: SourceNode, inputEdges: Edge[], inputNodes: GraphNode[], evaluate: Evaluator) => any;
8
- export declare const toGlsl: (node: DataNode) => string;
9
- export declare const evaluateNode: (engine: Engine, graph: Graph, node: GraphNode) => any;
@@ -1,8 +0,0 @@
1
- import { ShaderStage } from './graph-types';
2
- import { BinaryNode, CodeNode, NodeConfig } from './code-nodes';
3
- import { NodePosition } from './base-node';
4
- export declare const sourceNode: (id: string, name: string, position: NodePosition, config: NodeConfig, source: string, stage: ShaderStage, originalEngine?: string) => CodeNode;
5
- export declare const outputNode: (id: string, name: string, position: NodePosition, stage: ShaderStage) => CodeNode;
6
- export declare const expressionNode: (id: string, name: string, position: NodePosition, source: string) => CodeNode;
7
- export declare const addNode: (id: string, position: NodePosition) => BinaryNode;
8
- export declare const multiplyNode: (id: string, position: NodePosition) => BinaryNode;
@@ -1,38 +0,0 @@
1
- import { DataNode } from './data-nodes';
2
- import { Edge } from './edge';
3
- import { SourceNode } from './code-nodes';
4
- /**
5
- * Core graph types.
6
- *
7
- * Originally abstracted out of graph.ts to avoid a circular
8
- * dependency between graph.ts and parsers.ts. Both files need these types at
9
- * module initialization time, and without this third file, the types will be
10
- * undefined in either graph/parsers.ts at init time. If the types were only
11
- * used at runtime it would be fine, because the circular depenency is resolved
12
- * by then.
13
- */
14
- export type ShaderStage = 'fragment' | 'vertex';
15
- /**
16
- * The type applied to the edge representing a link between node stages
17
- */
18
- export declare enum EdgeLink {
19
- NEXT_STAGE = "next_stage"
20
- }
21
- /**
22
- * The handle types for links. These become <Handle /> ids
23
- */
24
- export declare enum LinkHandle {
25
- NEXT_STAGE = "next_stage",
26
- PREVIOUS_STAGE = "previous_stage"
27
- }
28
- export declare enum NodeType {
29
- OUTPUT = "output",
30
- BINARY = "binary",
31
- SOURCE = "source"
32
- }
33
- export type GraphNode = SourceNode | DataNode;
34
- export interface Graph {
35
- nodes: GraphNode[];
36
- edges: Edge[];
37
- }
38
- export declare const MAGIC_OUTPUT_STMTS = "mainStmts";
@@ -1,89 +0,0 @@
1
- import { Program } from '@shaderfrog/glsl-parser/ast';
2
- import { Engine, EngineContext } from '../engine';
3
- import { NodeErrors } from './context';
4
- import { ShaderSections } from './shader-sections';
5
- import { DataNode } from './data-nodes';
6
- import { Edge } from './edge';
7
- import { CodeNode, SourceNode } from './code-nodes';
8
- import { NodeInput } from './base-node';
9
- import { ProduceNodeFiller } from './parsers';
10
- import { Graph, GraphNode } from './graph-types';
11
- export declare const isDataNode: (node: GraphNode) => node is DataNode;
12
- export declare const isSourceNode: (node: GraphNode) => node is SourceNode;
13
- export declare const findNode: (graph: Graph, id: string) => GraphNode;
14
- export declare const doesLinkThruShader: (graph: Graph, node: GraphNode) => boolean;
15
- export declare const nodeName: (node: GraphNode) => string;
16
- export declare const mangleName: (name: string, node: GraphNode, nextSibling?: GraphNode) => string;
17
- export declare const mangleVar: (name: string, engine: Engine, node: GraphNode, sibling?: GraphNode) => string;
18
- export declare const mangleEntireProgram: (engine: Engine, ast: Program, node: GraphNode, sibling?: GraphNode) => void;
19
- export declare const mangleMainFn: (ast: Program, node: GraphNode, sibling?: GraphNode) => void;
20
- export declare const ensureFromNode: (graph: Graph, inputEdge: Edge) => GraphNode;
21
- export declare const resetGraphIds: (graph: Graph) => Graph;
22
- export declare const findLinkedNode: (graph: Graph, id: string) => GraphNode;
23
- /**
24
- * Find any unconnected vertex nodes linked to collected fragment nodes
25
- */
26
- export declare const findLinkedVertexNodes: (graph: Graph, existingIds?: NodeIds) => GraphNode[];
27
- export type Predicates = {
28
- node?: (node: GraphNode, inputEdges: Edge[], lastResult: SearchResult) => boolean;
29
- edge?: (input: NodeInput | undefined, node: GraphNode, inputEdge: Edge | undefined, fromNode: GraphNode | undefined, lastResult: SearchResult) => boolean;
30
- input?: (input: NodeInput, node: GraphNode, inputEdge: Edge | undefined, fromNode: GraphNode | undefined, lastResult: SearchResult) => boolean;
31
- };
32
- export type SearchResult = {
33
- nodes: Record<string, GraphNode>;
34
- inputs: Record<string, NodeInput[]>;
35
- edges: Edge[];
36
- };
37
- export declare const consSearchResult: () => SearchResult;
38
- export declare const mergeSearchResults: (a: SearchResult, b: SearchResult) => SearchResult;
39
- /**
40
- * Create the inputs on a node from the properties. This used to be done at
41
- * context time. Doing it at node creation time lets us auto-bake edges into
42
- * the node at initial graph creation time.
43
- */
44
- export declare const prepopulatePropertyInputs: (node: CodeNode) => CodeNode;
45
- /**
46
- * Recursively filter the graph, starting from a specific node, looking for
47
- * nodes and edges that match predicates.
48
- *
49
- * Inputs can only be filtered if the graph context has been computed, since
50
- * inputs aren't created until then.
51
- */
52
- export declare const filterGraphFromNode: (graph: Graph, node: GraphNode, predicates: Predicates, depth?: number, lastResult?: SearchResult) => SearchResult;
53
- export declare const collectConnectedNodes: (graph: Graph, node: GraphNode) => NodeIds;
54
- export declare const filterGraphNodes: (graph: Graph, nodes: GraphNode[], filter: Predicates, depth?: number) => SearchResult;
55
- type NodeIds = Record<string, GraphNode>;
56
- export type CompileNodeResult = [
57
- compiledSections: ShaderSections,
58
- filler: ReturnType<ProduceNodeFiller>,
59
- compiledIds: NodeIds
60
- ];
61
- export declare const isDataInput: (input: NodeInput) => boolean;
62
- export declare const compileNode: (engine: Engine, graph: Graph, edges: Edge[], engineContext: EngineContext, node: GraphNode, activeIds?: NodeIds) => CompileNodeResult;
63
- export type CompileGraphResult = {
64
- fragment: ShaderSections;
65
- vertex: ShaderSections;
66
- outputFrag: GraphNode;
67
- outputVert: GraphNode;
68
- orphanNodes: GraphNode[];
69
- activeNodeIds: Set<string>;
70
- };
71
- export declare const compileGraph: (engineContext: EngineContext, engine: Engine, graph: Graph) => CompileGraphResult;
72
- /**
73
- * Find engine nodes to set properties on, like find a Physical node so
74
- * consumers can set physicalNode.myProperty = 123.
75
- *
76
- * Finds all active nodes in the graph that have inputs that are properties,
77
- * which currently means it will find all active engine nodes.
78
- */
79
- export declare const collectNodeProperties: (graph: Graph) => SearchResult;
80
- export type IndexedDataInputs = Record<string, NodeInput[]>;
81
- export type CompileResult = {
82
- fragmentResult: string;
83
- vertexResult: string;
84
- compileResult: CompileGraphResult;
85
- dataNodes: Record<string, GraphNode>;
86
- dataInputs: IndexedDataInputs;
87
- };
88
- export declare const compileSource: (graph: Graph, engine: Engine, ctx: EngineContext) => Promise<CompileResult | NodeErrors>;
89
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,11 +0,0 @@
1
- export * from './base-node';
2
- export * from './data-nodes';
3
- export * from './graph-node';
4
- export * from './code-nodes';
5
- export * from './edge';
6
- export * from './parsers';
7
- export * from './context';
8
- export * from './evaluate';
9
- export * from './graph-types';
10
- export * from './graph';
11
- export * from './shader-sections';
@@ -1,39 +0,0 @@
1
- import { AstNode, Program } from '@shaderfrog/glsl-parser/ast';
2
- import { Engine, EngineContext } from '../engine';
3
- import { Edge } from './edge';
4
- import { SourceNode } from './code-nodes';
5
- import { NodeInput } from './base-node';
6
- import { Graph } from './graph-types';
7
- import { Evaluate } from './evaluate';
8
- export declare const alphabet = "abcdefghijklmnopqrstuvwxyz";
9
- export type Filler = AstNode | AstNode[] | void;
10
- export type InputFiller = (filler: Filler) => AstNode | Program;
11
- export type InputFillerGroup = {
12
- filler: InputFiller;
13
- backfillArgs?: AstNode[];
14
- };
15
- export type InputFillers = Record<string, InputFillerGroup>;
16
- type FillerArguments = AstNode[];
17
- export type ComputedInput = [NodeInput, InputFiller, FillerArguments?];
18
- export type ProduceAst = (engineContext: EngineContext, engine: Engine, graph: Graph, node: SourceNode, inputEdges: Edge[]) => AstNode | Program;
19
- export type OnBeforeCompile = (graph: Graph, engineContext: EngineContext, node: SourceNode, sibling?: SourceNode) => Promise<void>;
20
- export type ManipulateAst = (engineContext: EngineContext, engine: Engine, graph: Graph, ast: AstNode | Program, inputEdges: Edge[], node: SourceNode, sibling: SourceNode) => AstNode | Program;
21
- export type NodeParser = {
22
- onBeforeCompile?: OnBeforeCompile;
23
- manipulateAst?: ManipulateAst;
24
- findInputs?: FindInputs;
25
- produceFiller?: ProduceNodeFiller;
26
- };
27
- export type FindInputs = (engineContext: EngineContext, ast: Program | AstNode, inputEdges: Edge[], node: SourceNode, sibling: SourceNode) => ComputedInput[];
28
- export type ProduceNodeFiller = (node: SourceNode, ast: Program | AstNode) => Filler;
29
- type CoreNodeParser = {
30
- produceAst: ProduceAst;
31
- findInputs: FindInputs;
32
- produceFiller: ProduceNodeFiller;
33
- evaluate?: Evaluate;
34
- };
35
- type CoreParser = {
36
- [key: string]: CoreNodeParser;
37
- };
38
- export declare const coreParsers: CoreParser;
39
- export {};
@@ -1,47 +0,0 @@
1
- /**
2
- * Categorizing / deduping parts of shaders to help merge them together
3
- */
4
- import { AstNode, DeclarationStatementNode, PreprocessorNode } from '@shaderfrog/glsl-parser/ast';
5
- import { Program } from '@shaderfrog/glsl-parser/ast';
6
- export interface ShaderSections {
7
- precision: DeclarationStatementNode[];
8
- version: AstNode[];
9
- preprocessor: PreprocessorNode[];
10
- structs: AstNode[];
11
- inStatements: DeclarationStatementNode[];
12
- outStatements: DeclarationStatementNode[];
13
- uniforms: DeclarationStatementNode[];
14
- program: AstNode[];
15
- }
16
- export declare const emptyShaderSections: () => ShaderSections;
17
- declare enum Precision {
18
- highp = 2,
19
- mediump = 1,
20
- lowp = 0
21
- }
22
- export declare const higherPrecision: (p1: Precision, p2: Precision) => Precision;
23
- export declare const dedupeVersions: (nodes: AstNode[]) => AstNode;
24
- export declare const highestPrecisions: (nodes: DeclarationStatementNode[]) => DeclarationStatementNode[];
25
- export declare const dedupeQualifiedStatements: (statements: DeclarationStatementNode[], qualifier: string) => any;
26
- /**
27
- * Merge uniforms together into lists of identifiers under the same type.
28
- * There's special case handling for mixing of uniforms with "interface blocks"
29
- * and those without when merging to make sure the interface block definition is
30
- * preserved. Check out the tests for more.
31
- *
32
- * This function consumes uniforms as found by findShaderSections, so the
33
- * definitions must line up
34
- */
35
- export declare const dedupeUniforms: (statements: DeclarationStatementNode[]) => any;
36
- export declare const mergeShaderSections: (s1: ShaderSections, s2: ShaderSections) => ShaderSections;
37
- export type MergeOptions = {
38
- includePrecisions: boolean;
39
- includeVersion: boolean;
40
- };
41
- export declare const shaderSectionsToProgram: (sections: ShaderSections, mergeOptions: MergeOptions) => Program;
42
- /**
43
- * Group an AST into logical sections. The output of this funciton is consumed
44
- * by the dedupe methods, namely dedupeUniforms, so the data shapes are coupled
45
- */
46
- export declare const findShaderSections: (ast: Program) => ShaderSections;
47
- export {};
package/esm/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './graph';
2
- export * from './strategy';
3
- export * from './engine';
package/esm/package.json DELETED
@@ -1 +0,0 @@
1
- {"type": "module"}
@@ -1,28 +0,0 @@
1
- import { PBRMaterial, Camera, Scene } from 'babylonjs';
2
- import { Engine } from '../../engine';
3
- import { ShaderStage } from '../../graph/graph-types';
4
- import { CodeNode } from '../../graph/code-nodes';
5
- import { NodePosition } from '../../graph/base-node';
6
- import { UniformDataType } from '../../graph/data-nodes';
7
- export declare const physicalDefaultProperties: Partial<Record<keyof PBRMaterial, any>>;
8
- export declare const physicalNode: (id: string, name: string, position: NodePosition, uniforms: UniformDataType[], stage: ShaderStage | undefined) => CodeNode;
9
- export type RuntimeContext = {
10
- scene: Scene;
11
- camera: Camera;
12
- BABYLON: any;
13
- sceneData: any;
14
- cache: {
15
- data: {
16
- [key: string]: any;
17
- };
18
- nodes: {
19
- [id: string]: {
20
- fragment: string;
21
- vertex: string;
22
- };
23
- };
24
- };
25
- };
26
- export declare const toonNode: (id: string, name: string, position: NodePosition, uniforms: UniformDataType[], stage: ShaderStage | undefined) => CodeNode;
27
- export declare let mIdx: number;
28
- export declare const babylengine: Engine;
@@ -1,3 +0,0 @@
1
- import { EngineImporters } from '../../engine';
2
- declare const importers: EngineImporters;
3
- export default importers;
@@ -1,2 +0,0 @@
1
- import { babylengine } from './bablyengine';
2
- export { babylengine as engine };
@@ -1,3 +0,0 @@
1
- import { EngineImporters } from '../../engine';
2
- declare const importers: EngineImporters;
3
- export default importers;
@@ -1,2 +0,0 @@
1
- import { playengine } from './playengine';
2
- export { playengine as engine };
@@ -1,39 +0,0 @@
1
- import * as pc from 'playcanvas';
2
- import { Engine } from '../../engine';
3
- import { ShaderStage } from '../../graph/graph-types';
4
- import { CodeNode, NodeProperty } from '../../graph/code-nodes';
5
- import { NodePosition } from '../../graph/base-node';
6
- import { UniformDataType } from '../../graph/data-nodes';
7
- export declare const physicalDefaultProperties: {
8
- blendType: number;
9
- opacity: number;
10
- useMetalness: boolean;
11
- cull: number;
12
- };
13
- /**
14
- * For the use of "0.5", apparently PlayCanvas optimizes uniform
15
- * generation where if you set diffuse to white (1,1,1) then it doesn't
16
- * add the diffuse uniform, because that's the default state.
17
- */
18
- export declare const defaultPropertySetting: (app: pc.Application, property: NodeProperty) => 0.5 | pc.Texture | pc.Color;
19
- export declare const physicalNode: (id: string, name: string, position: NodePosition, uniforms: UniformDataType[], stage: ShaderStage | undefined) => CodeNode;
20
- export type RuntimeContext = {
21
- scene: pc.Scene;
22
- camera: pc.Camera;
23
- pc: any;
24
- sceneData: any;
25
- cache: {
26
- data: {
27
- [key: string]: any;
28
- };
29
- nodes: {
30
- [id: string]: {
31
- fragment: string;
32
- vertex: string;
33
- };
34
- };
35
- };
36
- };
37
- export declare const toonNode: (id: string, name: string, position: NodePosition, uniforms: UniformDataType[], stage: ShaderStage | undefined) => CodeNode;
38
- export declare let mIdx: number;
39
- export declare const playengine: Engine;
@@ -1,3 +0,0 @@
1
- import { EngineImporters } from '../../engine';
2
- declare const importers: EngineImporters;
3
- export default importers;
@@ -1,2 +0,0 @@
1
- import { createMaterial, threngine } from './threngine';
2
- export { createMaterial, threngine as engine };