@shaderfrog/core 3.0.2 → 3.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.
@@ -25,6 +25,11 @@ export type NodePosition = {
25
25
  x: number;
26
26
  y: number;
27
27
  };
28
+ export type NodeInputSectionVisibility = 'visible' | 'hidden';
29
+ export type NodeInputSection = 'Properties' | 'Uniforms' | 'Code';
30
+ export type NodeDisplay = {
31
+ visibilities: Partial<Record<NodeInputSection, NodeInputSectionVisibility>>;
32
+ };
28
33
  export interface BaseNode {
29
34
  id: string;
30
35
  parentId?: string;
@@ -33,4 +38,5 @@ export interface BaseNode {
33
38
  inputs: NodeInput[];
34
39
  outputs: NodeOutput[];
35
40
  position: NodePosition;
41
+ display?: NodeDisplay;
36
42
  }
@@ -4,6 +4,7 @@ type Vector = 'vector2' | 'vector3' | 'vector4';
4
4
  type Color = 'rgb' | 'rgba';
5
5
  type Mat = 'mat2' | 'mat3' | 'mat4' | 'mat2x2' | 'mat2x3' | 'mat2x4' | 'mat3x2' | 'mat3x3' | 'mat3x4' | 'mat4x2' | 'mat4x3' | 'mat4x4';
6
6
  export type GraphDataType = Vector | Color | Mat | 'texture' | 'samplerCube' | 'number' | ArrayType;
7
+ export declare const canMapType: (fromType: GraphDataType | undefined, toType: GraphDataType | undefined) => boolean;
7
8
  export interface NumberNode extends BaseNode {
8
9
  type: 'number';
9
10
  value: string;
@@ -40,13 +41,17 @@ export interface TextureNode extends BaseNode {
40
41
  export declare const textureNode: (id: string, name: string, position: NodePosition, value?: TextureNodeValueData) => TextureNode;
41
42
  export type TextureDataUniform = Pick<TextureNode, 'type' | 'value' | 'name'>;
42
43
  export declare const textureUniformData: (name: string, value: TextureNodeValueData) => TextureDataUniform;
44
+ export type SamplerCubeNodeValueData = {
45
+ assetId?: number;
46
+ versionId?: number;
47
+ };
43
48
  export interface SamplerCubeNode extends BaseNode {
44
49
  type: 'samplerCube';
45
- value: string;
50
+ value?: SamplerCubeNodeValueData;
46
51
  }
47
- export declare const samplerCubeNode: (id: string, name: string, position: NodePosition, value: string) => SamplerCubeNode;
52
+ export declare const samplerCubeNode: (id: string, name: string, position: NodePosition, value?: SamplerCubeNodeValueData) => SamplerCubeNode;
48
53
  export type SamplerCubeDataUniform = Pick<SamplerCubeNode, 'type' | 'value' | 'name'>;
49
- export declare const samplerCubeUniformData: (name: string, value: string) => SamplerCubeDataUniform;
54
+ export declare const samplerCubeUniformData: (name: string, value: SamplerCubeNodeValueData) => SamplerCubeDataUniform;
50
55
  export type ArrayValue = string[];
51
56
  export interface ArrayNode extends BaseNode {
52
57
  type: 'array';
@@ -9,6 +9,20 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ var TypeCompatibility = [
13
+ new Set(['vector4', 'rgba']),
14
+ new Set(['vector3', 'rgb']),
15
+ // Note vector4 is wrong here - you can't plug a *data* vector4 into a
16
+ // texture. But the output of a shader node is a *bakeable* vector4. This
17
+ // allows that. Needs updating to take into account data vs code
18
+ new Set(['texture', 'samplerCube', 'vector4']),
19
+ ];
20
+ export var canMapType = function (fromType, toType) {
21
+ if (fromType === toType || !fromType || !toType) {
22
+ return true;
23
+ }
24
+ return TypeCompatibility.some(function (compatibility) { return compatibility.has(fromType) && compatibility.has(toType); });
25
+ };
12
26
  export var numberNode = function (id, name, position, value, optionals) { return ({
13
27
  type: 'number',
14
28
  id: id,
@@ -46,7 +60,7 @@ export var textureNode = function (id, name, position, value) { return ({
46
60
  {
47
61
  name: 'texture',
48
62
  id: '1',
49
- dataType: 'vector4',
63
+ dataType: 'texture',
50
64
  category: 'data',
51
65
  },
52
66
  ],
@@ -57,18 +71,22 @@ export var samplerCubeNode = function (id, name, position, value) { return ({
57
71
  id: id,
58
72
  name: name,
59
73
  position: position,
60
- value: value,
61
74
  inputs: [],
62
75
  outputs: [
63
76
  {
64
77
  name: 'samplerCube',
65
78
  id: '1',
66
- dataType: 'vector4',
79
+ dataType: 'samplerCube',
67
80
  category: 'data',
68
81
  },
69
82
  ],
83
+ value: value,
84
+ }); };
85
+ export var samplerCubeUniformData = function (name, value) { return ({
86
+ type: 'samplerCube',
87
+ name: name,
88
+ value: value,
70
89
  }); };
71
- export var samplerCubeUniformData = function (name, value) { return ({ type: 'samplerCube', name: name, value: value }); };
72
90
  export function arrayNode(id, name, position, value) {
73
91
  return {
74
92
  id: id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaderfrog/core",
3
- "version": "3.0.2",
3
+ "version": "3.1.0",
4
4
  "description": "Shaderfrog core",
5
5
  "type": "module",
6
6
  "files": [
@@ -50,7 +50,7 @@
50
50
  "peerDependencies": {
51
51
  "@shaderfrog/glsl-parser": "^6.0.0-beta.7",
52
52
  "babylonjs": ">=4",
53
- "playcanvas": "^1.65.3",
53
+ "playcanvas": ">=1.65.3",
54
54
  "three": ">=0.50"
55
55
  },
56
56
  "peerDependenciesMeta": {
@@ -129,6 +129,11 @@ export var phongNode = function (id, name, position, uniforms, stage) {
129
129
  : namedAttributeStrategy('position'),
130
130
  ],
131
131
  },
132
+ display: {
133
+ visibilities: {
134
+ Uniforms: 'hidden',
135
+ },
136
+ },
132
137
  inputs: [],
133
138
  outputs: [
134
139
  {
@@ -196,6 +201,11 @@ export var physicalNode = function (id, name, position, uniforms, stage) {
196
201
  : namedAttributeStrategy('position'),
197
202
  ],
198
203
  },
204
+ display: {
205
+ visibilities: {
206
+ Uniforms: 'hidden',
207
+ },
208
+ },
199
209
  inputs: [],
200
210
  outputs: [
201
211
  {
@@ -421,6 +431,11 @@ export var toonNode = function (id, name, position, uniforms, stage) {
421
431
  : namedAttributeStrategy('position'),
422
432
  ],
423
433
  },
434
+ display: {
435
+ visibilities: {
436
+ Uniforms: 'hidden',
437
+ },
438
+ },
424
439
  inputs: [],
425
440
  outputs: [
426
441
  {