@shaderfrog/core 0.0.1 → 0.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shaderfrog/core",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Shaderfrog core",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -12,6 +12,9 @@
12
12
  },
13
13
  "author": "Andrew Ray",
14
14
  "license": "ISC",
15
+ "files": [
16
+ "src"
17
+ ],
15
18
  "bugs": {
16
19
  "url": "https://github.com/ShaderFrog/core/issues"
17
20
  },
@@ -22,6 +25,7 @@
22
25
  "@babel/preset-typescript": "^7.21.5",
23
26
  "@types/jest": "^29.5.1",
24
27
  "@types/lodash.groupby": "^4.6.7",
28
+ "@types/three": "^0.152.0",
25
29
  "babel-jest": "^29.5.0",
26
30
  "babylonjs": "^6.2.0",
27
31
  "jest": "^29.5.0",
@@ -33,8 +37,8 @@
33
37
  "lodash.groupby": "^4.6.0"
34
38
  },
35
39
  "peerDependencies": {
36
- "babylonjs": ">= 4",
37
- "three": ">= 100"
40
+ "babylonjs": ">=4",
41
+ "three": ">=0.50"
38
42
  },
39
43
  "peerDependenciesMeta": {
40
44
  "babylonjs": {
@@ -1,6 +1,3 @@
1
1
  import { babylengine } from './bablyengine';
2
- import BabylonComponent from './BabylonComponent';
3
2
 
4
- export { BabylonComponent as Editor, babylengine as engine };
5
-
6
- export * from './examples';
3
+ export { babylengine as engine };
@@ -1,6 +1,3 @@
1
1
  import { threngine } from './threngine';
2
- import ThreeComponent from './ThreeComponent';
3
2
 
4
- export { ThreeComponent as Editor, threngine as engine };
5
-
6
- export * from './examples';
3
+ export { threngine as engine };
package/.eslintrc.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "extends": "next/core-web-vitals"
3
- }
package/.prettierrc.js DELETED
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- singleQuote: true,
3
- };
package/babel.config.js DELETED
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- presets: [
3
- ['@babel/preset-env', { targets: { node: 'current' } }],
4
- '@babel/preset-typescript',
5
- ],
6
- };
@@ -1,512 +0,0 @@
1
- import { Graph } from '../../core/graph';
2
- import {
3
- colorNode,
4
- DataNode,
5
- numberNode,
6
- numberUniformData,
7
- textureNode,
8
- vectorUniformData,
9
- } from '../../core/nodes/data-nodes';
10
- import { EdgeType, makeEdge } from '../../core/nodes/edge';
11
- import { outputNode } from '../../core/nodes/engine-node';
12
- import { fireFrag, fireVert } from '../../shaders/fireNode';
13
- import {
14
- heatShaderFragmentNode,
15
- heatShaderVertexNode,
16
- variation1 as heatmapV1,
17
- } from '../../shaders/heatmapShaderNode';
18
- import purpleNoiseNode from '../../shaders/purpleNoiseNode';
19
- import staticShaderNode, { variation1 } from '../../shaders/staticShaderNode';
20
- import { makeId } from '../../util/id';
21
- import { checkerboardF, checkerboardV } from '../../shaders/checkboardNode';
22
- import normalMapify from '../../shaders/normalmapifyNode';
23
- import { convertNode, convertToEngine, Engine } from '../../core/engine';
24
- import { babylengine } from '../../plugins/babylon/bablyengine';
25
- import { CoreNode } from '../../core/nodes/core-node';
26
- import { SourceNode } from '../../core/nodes/code-nodes';
27
-
28
- export enum Example {
29
- GLASS_FIREBALL = 'Glass Fireball',
30
- // GEMSTONE = 'Gemstone',
31
- LIVING_DIAMOND = 'Living Diamond',
32
- // TOON = 'Toon',
33
- DEFAULT = 'Mesh Physical Material',
34
- }
35
-
36
- const edgeFrom = (
37
- fromNode: CoreNode,
38
- toId: string,
39
- input: string,
40
- type?: EdgeType
41
- ) => makeEdge(makeId(), fromNode.id, toId, outFrom(fromNode), input, type);
42
-
43
- const outFrom = (node: CoreNode) => node.outputs[0].name;
44
-
45
- const konvert = (node: SourceNode) =>
46
- convertNode(node, babylengine.importers.three);
47
-
48
- export const makeExampleGraph = (example: Example): [Graph, string, string] => {
49
- console.log('🌈 Making new graph!!');
50
- let newGraph: Graph;
51
- let previewObject: string;
52
- let bg: string = '';
53
-
54
- // @ts-ignore
55
- if (example === Example.GEMSTONE) {
56
- const outputF = outputNode(
57
- makeId(),
58
- 'Output',
59
- { x: 434, y: -97 },
60
- 'fragment'
61
- );
62
- const outputV = outputNode(makeId(), 'Output', { x: 434, y: 20 }, 'vertex');
63
-
64
- const physicalGroupId = makeId();
65
- const physicalF = babylengine.constructors.physical(
66
- makeId(),
67
- 'Physical',
68
- physicalGroupId,
69
- { x: 178, y: -103 },
70
- [],
71
- 'fragment'
72
- );
73
- const physicalV = babylengine.constructors.physical(
74
- makeId(),
75
- 'Physical',
76
- physicalGroupId,
77
- { x: 434, y: 130 },
78
- [],
79
- 'vertex',
80
- physicalF.id
81
- );
82
- const staticF = konvert(
83
- staticShaderNode(makeId(), { x: -196, y: -303 }, variation1)
84
- );
85
- const heatmap = konvert(
86
- heatShaderFragmentNode(makeId(), { x: -478, y: 12 }, heatmapV1)
87
- );
88
- const heatmapV = konvert(
89
- heatShaderVertexNode(makeId(), heatmap.id, {
90
- x: -478,
91
- y: -194,
92
- })
93
- );
94
-
95
- const normaled = normalMapify(makeId(), { x: -178, y: -149 });
96
- const normalStrength = numberNode(
97
- makeId(),
98
- 'Normal Strength',
99
- { x: -482, y: -105 },
100
- '1..0'
101
- );
102
-
103
- const color = colorNode(makeId(), 'Color', { x: -187, y: -413 }, [
104
- '1.0',
105
- '0.75',
106
- '1.0',
107
- ]);
108
- const roughness = numberNode(
109
- makeId(),
110
- 'Roughness',
111
- { x: -187, y: 54 },
112
- '0.37'
113
- );
114
- // const transmission = numberNode(
115
- // makeId(),
116
- // 'Transmission',
117
- // { x: -187, y: 153 },
118
- // '0.5'
119
- // );
120
- // const thickness = numberNode(
121
- // makeId(),
122
- // 'Thickness',
123
- // { x: -187, y: 240 },
124
- // '1.0'
125
- // );
126
- // const ior = numberNode(makeId(), 'Ior', { x: -187, y: 328 }, '2.0');
127
-
128
- newGraph = {
129
- nodes: [
130
- color,
131
- normaled,
132
- normalStrength,
133
- roughness,
134
- // transmission,
135
- // thickness,
136
- // ior,
137
- staticF,
138
- heatmap,
139
- heatmapV,
140
- outputF,
141
- outputV,
142
- physicalF,
143
- physicalV,
144
- ],
145
- edges: [
146
- edgeFrom(physicalF, outputF.id, 'filler_frogFragOut', 'fragment'),
147
- edgeFrom(physicalV, outputV.id, 'filler_gl_Position', 'vertex'),
148
- edgeFrom(staticF, physicalF.id, 'property_albedoTexture', 'fragment'),
149
- edgeFrom(color, physicalF.id, 'property_albedoColor', 'fragment'),
150
- edgeFrom(roughness, physicalF.id, 'property_roughness', 'fragment'),
151
-
152
- // edgeFrom(
153
- // transmission,
154
- // physicalF.id,
155
- // 'property_transmission',
156
- // 'fragment'
157
- // ),
158
- // edgeFrom(thickness, physicalF.id, 'property_thickness', 'fragment'),
159
- // edgeFrom(ior, physicalF.id, 'property_ior', 'fragment'),
160
- edgeFrom(
161
- normalStrength,
162
- normaled.id,
163
- 'uniform_normal_strength',
164
- 'fragment'
165
- ),
166
- edgeFrom(heatmap, normaled.id, 'filler_normal_map', 'fragment'),
167
- edgeFrom(normaled, physicalF.id, 'property_bumpTexture', 'fragment'),
168
- ],
169
- };
170
- previewObject = 'icosahedron';
171
- bg = 'cityCourtYard';
172
- // @ts-ignore
173
- } else if (example === Example.TOON) {
174
- const outputF = outputNode(
175
- makeId(),
176
- 'Output',
177
- { x: 434, y: -97 },
178
- 'fragment'
179
- );
180
- const outputV = outputNode(makeId(), 'Output', { x: 434, y: 16 }, 'vertex');
181
-
182
- const toonGroupId = makeId();
183
- const toonF = babylengine.constructors.toon(
184
- makeId(),
185
- 'Toon',
186
- toonGroupId,
187
- { x: 178, y: -103 },
188
- [],
189
- 'fragment'
190
- );
191
- const toonV = babylengine.constructors.toon(
192
- makeId(),
193
- 'Toon',
194
- toonGroupId,
195
- { x: 434, y: 130 },
196
- [],
197
- 'vertex',
198
- toonF.id
199
- );
200
- const properties: [string, DataNode][] = [
201
- [
202
- 'albedoColor',
203
- colorNode(makeId(), 'Color', { x: -153, y: -268 }, ['0', '0.7', '0']),
204
- ],
205
- // [
206
- // 'gradientMap',
207
- // textureNode(
208
- // makeId(),
209
- // 'Gradient Map',
210
- // { x: -153, y: -160 },
211
- // 'threeTone'
212
- // ),
213
- // ],
214
- [
215
- 'bumpTexture',
216
- textureNode(
217
- makeId(),
218
- 'Bump Texture',
219
- { x: -153, y: -50 },
220
- 'brickNormal'
221
- ),
222
- ],
223
- ];
224
-
225
- newGraph = {
226
- nodes: [outputF, outputV, toonF, toonV, ...properties.map(([, p]) => p)],
227
- edges: [
228
- edgeFrom(toonF, outputF.id, 'filler_frogFragOut', 'fragment'),
229
- edgeFrom(toonV, outputV.id, 'filler_gl_Position', 'vertex'),
230
- ...properties.map(([name, prop]) =>
231
- edgeFrom(prop, toonF.id, `property_${name}`, prop.type)
232
- ),
233
- ],
234
- };
235
- previewObject = 'torusknot';
236
- bg = '';
237
- } else if (example === Example.DEFAULT) {
238
- const outputF = outputNode(
239
- makeId(),
240
- 'Output',
241
- { x: 434, y: -97 },
242
- 'fragment'
243
- );
244
- const outputV = outputNode(makeId(), 'Output', { x: 434, y: 16 }, 'vertex');
245
-
246
- const physicalGroupId = makeId();
247
- const physicalF = babylengine.constructors.physical(
248
- makeId(),
249
- 'Physical',
250
- physicalGroupId,
251
- { x: 178, y: -103 },
252
- [],
253
- 'fragment'
254
- );
255
- const physicalV = babylengine.constructors.physical(
256
- makeId(),
257
- 'Physical',
258
- physicalGroupId,
259
- { x: 434, y: 130 },
260
- [],
261
- 'vertex',
262
- physicalF.id
263
- );
264
-
265
- const checkerboardf = checkerboardF(makeId(), { x: -162, y: -105 });
266
- const checkerboardv = checkerboardV(makeId(), checkerboardf.id, {
267
- x: -162,
268
- y: 43,
269
- });
270
- newGraph = {
271
- nodes: [
272
- outputF,
273
- outputV,
274
- physicalF,
275
- physicalV,
276
- checkerboardf,
277
- checkerboardv,
278
- ],
279
- edges: [
280
- edgeFrom(physicalF, outputF.id, 'filler_frogFragOut', 'fragment'),
281
- edgeFrom(physicalV, outputV.id, 'filler_gl_Position', 'vertex'),
282
- edgeFrom(
283
- checkerboardf,
284
- physicalF.id,
285
- 'property_albedoTexture',
286
- 'fragment'
287
- ),
288
- ],
289
- };
290
- previewObject = 'sphere';
291
- bg = '';
292
- } else if (example === Example.LIVING_DIAMOND) {
293
- const outputF = outputNode(
294
- makeId(),
295
- 'Output',
296
- { x: 434, y: -97 },
297
- 'fragment'
298
- );
299
- const outputV = outputNode(makeId(), 'Output', { x: 434, y: 16 }, 'vertex');
300
-
301
- const nMap = konvert(normalMapify(makeId(), { x: -185, y: 507 }));
302
-
303
- const purpleNoise = konvert(
304
- purpleNoiseNode(makeId(), { x: -512, y: 434 }, [
305
- numberUniformData(
306
- 'speed',
307
- babylengine.name === 'babylon' ? '1.0' : '0.2'
308
- ),
309
- numberUniformData('brightnessX', '1.0'),
310
- numberUniformData('permutations', '10'),
311
- numberUniformData('iterations', '2'),
312
- vectorUniformData(
313
- 'uvScale',
314
- babylengine.name === 'babylon' ? ['0.1', '0.1'] : ['0.9', '0.9']
315
- ),
316
- vectorUniformData('color1', ['0', '1', '1']),
317
- vectorUniformData('color2', ['1', '0', '1']),
318
- vectorUniformData('color3', ['1', '1', '0']),
319
- ])
320
- );
321
-
322
- const properties = [
323
- numberNode(makeId(), 'Metallic', { x: -185, y: -110 }, '0.1'),
324
- numberNode(makeId(), 'Roughness', { x: -185, y: 0 }, '0.055'),
325
- numberNode(makeId(), 'Alpha', { x: -185, y: 110 }, '0.2'),
326
- ];
327
- const ior = numberNode(
328
- makeId(),
329
- 'Index Of Refraction',
330
- { x: -110, y: 62 },
331
- '1.05'
332
- );
333
-
334
- const physicalGroupId = makeId();
335
- const physicalF = babylengine.constructors.physical(
336
- makeId(),
337
- 'Physical',
338
- physicalGroupId,
339
- { x: 178, y: -103 },
340
- [],
341
- 'fragment'
342
- );
343
- const physicalV = babylengine.constructors.physical(
344
- makeId(),
345
- 'Physical',
346
- physicalGroupId,
347
- { x: 434, y: 130 },
348
- [],
349
- 'vertex',
350
- physicalF.id
351
- );
352
-
353
- newGraph = {
354
- nodes: [
355
- outputF,
356
- outputV,
357
- physicalF,
358
- physicalV,
359
- purpleNoise,
360
- nMap,
361
- ior,
362
- ...properties,
363
- ],
364
- edges: [
365
- edgeFrom(physicalF, outputF.id, 'filler_frogFragOut', 'fragment'),
366
- edgeFrom(physicalV, outputV.id, 'filler_gl_Position', 'vertex'),
367
- edgeFrom(purpleNoise, nMap.id, 'filler_normal_map', 'fragment'),
368
- edgeFrom(nMap, physicalF.id, 'property_bumpTexture', 'fragment'),
369
- edgeFrom(ior, physicalF.id, `property_indexOfRefraction`, 'number'),
370
- ...properties.map((prop) =>
371
- edgeFrom(
372
- prop,
373
- physicalF.id,
374
- `property_${prop.name.toLowerCase()}`,
375
- prop.type
376
- )
377
- ),
378
- ],
379
- };
380
- previewObject = 'icosahedron';
381
- bg = 'cityCourtYard';
382
- } else if (example === Example.GLASS_FIREBALL) {
383
- const outputF = outputNode(
384
- makeId(),
385
- 'Output',
386
- { x: 434, y: -97 },
387
- 'fragment'
388
- );
389
- const outputV = outputNode(makeId(), 'Output', { x: 434, y: 20 }, 'vertex');
390
-
391
- const physicalGroupId = makeId();
392
- const physicalF = babylengine.constructors.physical(
393
- makeId(),
394
- 'Physical',
395
- physicalGroupId,
396
- { x: 178, y: -103 },
397
- [],
398
- 'fragment'
399
- );
400
- const physicalV = babylengine.constructors.physical(
401
- makeId(),
402
- 'Physical',
403
- physicalGroupId,
404
- { x: 434, y: 130 },
405
- [],
406
- 'vertex',
407
- physicalF.id
408
- );
409
- const fireF = konvert(fireFrag(makeId(), { x: -88, y: -120 }));
410
- const fireV = konvert(
411
- fireVert(makeId(), fireF.id, { x: -88, y: 610 }, [
412
- numberUniformData('fireSpeed', '0.768'),
413
- numberUniformData('pulseHeight', '0.0'),
414
- numberUniformData('displacementHeight', '0.481'),
415
- numberUniformData('turbulenceDetail', '0.907'),
416
- ])
417
- );
418
-
419
- const roughness = numberNode(
420
- makeId(),
421
- 'Roughness',
422
- { x: -103, y: -16 },
423
- '0.1'
424
- );
425
- const metalness = numberNode(
426
- makeId(),
427
- 'Metalness',
428
- { x: -103, y: 62 },
429
- '0.09'
430
- );
431
- const alpha = numberNode(makeId(), 'Alpha', { x: -103, y: 62 }, '0.0');
432
- const ior = numberNode(
433
- makeId(),
434
- 'Index Of Refraction',
435
- { x: -110, y: 62 },
436
- '1.05'
437
- );
438
-
439
- newGraph = {
440
- nodes: [
441
- alpha,
442
- ior,
443
- roughness,
444
- metalness,
445
- fireF,
446
- fireV,
447
- outputF,
448
- outputV,
449
- physicalF,
450
- physicalV,
451
- ],
452
- edges: [
453
- edgeFrom(physicalF, outputF.id, 'filler_frogFragOut', 'fragment'),
454
- edgeFrom(physicalV, outputV.id, 'filler_gl_Position', 'vertex'),
455
- edgeFrom(fireF, physicalF.id, 'property_albedoTexture', 'fragment'),
456
- edgeFrom(roughness, physicalF.id, 'property_roughness', 'fragment'),
457
- edgeFrom(metalness, physicalF.id, 'property_metallic', 'fragment'),
458
- edgeFrom(alpha, physicalF.id, 'property_alpha', 'fragment'),
459
- edgeFrom(ior, physicalF.id, 'property_indexOfRefraction', 'fragment'),
460
- edgeFrom(fireV, physicalV.id, 'filler_position', 'vertex'),
461
- ],
462
- };
463
- previewObject = 'sphere';
464
- bg = 'cityCourtYard';
465
- } else {
466
- const outputF = outputNode(
467
- makeId(),
468
- 'Output',
469
- { x: 434, y: -97 },
470
- 'fragment'
471
- );
472
- const outputV = outputNode(makeId(), 'Output', { x: 434, y: 20 }, 'vertex');
473
-
474
- const physicalGroupId = makeId();
475
- const physicalF = babylengine.constructors.physical(
476
- makeId(),
477
- 'Physical',
478
- physicalGroupId,
479
- { x: 178, y: -103 },
480
- [],
481
- 'fragment'
482
- );
483
- const physicalV = babylengine.constructors.physical(
484
- makeId(),
485
- 'Physical',
486
- physicalGroupId,
487
- { x: 434, y: 130 },
488
- [],
489
- 'vertex',
490
- physicalF.id
491
- );
492
-
493
- const purpleNoise = konvert(purpleNoiseNode(makeId(), { x: -100, y: 0 }));
494
-
495
- newGraph = {
496
- nodes: [purpleNoise, outputF, outputV, physicalF, physicalV],
497
- edges: [
498
- edgeFrom(physicalF, outputF.id, 'filler_frogFragOut', 'fragment'),
499
- edgeFrom(physicalV, outputV.id, 'filler_gl_Position', 'vertex'),
500
- edgeFrom(
501
- purpleNoise,
502
- physicalF.id,
503
- 'property_albedoTexture',
504
- 'fragment'
505
- ),
506
- ],
507
- };
508
- previewObject = 'torusknot';
509
- }
510
-
511
- return [newGraph, previewObject, bg];
512
- };
@@ -1,680 +0,0 @@
1
- import { Graph } from '../../core/graph';
2
- import {
3
- colorNode,
4
- colorUniformData,
5
- DataNode,
6
- numberNode,
7
- numberUniformData,
8
- textureNode,
9
- textureUniformData,
10
- vectorUniformData,
11
- } from '../../core/nodes/data-nodes';
12
- import { EdgeType, makeEdge } from '../../core/nodes/edge';
13
- import { outputNode } from '../../core/nodes/engine-node';
14
- import { fireFrag, fireVert } from '../../shaders/fireNode';
15
- import {
16
- heatShaderFragmentNode,
17
- heatShaderVertexNode,
18
- variation1 as heatmapV1,
19
- } from '../../shaders/heatmapShaderNode';
20
- import purpleNoiseNode from '../../shaders/purpleNoiseNode';
21
- import staticShaderNode, { variation1 } from '../../shaders/staticShaderNode';
22
- import { makeId } from '../../util/id';
23
- import { checkerboardF, checkerboardV } from '../../shaders/checkboardNode';
24
- import normalMapify from '../../shaders/normalmapifyNode';
25
- import { Engine } from '../../core/engine';
26
- import { CoreNode } from '../../core/nodes/core-node';
27
- import { threngine } from '../../plugins/three/threngine';
28
- import perlinCloudsF from '../../shaders/perlinClouds';
29
- import sinCosVertWarp from '../../shaders/sinCosVertWarp';
30
- import starterVertex from '../../shaders/starterNode';
31
-
32
- export enum Example {
33
- GLASS_FIREBALL = 'Glass Fireball',
34
- GEMSTONE = 'Gemstone',
35
- LIVING_DIAMOND = 'Living Diamond',
36
- VERTEX_NOISE = 'Vertex Noise',
37
- TOON = 'Toon',
38
- EMPTY = 'Empty',
39
- PHYSICAL = 'Mesh Physical Material',
40
- }
41
-
42
- const edgeFrom = (
43
- fromNode: CoreNode,
44
- toId: string,
45
- input: string,
46
- type?: EdgeType
47
- ) => makeEdge(makeId(), fromNode.id, toId, outFrom(fromNode), input, type);
48
-
49
- const outFrom = (node: CoreNode) => node.outputs[0].name;
50
-
51
- export const makeExampleGraph = (example: Example): [Graph, string, string] => {
52
- console.log('🌈 Making new graph!!');
53
- let newGraph: Graph;
54
- let previewObject: string;
55
- let bg: string = '';
56
-
57
- if (example === Example.GEMSTONE) {
58
- const outputF = outputNode(
59
- makeId(),
60
- 'Output',
61
- { x: 434, y: -97 },
62
- 'fragment'
63
- );
64
- const outputV = outputNode(makeId(), 'Output', { x: 434, y: 20 }, 'vertex');
65
-
66
- const physicalGroupId = makeId();
67
- const physicalF = threngine.constructors.physical(
68
- makeId(),
69
- 'Physical',
70
- physicalGroupId,
71
- { x: 178, y: -103 },
72
- [],
73
- 'fragment'
74
- );
75
- const physicalV = threngine.constructors.physical(
76
- makeId(),
77
- 'Physical',
78
- physicalGroupId,
79
- { x: 434, y: 130 },
80
- [],
81
- 'vertex',
82
- physicalF.id
83
- );
84
- const staticF = staticShaderNode(
85
- makeId(),
86
- { x: -196, y: -303 },
87
- variation1
88
- );
89
- const heatmap = heatShaderFragmentNode(
90
- makeId(),
91
- { x: -478, y: 12 },
92
- heatmapV1
93
- );
94
- const heatmapV = heatShaderVertexNode(makeId(), heatmap.id, {
95
- x: -478,
96
- y: -194,
97
- });
98
-
99
- const normaled = normalMapify(makeId(), { x: -178, y: -149 });
100
- const normalStrength = numberNode(
101
- makeId(),
102
- 'Normal Strength',
103
- { x: -482, y: -105 },
104
- '1..0'
105
- );
106
-
107
- const color = colorNode(makeId(), 'Color', { x: -187, y: -413 }, [
108
- '1.0',
109
- '0.75',
110
- '1.0',
111
- ]);
112
- const roughness = numberNode(
113
- makeId(),
114
- 'Roughness',
115
- { x: -187, y: 54 },
116
- '0.37'
117
- );
118
- const transmission = numberNode(
119
- makeId(),
120
- 'Transmission',
121
- { x: -187, y: 153 },
122
- '0.5'
123
- );
124
- const thickness = numberNode(
125
- makeId(),
126
- 'Thickness',
127
- { x: -187, y: 240 },
128
- '1.0'
129
- );
130
- const ior = numberNode(makeId(), 'Ior', { x: -187, y: 328 }, '2.0');
131
-
132
- newGraph = {
133
- nodes: [
134
- color,
135
- normaled,
136
- normalStrength,
137
- roughness,
138
- transmission,
139
- thickness,
140
- ior,
141
- staticF,
142
- heatmap,
143
- heatmapV,
144
- outputF,
145
- outputV,
146
- physicalF,
147
- physicalV,
148
- ],
149
- edges: [
150
- edgeFrom(physicalF, outputF.id, 'filler_frogFragOut', 'fragment'),
151
- edgeFrom(physicalV, outputV.id, 'filler_gl_Position', 'vertex'),
152
- edgeFrom(staticF, physicalF.id, 'property_map', 'fragment'),
153
- edgeFrom(color, physicalF.id, 'property_color', 'fragment'),
154
- edgeFrom(roughness, physicalF.id, 'property_roughness', 'fragment'),
155
-
156
- edgeFrom(
157
- transmission,
158
- physicalF.id,
159
- 'property_transmission',
160
- 'fragment'
161
- ),
162
- edgeFrom(thickness, physicalF.id, 'property_thickness', 'fragment'),
163
- edgeFrom(ior, physicalF.id, 'property_ior', 'fragment'),
164
- edgeFrom(
165
- normalStrength,
166
- normaled.id,
167
- 'uniform_normal_strength',
168
- 'fragment'
169
- ),
170
- edgeFrom(heatmap, normaled.id, 'filler_normal_map', 'fragment'),
171
- edgeFrom(
172
- normaled,
173
- physicalF.id,
174
- threngine.name === 'three'
175
- ? 'property_normalMap'
176
- : 'property_bumpTexture',
177
- 'fragment'
178
- ),
179
- ],
180
- };
181
- previewObject = 'icosahedron';
182
- bg = 'warehouseEnvTexture';
183
- } else if (example === Example.TOON) {
184
- const outputF = outputNode(
185
- makeId(),
186
- 'Output',
187
- { x: 434, y: -97 },
188
- 'fragment'
189
- );
190
- const outputV = outputNode(makeId(), 'Output', { x: 434, y: 16 }, 'vertex');
191
-
192
- const toonGroupId = makeId();
193
- const toonF = threngine.constructors.toon(
194
- makeId(),
195
- 'Toon',
196
- toonGroupId,
197
- { x: 178, y: -103 },
198
- [],
199
- 'fragment'
200
- );
201
- const toonV = threngine.constructors.toon(
202
- makeId(),
203
- 'Toon',
204
- toonGroupId,
205
- { x: 434, y: 130 },
206
- [],
207
- 'vertex',
208
- toonF.id
209
- );
210
- const pps: [string, DataNode][] = [
211
- [
212
- 'color',
213
- colorNode(makeId(), 'Color', { x: -153, y: -268 }, ['0', '0.7', '0']),
214
- ],
215
- [
216
- 'gradientMap',
217
- textureNode(
218
- makeId(),
219
- 'Gradient Map',
220
- { x: -153, y: -160 },
221
- 'threeTone'
222
- ),
223
- ],
224
- [
225
- 'normalMap',
226
- textureNode(makeId(), 'Normal Map', { x: -153, y: -50 }, 'brickNormal'),
227
- ],
228
- ];
229
-
230
- newGraph = {
231
- nodes: [outputF, outputV, toonF, toonV, ...pps.map(([, p]) => p)],
232
- edges: [
233
- edgeFrom(toonF, outputF.id, 'filler_frogFragOut', 'fragment'),
234
- edgeFrom(toonV, outputV.id, 'filler_gl_Position', 'vertex'),
235
- ...pps.map(([name, prop]) =>
236
- edgeFrom(prop, toonF.id, `property_${name}`, prop.type)
237
- ),
238
- ],
239
- };
240
- previewObject = 'torusknot';
241
- bg = '';
242
- } else if (example === Example.EMPTY) {
243
- const outputF = outputNode(
244
- makeId(),
245
- 'Output',
246
- { x: 778, y: -75 },
247
- 'fragment'
248
- );
249
- const outputV = outputNode(
250
- makeId(),
251
- 'Output',
252
- { x: 778, y: 134 },
253
- 'vertex'
254
- );
255
-
256
- const vertex = starterVertex(makeId(), { x: 434, y: 130 });
257
-
258
- newGraph = {
259
- nodes: [outputF, outputV, vertex],
260
- edges: [edgeFrom(vertex, outputV.id, 'filler_gl_Position', 'vertex')],
261
- };
262
- previewObject = 'sphere';
263
- bg = '';
264
- } else if (example === Example.PHYSICAL) {
265
- const outputF = outputNode(
266
- makeId(),
267
- 'Output',
268
- { x: 434, y: -97 },
269
- 'fragment'
270
- );
271
- const outputV = outputNode(makeId(), 'Output', { x: 434, y: 16 }, 'vertex');
272
-
273
- const physicalGroupId = makeId();
274
- const physicalF = threngine.constructors.physical(
275
- makeId(),
276
- 'Physical',
277
- physicalGroupId,
278
- { x: 178, y: -103 },
279
- [],
280
- 'fragment'
281
- );
282
- const physicalV = threngine.constructors.physical(
283
- makeId(),
284
- 'Physical',
285
- physicalGroupId,
286
- { x: 434, y: 130 },
287
- [],
288
- 'vertex',
289
- physicalF.id
290
- );
291
-
292
- const checkerboardf = checkerboardF(makeId(), { x: -162, y: -105 });
293
- const checkerboardv = checkerboardV(makeId(), checkerboardf.id, {
294
- x: -162,
295
- y: 43,
296
- });
297
- newGraph = {
298
- nodes: [
299
- outputF,
300
- outputV,
301
- physicalF,
302
- physicalV,
303
- checkerboardf,
304
- checkerboardv,
305
- ],
306
- edges: [
307
- edgeFrom(physicalF, outputF.id, 'filler_frogFragOut', 'fragment'),
308
- edgeFrom(physicalV, outputV.id, 'filler_gl_Position', 'vertex'),
309
- edgeFrom(
310
- checkerboardf,
311
- physicalF.id,
312
- threngine.name === 'three'
313
- ? 'property_map'
314
- : 'property_albedoTexture',
315
- 'fragment'
316
- ),
317
- ],
318
- };
319
- previewObject = 'sphere';
320
- bg = '';
321
- } else if (example === Example.LIVING_DIAMOND) {
322
- const outputF = outputNode(
323
- makeId(),
324
- 'Output',
325
- { x: 434, y: -97 },
326
- 'fragment'
327
- );
328
- const outputV = outputNode(makeId(), 'Output', { x: 434, y: 16 }, 'vertex');
329
-
330
- const nMap = normalMapify(makeId(), { x: -185, y: 507 });
331
-
332
- const purpleNoise = purpleNoiseNode(makeId(), { x: -512, y: 434 }, [
333
- numberUniformData('speed', threngine.name === 'babylon' ? '1.0' : '0.2'),
334
- numberUniformData('brightnessX', '1.0'),
335
- numberUniformData('permutations', '10'),
336
- numberUniformData('iterations', '2'),
337
- vectorUniformData(
338
- 'uvScale',
339
- threngine.name === 'babylon' ? ['0.1', '0.1'] : ['0.9', '0.9']
340
- ),
341
- vectorUniformData('color1', ['0', '1', '1']),
342
- vectorUniformData('color2', ['1', '0', '1']),
343
- vectorUniformData('color3', ['1', '1', '0']),
344
- ]);
345
-
346
- const properties = [
347
- numberNode(
348
- makeId(),
349
- // threngine.name === 'three' ? 'Metalness' : 'Metallic',
350
- 'Metalness',
351
- { x: -185, y: -110 },
352
- '0.1'
353
- ),
354
- numberNode(makeId(), 'Roughness', { x: -185, y: 0 }, '0.055'),
355
- numberNode(
356
- makeId(),
357
- // threngine.name === 'three' ? 'Transmission' : 'Alpha',
358
- 'Transmission',
359
- { x: -185, y: 110 },
360
- '0.9'
361
- ),
362
- // ...(threngine.name === 'three'
363
- // ? [
364
- numberNode(makeId(), 'Thickness', { x: -185, y: 220 }, '1.1'),
365
- numberNode(makeId(), 'Index of Refraction', { x: -185, y: 330 }, '2.4'),
366
- // ]
367
- // : []),
368
- ];
369
-
370
- const physicalGroupId = makeId();
371
- const physicalF = threngine.constructors.physical(
372
- makeId(),
373
- 'Physical',
374
- physicalGroupId,
375
- { x: 178, y: -103 },
376
- [],
377
- 'fragment'
378
- );
379
- const physicalV = threngine.constructors.physical(
380
- makeId(),
381
- 'Physical',
382
- physicalGroupId,
383
- { x: 434, y: 130 },
384
- [],
385
- 'vertex',
386
- physicalF.id
387
- );
388
-
389
- newGraph = {
390
- nodes: [
391
- outputF,
392
- outputV,
393
- physicalF,
394
- physicalV,
395
- purpleNoise,
396
- nMap,
397
- ...properties,
398
- ],
399
- edges: [
400
- edgeFrom(physicalF, outputF.id, 'filler_frogFragOut', 'fragment'),
401
- edgeFrom(physicalV, outputV.id, 'filler_gl_Position', 'vertex'),
402
- edgeFrom(purpleNoise, nMap.id, 'filler_normal_map', 'fragment'),
403
- edgeFrom(
404
- nMap,
405
- physicalF.id,
406
- 'property_normalMap',
407
- // threngine.name === 'three'
408
- // ? 'property_normalMap'
409
- // : 'property_bumpTexture',
410
- 'fragment'
411
- ),
412
- ...properties.map((prop) =>
413
- edgeFrom(
414
- prop,
415
- physicalF.id,
416
- `property_${
417
- prop.name === 'Index of Refraction'
418
- ? 'ior'
419
- : prop.name.toLowerCase()
420
- }`,
421
- prop.type
422
- )
423
- ),
424
- ],
425
- };
426
- previewObject = 'icosahedron';
427
- bg = 'warehouseEnvTexture';
428
- } else if (example === Example.VERTEX_NOISE) {
429
- const outputF = outputNode(
430
- makeId(),
431
- 'Output',
432
- { x: 434, y: -97 },
433
- 'fragment'
434
- );
435
- const outputV = outputNode(makeId(), 'Output', { x: 434, y: 16 }, 'vertex');
436
-
437
- const vertexNoise = sinCosVertWarp(makeId(), { x: -512, y: 0 });
438
- const clouds = perlinCloudsF(makeId(), { x: -512, y: 434 }, [
439
- colorUniformData('color', ['1', '1', '1']),
440
- numberUniformData('scale', '0.1'),
441
- textureUniformData('noiseImage', 'grayscale-noise'),
442
- vectorUniformData('speed', ['-0.001', '-0.001']),
443
- numberUniformData('cloudBrightness', '0.2'),
444
- numberUniformData('cloudMorphSpeed', '0.2'),
445
- numberUniformData('cloudMorphDirection', '1'),
446
- numberUniformData('cloudCover', '0.65'),
447
- ]);
448
-
449
- const properties = [
450
- numberNode(makeId(), 'Roughness', { x: -185, y: 0 }, '0.0'),
451
- numberNode(makeId(), 'Transmission', { x: -200, y: 110 }, '0.9'),
452
- numberNode(makeId(), 'Thickness', { x: -230, y: 220 }, '1.1'),
453
- numberNode(makeId(), 'Index of Refraction', { x: -245, y: 330 }, '1.5', {
454
- range: [0, 5],
455
- }),
456
- ];
457
-
458
- const physicalGroupId = makeId();
459
- const physicalF = threngine.constructors.physical(
460
- makeId(),
461
- 'Physical',
462
- physicalGroupId,
463
- { x: 178, y: -103 },
464
- [],
465
- 'fragment'
466
- );
467
- const physicalV = threngine.constructors.physical(
468
- makeId(),
469
- 'Physical',
470
- physicalGroupId,
471
- { x: 434, y: 130 },
472
- [],
473
- 'vertex',
474
- physicalF.id
475
- );
476
-
477
- newGraph = {
478
- nodes: [
479
- outputF,
480
- outputV,
481
- physicalF,
482
- physicalV,
483
- clouds,
484
- vertexNoise,
485
- ...properties,
486
- ],
487
- edges: [
488
- edgeFrom(physicalF, outputF.id, 'filler_frogFragOut', 'fragment'),
489
- edgeFrom(physicalV, outputV.id, 'filler_gl_Position', 'vertex'),
490
- edgeFrom(clouds, physicalF.id, 'property_map', 'fragment'),
491
- edgeFrom(vertexNoise, physicalV.id, 'filler_position', 'vertex'),
492
- ...properties.map((prop) =>
493
- edgeFrom(
494
- prop,
495
- physicalF.id,
496
- `property_${
497
- prop.name === 'Index of Refraction'
498
- ? 'ior'
499
- : prop.name.toLowerCase()
500
- }`,
501
- prop.type
502
- )
503
- ),
504
- ],
505
- };
506
- previewObject = 'sphere';
507
- bg = 'pondCubeMap';
508
- } else if (example === Example.GLASS_FIREBALL) {
509
- const outputF = outputNode(
510
- makeId(),
511
- 'Output',
512
- { x: 434, y: -97 },
513
- 'fragment'
514
- );
515
- const outputV = outputNode(makeId(), 'Output', { x: 434, y: 20 }, 'vertex');
516
-
517
- const physicalGroupId = makeId();
518
- const physicalF = threngine.constructors.physical(
519
- makeId(),
520
- 'Physical',
521
- physicalGroupId,
522
- { x: 178, y: -103 },
523
- [],
524
- 'fragment'
525
- );
526
- const physicalV = threngine.constructors.physical(
527
- makeId(),
528
- 'Physical',
529
- physicalGroupId,
530
- { x: 434, y: 130 },
531
- [],
532
- 'vertex',
533
- physicalF.id
534
- );
535
- const fireF = fireFrag(makeId(), { x: -88, y: -120 });
536
- const fireV = fireVert(makeId(), fireF.id, { x: -88, y: 610 }, [
537
- numberUniformData('fireSpeed', '0.768'),
538
- numberUniformData('pulseHeight', '0.0'),
539
- numberUniformData('displacementHeight', '0.481'),
540
- numberUniformData('turbulenceDetail', '0.907'),
541
- ]);
542
-
543
- const color = colorNode(makeId(), 'Color', { x: -97, y: -223 }, [
544
- '1',
545
- '0.8',
546
- '0.6',
547
- ]);
548
- const roughness = numberNode(
549
- makeId(),
550
- 'Roughness',
551
- { x: -103, y: -16 },
552
- '0.1'
553
- );
554
- const metalness = numberNode(
555
- makeId(),
556
- 'Metalness',
557
- { x: -103, y: 62 },
558
- '0.09'
559
- );
560
- const transmission = numberNode(
561
- makeId(),
562
- 'Transmission',
563
- { x: -103, y: 153 },
564
- '0.7'
565
- );
566
- const thickness = numberNode(
567
- makeId(),
568
- 'Thickness',
569
- { x: -103, y: 240 },
570
- '1.0'
571
- );
572
- const ior = numberNode(makeId(), 'Ior', { x: -103, y: 328 }, '1.75');
573
-
574
- newGraph = {
575
- nodes: [
576
- color,
577
- roughness,
578
- metalness,
579
- transmission,
580
- thickness,
581
- ior,
582
- fireF,
583
- fireV,
584
- outputF,
585
- outputV,
586
- physicalF,
587
- physicalV,
588
- ],
589
- edges: [
590
- edgeFrom(physicalF, outputF.id, 'filler_frogFragOut', 'fragment'),
591
- edgeFrom(physicalV, outputV.id, 'filler_gl_Position', 'vertex'),
592
- edgeFrom(
593
- fireF,
594
- physicalF.id,
595
- // threngine.name === 'three' ? 'property_map' : 'property_albedoTexture',
596
- 'property_map',
597
- 'fragment'
598
- ),
599
- edgeFrom(
600
- color,
601
- physicalF.id,
602
- // threngine.name === 'three' ? 'property_color' : 'property_albedoColor',
603
- 'property_color',
604
- 'fragment'
605
- ),
606
- edgeFrom(roughness, physicalF.id, 'property_roughness', 'fragment'),
607
- edgeFrom(
608
- metalness,
609
- physicalF.id,
610
- // threngine.name === 'three' ? 'property_metalness' : 'property_metallic',
611
- 'property_metalness',
612
- 'fragment'
613
- ),
614
- edgeFrom(
615
- transmission,
616
- physicalF.id,
617
- 'property_transmission',
618
- 'fragment'
619
- ),
620
- edgeFrom(thickness, physicalF.id, 'property_thickness', 'fragment'),
621
- edgeFrom(ior, physicalF.id, 'property_ior', 'fragment'),
622
-
623
- edgeFrom(fireV, physicalV.id, 'filler_position', 'vertex'),
624
- ],
625
- };
626
- previewObject = 'sphere';
627
- bg = 'warehouseEnvTexture';
628
- } else {
629
- const outputF = outputNode(
630
- makeId(),
631
- 'Output',
632
- { x: 434, y: -97 },
633
- 'fragment'
634
- );
635
- const outputV = outputNode(makeId(), 'Output', { x: 434, y: 20 }, 'vertex');
636
-
637
- const physicalGroupId = makeId();
638
- const physicalF = threngine.constructors.physical(
639
- makeId(),
640
- 'Physical',
641
- physicalGroupId,
642
- { x: 178, y: -103 },
643
- [],
644
- 'fragment'
645
- );
646
- const physicalV = threngine.constructors.physical(
647
- makeId(),
648
- 'Physical',
649
- physicalGroupId,
650
- { x: 434, y: 130 },
651
- [],
652
- 'vertex',
653
- physicalF.id
654
- );
655
-
656
- const purpleNoise = purpleNoiseNode(makeId(), { x: -100, y: 0 });
657
- // const purpleNoise =
658
- // threngine.name === 'babylon'
659
- // ? convertNode(purple, threngine.importers.three)
660
- // : purple;
661
-
662
- newGraph = {
663
- nodes: [purpleNoise, outputF, outputV, physicalF, physicalV],
664
- edges: [
665
- edgeFrom(physicalF, outputF.id, 'filler_frogFragOut', 'fragment'),
666
- edgeFrom(physicalV, outputV.id, 'filler_gl_Position', 'vertex'),
667
- edgeFrom(
668
- purpleNoise,
669
- physicalF.id,
670
- // threngine.name === 'three' ? 'property_map' : 'property_albedoTexture',
671
- 'property_map',
672
- 'fragment'
673
- ),
674
- ],
675
- };
676
- previewObject = 'torusknot';
677
- }
678
-
679
- return [newGraph, previewObject, bg];
680
- };