@luma.gl/engine 8.5.13 → 8.5.16

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 (88) hide show
  1. package/dist/dist.js +5882 -5979
  2. package/dist/dist.min.js +1 -1
  3. package/dist/es5/animation/key-frames.js.map +1 -1
  4. package/dist/es5/animation/timeline.js +1 -1
  5. package/dist/es5/animation/timeline.js.map +1 -1
  6. package/dist/es5/bundle.js.map +1 -1
  7. package/dist/es5/geometries/cone-geometry.js +6 -4
  8. package/dist/es5/geometries/cone-geometry.js.map +1 -1
  9. package/dist/es5/geometries/cube-geometry.js +6 -4
  10. package/dist/es5/geometries/cube-geometry.js.map +1 -1
  11. package/dist/es5/geometries/cylinder-geometry.js +6 -4
  12. package/dist/es5/geometries/cylinder-geometry.js.map +1 -1
  13. package/dist/es5/geometries/ico-sphere-geometry.js +6 -4
  14. package/dist/es5/geometries/ico-sphere-geometry.js.map +1 -1
  15. package/dist/es5/geometries/index.js.map +1 -1
  16. package/dist/es5/geometries/plane-geometry.js +6 -4
  17. package/dist/es5/geometries/plane-geometry.js.map +1 -1
  18. package/dist/es5/geometries/sphere-geometry.js +6 -4
  19. package/dist/es5/geometries/sphere-geometry.js.map +1 -1
  20. package/dist/es5/geometries/truncated-cone-geometry.js +6 -4
  21. package/dist/es5/geometries/truncated-cone-geometry.js.map +1 -1
  22. package/dist/es5/geometry/geometry-utils.js.map +1 -1
  23. package/dist/es5/geometry/geometry.js +10 -12
  24. package/dist/es5/geometry/geometry.js.map +1 -1
  25. package/dist/es5/index.js +24 -24
  26. package/dist/es5/index.js.map +1 -1
  27. package/dist/es5/lib/animation-loop.d.ts +1 -1
  28. package/dist/es5/lib/animation-loop.js +2 -2
  29. package/dist/es5/lib/animation-loop.js.map +1 -1
  30. package/dist/es5/lib/model-utils.js +2 -2
  31. package/dist/es5/lib/model-utils.js.map +1 -1
  32. package/dist/es5/lib/model.js +1 -1
  33. package/dist/es5/lib/model.js.map +1 -1
  34. package/dist/es5/lib/program-manager.js +8 -10
  35. package/dist/es5/lib/program-manager.js.map +1 -1
  36. package/dist/es5/transform/buffer-transform.js +1 -1
  37. package/dist/es5/transform/buffer-transform.js.map +1 -1
  38. package/dist/es5/transform/texture-transform.js.map +1 -1
  39. package/dist/es5/transform/transform-shader-utils.js +1 -1
  40. package/dist/es5/transform/transform-shader-utils.js.map +1 -1
  41. package/dist/es5/transform/transform.js +6 -8
  42. package/dist/es5/transform/transform.js.map +1 -1
  43. package/dist/es5/utils/clip-space.js +4 -2
  44. package/dist/es5/utils/clip-space.js.map +1 -1
  45. package/dist/esm/animation/key-frames.js.map +1 -1
  46. package/dist/esm/animation/timeline.js.map +1 -1
  47. package/dist/esm/bundle.js.map +1 -1
  48. package/dist/esm/geometries/cone-geometry.js +2 -1
  49. package/dist/esm/geometries/cone-geometry.js.map +1 -1
  50. package/dist/esm/geometries/cube-geometry.js +2 -1
  51. package/dist/esm/geometries/cube-geometry.js.map +1 -1
  52. package/dist/esm/geometries/cylinder-geometry.js +2 -1
  53. package/dist/esm/geometries/cylinder-geometry.js.map +1 -1
  54. package/dist/esm/geometries/ico-sphere-geometry.js +3 -2
  55. package/dist/esm/geometries/ico-sphere-geometry.js.map +1 -1
  56. package/dist/esm/geometries/index.js.map +1 -1
  57. package/dist/esm/geometries/plane-geometry.js +6 -5
  58. package/dist/esm/geometries/plane-geometry.js.map +1 -1
  59. package/dist/esm/geometries/sphere-geometry.js +2 -1
  60. package/dist/esm/geometries/sphere-geometry.js.map +1 -1
  61. package/dist/esm/geometries/truncated-cone-geometry.js +2 -1
  62. package/dist/esm/geometries/truncated-cone-geometry.js.map +1 -1
  63. package/dist/esm/geometry/geometry-utils.js.map +1 -1
  64. package/dist/esm/geometry/geometry.js +4 -3
  65. package/dist/esm/geometry/geometry.js.map +1 -1
  66. package/dist/esm/index.js.map +1 -1
  67. package/dist/esm/lib/animation-loop.d.ts +1 -1
  68. package/dist/esm/lib/animation-loop.js +19 -15
  69. package/dist/esm/lib/animation-loop.js.map +1 -1
  70. package/dist/esm/lib/model-utils.js +1 -1
  71. package/dist/esm/lib/model-utils.js.map +1 -1
  72. package/dist/esm/lib/model.js +23 -13
  73. package/dist/esm/lib/model.js.map +1 -1
  74. package/dist/esm/lib/program-manager.js +5 -3
  75. package/dist/esm/lib/program-manager.js.map +1 -1
  76. package/dist/esm/transform/buffer-transform.js +20 -10
  77. package/dist/esm/transform/buffer-transform.js.map +1 -1
  78. package/dist/esm/transform/texture-transform.js +21 -11
  79. package/dist/esm/transform/texture-transform.js.map +1 -1
  80. package/dist/esm/transform/transform-shader-utils.js +23 -25
  81. package/dist/esm/transform/transform-shader-utils.js.map +1 -1
  82. package/dist/esm/transform/transform.js +13 -6
  83. package/dist/esm/transform/transform.js.map +1 -1
  84. package/dist/esm/utils/clip-space.js +1 -16
  85. package/dist/esm/utils/clip-space.js.map +1 -1
  86. package/package.json +8 -7
  87. package/src/lib/animation-loop.d.ts +1 -1
  88. package/src/lib/model.js +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/program-manager.js"],"names":["assembleShaders","Program","ProgramManager","getDefaultProgramManager","gl","luma","defaultProgramManager","constructor","_programCache","_getUniforms","_registeredModules","_hookFunctions","_defaultModules","_hashes","_hashCounter","stateHash","_useCounts","addDefaultModule","module","find","m","name","push","removeDefaultModule","moduleName","filter","addShaderHook","hook","opts","Object","assign","get","props","vs","fs","defines","inject","varyings","bufferMode","transpileToGLSL100","modules","_getModuleList","vsHash","_getHash","fsHash","moduleHashes","map","sort","varyingHashes","v","defineKeys","keys","injectKeys","defineHashes","injectHashes","key","hash","join","assembled","hookFunctions","getUniforms","x","program","release","delete","undefined","appModules","Array","length","seen","count","i","len"],"mappings":"AAAA,SAAQA,eAAR,QAA8B,sBAA9B;AACA,SAAQC,OAAR,QAAsB,gBAAtB;AAEA,eAAe,MAAMC,cAAN,CAAqB;AAClC,SAAOC,wBAAP,CAAgCC,EAAhC,EAAoC;AAClC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GAAG,CAAZ;;AAEA,SAAK,IAAIC,CAAC,GAAG,CAAR,EAAWC,GAAG,GAAG,KAAK5D,eAAL,CAAqBwD,MAA3C,EAAmDG,CAAC,GAAGC,GAAvD,EAA4D,EAAED,CAA9D,EAAiE;AAC/D,YAAMrD,MAAM,GAAG,KAAKN,eAAL,CAAqB2D,CAArB,CAAf;AACA,YAAMlD,IAAI,GAAGH,MAAM,CAACG,IAApB;AACAmB,MAAAA,OAAO,CAAC8B,KAAK,EAAN,CAAP,GAAmBpD,MAAnB;AACAmD,MAAAA,IAAI,CAAChD,IAAD,CAAJ,GAAa,IAAb;AACD;;AAED,SAAK,IAAIkD,CAAC,GAAG,CAAR,EAAWC,GAAG,GAAGN,UAAU,CAACE,MAAjC,EAAyCG,CAAC,GAAGC,GAA7C,EAAkD,EAAED,CAApD,EAAuD;AACrD,YAAMrD,MAAM,GAAGgD,UAAU,CAACK,CAAD,CAAzB;AACA,YAAMlD,IAAI,GAAGH,MAAM,CAACG,IAApB;;AACA,UAAI,CAACgD,IAAI,CAAChD,IAAD,CAAT,EAAiB;AACfmB,QAAAA,OAAO,CAAC8B,KAAK,EAAN,CAAP,GAAmBpD,MAAnB;AACAmD,QAAAA,IAAI,CAAChD,IAAD,CAAJ,GAAa,IAAb;AACD;AACF;;AAEDmB,IAAAA,OAAO,CAAC4B,MAAR,GAAiBE,KAAjB;AAEA,WAAO9B,OAAP;AACD;;AAnKiC","sourcesContent":["import {assembleShaders} from '@luma.gl/shadertools';\nimport {Program} from '@luma.gl/webgl';\n\nexport default class ProgramManager {\n static getDefaultProgramManager(gl) {\n gl.luma = gl.luma || {};\n gl.luma.defaultProgramManager = gl.luma.defaultProgramManager || new ProgramManager(gl);\n\n return gl.luma.defaultProgramManager;\n }\n\n constructor(gl) {\n this.gl = gl;\n\n this._programCache = {};\n this._getUniforms = {};\n this._registeredModules = {}; // TODO: Remove? This isn't used anywhere in luma.gl\n this._hookFunctions = [];\n this._defaultModules = [];\n\n this._hashes = {};\n this._hashCounter = 0;\n this.stateHash = 0; // Used change hashing if hooks are modified\n this._useCounts = {};\n }\n\n addDefaultModule(module) {\n if (!this._defaultModules.find(m => m.name === module.name)) {\n this._defaultModules.push(module);\n }\n\n this.stateHash++;\n }\n\n removeDefaultModule(module) {\n const moduleName = typeof module === 'string' ? module : module.name;\n this._defaultModules = this._defaultModules.filter(m => m.name !== moduleName);\n this.stateHash++;\n }\n\n addShaderHook(hook, opts) {\n if (opts) {\n hook = Object.assign(opts, {hook});\n }\n\n this._hookFunctions.push(hook);\n\n this.stateHash++;\n }\n\n get(props = {}) {\n const {\n vs = '',\n fs = '',\n defines = {},\n inject = {},\n varyings = [],\n bufferMode = 0x8c8d,\n transpileToGLSL100 = false\n } = props; // varyings/bufferMode for xform feedback, 0x8c8d = SEPARATE_ATTRIBS\n\n const modules = this._getModuleList(props.modules); // Combine with default modules\n\n const vsHash = this._getHash(vs);\n const fsHash = this._getHash(fs);\n const moduleHashes = modules.map(m => this._getHash(m.name)).sort();\n const varyingHashes = varyings.map(v => this._getHash(v));\n\n const defineKeys = Object.keys(defines).sort();\n const injectKeys = Object.keys(inject).sort();\n const defineHashes = [];\n const injectHashes = [];\n\n for (const key of defineKeys) {\n defineHashes.push(this._getHash(key));\n defineHashes.push(this._getHash(defines[key]));\n }\n\n for (const key of injectKeys) {\n injectHashes.push(this._getHash(key));\n injectHashes.push(this._getHash(inject[key]));\n }\n\n const hash = `${vsHash}/${fsHash}D${defineHashes.join('/')}M${moduleHashes.join(\n '/'\n )}I${injectHashes.join('/')}V${varyingHashes.join('/')}H${this.stateHash}B${bufferMode}${\n transpileToGLSL100 ? 'T' : ''\n }`;\n\n if (!this._programCache[hash]) {\n const assembled = assembleShaders(this.gl, {\n vs,\n fs,\n modules,\n inject,\n defines,\n hookFunctions: this._hookFunctions,\n transpileToGLSL100\n });\n\n this._programCache[hash] = new Program(this.gl, {\n hash,\n vs: assembled.vs,\n fs: assembled.fs,\n varyings,\n bufferMode\n });\n\n this._getUniforms[hash] = assembled.getUniforms || (x => {});\n this._useCounts[hash] = 0;\n }\n\n this._useCounts[hash]++;\n\n return this._programCache[hash];\n }\n\n getUniforms(program) {\n return this._getUniforms[program.hash] || null;\n }\n\n release(program) {\n const hash = program.hash;\n this._useCounts[hash]--;\n\n if (this._useCounts[hash] === 0) {\n this._programCache[hash].delete();\n delete this._programCache[hash];\n delete this._getUniforms[hash];\n delete this._useCounts[hash];\n }\n }\n\n _getHash(key) {\n if (this._hashes[key] === undefined) {\n this._hashes[key] = this._hashCounter++;\n }\n\n return this._hashes[key];\n }\n\n // Dedup and combine with default modules\n _getModuleList(appModules = []) {\n const modules = new Array(this._defaultModules.length + appModules.length);\n const seen = {};\n let count = 0;\n\n for (let i = 0, len = this._defaultModules.length; i < len; ++i) {\n const module = this._defaultModules[i];\n const name = module.name;\n modules[count++] = module;\n seen[name] = true;\n }\n\n for (let i = 0, len = appModules.length; i < len; ++i) {\n const module = appModules[i];\n const name = module.name;\n if (!seen[name]) {\n modules[count++] = module;\n seen[name] = true;\n }\n }\n\n modules.length = count;\n\n return modules;\n }\n}\n"],"file":"program-manager.js"}
1
+ {"version":3,"file":"program-manager.js","names":["assembleShaders","Program","ProgramManager","getDefaultProgramManager","gl","luma","defaultProgramManager","constructor","_programCache","_getUniforms","_registeredModules","_hookFunctions","_defaultModules","_hashes","_hashCounter","stateHash","_useCounts","addDefaultModule","module","find","m","name","push","removeDefaultModule","moduleName","filter","addShaderHook","hook","opts","Object","assign","get","props","vs","fs","defines","inject","varyings","bufferMode","transpileToGLSL100","modules","_getModuleList","vsHash","_getHash","fsHash","moduleHashes","map","sort","varyingHashes","v","defineKeys","keys","injectKeys","defineHashes","injectHashes","key","hash","join","assembled","hookFunctions","getUniforms","x","program","release","delete","undefined","appModules","Array","length","seen","count","i","len"],"sources":["../../../src/lib/program-manager.js"],"sourcesContent":["import {assembleShaders} from '@luma.gl/shadertools';\nimport {Program} from '@luma.gl/webgl';\n\nexport default class ProgramManager {\n static getDefaultProgramManager(gl) {\n gl.luma = gl.luma || {};\n gl.luma.defaultProgramManager = gl.luma.defaultProgramManager || new ProgramManager(gl);\n\n return gl.luma.defaultProgramManager;\n }\n\n constructor(gl) {\n this.gl = gl;\n\n this._programCache = {};\n this._getUniforms = {};\n this._registeredModules = {}; // TODO: Remove? This isn't used anywhere in luma.gl\n this._hookFunctions = [];\n this._defaultModules = [];\n\n this._hashes = {};\n this._hashCounter = 0;\n this.stateHash = 0; // Used change hashing if hooks are modified\n this._useCounts = {};\n }\n\n addDefaultModule(module) {\n if (!this._defaultModules.find(m => m.name === module.name)) {\n this._defaultModules.push(module);\n }\n\n this.stateHash++;\n }\n\n removeDefaultModule(module) {\n const moduleName = typeof module === 'string' ? module : module.name;\n this._defaultModules = this._defaultModules.filter(m => m.name !== moduleName);\n this.stateHash++;\n }\n\n addShaderHook(hook, opts) {\n if (opts) {\n hook = Object.assign(opts, {hook});\n }\n\n this._hookFunctions.push(hook);\n\n this.stateHash++;\n }\n\n get(props = {}) {\n const {\n vs = '',\n fs = '',\n defines = {},\n inject = {},\n varyings = [],\n bufferMode = 0x8c8d,\n transpileToGLSL100 = false\n } = props; // varyings/bufferMode for xform feedback, 0x8c8d = SEPARATE_ATTRIBS\n\n const modules = this._getModuleList(props.modules); // Combine with default modules\n\n const vsHash = this._getHash(vs);\n const fsHash = this._getHash(fs);\n const moduleHashes = modules.map(m => this._getHash(m.name)).sort();\n const varyingHashes = varyings.map(v => this._getHash(v));\n\n const defineKeys = Object.keys(defines).sort();\n const injectKeys = Object.keys(inject).sort();\n const defineHashes = [];\n const injectHashes = [];\n\n for (const key of defineKeys) {\n defineHashes.push(this._getHash(key));\n defineHashes.push(this._getHash(defines[key]));\n }\n\n for (const key of injectKeys) {\n injectHashes.push(this._getHash(key));\n injectHashes.push(this._getHash(inject[key]));\n }\n\n const hash = `${vsHash}/${fsHash}D${defineHashes.join('/')}M${moduleHashes.join(\n '/'\n )}I${injectHashes.join('/')}V${varyingHashes.join('/')}H${this.stateHash}B${bufferMode}${\n transpileToGLSL100 ? 'T' : ''\n }`;\n\n if (!this._programCache[hash]) {\n const assembled = assembleShaders(this.gl, {\n vs,\n fs,\n modules,\n inject,\n defines,\n hookFunctions: this._hookFunctions,\n transpileToGLSL100\n });\n\n this._programCache[hash] = new Program(this.gl, {\n hash,\n vs: assembled.vs,\n fs: assembled.fs,\n varyings,\n bufferMode\n });\n\n this._getUniforms[hash] = assembled.getUniforms || (x => {});\n this._useCounts[hash] = 0;\n }\n\n this._useCounts[hash]++;\n\n return this._programCache[hash];\n }\n\n getUniforms(program) {\n return this._getUniforms[program.hash] || null;\n }\n\n release(program) {\n const hash = program.hash;\n this._useCounts[hash]--;\n\n if (this._useCounts[hash] === 0) {\n this._programCache[hash].delete();\n delete this._programCache[hash];\n delete this._getUniforms[hash];\n delete this._useCounts[hash];\n }\n }\n\n _getHash(key) {\n if (this._hashes[key] === undefined) {\n this._hashes[key] = this._hashCounter++;\n }\n\n return this._hashes[key];\n }\n\n // Dedup and combine with default modules\n _getModuleList(appModules = []) {\n const modules = new Array(this._defaultModules.length + appModules.length);\n const seen = {};\n let count = 0;\n\n for (let i = 0, len = this._defaultModules.length; i < len; ++i) {\n const module = this._defaultModules[i];\n const name = module.name;\n modules[count++] = module;\n seen[name] = true;\n }\n\n for (let i = 0, len = appModules.length; i < len; ++i) {\n const module = appModules[i];\n const name = module.name;\n if (!seen[name]) {\n modules[count++] = module;\n seen[name] = true;\n }\n }\n\n modules.length = count;\n\n return modules;\n }\n}\n"],"mappings":"AAAA,SAAQA,eAAR,QAA8B,sBAA9B;AACA,SAAQC,OAAR,QAAsB,gBAAtB;AAEA,eAAe,MAAMC,cAAN,CAAqB;EACH,OAAxBC,wBAAwB,CAACC,EAAD,EAAK;IAClCA,EAAE,CAACC,IAAH,GAAUD,EAAE,CAACC,IAAH,IAAW,EAArB;IACAD,EAAE,CAACC,IAAH,CAAQC,qBAAR,GAAgCF,EAAE,CAACC,IAAH,CAAQC,qBAAR,I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ED,KAAK,IAAIkD,CAAC,GAAG,CAAR,EAAWC,GAAG,GAAGN,UAAU,CAACE,MAAjC,EAAyCG,CAAC,GAAGC,GAA7C,EAAkD,EAAED,CAApD,EAAuD;MACrD,MAAMrD,MAAM,GAAGgD,UAAU,CAACK,CAAD,CAAzB;MACA,MAAMlD,IAAI,GAAGH,MAAM,CAACG,IAApB;;MACA,IAAI,CAACgD,IAAI,CAAChD,IAAD,CAAT,EAAiB;QACfmB,OAAO,CAAC8B,KAAK,EAAN,CAAP,GAAmBpD,MAAnB;QACAmD,IAAI,CAAChD,IAAD,CAAJ,GAAa,IAAb;MACD;IACF;;IAEDmB,OAAO,CAAC4B,MAAR,GAAiBE,KAAjB;IAEA,OAAO9B,OAAP;EACD;;AAnKiC"}
@@ -2,7 +2,8 @@ import { isWebGL2 } from '@luma.gl/gltools';
2
2
  import { Buffer, TransformFeedback } from '@luma.gl/webgl';
3
3
  import { assert } from '@luma.gl/webgl';
4
4
  export default class BufferTransform {
5
- constructor(gl, props = {}) {
5
+ constructor(gl) {
6
+ let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6
7
  this.gl = gl;
7
8
  this.currentIndex = 0;
8
9
  this.feedbackMap = {};
@@ -21,7 +22,8 @@ export default class BufferTransform {
21
22
  }
22
23
  }
23
24
 
24
- updateModelProps(props = {}) {
25
+ updateModelProps() {
26
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
25
27
  const {
26
28
  varyings
27
29
  } = this;
@@ -35,7 +37,8 @@ export default class BufferTransform {
35
37
  return props;
36
38
  }
37
39
 
38
- getDrawOptions(opts = {}) {
40
+ getDrawOptions() {
41
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
39
42
  const binding = this.bindings[this.currentIndex];
40
43
  const {
41
44
  sourceBuffers,
@@ -57,7 +60,9 @@ export default class BufferTransform {
57
60
  return false;
58
61
  }
59
62
 
60
- update(opts = {}) {
63
+ update() {
64
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
65
+
61
66
  this._setupBuffers(opts);
62
67
  }
63
68
 
@@ -74,7 +79,8 @@ export default class BufferTransform {
74
79
  return bufferOrParams instanceof Buffer ? bufferOrParams : bufferOrParams.buffer;
75
80
  }
76
81
 
77
- getData(options = {}) {
82
+ getData() {
83
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
78
84
  const {
79
85
  varyingName
80
86
  } = options;
@@ -93,7 +99,9 @@ export default class BufferTransform {
93
99
  }
94
100
  }
95
101
 
96
- _initialize(props = {}) {
102
+ _initialize() {
103
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
104
+
97
105
  this._setupBuffers(props);
98
106
 
99
107
  this.varyings = props.varyings || Object.keys(this.bindings[this.currentIndex].feedbackBuffers);
@@ -146,7 +154,8 @@ export default class BufferTransform {
146
154
  return feedbackBuffers;
147
155
  }
148
156
 
149
- _setupBuffers(props = {}) {
157
+ _setupBuffers() {
158
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
150
159
  const {
151
160
  sourceBuffers = null
152
161
  } = props;
@@ -160,9 +169,10 @@ export default class BufferTransform {
160
169
  });
161
170
  }
162
171
 
163
- _setupTransformFeedback(binding, {
164
- model
165
- }) {
172
+ _setupTransformFeedback(binding, _ref) {
173
+ let {
174
+ model
175
+ } = _ref;
166
176
  const {
167
177
  program
168
178
  } = model;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/transform/buffer-transform.js"],"names":["isWebGL2","Buffer","TransformFeedback","assert","BufferTransform","constructor","gl","props","currentIndex","feedbackMap","varyings","bindings","resources","_initialize","Object","seal","setupResources","opts","binding","_setupTransformFeedback","updateModelProps","length","assign","getDrawOptions","sourceBuffers","transformFeedback","attributes","swap","_getNextIndex","update","_setupBuffers","getBuffer","varyingName","feedbackBuffers","bufferOrParams","buffer","getData","options","delete","name","keys","_getFeedbackBuffers","sourceName","feedbackName","bufferName","bufferOrRef","sourceBuffer","byteLength","usage","accessor","_createNewBuffer","_updateBindings","model","program","buffers","_updateBinding","_swapBuffers","nextIndex","setBuffers","srcName","dstName"],"mappings":"AAAA,SAAQA,QAAR,QAAuB,kBAAvB;AACA,SAAQC,MAAR,EAAgBC,iBAAhB,QAAwC,gBAAxC;AACA,SAAQC,MAAR,QAAqB,gBAArB;AAEA,eAAe,MAAMC,eAAN,CAAsB;AACnCC,EAAAA,WAAW,CAACC,EAAD,EAAKC,KAAK,GAAG,EAAb,EAAiB;AAC1B,SAAKD,EAAL,GAAUA,EAAV;AACA,SAAKE,YAAL,GAAoB,CAApB;AACA,SAAKC,WAAL,GAAmB,EAAnB;AACA,SAAKC,QAAL,GAAgB,IAAhB;AACA,SAAKC,QAAL,GAAgB,EAAhB;AAEA,SAAKC,SAAL,GAAiB,EAAjB;;AAEA,SAAKC,WAAL,CAAiBN,KAAjB;;AACAO,IAAAA,MAAM,CAACC,IAAP,CAAY,IAAZ;AACD;;AAEDC,EAAAA,cAAc,CAACC,IAAD,EAAO;AACnB,SAAK,MAAMC,OAAX,IAAsB,KAAKP,QAA3B,EAAqC;AACnC,WAAKQ,uBAAL,CAA6BD,OAA7B,EAAsCD,IAAtC;AACD;AACF;;AAEDG,EAAAA,gBAAgB,CAACb,KAAK,GAAG,EAAT,EAAa;AAC3B,UAAM;AAACG,MAAAA;AAAD,QAAa,IAAnB;;AACA,QAAIA,QAAQ,CAACW,MAAT,GAAkB,CAAtB,EAAyB;AACvBd,MAAAA,KAAK,GAAGO,MAAM,CAACQ,MAAP,CAAc,EAAd,EAAkBf,KAAlB,EAAyB;AAACG,QAAAA;AAAD,OAAzB,CAAR;AACD;;AACD,WAAOH,KAAP;AACD;;AAEDgB,EAAAA,cAAc,CAACN,IAAI,GAAG,EAAR,EAAY;AACxB,UAAMC,OAAO,GAAG,KAAKP,QAAL,CAAc,KAAKH,YAAnB,CAAhB;AACA,UAAM;AAACgB,MAAAA,aAAD;AAAgBC,MAAAA;AAAhB,QAAqCP,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AACmC,OAAD,CAAb,GAAyB1C,IAAI,CAACgB,eAAL,CAAqB2B,OAArB,CAAzB;AACA3B,MAAAA,eAAe,CAAC2B,OAAD,CAAf,GAA2B3C,IAAI,CAACO,aAAL,CAAmBmC,OAAnB,CAA3B;AAGAxD,MAAAA,MAAM,CAAC8B,eAAe,CAAC2B,OAAD,CAAf,YAAoC3D,MAArC,CAAN;AACD;;AACD,WAAO;AAACuB,MAAAA,aAAD;AAAgBS,MAAAA;AAAhB,KAAP;AACD;;AAGDiB,EAAAA,gBAAgB,CAACX,IAAD,EAAOtB,IAAP,EAAa;AAC3B,UAAMkB,MAAM,GAAG,IAAIlC,MAAJ,CAAW,KAAKK,EAAhB,EAAoBW,IAApB,CAAf;;AACA,QAAI,KAAKL,SAAL,CAAe2B,IAAf,CAAJ,EAA0B;AACxB,WAAK3B,SAAL,CAAe2B,IAAf,EAAqBD,MAArB;AACD;;AACD,SAAK1B,SAAL,CAAe2B,IAAf,IAAuBJ,MAAvB;AACA,WAAOA,MAAP;AACD;;AAEDP,EAAAA,aAAa,GAAG;AACd,WAAO,CAAC,KAAKpB,YAAL,GAAoB,CAArB,IAA0B,CAAjC;AACD;;AAjMkC","sourcesContent":["import {isWebGL2} from '@luma.gl/gltools';\nimport {Buffer, TransformFeedback} from '@luma.gl/webgl';\nimport {assert} from '@luma.gl/webgl';\n\nexport default class BufferTransform {\n constructor(gl, props = {}) {\n this.gl = gl;\n this.currentIndex = 0;\n this.feedbackMap = {};\n this.varyings = null; // varyings array\n this.bindings = []; // each element is an object : {sourceBuffers, feedbackBuffers, transformFeedback}\n\n this.resources = {}; // resources to be deleted\n\n this._initialize(props);\n Object.seal(this);\n }\n\n setupResources(opts) {\n for (const binding of this.bindings) {\n this._setupTransformFeedback(binding, opts);\n }\n }\n\n updateModelProps(props = {}) {\n const {varyings} = this;\n if (varyings.length > 0) {\n props = Object.assign({}, props, {varyings});\n }\n return props;\n }\n\n getDrawOptions(opts = {}) {\n const binding = this.bindings[this.currentIndex];\n const {sourceBuffers, transformFeedback} = binding;\n const attributes = Object.assign({}, sourceBuffers, opts.attributes);\n\n return {attributes, transformFeedback};\n }\n\n swap() {\n if (this.feedbackMap) {\n this.currentIndex = this._getNextIndex();\n return true;\n }\n return false;\n }\n\n // update source and/or feedbackBuffers\n update(opts = {}) {\n this._setupBuffers(opts);\n }\n\n // returns current feedbackBuffer of given name\n getBuffer(varyingName) {\n const {feedbackBuffers} = this.bindings[this.currentIndex];\n const bufferOrParams = varyingName ? feedbackBuffers[varyingName] : null;\n if (!bufferOrParams) {\n return null;\n }\n return bufferOrParams instanceof Buffer ? bufferOrParams : bufferOrParams.buffer;\n }\n\n getData(options = {}) {\n const {varyingName} = options;\n const buffer = this.getBuffer(varyingName);\n if (buffer) {\n return buffer.getData();\n }\n return null;\n }\n\n // Delete owned resources.\n delete() {\n for (const name in this.resources) {\n this.resources[name].delete();\n }\n }\n\n // Private\n\n _initialize(props = {}) {\n this._setupBuffers(props);\n this.varyings = props.varyings || Object.keys(this.bindings[this.currentIndex].feedbackBuffers);\n if (this.varyings.length > 0) {\n // if writting to buffers make sure it is WebGL2\n assert(isWebGL2(this.gl));\n }\n }\n\n // auto create feedback buffers if requested\n _getFeedbackBuffers(props) {\n const {sourceBuffers = {}} = props;\n const feedbackBuffers = {};\n if (this.bindings[this.currentIndex]) {\n // this gurantees a partial feedback buffer set doesn't update\n // previously set buffers during auto creation mode.\n Object.assign(feedbackBuffers, this.bindings[this.currentIndex].feedbackBuffers);\n }\n if (this.feedbackMap) {\n // feedbackMap is defined as sourceBuffer as key and feedbackBuffer name as object\n for (const sourceName in this.feedbackMap) {\n const feedbackName = this.feedbackMap[sourceName];\n if (sourceName in sourceBuffers) {\n feedbackBuffers[feedbackName] = sourceName;\n }\n }\n }\n Object.assign(feedbackBuffers, props.feedbackBuffers);\n for (const bufferName in feedbackBuffers) {\n const bufferOrRef = feedbackBuffers[bufferName];\n if (typeof bufferOrRef === 'string') {\n // Create new buffer with same layout and settings as source buffer\n const sourceBuffer = sourceBuffers[bufferOrRef];\n const {byteLength, usage, accessor} = sourceBuffer;\n feedbackBuffers[bufferName] = this._createNewBuffer(bufferName, {\n byteLength,\n usage,\n accessor\n });\n }\n }\n\n return feedbackBuffers;\n }\n\n _setupBuffers(props = {}) {\n const {sourceBuffers = null} = props;\n Object.assign(this.feedbackMap, props.feedbackMap);\n const feedbackBuffers = this._getFeedbackBuffers(props);\n this._updateBindings({sourceBuffers, feedbackBuffers});\n }\n\n _setupTransformFeedback(binding, {model}) {\n const {program} = model;\n binding.transformFeedback = new TransformFeedback(this.gl, {\n program,\n buffers: binding.feedbackBuffers\n });\n }\n\n _updateBindings(opts) {\n this.bindings[this.currentIndex] = this._updateBinding(this.bindings[this.currentIndex], opts);\n if (this.feedbackMap) {\n const {sourceBuffers, feedbackBuffers} = this._swapBuffers(this.bindings[this.currentIndex]);\n const nextIndex = this._getNextIndex();\n this.bindings[nextIndex] = this._updateBinding(this.bindings[nextIndex], {\n sourceBuffers,\n feedbackBuffers\n });\n }\n }\n\n _updateBinding(binding, opts) {\n if (!binding) {\n return {\n sourceBuffers: Object.assign({}, opts.sourceBuffers),\n feedbackBuffers: Object.assign({}, opts.feedbackBuffers)\n };\n }\n Object.assign(binding.sourceBuffers, opts.sourceBuffers);\n Object.assign(binding.feedbackBuffers, opts.feedbackBuffers);\n if (binding.transformFeedback) {\n binding.transformFeedback.setBuffers(binding.feedbackBuffers);\n }\n return binding;\n }\n\n _swapBuffers(opts) {\n if (!this.feedbackMap) {\n return null;\n }\n const sourceBuffers = Object.assign({}, opts.sourceBuffers);\n const feedbackBuffers = Object.assign({}, opts.feedbackBuffers);\n for (const srcName in this.feedbackMap) {\n const dstName = this.feedbackMap[srcName];\n sourceBuffers[srcName] = opts.feedbackBuffers[dstName];\n feedbackBuffers[dstName] = opts.sourceBuffers[srcName];\n\n // make sure the new destination buffer is a Buffer object\n assert(feedbackBuffers[dstName] instanceof Buffer);\n }\n return {sourceBuffers, feedbackBuffers};\n }\n\n // Create a buffer and add to list of buffers to be deleted.\n _createNewBuffer(name, opts) {\n const buffer = new Buffer(this.gl, opts);\n if (this.resources[name]) {\n this.resources[name].delete();\n }\n this.resources[name] = buffer;\n return buffer;\n }\n\n _getNextIndex() {\n return (this.currentIndex + 1) % 2;\n }\n}\n"],"file":"buffer-transform.js"}
1
+ {"version":3,"file":"buffer-transform.js","names":["isWebGL2","Buffer","TransformFeedback","assert","BufferTransform","constructor","gl","props","currentIndex","feedbackMap","varyings","bindings","resources","_initialize","Object","seal","setupResources","opts","binding","_setupTransformFeedback","updateModelProps","length","assign","getDrawOptions","sourceBuffers","transformFeedback","attributes","swap","_getNextIndex","update","_setupBuffers","getBuffer","varyingName","feedbackBuffers","bufferOrParams","buffer","getData","options","delete","name","keys","_getFeedbackBuffers","sourceName","feedbackName","bufferName","bufferOrRef","sourceBuffer","byteLength","usage","accessor","_createNewBuffer","_updateBindings","model","program","buffers","_updateBinding","_swapBuffers","nextIndex","setBuffers","srcName","dstName"],"sources":["../../../src/transform/buffer-transform.js"],"sourcesContent":["import {isWebGL2} from '@luma.gl/gltools';\nimport {Buffer, TransformFeedback} from '@luma.gl/webgl';\nimport {assert} from '@luma.gl/webgl';\n\nexport default class BufferTransform {\n constructor(gl, props = {}) {\n this.gl = gl;\n this.currentIndex = 0;\n this.feedbackMap = {};\n this.varyings = null; // varyings array\n this.bindings = []; // each element is an object : {sourceBuffers, feedbackBuffers, transformFeedback}\n\n this.resources = {}; // resources to be deleted\n\n this._initialize(props);\n Object.seal(this);\n }\n\n setupResources(opts) {\n for (const binding of this.bindings) {\n this._setupTransformFeedback(binding, opts);\n }\n }\n\n updateModelProps(props = {}) {\n const {varyings} = this;\n if (varyings.length > 0) {\n props = Object.assign({}, props, {varyings});\n }\n return props;\n }\n\n getDrawOptions(opts = {}) {\n const binding = this.bindings[this.currentIndex];\n const {sourceBuffers, transformFeedback} = binding;\n const attributes = Object.assign({}, sourceBuffers, opts.attributes);\n\n return {attributes, transformFeedback};\n }\n\n swap() {\n if (this.feedbackMap) {\n this.currentIndex = this._getNextIndex();\n return true;\n }\n return false;\n }\n\n // update source and/or feedbackBuffers\n update(opts = {}) {\n this._setupBuffers(opts);\n }\n\n // returns current feedbackBuffer of given name\n getBuffer(varyingName) {\n const {feedbackBuffers} = this.bindings[this.currentIndex];\n const bufferOrParams = varyingName ? feedbackBuffers[varyingName] : null;\n if (!bufferOrParams) {\n return null;\n }\n return bufferOrParams instanceof Buffer ? bufferOrParams : bufferOrParams.buffer;\n }\n\n getData(options = {}) {\n const {varyingName} = options;\n const buffer = this.getBuffer(varyingName);\n if (buffer) {\n return buffer.getData();\n }\n return null;\n }\n\n // Delete owned resources.\n delete() {\n for (const name in this.resources) {\n this.resources[name].delete();\n }\n }\n\n // Private\n\n _initialize(props = {}) {\n this._setupBuffers(props);\n this.varyings = props.varyings || Object.keys(this.bindings[this.currentIndex].feedbackBuffers);\n if (this.varyings.length > 0) {\n // if writting to buffers make sure it is WebGL2\n assert(isWebGL2(this.gl));\n }\n }\n\n // auto create feedback buffers if requested\n _getFeedbackBuffers(props) {\n const {sourceBuffers = {}} = props;\n const feedbackBuffers = {};\n if (this.bindings[this.currentIndex]) {\n // this gurantees a partial feedback buffer set doesn't update\n // previously set buffers during auto creation mode.\n Object.assign(feedbackBuffers, this.bindings[this.currentIndex].feedbackBuffers);\n }\n if (this.feedbackMap) {\n // feedbackMap is defined as sourceBuffer as key and feedbackBuffer name as object\n for (const sourceName in this.feedbackMap) {\n const feedbackName = this.feedbackMap[sourceName];\n if (sourceName in sourceBuffers) {\n feedbackBuffers[feedbackName] = sourceName;\n }\n }\n }\n Object.assign(feedbackBuffers, props.feedbackBuffers);\n for (const bufferName in feedbackBuffers) {\n const bufferOrRef = feedbackBuffers[bufferName];\n if (typeof bufferOrRef === 'string') {\n // Create new buffer with same layout and settings as source buffer\n const sourceBuffer = sourceBuffers[bufferOrRef];\n const {byteLength, usage, accessor} = sourceBuffer;\n feedbackBuffers[bufferName] = this._createNewBuffer(bufferName, {\n byteLength,\n usage,\n accessor\n });\n }\n }\n\n return feedbackBuffers;\n }\n\n _setupBuffers(props = {}) {\n const {sourceBuffers = null} = props;\n Object.assign(this.feedbackMap, props.feedbackMap);\n const feedbackBuffers = this._getFeedbackBuffers(props);\n this._updateBindings({sourceBuffers, feedbackBuffers});\n }\n\n _setupTransformFeedback(binding, {model}) {\n const {program} = model;\n binding.transformFeedback = new TransformFeedback(this.gl, {\n program,\n buffers: binding.feedbackBuffers\n });\n }\n\n _updateBindings(opts) {\n this.bindings[this.currentIndex] = this._updateBinding(this.bindings[this.currentIndex], opts);\n if (this.feedbackMap) {\n const {sourceBuffers, feedbackBuffers} = this._swapBuffers(this.bindings[this.currentIndex]);\n const nextIndex = this._getNextIndex();\n this.bindings[nextIndex] = this._updateBinding(this.bindings[nextIndex], {\n sourceBuffers,\n feedbackBuffers\n });\n }\n }\n\n _updateBinding(binding, opts) {\n if (!binding) {\n return {\n sourceBuffers: Object.assign({}, opts.sourceBuffers),\n feedbackBuffers: Object.assign({}, opts.feedbackBuffers)\n };\n }\n Object.assign(binding.sourceBuffers, opts.sourceBuffers);\n Object.assign(binding.feedbackBuffers, opts.feedbackBuffers);\n if (binding.transformFeedback) {\n binding.transformFeedback.setBuffers(binding.feedbackBuffers);\n }\n return binding;\n }\n\n _swapBuffers(opts) {\n if (!this.feedbackMap) {\n return null;\n }\n const sourceBuffers = Object.assign({}, opts.sourceBuffers);\n const feedbackBuffers = Object.assign({}, opts.feedbackBuffers);\n for (const srcName in this.feedbackMap) {\n const dstName = this.feedbackMap[srcName];\n sourceBuffers[srcName] = opts.feedbackBuffers[dstName];\n feedbackBuffers[dstName] = opts.sourceBuffers[srcName];\n\n // make sure the new destination buffer is a Buffer object\n assert(feedbackBuffers[dstName] instanceof Buffer);\n }\n return {sourceBuffers, feedbackBuffers};\n }\n\n // Create a buffer and add to list of buffers to be deleted.\n _createNewBuffer(name, opts) {\n const buffer = new Buffer(this.gl, opts);\n if (this.resources[name]) {\n this.resources[name].delete();\n }\n this.resources[name] = buffer;\n return buffer;\n }\n\n _getNextIndex() {\n return (this.currentIndex + 1) % 2;\n }\n}\n"],"mappings":"AAAA,SAAQA,QAAR,QAAuB,kBAAvB;AACA,SAAQC,MAAR,EAAgBC,iBAAhB,QAAwC,gBAAxC;AACA,SAAQC,MAAR,QAAqB,gBAArB;AAEA,eAAe,MAAMC,eAAN,CAAsB;EACnCC,WAAW,CAACC,EAAD,EAAiB;IAAA,IAAZC,KAAY,uEAAJ,EAAI;IAC1B,KAAKD,EAAL,GAAUA,EAAV;IACA,KAAKE,YAAL,GAAoB,CAApB;IACA,KAAKC,WAAL,GAAmB,EAAnB;IACA,KAAKC,QAAL,GAAgB,IAAhB;IACA,KAAKC,QAAL,GAAgB,EAAhB;IAEA,KAAKC,SAAL,GAAiB,EAAjB;;IAEA,KAAKC,WAAL,CAAiBN,KAAjB;;IACAO,MAAM,CAACC,IAAP,CAAY,IAAZ;EACD;;EAEDC,cAAc,CAACC,IAAD,EAAO;IACnB,KAAK,MAAMC,OAAX,IAAsB,KAAKP,QAA3B,EAAqC;MACnC,KAAKQ,uBAAL,CAA6BD,OAA7B,EAAsCD,IAAtC;IACD;EACF;;EAEDG,gBAAgB,GAAa;IAAA,IAAZb,KAAY,uEAAJ,EAAI;IAC3B,MAAM;MAACG;IAAD,IAAa,IAAnB;;IACA,IAAIA,QAAQ,CAACW,MAAT,GAAkB,CAAtB,EAAyB;MACvBd,KAAK,GAAGO,MAAM,CAACQ,MAAP,CAAc,EAAd,EAAkBf,KAAlB,EAAyB;QAACG;MAAD,CAAzB,CAAR;IACD;;IACD,OAAOH,KAAP;EACD;;EAEDgB,cAAc,GAAY;IAAA,IAAXN,IAAW,uEAAJ,EAAI;IACxB,MAAMC,OAAO,GAAG,KAAKP,QAAL,CAAc,KAAKH,YAAnB,CAAhB;IACA,MAAM;MAACgB,aAAD;MAAgBC;IAAhB,IAAqCP,OAA3C;IACA,MAAMQ,UAAU,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B,IAAP,EAAa;IAC3B,MAAMkB,MAAM,GAAG,IAAIlC,MAAJ,CAAW,KAAKK,EAAhB,EAAoBW,IAApB,CAAf;;IACA,IAAI,KAAKL,SAAL,CAAe2B,IAAf,CAAJ,EAA0B;MACxB,KAAK3B,SAAL,CAAe2B,IAAf,EAAqBD,MAArB;IACD;;IACD,KAAK1B,SAAL,CAAe2B,IAAf,IAAuBJ,MAAvB;IACA,OAAOA,MAAP;EACD;;EAEDP,aAAa,GAAG;IACd,OAAO,CAAC,KAAKpB,YAAL,GAAoB,CAArB,IAA0B,CAAjC;EACD;;AAjMkC"}
@@ -9,7 +9,8 @@ const SRC_TEX_PARAMETER_OVERRIDES = {
9
9
  };
10
10
  const FS_OUTPUT_VARIABLE = 'transform_output';
11
11
  export default class TextureTransform {
12
- constructor(gl, props = {}) {
12
+ constructor(gl) {
13
+ let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
13
14
  this.gl = gl;
14
15
  this.id = this.currentIndex = 0;
15
16
  this._swapTexture = null;
@@ -24,13 +25,16 @@ export default class TextureTransform {
24
25
  Object.seal(this);
25
26
  }
26
27
 
27
- updateModelProps(props = {}) {
28
+ updateModelProps() {
29
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
30
+
28
31
  const updatedModelProps = this._processVertexShader(props);
29
32
 
30
33
  return Object.assign({}, props, updatedModelProps);
31
34
  }
32
35
 
33
- getDrawOptions(opts = {}) {
36
+ getDrawOptions() {
37
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
34
38
  const {
35
39
  sourceBuffers,
36
40
  sourceTextures,
@@ -83,7 +87,9 @@ export default class TextureTransform {
83
87
  return false;
84
88
  }
85
89
 
86
- update(opts = {}) {
90
+ update() {
91
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
92
+
87
93
  this._setupTextures(opts);
88
94
  }
89
95
 
@@ -94,9 +100,10 @@ export default class TextureTransform {
94
100
  return targetTexture;
95
101
  }
96
102
 
97
- getData({
98
- packed = false
99
- } = {}) {
103
+ getData() {
104
+ let {
105
+ packed = false
106
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
100
107
  const {
101
108
  framebuffer
102
109
  } = this.bindings[this.currentIndex];
@@ -135,7 +142,8 @@ export default class TextureTransform {
135
142
  }
136
143
  }
137
144
 
138
- _initialize(props = {}) {
145
+ _initialize() {
146
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
139
147
  const {
140
148
  _targetTextureVarying,
141
149
  _swapTexture
@@ -167,7 +175,8 @@ export default class TextureTransform {
167
175
  return this._createNewTexture(refTexture);
168
176
  }
169
177
 
170
- _setupTextures(props = {}) {
178
+ _setupTextures() {
179
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
171
180
  const {
172
181
  sourceBuffers,
173
182
  _sourceTextures = {},
@@ -277,7 +286,7 @@ export default class TextureTransform {
277
286
  });
278
287
  } else {
279
288
  binding.framebuffer = new Framebuffer(this.gl, {
280
- id: `transform-framebuffer`,
289
+ id: "transform-framebuffer",
281
290
  width,
282
291
  height,
283
292
  attachments: {
@@ -340,7 +349,8 @@ export default class TextureTransform {
340
349
  return (this.currentIndex + 1) % 2;
341
350
  }
342
351
 
343
- _processVertexShader(props = {}) {
352
+ _processVertexShader() {
353
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
344
354
  const {
345
355
  sourceTextures,
346
356
  targetTexture
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/transform/texture-transform.js"],"names":["cloneTextureFrom","readPixelsToArray","getShaderVersion","Buffer","Texture2D","Framebuffer","_transform","transformModule","getPassthroughFS","typeToChannelCount","combineInjects","updateForTextures","getSizeUniforms","SRC_TEX_PARAMETER_OVERRIDES","FS_OUTPUT_VARIABLE","TextureTransform","constructor","gl","props","id","currentIndex","_swapTexture","targetTextureVarying","targetTextureType","samplerTextureMap","bindings","resources","_initialize","Object","seal","updateModelProps","updatedModelProps","_processVertexShader","assign","getDrawOptions","opts","sourceBuffers","sourceTextures","framebuffer","targetTexture","attributes","uniforms","parameters","discard","hasSourceTextures","hasTargetTexture","transform_elementID","elementIDBuffer","sampler","textureName","_setSourceTextureParameters","sizeUniforms","sourceTextureMap","viewport","width","height","swap","_getNextIndex","update","_setupTextures","getTargetTexture","getData","packed","pixels","ArrayType","channelCount","packedPixels","length","packCount","i","j","getFramebuffer","currentResources","delete","ownTexture","_targetTextureVarying","_createTargetTexture","textureOrReference","refTexture","_targetRefTexName","_createNewTexture","_sourceTextures","_targetTexture","keys","_updateBindings","_updateElementIDBuffer","elementCount","elementIds","Float32Array","forEach","_","index","array","data","accessor","size","setData","_updateBinding","_swapTextures","nextIndex","binding","attachments","resizeAttachments","resize","name","setParameters","texture","pixelStore","vs","inject","combinedInject","fs","_fs","version","input","inputType","output","modules","concat"],"mappings":"AAGA,SACEA,gBADF,EAEEC,iBAFF,EAGEC,gBAHF,EAIEC,MAJF,EAKEC,SALF,EAMEC,WANF,QAOO,gBAPP;AASA,SACEC,UAAU,IAAIC,eADhB,EAEEC,gBAFF,EAGEC,kBAHF,EAIEC,cAJF,QAKO,sBALP;AAOA,SAAQC,iBAAR,EAA2BC,eAA3B,QAAiD,0BAAjD;AAIA,MAAMC,2BAA2B,GAAG;AAClC,eADkC;AAElC,eAFkC;AAGlC,gBAHkC;AAIlC;AAJkC,CAApC;AAMA,MAAMC,kBAAkB,GAAG,kBAA3B;AAEA,eAAe,MAAMC,gBAAN,CAAuB;AACpCC,EAAAA,WAAW,CAACC,EAAD,EAAKC,KAAK,GAAG,EAAb,EAAiB;AAC1B,SAAKD,EAAL,GAAUA,EAAV;AACA,SAAKE,EAAL,GAAU,KAAKC,YAAL,GAAoB,CAA9B;AACA,SAAKC,YAAL,GAAoB,IAApB;AACA,SAAKC,oBAAL,GAA4B,IAA5B;AACA,SAAKC,iBAAL,GAAyB,IAAzB;AACA,SAAKC,iBAAL,GAAyB,IAAzB;AACA,SAAK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rFiG,MAAAA,EAAE,EAAE1F,KAAK,CAAC0F,EAD2E;AAErFxD,MAAAA,gBAAgB,EAAEf,cAFmE;AAGrFf,MAAAA,oBAAoB,EAAE,KAAKA,oBAH0D;AAIrFiB,MAAAA;AAJqF,KAAD,CAAtF;AAMA,UAAMuE,cAAc,GAAGpG,cAAc,CAAC,CAACQ,KAAK,CAAC2F,MAAN,IAAgB,EAAjB,EAAqBA,MAArB,CAAD,CAArC;AACA,SAAKtF,iBAAL,GAAyBA,iBAAzB;AACA,SAAKC,iBAAL,GAAyBA,iBAAzB;AACA,UAAMuF,EAAE,GACN7F,KAAK,CAAC8F,GAAN,IACAxG,gBAAgB,CAAC;AACfyG,MAAAA,OAAO,EAAE/G,gBAAgB,CAAC0G,EAAD,CADV;AAEfM,MAAAA,KAAK,EAAE,KAAK5F,oBAFG;AAGf6F,MAAAA,SAAS,EAAE5F,iBAHI;AAIf6F,MAAAA,MAAM,EAAEtG;AAJO,KAAD,CAFlB;AAQA,UAAMuG,OAAO,GACX,KAAKzE,iBAAL,IAA0B,KAAKtB,oBAA/B,GACI,CAACf,eAAD,EAAkB+G,MAAlB,CAAyBpG,KAAK,CAACmG,OAAN,IAAiB,EAA1C,CADJ,GAEInG,KAAK,CAACmG,OAHZ;AAIA,WAAO;AAACT,MAAAA,EAAD;AAAKG,MAAAA,EAAL;AAASM,MAAAA,OAAT;AAAkB5E,MAAAA,QAAlB;AAA4BoE,MAAAA,MAAM,EAAEC;AAApC,KAAP;AACD;;AA7SmC","sourcesContent":["/** @typedef {import('./transform').TransformProps} TransformProps */\nimport GL from '@luma.gl/constants';\n\nimport {\n cloneTextureFrom,\n readPixelsToArray,\n getShaderVersion,\n Buffer,\n Texture2D,\n Framebuffer\n} from '@luma.gl/webgl';\n\nimport {\n _transform as transformModule,\n getPassthroughFS,\n typeToChannelCount,\n combineInjects\n} from '@luma.gl/shadertools';\n\nimport {updateForTextures, getSizeUniforms} from './transform-shader-utils';\n\n// TODO: move these constants to transform-shader-utils\n// Texture parameters needed so sample can precisely pick pixel for given element id.\nconst SRC_TEX_PARAMETER_OVERRIDES = {\n [GL.TEXTURE_MIN_FILTER]: GL.NEAREST,\n [GL.TEXTURE_MAG_FILTER]: GL.NEAREST,\n [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,\n [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE\n};\nconst FS_OUTPUT_VARIABLE = 'transform_output';\n\nexport default class TextureTransform {\n constructor(gl, props = {}) {\n this.gl = gl;\n this.id = this.currentIndex = 0;\n this._swapTexture = null;\n this.targetTextureVarying = null;\n this.targetTextureType = null;\n this.samplerTextureMap = null;\n this.bindings = []; // each element is an object : {sourceTextures, targetTexture, framebuffer}\n\n this.resources = {}; // resources to be deleted\n\n this._initialize(props);\n Object.seal(this);\n }\n\n updateModelProps(props = {}) {\n const updatedModelProps = this._processVertexShader(props);\n return Object.assign({}, props, updatedModelProps);\n }\n\n getDrawOptions(opts = {}) {\n const {sourceBuffers, sourceTextures, framebuffer, targetTexture} = this.bindings[\n this.currentIndex\n ];\n\n const attributes = Object.assign({}, sourceBuffers, opts.attributes);\n const uniforms = Object.assign({}, opts.uniforms);\n const parameters = Object.assign({}, opts.parameters);\n let discard = opts.discard;\n\n if (this.hasSourceTextures || this.hasTargetTexture) {\n attributes.transform_elementID = this.elementIDBuffer;\n\n for (const sampler in this.samplerTextureMap) {\n const textureName = this.samplerTextureMap[sampler];\n uniforms[sampler] = sourceTextures[textureName];\n }\n this._setSourceTextureParameters();\n // get texture size uniforms\n const sizeUniforms = getSizeUniforms({\n sourceTextureMap: sourceTextures,\n targetTextureVarying: this.targetTextureVarying,\n targetTexture\n });\n Object.assign(uniforms, sizeUniforms);\n }\n\n if (this.hasTargetTexture) {\n discard = false;\n parameters.viewport = [0, 0, framebuffer.width, framebuffer.height];\n }\n\n return {attributes, framebuffer, uniforms, discard, parameters};\n }\n\n swap() {\n if (this._swapTexture) {\n this.currentIndex = this._getNextIndex();\n return true;\n }\n return false;\n }\n\n // update source and/or feedbackBuffers\n update(opts = {}) {\n this._setupTextures(opts);\n }\n\n // returns current target texture\n getTargetTexture() {\n const {targetTexture} = this.bindings[this.currentIndex];\n return targetTexture;\n }\n\n getData({packed = false} = {}) {\n const {framebuffer} = this.bindings[this.currentIndex];\n const pixels = readPixelsToArray(framebuffer);\n\n if (!packed) {\n return pixels;\n }\n\n // readPixels returns 4 elements for each pixel, pack the elements when requested\n const ArrayType = pixels.constructor;\n const channelCount = typeToChannelCount(this.targetTextureType);\n // @ts-ignore\n const packedPixels = new ArrayType((pixels.length * channelCount) / 4);\n let packCount = 0;\n for (let i = 0; i < pixels.length; i += 4) {\n for (let j = 0; j < channelCount; j++) {\n packedPixels[packCount++] = pixels[i + j];\n }\n }\n return packedPixels;\n }\n\n // returns current framebuffer object that is being used.\n getFramebuffer() {\n const currentResources = this.bindings[this.currentIndex];\n return currentResources.framebuffer;\n }\n\n // Delete owned resources.\n delete() {\n if (this.ownTexture) {\n this.ownTexture.delete();\n }\n if (this.elementIDBuffer) {\n this.elementIDBuffer.delete();\n }\n }\n\n // Private\n\n _initialize(props = {}) {\n const {_targetTextureVarying, _swapTexture} = props;\n this._swapTexture = _swapTexture;\n this.targetTextureVarying = _targetTextureVarying;\n this.hasTargetTexture = _targetTextureVarying;\n this._setupTextures(props);\n }\n\n // auto create target texture if requested\n _createTargetTexture(props) {\n const {sourceTextures, textureOrReference} = props;\n if (textureOrReference instanceof Texture2D) {\n return textureOrReference;\n }\n // 'targetTexture' is a reference souce texture.\n const refTexture = sourceTextures[textureOrReference];\n if (!refTexture) {\n return null;\n }\n\n // save reference texture name, when corresponding source texture is updated\n // we also update target texture.\n this._targetRefTexName = textureOrReference;\n\n return this._createNewTexture(refTexture);\n }\n\n /** @param {TransformProps} props */\n _setupTextures(props = {}) {\n const {sourceBuffers, _sourceTextures = {}, _targetTexture} = props;\n const targetTexture = this._createTargetTexture({\n sourceTextures: _sourceTextures,\n textureOrReference: _targetTexture\n });\n this.hasSourceTextures =\n this.hasSourceTextures || (_sourceTextures && Object.keys(_sourceTextures).length > 0);\n this._updateBindings({sourceBuffers, sourceTextures: _sourceTextures, targetTexture});\n if ('elementCount' in props) {\n this._updateElementIDBuffer(props.elementCount);\n }\n }\n\n _updateElementIDBuffer(elementCount) {\n if (typeof elementCount !== 'number' || this.elementCount >= elementCount) {\n return;\n }\n // NOTE: using float so this will work with GLSL 1.0 shaders.\n const elementIds = new Float32Array(elementCount);\n elementIds.forEach((_, index, array) => {\n array[index] = index;\n });\n if (!this.elementIDBuffer) {\n this.elementIDBuffer = new Buffer(this.gl, {\n data: elementIds,\n accessor: {size: 1}\n });\n } else {\n this.elementIDBuffer.setData({data: elementIds});\n }\n this.elementCount = elementCount;\n }\n\n _updateBindings(opts) {\n this.bindings[this.currentIndex] = this._updateBinding(this.bindings[this.currentIndex], opts);\n if (this._swapTexture) {\n const {sourceTextures, targetTexture} = this._swapTextures(this.bindings[this.currentIndex]);\n const nextIndex = this._getNextIndex();\n this.bindings[nextIndex] = this._updateBinding(this.bindings[nextIndex], {\n sourceTextures,\n targetTexture\n });\n }\n }\n\n _updateBinding(binding, opts) {\n const {sourceBuffers, sourceTextures, targetTexture} = opts;\n if (!binding) {\n binding = {\n sourceBuffers: {},\n sourceTextures: {},\n targetTexture: null\n };\n }\n Object.assign(binding.sourceTextures, sourceTextures);\n Object.assign(binding.sourceBuffers, sourceBuffers);\n if (targetTexture) {\n binding.targetTexture = targetTexture;\n\n const {width, height} = targetTexture;\n const {framebuffer} = binding;\n if (framebuffer) {\n // First update texture without re-sizing attachments\n framebuffer.update({\n attachments: {[GL.COLOR_ATTACHMENT0]: targetTexture},\n resizeAttachments: false\n });\n // Resize to new taget texture size\n framebuffer.resize({width, height});\n } else {\n binding.framebuffer = new Framebuffer(this.gl, {\n id: `transform-framebuffer`,\n width,\n height,\n attachments: {\n [GL.COLOR_ATTACHMENT0]: targetTexture\n }\n });\n }\n }\n return binding;\n }\n\n // set texture filtering parameters on source textures.\n _setSourceTextureParameters() {\n const index = this.currentIndex;\n const {sourceTextures} = this.bindings[index];\n for (const name in sourceTextures) {\n sourceTextures[name].setParameters(SRC_TEX_PARAMETER_OVERRIDES);\n }\n }\n\n _swapTextures(opts) {\n if (!this._swapTexture) {\n return null;\n }\n const sourceTextures = Object.assign({}, opts.sourceTextures);\n sourceTextures[this._swapTexture] = opts.targetTexture;\n\n const targetTexture = opts.sourceTextures[this._swapTexture];\n\n return {sourceTextures, targetTexture};\n }\n\n // Create a buffer and add to list of buffers to be deleted.\n _createNewTexture(refTexture) {\n const texture = cloneTextureFrom(refTexture, {\n parameters: {\n [GL.TEXTURE_MIN_FILTER]: GL.NEAREST,\n [GL.TEXTURE_MAG_FILTER]: GL.NEAREST,\n [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,\n [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE\n },\n pixelStore: {\n [GL.UNPACK_FLIP_Y_WEBGL]: false\n }\n });\n\n // thre can only be one target texture\n if (this.ownTexture) {\n this.ownTexture.delete();\n }\n this.ownTexture = texture;\n\n return texture;\n }\n\n _getNextIndex() {\n return (this.currentIndex + 1) % 2;\n }\n\n // build and return shader releated parameters\n _processVertexShader(props = {}) {\n const {sourceTextures, targetTexture} = this.bindings[this.currentIndex];\n // @ts-ignore TODO - uniforms is not present\n const {vs, uniforms, targetTextureType, inject, samplerTextureMap} = updateForTextures({\n vs: props.vs,\n sourceTextureMap: sourceTextures,\n targetTextureVarying: this.targetTextureVarying,\n targetTexture\n });\n const combinedInject = combineInjects([props.inject || {}, inject]);\n this.targetTextureType = targetTextureType;\n this.samplerTextureMap = samplerTextureMap;\n const fs =\n props._fs ||\n getPassthroughFS({\n version: getShaderVersion(vs),\n input: this.targetTextureVarying,\n inputType: targetTextureType,\n output: FS_OUTPUT_VARIABLE\n });\n const modules =\n this.hasSourceTextures || this.targetTextureVarying\n ? [transformModule].concat(props.modules || [])\n : props.modules;\n return {vs, fs, modules, uniforms, inject: combinedInject};\n }\n}\n"],"file":"texture-transform.js"}
1
+ {"version":3,"file":"texture-transform.js","names":["cloneTextureFrom","readPixelsToArray","getShaderVersion","Buffer","Texture2D","Framebuffer","_transform","transformModule","getPassthroughFS","typeToChannelCount","combineInjects","updateForTextures","getSizeUniforms","SRC_TEX_PARAMETER_OVERRIDES","FS_OUTPUT_VARIABLE","TextureTransform","constructor","gl","props","id","currentIndex","_swapTexture","targetTextureVarying","targetTextureType","samplerTextureMap","bindings","resources","_initialize","Object","seal","updateModelProps","updatedModelProps","_processVertexShader","assign","getDrawOptions","opts","sourceBuffers","sourceTextures","framebuffer","targetTexture","attributes","uniforms","parameters","discard","hasSourceTextures","hasTargetTexture","transform_elementID","elementIDBuffer","sampler","textureName","_setSourceTextureParameters","sizeUniforms","sourceTextureMap","viewport","width","height","swap","_getNextIndex","update","_setupTextures","getTargetTexture","getData","packed","pixels","ArrayType","channelCount","packedPixels","length","packCount","i","j","getFramebuffer","currentResources","delete","ownTexture","_targetTextureVarying","_createTargetTexture","textureOrReference","refTexture","_targetRefTexName","_createNewTexture","_sourceTextures","_targetTexture","keys","_updateBindings","_updateElementIDBuffer","elementCount","elementIds","Float32Array","forEach","_","index","array","data","accessor","size","setData","_updateBinding","_swapTextures","nextIndex","binding","attachments","resizeAttachments","resize","name","setParameters","texture","pixelStore","vs","inject","combinedInject","fs","_fs","version","input","inputType","output","modules","concat"],"sources":["../../../src/transform/texture-transform.js"],"sourcesContent":["/** @typedef {import('./transform').TransformProps} TransformProps */\nimport GL from '@luma.gl/constants';\n\nimport {\n cloneTextureFrom,\n readPixelsToArray,\n getShaderVersion,\n Buffer,\n Texture2D,\n Framebuffer\n} from '@luma.gl/webgl';\n\nimport {\n _transform as transformModule,\n getPassthroughFS,\n typeToChannelCount,\n combineInjects\n} from '@luma.gl/shadertools';\n\nimport {updateForTextures, getSizeUniforms} from './transform-shader-utils';\n\n// TODO: move these constants to transform-shader-utils\n// Texture parameters needed so sample can precisely pick pixel for given element id.\nconst SRC_TEX_PARAMETER_OVERRIDES = {\n [GL.TEXTURE_MIN_FILTER]: GL.NEAREST,\n [GL.TEXTURE_MAG_FILTER]: GL.NEAREST,\n [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,\n [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE\n};\nconst FS_OUTPUT_VARIABLE = 'transform_output';\n\nexport default class TextureTransform {\n constructor(gl, props = {}) {\n this.gl = gl;\n this.id = this.currentIndex = 0;\n this._swapTexture = null;\n this.targetTextureVarying = null;\n this.targetTextureType = null;\n this.samplerTextureMap = null;\n this.bindings = []; // each element is an object : {sourceTextures, targetTexture, framebuffer}\n\n this.resources = {}; // resources to be deleted\n\n this._initialize(props);\n Object.seal(this);\n }\n\n updateModelProps(props = {}) {\n const updatedModelProps = this._processVertexShader(props);\n return Object.assign({}, props, updatedModelProps);\n }\n\n getDrawOptions(opts = {}) {\n const {sourceBuffers, sourceTextures, framebuffer, targetTexture} = this.bindings[\n this.currentIndex\n ];\n\n const attributes = Object.assign({}, sourceBuffers, opts.attributes);\n const uniforms = Object.assign({}, opts.uniforms);\n const parameters = Object.assign({}, opts.parameters);\n let discard = opts.discard;\n\n if (this.hasSourceTextures || this.hasTargetTexture) {\n attributes.transform_elementID = this.elementIDBuffer;\n\n for (const sampler in this.samplerTextureMap) {\n const textureName = this.samplerTextureMap[sampler];\n uniforms[sampler] = sourceTextures[textureName];\n }\n this._setSourceTextureParameters();\n // get texture size uniforms\n const sizeUniforms = getSizeUniforms({\n sourceTextureMap: sourceTextures,\n targetTextureVarying: this.targetTextureVarying,\n targetTexture\n });\n Object.assign(uniforms, sizeUniforms);\n }\n\n if (this.hasTargetTexture) {\n discard = false;\n parameters.viewport = [0, 0, framebuffer.width, framebuffer.height];\n }\n\n return {attributes, framebuffer, uniforms, discard, parameters};\n }\n\n swap() {\n if (this._swapTexture) {\n this.currentIndex = this._getNextIndex();\n return true;\n }\n return false;\n }\n\n // update source and/or feedbackBuffers\n update(opts = {}) {\n this._setupTextures(opts);\n }\n\n // returns current target texture\n getTargetTexture() {\n const {targetTexture} = this.bindings[this.currentIndex];\n return targetTexture;\n }\n\n getData({packed = false} = {}) {\n const {framebuffer} = this.bindings[this.currentIndex];\n const pixels = readPixelsToArray(framebuffer);\n\n if (!packed) {\n return pixels;\n }\n\n // readPixels returns 4 elements for each pixel, pack the elements when requested\n const ArrayType = pixels.constructor;\n const channelCount = typeToChannelCount(this.targetTextureType);\n // @ts-ignore\n const packedPixels = new ArrayType((pixels.length * channelCount) / 4);\n let packCount = 0;\n for (let i = 0; i < pixels.length; i += 4) {\n for (let j = 0; j < channelCount; j++) {\n packedPixels[packCount++] = pixels[i + j];\n }\n }\n return packedPixels;\n }\n\n // returns current framebuffer object that is being used.\n getFramebuffer() {\n const currentResources = this.bindings[this.currentIndex];\n return currentResources.framebuffer;\n }\n\n // Delete owned resources.\n delete() {\n if (this.ownTexture) {\n this.ownTexture.delete();\n }\n if (this.elementIDBuffer) {\n this.elementIDBuffer.delete();\n }\n }\n\n // Private\n\n _initialize(props = {}) {\n const {_targetTextureVarying, _swapTexture} = props;\n this._swapTexture = _swapTexture;\n this.targetTextureVarying = _targetTextureVarying;\n this.hasTargetTexture = _targetTextureVarying;\n this._setupTextures(props);\n }\n\n // auto create target texture if requested\n _createTargetTexture(props) {\n const {sourceTextures, textureOrReference} = props;\n if (textureOrReference instanceof Texture2D) {\n return textureOrReference;\n }\n // 'targetTexture' is a reference souce texture.\n const refTexture = sourceTextures[textureOrReference];\n if (!refTexture) {\n return null;\n }\n\n // save reference texture name, when corresponding source texture is updated\n // we also update target texture.\n this._targetRefTexName = textureOrReference;\n\n return this._createNewTexture(refTexture);\n }\n\n /** @param {TransformProps} props */\n _setupTextures(props = {}) {\n const {sourceBuffers, _sourceTextures = {}, _targetTexture} = props;\n const targetTexture = this._createTargetTexture({\n sourceTextures: _sourceTextures,\n textureOrReference: _targetTexture\n });\n this.hasSourceTextures =\n this.hasSourceTextures || (_sourceTextures && Object.keys(_sourceTextures).length > 0);\n this._updateBindings({sourceBuffers, sourceTextures: _sourceTextures, targetTexture});\n if ('elementCount' in props) {\n this._updateElementIDBuffer(props.elementCount);\n }\n }\n\n _updateElementIDBuffer(elementCount) {\n if (typeof elementCount !== 'number' || this.elementCount >= elementCount) {\n return;\n }\n // NOTE: using float so this will work with GLSL 1.0 shaders.\n const elementIds = new Float32Array(elementCount);\n elementIds.forEach((_, index, array) => {\n array[index] = index;\n });\n if (!this.elementIDBuffer) {\n this.elementIDBuffer = new Buffer(this.gl, {\n data: elementIds,\n accessor: {size: 1}\n });\n } else {\n this.elementIDBuffer.setData({data: elementIds});\n }\n this.elementCount = elementCount;\n }\n\n _updateBindings(opts) {\n this.bindings[this.currentIndex] = this._updateBinding(this.bindings[this.currentIndex], opts);\n if (this._swapTexture) {\n const {sourceTextures, targetTexture} = this._swapTextures(this.bindings[this.currentIndex]);\n const nextIndex = this._getNextIndex();\n this.bindings[nextIndex] = this._updateBinding(this.bindings[nextIndex], {\n sourceTextures,\n targetTexture\n });\n }\n }\n\n _updateBinding(binding, opts) {\n const {sourceBuffers, sourceTextures, targetTexture} = opts;\n if (!binding) {\n binding = {\n sourceBuffers: {},\n sourceTextures: {},\n targetTexture: null\n };\n }\n Object.assign(binding.sourceTextures, sourceTextures);\n Object.assign(binding.sourceBuffers, sourceBuffers);\n if (targetTexture) {\n binding.targetTexture = targetTexture;\n\n const {width, height} = targetTexture;\n const {framebuffer} = binding;\n if (framebuffer) {\n // First update texture without re-sizing attachments\n framebuffer.update({\n attachments: {[GL.COLOR_ATTACHMENT0]: targetTexture},\n resizeAttachments: false\n });\n // Resize to new taget texture size\n framebuffer.resize({width, height});\n } else {\n binding.framebuffer = new Framebuffer(this.gl, {\n id: `transform-framebuffer`,\n width,\n height,\n attachments: {\n [GL.COLOR_ATTACHMENT0]: targetTexture\n }\n });\n }\n }\n return binding;\n }\n\n // set texture filtering parameters on source textures.\n _setSourceTextureParameters() {\n const index = this.currentIndex;\n const {sourceTextures} = this.bindings[index];\n for (const name in sourceTextures) {\n sourceTextures[name].setParameters(SRC_TEX_PARAMETER_OVERRIDES);\n }\n }\n\n _swapTextures(opts) {\n if (!this._swapTexture) {\n return null;\n }\n const sourceTextures = Object.assign({}, opts.sourceTextures);\n sourceTextures[this._swapTexture] = opts.targetTexture;\n\n const targetTexture = opts.sourceTextures[this._swapTexture];\n\n return {sourceTextures, targetTexture};\n }\n\n // Create a buffer and add to list of buffers to be deleted.\n _createNewTexture(refTexture) {\n const texture = cloneTextureFrom(refTexture, {\n parameters: {\n [GL.TEXTURE_MIN_FILTER]: GL.NEAREST,\n [GL.TEXTURE_MAG_FILTER]: GL.NEAREST,\n [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,\n [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE\n },\n pixelStore: {\n [GL.UNPACK_FLIP_Y_WEBGL]: false\n }\n });\n\n // thre can only be one target texture\n if (this.ownTexture) {\n this.ownTexture.delete();\n }\n this.ownTexture = texture;\n\n return texture;\n }\n\n _getNextIndex() {\n return (this.currentIndex + 1) % 2;\n }\n\n // build and return shader releated parameters\n _processVertexShader(props = {}) {\n const {sourceTextures, targetTexture} = this.bindings[this.currentIndex];\n // @ts-ignore TODO - uniforms is not present\n const {vs, uniforms, targetTextureType, inject, samplerTextureMap} = updateForTextures({\n vs: props.vs,\n sourceTextureMap: sourceTextures,\n targetTextureVarying: this.targetTextureVarying,\n targetTexture\n });\n const combinedInject = combineInjects([props.inject || {}, inject]);\n this.targetTextureType = targetTextureType;\n this.samplerTextureMap = samplerTextureMap;\n const fs =\n props._fs ||\n getPassthroughFS({\n version: getShaderVersion(vs),\n input: this.targetTextureVarying,\n inputType: targetTextureType,\n output: FS_OUTPUT_VARIABLE\n });\n const modules =\n this.hasSourceTextures || this.targetTextureVarying\n ? [transformModule].concat(props.modules || [])\n : props.modules;\n return {vs, fs, modules, uniforms, inject: combinedInject};\n }\n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IAA1C,IAA+Db,iBAAiB,CAAC;MACrFiG,EAAE,EAAE1F,KAAK,CAAC0F,EAD2E;MAErFxD,gBAAgB,EAAEf,cAFmE;MAGrFf,oBAAoB,EAAE,KAAKA,oBAH0D;MAIrFiB;IAJqF,CAAD,CAAtF;IAMA,MAAMuE,cAAc,GAAGpG,cAAc,CAAC,CAACQ,KAAK,CAAC2F,MAAN,IAAgB,EAAjB,EAAqBA,MAArB,CAAD,CAArC;IACA,KAAKtF,iBAAL,GAAyBA,iBAAzB;IACA,KAAKC,iBAAL,GAAyBA,iBAAzB;IACA,MAAMuF,EAAE,GACN7F,KAAK,CAAC8F,GAAN,IACAxG,gBAAgB,CAAC;MACfyG,OAAO,EAAE/G,gBAAgB,CAAC0G,EAAD,CADV;MAEfM,KAAK,EAAE,KAAK5F,oBAFG;MAGf6F,SAAS,EAAE5F,iBAHI;MAIf6F,MAAM,EAAEtG;IAJO,CAAD,CAFlB;IAQA,MAAMuG,OAAO,GACX,KAAKzE,iBAAL,IAA0B,KAAKtB,oBAA/B,GACI,CAACf,eAAD,EAAkB+G,MAAlB,CAAyBpG,KAAK,CAACmG,OAAN,IAAiB,EAA1C,CADJ,GAEInG,KAAK,CAACmG,OAHZ;IAIA,OAAO;MAACT,EAAD;MAAKG,EAAL;MAASM,OAAT;MAAkB5E,QAAlB;MAA4BoE,MAAM,EAAEC;IAApC,CAAP;EACD;;AA7SmC"}
@@ -3,12 +3,13 @@ import { combineInjects, getQualifierDetails, typeToChannelSuffix } from '@luma.
3
3
  const SAMPLER_UNIFORM_PREFIX = 'transform_uSampler_';
4
4
  const SIZE_UNIFORM_PREFIX = 'transform_uSize_';
5
5
  const VS_POS_VARIABLE = 'transform_position';
6
- export function updateForTextures({
7
- vs,
8
- sourceTextureMap,
9
- targetTextureVarying,
10
- targetTexture
11
- }) {
6
+ export function updateForTextures(_ref) {
7
+ let {
8
+ vs,
9
+ sourceTextureMap,
10
+ targetTextureVarying,
11
+ targetTexture
12
+ } = _ref;
12
13
  const texAttributeNames = Object.keys(sourceTextureMap);
13
14
  let sourceCount = texAttributeNames.length;
14
15
  let targetTextureType = null;
@@ -42,11 +43,9 @@ export function updateForTextures({
42
43
 
43
44
  if (targetTextureVarying) {
44
45
  assert(targetTexture);
45
- const sizeName = `${SIZE_UNIFORM_PREFIX}${targetTextureVarying}`;
46
- const uniformDeclaration = `uniform vec2 ${sizeName};\n`;
47
- const posInstructions = `\
48
- vec2 ${VS_POS_VARIABLE} = transform_getPos(${sizeName});
49
- gl_Position = vec4(${VS_POS_VARIABLE}, 0, 1.);\n`;
46
+ const sizeName = "".concat(SIZE_UNIFORM_PREFIX).concat(targetTextureVarying);
47
+ const uniformDeclaration = "uniform vec2 ".concat(sizeName, ";\n");
48
+ const posInstructions = " vec2 ".concat(VS_POS_VARIABLE, " = transform_getPos(").concat(sizeName, ");\n gl_Position = vec4(").concat(VS_POS_VARIABLE, ", 0, 1.);\n");
50
49
  const inject = {
51
50
  'vs:#decl': uniformDeclaration,
52
51
  'vs:#main-start': posInstructions
@@ -64,11 +63,12 @@ export function updateForTextures({
64
63
  samplerTextureMap
65
64
  };
66
65
  }
67
- export function getSizeUniforms({
68
- sourceTextureMap,
69
- targetTextureVarying,
70
- targetTexture
71
- }) {
66
+ export function getSizeUniforms(_ref2) {
67
+ let {
68
+ sourceTextureMap,
69
+ targetTextureVarying,
70
+ targetTexture
71
+ } = _ref2;
72
72
  const uniforms = {};
73
73
  let width;
74
74
  let height;
@@ -78,7 +78,7 @@ export function getSizeUniforms({
78
78
  width,
79
79
  height
80
80
  } = targetTexture);
81
- uniforms[`${SIZE_UNIFORM_PREFIX}${targetTextureVarying}`] = [width, height];
81
+ uniforms["".concat(SIZE_UNIFORM_PREFIX).concat(targetTextureVarying)] = [width, height];
82
82
  }
83
83
 
84
84
  for (const textureName in sourceTextureMap) {
@@ -86,7 +86,7 @@ export function getSizeUniforms({
86
86
  width,
87
87
  height
88
88
  } = sourceTextureMap[textureName]);
89
- uniforms[`${SIZE_UNIFORM_PREFIX}${textureName}`] = [width, height];
89
+ uniforms["".concat(SIZE_UNIFORM_PREFIX).concat(textureName)] = [width, height];
90
90
  }
91
91
 
92
92
  return uniforms;
@@ -97,11 +97,9 @@ function getAttributeDefinition(line) {
97
97
  }
98
98
 
99
99
  function getSamplerDeclerations(textureName) {
100
- const samplerName = `${SAMPLER_UNIFORM_PREFIX}${textureName}`;
101
- const sizeName = `${SIZE_UNIFORM_PREFIX}${textureName}`;
102
- const uniformDeclerations = `\
103
- uniform sampler2D ${samplerName};
104
- uniform vec2 ${sizeName};`;
100
+ const samplerName = "".concat(SAMPLER_UNIFORM_PREFIX).concat(textureName);
101
+ const sizeName = "".concat(SIZE_UNIFORM_PREFIX).concat(textureName);
102
+ const uniformDeclerations = " uniform sampler2D ".concat(samplerName, ";\n uniform vec2 ").concat(sizeName, ";");
105
103
  return {
106
104
  samplerName,
107
105
  sizeName,
@@ -132,14 +130,14 @@ export function processAttributeDefinition(line, textureMap) {
132
130
  } = attributeData;
133
131
 
134
132
  if (name && textureMap[name]) {
135
- const updatedLine = `\// ${line} => Replaced by Transform with a sampler`;
133
+ const updatedLine = "// ".concat(line, " => Replaced by Transform with a sampler");
136
134
  const {
137
135
  samplerName,
138
136
  sizeName,
139
137
  uniformDeclerations
140
138
  } = getSamplerDeclerations(name);
141
139
  const channels = typeToChannelSuffix(type);
142
- const sampleInstruction = ` ${type} ${name} = transform_getInput(${samplerName}, ${sizeName}).${channels};\n`;
140
+ const sampleInstruction = " ".concat(type, " ").concat(name, " = transform_getInput(").concat(samplerName, ", ").concat(sizeName, ").").concat(channels, ";\n");
143
141
  samplerTextureMap[samplerName] = name;
144
142
  const inject = {
145
143
  'vs:#decl': uniformDeclerations,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/transform/transform-shader-utils.js"],"names":["assert","combineInjects","getQualifierDetails","typeToChannelSuffix","SAMPLER_UNIFORM_PREFIX","SIZE_UNIFORM_PREFIX","VS_POS_VARIABLE","updateForTextures","vs","sourceTextureMap","targetTextureVarying","targetTexture","texAttributeNames","Object","keys","sourceCount","length","targetTextureType","samplerTextureMap","updatedVs","finalInject","vsLines","split","updateVsLines","slice","forEach","line","index","lines","updated","processAttributeDefinition","updatedLine","inject","assign","getVaryingType","sizeName","uniformDeclaration","posInstructions","join","getSizeUniforms","uniforms","width","height","textureName","getAttributeDefinition","getSamplerDeclerations","samplerName","uniformDeclerations","varying","qualaiferDetails","name","type","textureMap","attributeData","channels","sampleInstruction"],"mappings":"AAAA,SAAQA,MAAR,QAAqB,gBAArB;AACA,SAAQC,cAAR,EAAwBC,mBAAxB,EAA6CC,mBAA7C,QAAuE,sBAAvE;AAEA,MAAMC,sBAAsB,GAAG,qBAA/B;AACA,MAAMC,mBAAmB,GAAG,kBAA5B;AACA,MAAMC,eAAe,GAAG,oBAAxB;AAKA,OAAO,SAASC,iBAAT,CAA2B;AAACC,EAAAA,EAAD;AAAKC,EAAAA,gBAAL;AAAuBC,EAAAA,oBAAvB;AAA6CC,EAAAA;AAA7C,CAA3B,EAAwF;AAC7F,QAAMC,iBAAiB,GAAGC,MAAM,CAACC,IAAP,CAAYL,gBAAZ,CAA1B;AACA,MAAIM,WAAW,GAAGH,iBAAiB,CAACI,MAApC;AACA,MAAIC,iBAAiB,GAAG,IAAxB;AACA,QAAMC,iBAAiB,GAAG,EAA1B;AACA,MAAIC,SAAS,GAAGX,EAAhB;AACA,MAAIY,WAAW,GAAG,EAAlB;;AAEA,MAAIL,WAAW,GAAG,CAAd,IAAmBL,oBAAvB,EAA6C;AAC3C,UAAMW,OAAO,GAAGF,SAAS,CAACG,KAAV,CAAgB,IAAhB,CAAhB;AACA,UAAMC,aAAa,GAAGF,OAAO,CAACG,KAAR,EAAtB;AACAH,IAAAA,OAAO,CAACI,OAAR,CAAgB,CAACC,IAAD,EAAOC,KAAP,EAAcC,KAAd,KAAwB;AAEtC,UAAIb,WAAW,GAAG,CAAlB,EAAqB;AACnB,cAAMc,OAAO,GAAGC,0BAA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,CAAP,CAA5C;;AACA,MAAI,CAACuB,gBAAL,EAAuB;AACrB,WAAO,IAAP;AACD;;AACD,SAAOA,gBAAgB,CAACC,IAAjB,KAA0BF,OAA1B,GAAoCC,gBAAgB,CAACE,IAArD,GAA4D,IAAnE;AACD;AAGD,OAAO,SAASrB,0BAAT,CAAoCJ,IAApC,EAA0C0B,UAA1C,EAAsD;AAC3D,QAAMlC,iBAAiB,GAAG,EAA1B;AACA,QAAMmC,aAAa,GAAGT,sBAAsB,CAAClB,IAAD,CAA5C;;AACA,MAAI,CAAC2B,aAAL,EAAoB;AAClB,WAAO,IAAP;AACD;;AACD,QAAM;AAACF,IAAAA,IAAD;AAAOD,IAAAA;AAAP,MAAeG,aAArB;;AACA,MAAIH,IAAI,IAAIE,UAAU,CAACF,IAAD,CAAtB,EAA8B;AAE5B,UAAMnB,WAAW,GAAI,OAAML,IAAK,0CAAhC;AACA,UAAM;AAACoB,MAAAA,WAAD;AAAcX,MAAAA,QAAd;AAAwBY,MAAAA;AAAxB,QAA+CF,sBAAsB,CAACK,IAAD,CAA3E;AAEA,UAAMI,QAAQ,GAAGnD,mBAAmB,CAACgD,IAAD,CAApC;AACA,UAAMI,iBAAiB,GAAI,KAAIJ,IAAK,IAAGD,IAAK,yBAAwBJ,WAAY,KAAIX,QAAS,KAAImB,QAAS,KAA1G;AAEApC,IAAAA,iBAAiB,CAAC4B,WAAD,CAAjB,GAAiCI,IAAjC;AACA,UAAMlB,MAAM,GAAG;AACb,kBAAYe,mBADC;AAEb,wBAAkBQ;AAFL,KAAf;AAMA,WAAO;AAELxB,MAAAA,WAFK;AAILC,MAAAA,MAJK;AAMLd,MAAAA;AANK,KAAP;AAQD;;AACD,SAAO,IAAP;AACD","sourcesContent":["import {assert} from '@luma.gl/webgl';\nimport {combineInjects, getQualifierDetails, typeToChannelSuffix} from '@luma.gl/shadertools';\n\nconst SAMPLER_UNIFORM_PREFIX = 'transform_uSampler_';\nconst SIZE_UNIFORM_PREFIX = 'transform_uSize_';\nconst VS_POS_VARIABLE = 'transform_position';\n\n// Scan provided vertex shader\n// for each texture attribute, inject sampler instructions and build uniforms for sampler\n// for texture target, get varying type and inject position instruction\nexport function updateForTextures({vs, sourceTextureMap, targetTextureVarying, targetTexture}) {\n const texAttributeNames = Object.keys(sourceTextureMap);\n let sourceCount = texAttributeNames.length;\n let targetTextureType = null;\n const samplerTextureMap = {};\n let updatedVs = vs;\n let finalInject = {};\n\n if (sourceCount > 0 || targetTextureVarying) {\n const vsLines = updatedVs.split('\\n');\n const updateVsLines = vsLines.slice();\n vsLines.forEach((line, index, lines) => {\n // TODO add early exit\n if (sourceCount > 0) {\n const updated = processAttributeDefinition(line, sourceTextureMap);\n if (updated) {\n const {updatedLine, inject} = updated;\n updateVsLines[index] = updatedLine;\n // sampleInstructions.push(sampleInstruction);\n finalInject = combineInjects([finalInject, inject]);\n Object.assign(samplerTextureMap, updated.samplerTextureMap);\n sourceCount--;\n }\n }\n if (targetTextureVarying && !targetTextureType) {\n targetTextureType = getVaryingType(line, targetTextureVarying);\n }\n });\n\n if (targetTextureVarying) {\n assert(targetTexture);\n const sizeName = `${SIZE_UNIFORM_PREFIX}${targetTextureVarying}`;\n\n const uniformDeclaration = `uniform vec2 ${sizeName};\\n`;\n const posInstructions = `\\\n vec2 ${VS_POS_VARIABLE} = transform_getPos(${sizeName});\n gl_Position = vec4(${VS_POS_VARIABLE}, 0, 1.);\\n`;\n const inject = {\n 'vs:#decl': uniformDeclaration,\n 'vs:#main-start': posInstructions\n };\n finalInject = combineInjects([finalInject, inject]);\n }\n updatedVs = updateVsLines.join('\\n');\n }\n return {\n // updated vertex shader (commented texture attribute definition)\n vs: updatedVs,\n // type (float, vec2, vec3 of vec4) target texture varying\n targetTextureType,\n // required vertex and fragment shader injects\n inject: finalInject,\n // map of sampler name to texture name, can be used to set attributes\n // usefull when swapping textures, as source and destination texture change when swap is called.\n samplerTextureMap\n };\n}\n\n// builds and returns an object contaning size uniform for each texture\nexport function getSizeUniforms({sourceTextureMap, targetTextureVarying, targetTexture}) {\n const uniforms = {};\n let width;\n let height;\n if (targetTextureVarying) {\n ({width, height} = targetTexture);\n uniforms[`${SIZE_UNIFORM_PREFIX}${targetTextureVarying}`] = [width, height];\n }\n for (const textureName in sourceTextureMap) {\n ({width, height} = sourceTextureMap[textureName]);\n uniforms[`${SIZE_UNIFORM_PREFIX}${textureName}`] = [width, height];\n }\n return uniforms;\n}\n\n// Checks if provided line is defining an attribute, if so returns details otherwise null\nfunction getAttributeDefinition(line) {\n return getQualifierDetails(line, ['attribute', 'in']);\n}\n\nfunction getSamplerDeclerations(textureName) {\n const samplerName = `${SAMPLER_UNIFORM_PREFIX}${textureName}`;\n const sizeName = `${SIZE_UNIFORM_PREFIX}${textureName}`;\n const uniformDeclerations = `\\\n uniform sampler2D ${samplerName};\n uniform vec2 ${sizeName};`;\n return {samplerName, sizeName, uniformDeclerations};\n}\n\n// Return size (float, vec2 etc) of a given varying, null if doens't exist.\nexport function getVaryingType(line, varying) {\n const qualaiferDetails = getQualifierDetails(line, ['varying', 'out']);\n if (!qualaiferDetails) {\n return null;\n }\n return qualaiferDetails.name === varying ? qualaiferDetails.type : null;\n}\n\n// build required definitions, sample instructions for each texture attribute\nexport function processAttributeDefinition(line, textureMap) {\n const samplerTextureMap = {};\n const attributeData = getAttributeDefinition(line);\n if (!attributeData) {\n return null;\n }\n const {type, name} = attributeData;\n if (name && textureMap[name]) {\n // eslint-disable-next-line no-useless-escape\n const updatedLine = `\\// ${line} => Replaced by Transform with a sampler`;\n const {samplerName, sizeName, uniformDeclerations} = getSamplerDeclerations(name);\n\n const channels = typeToChannelSuffix(type);\n const sampleInstruction = ` ${type} ${name} = transform_getInput(${samplerName}, ${sizeName}).${channels};\\n`;\n\n samplerTextureMap[samplerName] = name;\n const inject = {\n 'vs:#decl': uniformDeclerations,\n 'vs:#main-start': sampleInstruction\n };\n\n // samplerNameMap\n return {\n // update vertex shader line.\n updatedLine,\n // inject object with sampler instructions.\n inject,\n // sampler name to texture name map\n samplerTextureMap\n };\n }\n return null;\n}\n"],"file":"transform-shader-utils.js"}
1
+ {"version":3,"file":"transform-shader-utils.js","names":["assert","combineInjects","getQualifierDetails","typeToChannelSuffix","SAMPLER_UNIFORM_PREFIX","SIZE_UNIFORM_PREFIX","VS_POS_VARIABLE","updateForTextures","vs","sourceTextureMap","targetTextureVarying","targetTexture","texAttributeNames","Object","keys","sourceCount","length","targetTextureType","samplerTextureMap","updatedVs","finalInject","vsLines","split","updateVsLines","slice","forEach","line","index","lines","updated","processAttributeDefinition","updatedLine","inject","assign","getVaryingType","sizeName","uniformDeclaration","posInstructions","join","getSizeUniforms","uniforms","width","height","textureName","getAttributeDefinition","getSamplerDeclerations","samplerName","uniformDeclerations","varying","qualaiferDetails","name","type","textureMap","attributeData","channels","sampleInstruction"],"sources":["../../../src/transform/transform-shader-utils.js"],"sourcesContent":["import {assert} from '@luma.gl/webgl';\nimport {combineInjects, getQualifierDetails, typeToChannelSuffix} from '@luma.gl/shadertools';\n\nconst SAMPLER_UNIFORM_PREFIX = 'transform_uSampler_';\nconst SIZE_UNIFORM_PREFIX = 'transform_uSize_';\nconst VS_POS_VARIABLE = 'transform_position';\n\n// Scan provided vertex shader\n// for each texture attribute, inject sampler instructions and build uniforms for sampler\n// for texture target, get varying type and inject position instruction\nexport function updateForTextures({vs, sourceTextureMap, targetTextureVarying, targetTexture}) {\n const texAttributeNames = Object.keys(sourceTextureMap);\n let sourceCount = texAttributeNames.length;\n let targetTextureType = null;\n const samplerTextureMap = {};\n let updatedVs = vs;\n let finalInject = {};\n\n if (sourceCount > 0 || targetTextureVarying) {\n const vsLines = updatedVs.split('\\n');\n const updateVsLines = vsLines.slice();\n vsLines.forEach((line, index, lines) => {\n // TODO add early exit\n if (sourceCount > 0) {\n const updated = processAttributeDefinition(line, sourceTextureMap);\n if (updated) {\n const {updatedLine, inject} = updated;\n updateVsLines[index] = updatedLine;\n // sampleInstructions.push(sampleInstruction);\n finalInject = combineInjects([finalInject, inject]);\n Object.assign(samplerTextureMap, updated.samplerTextureMap);\n sourceCount--;\n }\n }\n if (targetTextureVarying && !targetTextureType) {\n targetTextureType = getVaryingType(line, targetTextureVarying);\n }\n });\n\n if (targetTextureVarying) {\n assert(targetTexture);\n const sizeName = `${SIZE_UNIFORM_PREFIX}${targetTextureVarying}`;\n\n const uniformDeclaration = `uniform vec2 ${sizeName};\\n`;\n const posInstructions = `\\\n vec2 ${VS_POS_VARIABLE} = transform_getPos(${sizeName});\n gl_Position = vec4(${VS_POS_VARIABLE}, 0, 1.);\\n`;\n const inject = {\n 'vs:#decl': uniformDeclaration,\n 'vs:#main-start': posInstructions\n };\n finalInject = combineInjects([finalInject, inject]);\n }\n updatedVs = updateVsLines.join('\\n');\n }\n return {\n // updated vertex shader (commented texture attribute definition)\n vs: updatedVs,\n // type (float, vec2, vec3 of vec4) target texture varying\n targetTextureType,\n // required vertex and fragment shader injects\n inject: finalInject,\n // map of sampler name to texture name, can be used to set attributes\n // usefull when swapping textures, as source and destination texture change when swap is called.\n samplerTextureMap\n };\n}\n\n// builds and returns an object contaning size uniform for each texture\nexport function getSizeUniforms({sourceTextureMap, targetTextureVarying, targetTexture}) {\n const uniforms = {};\n let width;\n let height;\n if (targetTextureVarying) {\n ({width, height} = targetTexture);\n uniforms[`${SIZE_UNIFORM_PREFIX}${targetTextureVarying}`] = [width, height];\n }\n for (const textureName in sourceTextureMap) {\n ({width, height} = sourceTextureMap[textureName]);\n uniforms[`${SIZE_UNIFORM_PREFIX}${textureName}`] = [width, height];\n }\n return uniforms;\n}\n\n// Checks if provided line is defining an attribute, if so returns details otherwise null\nfunction getAttributeDefinition(line) {\n return getQualifierDetails(line, ['attribute', 'in']);\n}\n\nfunction getSamplerDeclerations(textureName) {\n const samplerName = `${SAMPLER_UNIFORM_PREFIX}${textureName}`;\n const sizeName = `${SIZE_UNIFORM_PREFIX}${textureName}`;\n const uniformDeclerations = `\\\n uniform sampler2D ${samplerName};\n uniform vec2 ${sizeName};`;\n return {samplerName, sizeName, uniformDeclerations};\n}\n\n// Return size (float, vec2 etc) of a given varying, null if doens't exist.\nexport function getVaryingType(line, varying) {\n const qualaiferDetails = getQualifierDetails(line, ['varying', 'out']);\n if (!qualaiferDetails) {\n return null;\n }\n return qualaiferDetails.name === varying ? qualaiferDetails.type : null;\n}\n\n// build required definitions, sample instructions for each texture attribute\nexport function processAttributeDefinition(line, textureMap) {\n const samplerTextureMap = {};\n const attributeData = getAttributeDefinition(line);\n if (!attributeData) {\n return null;\n }\n const {type, name} = attributeData;\n if (name && textureMap[name]) {\n // eslint-disable-next-line no-useless-escape\n const updatedLine = `\\// ${line} => Replaced by Transform with a sampler`;\n const {samplerName, sizeName, uniformDeclerations} = getSamplerDeclerations(name);\n\n const channels = typeToChannelSuffix(type);\n const sampleInstruction = ` ${type} ${name} = transform_getInput(${samplerName}, ${sizeName}).${channels};\\n`;\n\n samplerTextureMap[samplerName] = name;\n const inject = {\n 'vs:#decl': uniformDeclerations,\n 'vs:#main-start': sampleInstruction\n };\n\n // samplerNameMap\n return {\n // update vertex shader line.\n updatedLine,\n // inject object with sampler instructions.\n inject,\n // sampler name to texture name map\n samplerTextureMap\n };\n }\n return null;\n}\n"],"mappings":"AAAA,SAAQA,MAAR,QAAqB,gBAArB;AACA,SAAQC,cAAR,EAAwBC,mBAAxB,EAA6CC,mBAA7C,QAAuE,sBAAvE;AAEA,MAAMC,sBAAsB,GAAG,qBAA/B;AACA,MAAMC,mBAAmB,GAAG,kBAA5B;AACA,MAAMC,eAAe,GAAG,oBAAxB;AAKA,OAAO,SAASC,iBAAT,OAAwF;EAAA,IAA7D;IAACC,EAAD;IAAKC,gBAAL;IAAuBC,oBAAvB;IAA6CC;EAA7C,CAA6D;EAC7F,MAAMC,iBAAiB,GAAGC,MAAM,CAACC,IAAP,CAAYL,gBAAZ,CAA1B;EACA,IAAIM,WAAW,GAAGH,iBAAiB,CAACI,MAApC;EACA,IAAIC,iBAAiB,GAAG,IAAxB;EACA,M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(gl) {
13
+ let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
13
14
  this.gl = gl;
14
15
  this.model = null;
15
16
  this.elementCount = 0;
@@ -42,7 +43,8 @@ export default class Transform {
42
43
  }
43
44
  }
44
45
 
45
- run(opts = {}) {
46
+ run() {
47
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
46
48
  const {
47
49
  clearRenderTarget = true
48
50
  } = opts;
@@ -69,11 +71,13 @@ export default class Transform {
69
71
  assert(swapped, 'Nothing to swap');
70
72
  }
71
73
 
72
- getBuffer(varyingName = null) {
74
+ getBuffer() {
75
+ let varyingName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
73
76
  return this.bufferTransform && this.bufferTransform.getBuffer(varyingName);
74
77
  }
75
78
 
76
- getData(opts = {}) {
79
+ getData() {
80
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
77
81
  const resourceTransforms = [this.bufferTransform, this.textureTransform].filter(Boolean);
78
82
 
79
83
  for (const resourceTransform of resourceTransforms) {
@@ -91,7 +95,9 @@ export default class Transform {
91
95
  return this.textureTransform && this.textureTransform.getFramebuffer();
92
96
  }
93
97
 
94
- update(opts = {}) {
98
+ update() {
99
+ let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
100
+
95
101
  if ('elementCount' in opts) {
96
102
  this.model.setVertexCount(opts.elementCount);
97
103
  }
@@ -103,7 +109,8 @@ export default class Transform {
103
109
  }
104
110
  }
105
111
 
106
- _initialize(props = {}) {
112
+ _initialize() {
113
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
107
114
  const {
108
115
  gl
109
116
  } = this;