@shaderfrog/core 1.1.1 → 1.2.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.
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __assign = (this && this.__assign) || function () {
2
3
  __assign = Object.assign || function(t) {
3
4
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -70,16 +71,21 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
70
71
  }
71
72
  return to.concat(ar || Array.prototype.slice.call(from));
72
73
  };
74
+ var __importDefault = (this && this.__importDefault) || function (mod) {
75
+ return (mod && mod.__esModule) ? mod : { "default": mod };
76
+ };
73
77
  var _a, _b;
74
- import { ShaderLib, RawShaderMaterial, Vector2, Vector3, Vector4, Color, GLSL3, Light, Texture, MeshPhongMaterial, MeshPhysicalMaterial, MeshToonMaterial, } from 'three';
75
- import { NodeType } from '../../graph/graph-types';
76
- import { prepopulatePropertyInputs, mangleMainFn } from '../../graph/graph';
77
- import importers from './importers';
78
- import { EngineNodeType } from '../../engine';
79
- import { doesLinkThruShader, nodeName } from '../../graph/graph';
80
- import { returnGlPosition, returnGlPositionHardCoded, returnGlPositionVec3Right, } from '../../util/ast';
81
- import { property, } from '../../graph/code-nodes';
82
- import { namedAttributeStrategy, texture2DStrategy, uniformStrategy, } from '../../strategy';
78
+ Object.defineProperty(exports, "__esModule", { value: true });
79
+ exports.createMaterial = exports.threngine = exports.toonNode = exports.defaultPropertySetting = exports.physicalNode = exports.phongNode = void 0;
80
+ var three_1 = require("three");
81
+ var graph_types_1 = require("../../graph/graph-types");
82
+ var graph_1 = require("../../graph/graph");
83
+ var importers_1 = __importDefault(require("./importers"));
84
+ var engine_1 = require("../../engine");
85
+ var graph_2 = require("../../graph/graph");
86
+ var ast_1 = require("../../util/ast");
87
+ var code_nodes_1 = require("../../graph/code-nodes");
88
+ var strategy_1 = require("../../strategy");
83
89
  var log = function () {
84
90
  var _a;
85
91
  var args = [];
@@ -88,42 +94,42 @@ var log = function () {
88
94
  }
89
95
  return (_a = console.log).call.apply(_a, __spreadArray([console, '\x1b[35m(three)\x1b[0m'], __read(args), false));
90
96
  };
91
- export var phongNode = function (id, name, position, uniforms, stage) {
92
- return prepopulatePropertyInputs({
97
+ var phongNode = function (id, name, position, uniforms, stage) {
98
+ return (0, graph_1.prepopulatePropertyInputs)({
93
99
  id: id,
94
100
  name: 'MeshPhongMaterial',
95
101
  position: position,
96
102
  engine: true,
97
- type: EngineNodeType.phong,
103
+ type: engine_1.EngineNodeType.phong,
98
104
  config: {
99
105
  version: 3,
100
106
  uniforms: uniforms,
101
107
  preprocess: true,
102
108
  mangle: false,
103
109
  properties: [
104
- property('Color', 'color', 'rgb', 'uniform_diffuse'),
105
- property('Emissive', 'emissive', 'rgb', 'uniform_emissive'),
106
- property('Emissive Map', 'emissiveMap', 'texture', 'filler_emissiveMap'),
107
- property('Emissive Intensity', 'emissiveIntensity', 'number', 'uniform_emissive'),
108
- property('Texture', 'map', 'texture', 'filler_map'),
109
- property('Normal Map', 'normalMap', 'texture', 'filler_normalMap'),
110
- property('Normal Scale', 'normalScale', 'vector2'),
111
- property('AO Map', 'aoMap', 'texture', 'filler_aoMap'),
112
- property('AO Intensity', 'aoMapIntensity', 'number', 'filler_aoMapIntensity'),
113
- property('Shininess', 'shininess', 'number'),
114
- property('Reflectivity', 'reflectivity', 'number'),
115
- property('Refraction Ratio', 'refractionRatio', 'number'),
116
- property('Specular', 'specular', 'rgb', 'uniform_specular'),
117
- property('Specular Map', 'specularMap', 'texture', 'filler_specularMap'),
118
- property('Displacement Map', 'displacementMap', 'texture', 'filler_displacementMap'),
119
- property('Displacement Scale', 'displacementScale', 'number'),
120
- property('Env Map', 'envMap', 'samplerCube'),
110
+ (0, code_nodes_1.property)('Color', 'color', 'rgb', 'uniform_diffuse'),
111
+ (0, code_nodes_1.property)('Emissive', 'emissive', 'rgb', 'uniform_emissive'),
112
+ (0, code_nodes_1.property)('Emissive Map', 'emissiveMap', 'texture', 'filler_emissiveMap'),
113
+ (0, code_nodes_1.property)('Emissive Intensity', 'emissiveIntensity', 'number', 'uniform_emissive'),
114
+ (0, code_nodes_1.property)('Texture', 'map', 'texture', 'filler_map'),
115
+ (0, code_nodes_1.property)('Normal Map', 'normalMap', 'texture', 'filler_normalMap'),
116
+ (0, code_nodes_1.property)('Normal Scale', 'normalScale', 'vector2'),
117
+ (0, code_nodes_1.property)('AO Map', 'aoMap', 'texture', 'filler_aoMap'),
118
+ (0, code_nodes_1.property)('AO Intensity', 'aoMapIntensity', 'number', 'filler_aoMapIntensity'),
119
+ (0, code_nodes_1.property)('Shininess', 'shininess', 'number'),
120
+ (0, code_nodes_1.property)('Reflectivity', 'reflectivity', 'number'),
121
+ (0, code_nodes_1.property)('Refraction Ratio', 'refractionRatio', 'number'),
122
+ (0, code_nodes_1.property)('Specular', 'specular', 'rgb', 'uniform_specular'),
123
+ (0, code_nodes_1.property)('Specular Map', 'specularMap', 'texture', 'filler_specularMap'),
124
+ (0, code_nodes_1.property)('Displacement Map', 'displacementMap', 'texture', 'filler_displacementMap'),
125
+ (0, code_nodes_1.property)('Displacement Scale', 'displacementScale', 'number'),
126
+ (0, code_nodes_1.property)('Env Map', 'envMap', 'samplerCube'),
121
127
  ],
122
128
  strategies: [
123
- uniformStrategy(),
129
+ (0, strategy_1.uniformStrategy)(),
124
130
  stage === 'fragment'
125
- ? texture2DStrategy()
126
- : namedAttributeStrategy('position'),
131
+ ? (0, strategy_1.texture2DStrategy)()
132
+ : (0, strategy_1.namedAttributeStrategy)('position'),
127
133
  ],
128
134
  },
129
135
  inputs: [],
@@ -139,56 +145,57 @@ export var phongNode = function (id, name, position, uniforms, stage) {
139
145
  stage: stage,
140
146
  });
141
147
  };
142
- export var physicalNode = function (id, name, position, uniforms, stage) {
143
- return prepopulatePropertyInputs({
148
+ exports.phongNode = phongNode;
149
+ var physicalNode = function (id, name, position, uniforms, stage) {
150
+ return (0, graph_1.prepopulatePropertyInputs)({
144
151
  id: id,
145
152
  name: 'MeshPhysicalMaterial',
146
153
  position: position,
147
154
  engine: true,
148
- type: EngineNodeType.physical,
155
+ type: engine_1.EngineNodeType.physical,
149
156
  config: {
150
157
  uniforms: uniforms,
151
158
  version: 3,
152
159
  mangle: false,
153
160
  preprocess: true,
154
161
  properties: [
155
- property('Color', 'color', 'rgb', 'uniform_diffuse'),
156
- property('Texture', 'map', 'texture', 'filler_map'),
157
- property('Opacity', 'opacity', 'number'),
158
- property('Normal Map', 'normalMap', 'texture', 'filler_normalMap'),
159
- property('Normal Scale', 'normalScale', 'vector2'),
160
- property('AO Map', 'aoMap', 'texture', 'filler_aoMap'),
161
- property('AO Intensity', 'aoMapIntensity', 'number', 'filler_aoMapIntensity'),
162
- property('Metalness', 'metalness', 'number', 'uniform_metalness'),
163
- property('Roughness', 'roughness', 'number', 'uniform_roughness'),
164
- property('Roughness Map', 'roughnessMap', 'texture', 'filler_roughnessMap'),
165
- property('Displacement Map', 'displacementMap', 'texture', 'filler_displacementMap'),
166
- property('Displacement Scale', 'displacementScale', 'number'),
162
+ (0, code_nodes_1.property)('Color', 'color', 'rgb', 'uniform_diffuse'),
163
+ (0, code_nodes_1.property)('Texture', 'map', 'texture', 'filler_map'),
164
+ (0, code_nodes_1.property)('Opacity', 'opacity', 'number'),
165
+ (0, code_nodes_1.property)('Normal Map', 'normalMap', 'texture', 'filler_normalMap'),
166
+ (0, code_nodes_1.property)('Normal Scale', 'normalScale', 'vector2'),
167
+ (0, code_nodes_1.property)('AO Map', 'aoMap', 'texture', 'filler_aoMap'),
168
+ (0, code_nodes_1.property)('AO Intensity', 'aoMapIntensity', 'number', 'filler_aoMapIntensity'),
169
+ (0, code_nodes_1.property)('Metalness', 'metalness', 'number', 'uniform_metalness'),
170
+ (0, code_nodes_1.property)('Roughness', 'roughness', 'number', 'uniform_roughness'),
171
+ (0, code_nodes_1.property)('Roughness Map', 'roughnessMap', 'texture', 'filler_roughnessMap'),
172
+ (0, code_nodes_1.property)('Displacement Map', 'displacementMap', 'texture', 'filler_displacementMap'),
173
+ (0, code_nodes_1.property)('Displacement Scale', 'displacementScale', 'number'),
167
174
  // MeshPhysicalMaterial gets envMap from the scene. MeshStandardMaterial
168
175
  // gets it from the material
169
176
  // property('Env Map', 'envMap', 'samplerCube'),
170
- property('Transmission', 'transmission', 'number'),
171
- property('Transmission Map', 'transmissionMap', 'texture', 'filler_transmissionMap'),
172
- property('Thickness', 'thickness', 'number'),
173
- property('Index of Refraction', 'ior', 'number'),
177
+ (0, code_nodes_1.property)('Transmission', 'transmission', 'number'),
178
+ (0, code_nodes_1.property)('Transmission Map', 'transmissionMap', 'texture', 'filler_transmissionMap'),
179
+ (0, code_nodes_1.property)('Thickness', 'thickness', 'number'),
180
+ (0, code_nodes_1.property)('Index of Refraction', 'ior', 'number'),
174
181
  // Sheen only works with directional lights?
175
182
  // https://discourse.threejs.org/t/meshphysicalmaterial-s-sheen/31901/6
176
183
  // property('Sheen', 'sheen', 'number'),
177
- property('Reflectivity', 'reflectivity', 'number'),
178
- property('Clearcoat', 'clearcoat', 'number'),
179
- property('Iridescence', 'iridescence', 'number'),
180
- property('Iridescence IOR', 'iridescenceIOR', 'number'),
181
- property('Iridescence Thickness Range', 'iridescenceThicknessRange', 'array', undefined, ['100', '400']),
184
+ (0, code_nodes_1.property)('Reflectivity', 'reflectivity', 'number'),
185
+ (0, code_nodes_1.property)('Clearcoat', 'clearcoat', 'number'),
186
+ (0, code_nodes_1.property)('Iridescence', 'iridescence', 'number'),
187
+ (0, code_nodes_1.property)('Iridescence IOR', 'iridescenceIOR', 'number'),
188
+ (0, code_nodes_1.property)('Iridescence Thickness Range', 'iridescenceThicknessRange', 'array', undefined, ['100', '400']),
182
189
  ],
183
190
  hardCodedProperties: {
184
191
  isMeshPhysicalMaterial: true,
185
192
  isMeshStandardMaterial: true,
186
193
  },
187
194
  strategies: [
188
- uniformStrategy(),
195
+ (0, strategy_1.uniformStrategy)(),
189
196
  stage === 'fragment'
190
- ? texture2DStrategy()
191
- : namedAttributeStrategy('position'),
197
+ ? (0, strategy_1.texture2DStrategy)()
198
+ : (0, strategy_1.namedAttributeStrategy)('position'),
192
199
  ],
193
200
  },
194
201
  inputs: [],
@@ -204,6 +211,7 @@ export var physicalNode = function (id, name, position, uniforms, stage) {
204
211
  stage: stage,
205
212
  });
206
213
  };
214
+ exports.physicalNode = physicalNode;
207
215
  var cacher = function (engineContext, graph, node, sibling, newValue) {
208
216
  var cacheKey = programCacheKey(engineContext, graph, node, sibling);
209
217
  if (engineContext.runtime.cache.data[cacheKey]) {
@@ -262,18 +270,18 @@ var onBeforeCompileMegaShader = function (engineContext, newMat) {
262
270
  };
263
271
  var megaShaderMainpulateAst = function (engineContext, engine, graph, ast, inputEdges, node, sibling) {
264
272
  var programAst = ast;
265
- var mainName = 'main' || nodeName(node);
273
+ var mainName = 'main' || (0, graph_2.nodeName)(node);
266
274
  if (node.stage === 'vertex') {
267
- if (doesLinkThruShader(graph, node)) {
268
- returnGlPositionHardCoded(mainName, programAst, 'vec3', 'transformed');
275
+ if ((0, graph_2.doesLinkThruShader)(graph, node)) {
276
+ (0, ast_1.returnGlPositionHardCoded)(mainName, programAst, 'vec3', 'transformed');
269
277
  }
270
278
  else {
271
- returnGlPosition(mainName, programAst);
279
+ (0, ast_1.returnGlPosition)(mainName, programAst);
272
280
  }
273
281
  }
274
282
  // We specify engine nodes are mangle: false, which is the graph step that
275
283
  // handles renaming the main fn, so we have to do it ourselves
276
- mangleMainFn(programAst, node, sibling);
284
+ (0, graph_1.mangleMainFn)(programAst, node, sibling);
277
285
  return programAst;
278
286
  };
279
287
  var nodeCacheKey = function (graph, node) {
@@ -298,7 +306,7 @@ var programCacheKey = function (engineContext, graph, node, sibling) {
298
306
  var scene = engineContext.runtime.scene;
299
307
  var lights = [];
300
308
  scene.traverse(function (obj) {
301
- if (obj instanceof Light) {
309
+ if (obj instanceof three_1.Light) {
302
310
  lights.push(obj.type);
303
311
  }
304
312
  });
@@ -312,20 +320,21 @@ var programCacheKey = function (engineContext, graph, node, sibling) {
312
320
  '|Envtex:' +
313
321
  scene.environmentTexture);
314
322
  };
315
- export var defaultPropertySetting = function (property) {
323
+ var defaultPropertySetting = function (property) {
316
324
  if (property.type === 'texture') {
317
- return new Texture();
325
+ return new three_1.Texture();
318
326
  }
319
327
  else if (property.type === 'number') {
320
328
  return 0.5;
321
329
  }
322
330
  else if (property.type === 'rgb') {
323
- return new Color(1, 1, 1);
331
+ return new three_1.Color(1, 1, 1);
324
332
  }
325
333
  else if (property.type === 'rgba') {
326
- return new Vector4(1, 1, 1, 1);
334
+ return new three_1.Vector4(1, 1, 1, 1);
327
335
  }
328
336
  };
337
+ exports.defaultPropertySetting = defaultPropertySetting;
329
338
  var threeMaterialProperties = function (graph, node, sibling) {
330
339
  // Find inputs to this node that are dependent on a property of the material
331
340
  var propertyInputs = node.inputs
@@ -344,7 +353,7 @@ var threeMaterialProperties = function (graph, node, sibling) {
344
353
  // Find the property itself
345
354
  var property_1 = (node.config.properties || []).find(function (p) { return p.property === propertyInput.property; });
346
355
  // Initialize the property on the material
347
- acc[property_1.property] = defaultPropertySetting(property_1);
356
+ acc[property_1.property] = (0, exports.defaultPropertySetting)(property_1);
348
357
  }
349
358
  return acc;
350
359
  }, {});
@@ -354,53 +363,53 @@ var evaluateNode = function (node) {
354
363
  return parseFloat(node.value);
355
364
  }
356
365
  if (node.type === 'vector2') {
357
- return new Vector2(parseFloat(node.value[0]), parseFloat(node.value[1]));
366
+ return new three_1.Vector2(parseFloat(node.value[0]), parseFloat(node.value[1]));
358
367
  }
359
368
  else if (node.type === 'vector3') {
360
- return new Vector3(parseFloat(node.value[0]), parseFloat(node.value[1]), parseFloat(node.value[2]));
369
+ return new three_1.Vector3(parseFloat(node.value[0]), parseFloat(node.value[1]), parseFloat(node.value[2]));
361
370
  }
362
371
  else if (node.type === 'vector4') {
363
- return new Vector4(parseFloat(node.value[0]), parseFloat(node.value[1]), parseFloat(node.value[2]), parseFloat(node.value[3]));
372
+ return new three_1.Vector4(parseFloat(node.value[0]), parseFloat(node.value[1]), parseFloat(node.value[2]), parseFloat(node.value[3]));
364
373
  }
365
374
  else if (node.type === 'rgb') {
366
- return new Color(parseFloat(node.value[0]), parseFloat(node.value[1]), parseFloat(node.value[2]));
375
+ return new three_1.Color(parseFloat(node.value[0]), parseFloat(node.value[1]), parseFloat(node.value[2]));
367
376
  }
368
377
  else if (node.type === 'rgba') {
369
- return new Vector4(parseFloat(node.value[0]), parseFloat(node.value[1]), parseFloat(node.value[2]), parseFloat(node.value[3]));
378
+ return new three_1.Vector4(parseFloat(node.value[0]), parseFloat(node.value[1]), parseFloat(node.value[2]), parseFloat(node.value[3]));
370
379
  }
371
380
  else {
372
381
  return node.value;
373
382
  }
374
383
  };
375
- export var toonNode = function (id, name, position, uniforms, stage) {
376
- return prepopulatePropertyInputs({
384
+ var toonNode = function (id, name, position, uniforms, stage) {
385
+ return (0, graph_1.prepopulatePropertyInputs)({
377
386
  id: id,
378
387
  name: 'MeshToonMaterial',
379
388
  position: position,
380
389
  engine: true,
381
- type: EngineNodeType.toon,
390
+ type: engine_1.EngineNodeType.toon,
382
391
  config: {
383
392
  uniforms: uniforms,
384
393
  version: 3,
385
394
  preprocess: true,
386
395
  mangle: false,
387
396
  properties: [
388
- property('Color', 'color', 'rgb', 'uniform_diffuse'),
389
- property('Texture', 'map', 'texture', 'filler_map'),
390
- property('Gradient Map', 'gradientMap', 'texture', 'filler_gradientMap'),
391
- property('Normal Map', 'normalMap', 'texture', 'filler_normalMap'),
392
- property('Normal Scale', 'normalScale', 'vector2'),
393
- property('AO Map', 'aoMap', 'texture', 'filler_aoMap'),
394
- property('AO Intensity', 'aoMapIntensity', 'number', 'filler_aoMapIntensity'),
395
- property('Displacement Map', 'displacementMap', 'texture', 'filler_displacementMap'),
396
- property('Displacement Scale', 'displacementScale', 'number'),
397
- property('Env Map', 'envMap', 'samplerCube'),
397
+ (0, code_nodes_1.property)('Color', 'color', 'rgb', 'uniform_diffuse'),
398
+ (0, code_nodes_1.property)('Texture', 'map', 'texture', 'filler_map'),
399
+ (0, code_nodes_1.property)('Gradient Map', 'gradientMap', 'texture', 'filler_gradientMap'),
400
+ (0, code_nodes_1.property)('Normal Map', 'normalMap', 'texture', 'filler_normalMap'),
401
+ (0, code_nodes_1.property)('Normal Scale', 'normalScale', 'vector2'),
402
+ (0, code_nodes_1.property)('AO Map', 'aoMap', 'texture', 'filler_aoMap'),
403
+ (0, code_nodes_1.property)('AO Intensity', 'aoMapIntensity', 'number', 'filler_aoMapIntensity'),
404
+ (0, code_nodes_1.property)('Displacement Map', 'displacementMap', 'texture', 'filler_displacementMap'),
405
+ (0, code_nodes_1.property)('Displacement Scale', 'displacementScale', 'number'),
406
+ (0, code_nodes_1.property)('Env Map', 'envMap', 'samplerCube'),
398
407
  ],
399
408
  strategies: [
400
- uniformStrategy(),
409
+ (0, strategy_1.uniformStrategy)(),
401
410
  stage === 'fragment'
402
- ? texture2DStrategy()
403
- : namedAttributeStrategy('position'),
411
+ ? (0, strategy_1.texture2DStrategy)()
412
+ : (0, strategy_1.namedAttributeStrategy)('position'),
404
413
  ],
405
414
  },
406
415
  inputs: [],
@@ -416,19 +425,20 @@ export var toonNode = function (id, name, position, uniforms, stage) {
416
425
  stage: stage,
417
426
  });
418
427
  };
419
- export var threngine = {
428
+ exports.toonNode = toonNode;
429
+ exports.threngine = {
420
430
  name: 'three',
421
431
  displayName: 'Three.js',
422
- importers: importers,
432
+ importers: importers_1.default,
423
433
  mergeOptions: {
424
434
  includePrecisions: true,
425
435
  includeVersion: true,
426
436
  },
427
437
  evaluateNode: evaluateNode,
428
438
  constructors: (_a = {},
429
- _a[EngineNodeType.phong] = phongNode,
430
- _a[EngineNodeType.physical] = physicalNode,
431
- _a[EngineNodeType.toon] = toonNode,
439
+ _a[engine_1.EngineNodeType.phong] = exports.phongNode,
440
+ _a[engine_1.EngineNodeType.physical] = exports.physicalNode,
441
+ _a[engine_1.EngineNodeType.toon] = exports.toonNode,
432
442
  _a),
433
443
  // TODO: Get from uniform lib?
434
444
  preserve: new Set([
@@ -504,27 +514,27 @@ export var threngine = {
504
514
  'displacementBias',
505
515
  ]),
506
516
  parsers: (_b = {},
507
- _b[NodeType.SOURCE] = {
517
+ _b[graph_types_1.NodeType.SOURCE] = {
508
518
  manipulateAst: function (engineContext, engine, graph, ast, inputEdges, node, sibling) {
509
519
  var programAst = ast;
510
- var mainName = 'main' || nodeName(node);
520
+ var mainName = 'main' || (0, graph_2.nodeName)(node);
511
521
  // This hinges on the vertex shader calling vec3(p)
512
522
  if (node.stage === 'vertex') {
513
- if (doesLinkThruShader(graph, node)) {
514
- returnGlPositionVec3Right(mainName, programAst);
523
+ if ((0, graph_2.doesLinkThruShader)(graph, node)) {
524
+ (0, ast_1.returnGlPositionVec3Right)(mainName, programAst);
515
525
  }
516
526
  else {
517
- returnGlPosition(mainName, programAst);
527
+ (0, ast_1.returnGlPosition)(mainName, programAst);
518
528
  }
519
529
  }
520
530
  return ast;
521
531
  },
522
532
  },
523
- _b[EngineNodeType.phong] = {
533
+ _b[engine_1.EngineNodeType.phong] = {
524
534
  onBeforeCompile: function (graph, engineContext, node, sibling) { return __awaiter(void 0, void 0, void 0, function () {
525
535
  return __generator(this, function (_a) {
526
536
  cacher(engineContext, graph, node, sibling, function () {
527
- return onBeforeCompileMegaShader(engineContext, new MeshPhongMaterial(__assign({
537
+ return onBeforeCompileMegaShader(engineContext, new three_1.MeshPhongMaterial(__assign({
528
538
  // @ts-ignore
529
539
  isMeshPhongMaterial: true }, threeMaterialProperties(graph, node, sibling))));
530
540
  });
@@ -533,22 +543,22 @@ export var threngine = {
533
543
  }); },
534
544
  manipulateAst: megaShaderMainpulateAst,
535
545
  },
536
- _b[EngineNodeType.physical] = {
546
+ _b[engine_1.EngineNodeType.physical] = {
537
547
  onBeforeCompile: function (graph, engineContext, node, sibling) { return __awaiter(void 0, void 0, void 0, function () {
538
548
  return __generator(this, function (_a) {
539
549
  cacher(engineContext, graph, node, sibling, function () {
540
- return onBeforeCompileMegaShader(engineContext, new MeshPhysicalMaterial(__assign(__assign({}, node.config.hardCodedProperties), threeMaterialProperties(graph, node, sibling))));
550
+ return onBeforeCompileMegaShader(engineContext, new three_1.MeshPhysicalMaterial(__assign(__assign({}, node.config.hardCodedProperties), threeMaterialProperties(graph, node, sibling))));
541
551
  });
542
552
  return [2 /*return*/];
543
553
  });
544
554
  }); },
545
555
  manipulateAst: megaShaderMainpulateAst,
546
556
  },
547
- _b[EngineNodeType.toon] = {
557
+ _b[engine_1.EngineNodeType.toon] = {
548
558
  onBeforeCompile: function (graph, engineContext, node, sibling) { return __awaiter(void 0, void 0, void 0, function () {
549
559
  return __generator(this, function (_a) {
550
560
  cacher(engineContext, graph, node, sibling, function () {
551
- return onBeforeCompileMegaShader(engineContext, new MeshToonMaterial(__assign({ gradientMap: new Texture(),
561
+ return onBeforeCompileMegaShader(engineContext, new three_1.MeshToonMaterial(__assign({ gradientMap: new three_1.Texture(),
552
562
  // @ts-ignore
553
563
  isMeshToonMaterial: true }, threeMaterialProperties(graph, node, sibling))));
554
564
  });
@@ -559,16 +569,16 @@ export var threngine = {
559
569
  },
560
570
  _b),
561
571
  };
562
- export var createMaterial = function (compileResult, ctx) {
572
+ var createMaterial = function (compileResult, ctx) {
563
573
  var engineMaterial = ctx.runtime.engineMaterial;
564
- var finalUniforms = __assign(__assign(__assign(__assign({}, ShaderLib.phong.uniforms), ShaderLib.toon.uniforms), ShaderLib.physical.uniforms), { time: { value: 0 }, cameraPosition: { value: new Vector3(1.0) } });
574
+ var finalUniforms = __assign(__assign(__assign(__assign({}, three_1.ShaderLib.phong.uniforms), three_1.ShaderLib.toon.uniforms), three_1.ShaderLib.physical.uniforms), { time: { value: 0 }, cameraPosition: { value: new three_1.Vector3(1.0) } });
565
575
  // Also the ThreeComponent's sceneConfig properties modify the material
566
576
  var initialProperties = {
567
577
  name: 'ShaderFrog Material',
568
578
  lights: true,
569
579
  uniforms: __assign({}, finalUniforms),
570
580
  // See https://github.com/mrdoob/three.js/pull/26809
571
- glslVersion: GLSL3,
581
+ glslVersion: three_1.GLSL3,
572
582
  vertexShader: compileResult === null || compileResult === void 0 ? void 0 : compileResult.vertexResult.replace('#version 300 es', ''),
573
583
  fragmentShader: compileResult === null || compileResult === void 0 ? void 0 : compileResult.fragmentResult.replace('#version 300 es', ''),
574
584
  };
@@ -596,7 +606,7 @@ export var createMaterial = function (compileResult, ctx) {
596
606
  var _c = __read(_a, 2), key = _c[0], value = _c[1];
597
607
  return (__assign(__assign({}, acc), (_b = {}, _b[key] = value, _b)));
598
608
  }, {});
599
- var material = new RawShaderMaterial(initialProperties);
609
+ var material = new three_1.RawShaderMaterial(initialProperties);
600
610
  // This prevents a deluge of warnings from three on the constructor saying
601
611
  // that each of these properties is not a property of the material
602
612
  Object.entries(additionalProperties).forEach(function (_a) {
@@ -606,3 +616,4 @@ export var createMaterial = function (compileResult, ctx) {
606
616
  });
607
617
  return material;
608
618
  };
619
+ exports.createMaterial = createMaterial;
@@ -1,19 +1,23 @@
1
- import { findAssignmentTo } from '../util/ast';
2
- import { nodeInput } from '../graph/base-node';
3
- import { StrategyType } from '.';
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyAssignmentToStrategy = exports.assignemntToStrategy = void 0;
4
+ var ast_1 = require("../util/ast");
5
+ var base_node_1 = require("../graph/base-node");
6
+ var _1 = require(".");
4
7
  // Constructor
5
- export var assignemntToStrategy = function (assignTo) { return ({
6
- type: StrategyType.ASSIGNMENT_TO,
8
+ var assignemntToStrategy = function (assignTo) { return ({
9
+ type: _1.StrategyType.ASSIGNMENT_TO,
7
10
  config: { assignTo: assignTo },
8
11
  }); };
12
+ exports.assignemntToStrategy = assignemntToStrategy;
9
13
  // Apply the strategy
10
- export var applyAssignmentToStrategy = function (strategy, ast, graphNode, siblingNode) {
11
- var assignNode = findAssignmentTo(ast, strategy.config.assignTo);
14
+ var applyAssignmentToStrategy = function (strategy, ast, graphNode, siblingNode) {
15
+ var assignNode = (0, ast_1.findAssignmentTo)(ast, strategy.config.assignTo);
12
16
  var name = strategy.config.assignTo;
13
17
  return assignNode
14
18
  ? [
15
19
  [
16
- nodeInput(name, "filler_".concat(name), 'filler', undefined, // Data type for what plugs into this filler
20
+ (0, base_node_1.nodeInput)(name, "filler_".concat(name), 'filler', undefined, // Data type for what plugs into this filler
17
21
  ['code', 'data'], false),
18
22
  function (fillerAst) {
19
23
  assignNode.expression.right =
@@ -24,3 +28,4 @@ export var applyAssignmentToStrategy = function (strategy, ast, graphNode, sibli
24
28
  ]
25
29
  : [];
26
30
  };
31
+ exports.applyAssignmentToStrategy = applyAssignmentToStrategy;
@@ -1,17 +1,21 @@
1
- import { findDeclarationOf } from '../util/ast';
2
- import { nodeInput } from '../graph/base-node';
3
- import { StrategyType } from '.';
4
- export var declarationOfStrategy = function (declarationOf) { return ({
5
- type: StrategyType.DECLARATION_OF,
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.constApplyDeclarationOf = exports.declarationOfStrategy = void 0;
4
+ var ast_1 = require("../util/ast");
5
+ var base_node_1 = require("../graph/base-node");
6
+ var _1 = require(".");
7
+ var declarationOfStrategy = function (declarationOf) { return ({
8
+ type: _1.StrategyType.DECLARATION_OF,
6
9
  config: { declarationOf: declarationOf },
7
10
  }); };
8
- export var constApplyDeclarationOf = function (strategy, ast, graphNode, siblingNode) {
9
- var declaration = findDeclarationOf(ast, strategy.config.declarationOf);
11
+ exports.declarationOfStrategy = declarationOfStrategy;
12
+ var constApplyDeclarationOf = function (strategy, ast, graphNode, siblingNode) {
13
+ var declaration = (0, ast_1.findDeclarationOf)(ast, strategy.config.declarationOf);
10
14
  var name = strategy.config.declarationOf;
11
15
  return declaration
12
16
  ? [
13
17
  [
14
- nodeInput(name, "filler_".concat(name), 'filler', undefined, // Data type for what plugs into this filler
18
+ (0, base_node_1.nodeInput)(name, "filler_".concat(name), 'filler', undefined, // Data type for what plugs into this filler
15
19
  ['code', 'data'], false),
16
20
  function (fillerAst) {
17
21
  declaration.initializer = fillerAst;
@@ -21,3 +25,4 @@ export var constApplyDeclarationOf = function (strategy, ast, graphNode, sibling
21
25
  ]
22
26
  : [];
23
27
  };
28
+ exports.constApplyDeclarationOf = constApplyDeclarationOf;
@@ -1,9 +1,13 @@
1
- import { StrategyType } from '.';
2
- export var hardCodeStrategy = function (inputs) { return ({
3
- type: StrategyType.HARD_CODE_INPUTS,
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyHardCodeStrategy = exports.hardCodeStrategy = void 0;
4
+ var _1 = require(".");
5
+ var hardCodeStrategy = function (inputs) { return ({
6
+ type: _1.StrategyType.HARD_CODE_INPUTS,
4
7
  config: { inputs: inputs },
5
8
  }); };
6
- export var applyHardCodeStrategy = function (strategy, ast, graphNode, siblingNode) {
9
+ exports.hardCodeStrategy = hardCodeStrategy;
10
+ var applyHardCodeStrategy = function (strategy, ast, graphNode, siblingNode) {
7
11
  return strategy.config.inputs.map(function (input) {
8
12
  // Broken out into two lines to enforce type checking on the array.
9
13
  var ci = [
@@ -21,3 +25,4 @@ export var applyHardCodeStrategy = function (strategy, ast, graphNode, siblingNo
21
25
  return ci;
22
26
  });
23
27
  };
28
+ exports.applyHardCodeStrategy = applyHardCodeStrategy;
package/strategy/index.js CHANGED
@@ -1,9 +1,25 @@
1
- export * from './hardCode';
2
- export * from './uniform';
3
- export * from './assignemntTo';
4
- export * from './inject';
5
- export * from './declarationOf';
6
- export * from './texture2D';
7
- export * from './namedAttribute';
8
- export * from './variable';
9
- export * from './strategy';
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./hardCode"), exports);
18
+ __exportStar(require("./uniform"), exports);
19
+ __exportStar(require("./assignemntTo"), exports);
20
+ __exportStar(require("./inject"), exports);
21
+ __exportStar(require("./declarationOf"), exports);
22
+ __exportStar(require("./texture2D"), exports);
23
+ __exportStar(require("./namedAttribute"), exports);
24
+ __exportStar(require("./variable"), exports);
25
+ __exportStar(require("./strategy"), exports);