@luma.gl/shadertools 9.0.20 → 9.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dist.dev.js CHANGED
@@ -5213,15 +5213,15 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
5213
5213
  lightPosition0: [1, 1, 2],
5214
5214
  // TODO - could combine direction and attenuation
5215
5215
  lightDirection0: [1, 1, 1],
5216
- lightAttenuation0: [1, 1, 1],
5216
+ lightAttenuation0: [1, 0, 0],
5217
5217
  lightColor1: [1, 1, 1],
5218
5218
  lightPosition1: [1, 1, 2],
5219
5219
  lightDirection1: [1, 1, 1],
5220
- lightAttenuation1: [1, 1, 1],
5220
+ lightAttenuation1: [1, 0, 0],
5221
5221
  lightColor2: [1, 1, 1],
5222
5222
  lightPosition2: [1, 1, 2],
5223
5223
  lightDirection2: [1, 1, 1],
5224
- lightAttenuation2: [1, 1, 1]
5224
+ lightAttenuation2: [1, 0, 0]
5225
5225
  }
5226
5226
  };
5227
5227
  function getUniforms2(props, prevUniforms = {}) {
@@ -5260,7 +5260,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
5260
5260
  const i = currentLight;
5261
5261
  lightSourceUniforms[`lightColor${i}`] = convertColor(pointLight);
5262
5262
  lightSourceUniforms[`lightPosition${i}`] = pointLight.position;
5263
- lightSourceUniforms[`lightAttenuation${i}`] = [pointLight.attenuation || 1, 0, 0];
5263
+ lightSourceUniforms[`lightAttenuation${i}`] = pointLight.attenuation || [1, 0, 0];
5264
5264
  currentLight++;
5265
5265
  }
5266
5266
  for (const directionalLight of directionalLights) {
@@ -5429,7 +5429,11 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 positio
5429
5429
  specularColor: [0.15, 0.15, 0.15]
5430
5430
  },
5431
5431
  getUniforms(props) {
5432
- return { ...gouraudMaterial.defaultUniforms, ...props };
5432
+ const uniforms = { ...props };
5433
+ if (uniforms.specularColor) {
5434
+ uniforms.specularColor = uniforms.specularColor.map((x) => x / 255);
5435
+ }
5436
+ return { ...gouraudMaterial.defaultUniforms, ...uniforms };
5433
5437
  }
5434
5438
  };
5435
5439
 
@@ -5456,7 +5460,11 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 positio
5456
5460
  specularColor: [0.15, 0.15, 0.15]
5457
5461
  },
5458
5462
  getUniforms(props) {
5459
- return { ...phongMaterial.defaultUniforms, ...props };
5463
+ const uniforms = { ...props };
5464
+ if (uniforms.specularColor) {
5465
+ uniforms.specularColor = uniforms.specularColor.map((x) => x / 255);
5466
+ }
5467
+ return { ...phongMaterial.defaultUniforms, ...uniforms };
5460
5468
  }
5461
5469
  };
5462
5470
 
package/dist/dist.min.js CHANGED
@@ -360,7 +360,7 @@ return pointLight.attenuation.x
360
360
  + pointLight.attenuation.y * distance
361
361
  + pointLight.attenuation.z * distance * distance;
362
362
  }
363
- `;var Wn=rt(ke(),1),jn=3,Oo=255,be;(function(n){n[n.POINT=0]="POINT",n[n.DIRECTIONAL=1]="DIRECTIONAL"})(be||(be={}));var Q={name:"lighting",vs:jt,fs:jt,getUniforms(n,e){return Uo(n)},defines:{MAX_LIGHTS:jn},uniformTypes:{enabled:"i32",lightType:"i32",directionalLightCount:"i32",pointLightCount:"i32",ambientLightColor:"vec3<f32>",lightColor0:"vec3<f32>",lightPosition0:"vec3<f32>",lightDirection0:"vec3<f32>",lightAttenuation0:"vec3<f32>",lightColor1:"vec3<f32>",lightPosition1:"vec3<f32>",lightDirection1:"vec3<f32>",lightAttenuation1:"vec3<f32>",lightColor2:"vec3<f32>",lightPosition2:"vec3<f32>",lightDirection2:"vec3<f32>",lightAttenuation2:"vec3<f32>"},defaultUniforms:{enabled:1,lightType:be.POINT,directionalLightCount:0,pointLightCount:0,ambientLightColor:[.1,.1,.1],lightColor0:[1,1,1],lightPosition0:[1,1,2],lightDirection0:[1,1,1],lightAttenuation0:[1,1,1],lightColor1:[1,1,1],lightPosition1:[1,1,2],lightDirection1:[1,1,1],lightAttenuation1:[1,1,1],lightColor2:[1,1,1],lightPosition2:[1,1,2],lightDirection2:[1,1,1],lightAttenuation2:[1,1,1]}};function Uo(n,e={}){if(n=n&&{...n},!n)return{...Q.defaultUniforms};n.lights&&(n={...n,...Do(n.lights),lights:void 0});let{ambientLight:t,pointLights:r,directionalLights:o}=n||{};if(!(t||r&&r.length>0||o&&o.length>0))return{...Q.defaultUniforms,enabled:0};let a={...Q.defaultUniforms,...e,...zo({ambientLight:t,pointLights:r,directionalLights:o})};return n.enabled!==void 0&&(a.enabled=n.enabled?1:0),a}function zo({ambientLight:n,pointLights:e=[],directionalLights:t=[]}){let r={};r.ambientLightColor=$t(n);let o=0;for(let i of e){r.lightType=be.POINT;let a=o;r[`lightColor${a}`]=$t(i),r[`lightPosition${a}`]=i.position,r[`lightAttenuation${a}`]=[i.attenuation||1,0,0],o++}for(let i of t){r.lightType=be.DIRECTIONAL;let a=o;r[`lightColor${a}`]=$t(i),r[`lightDirection${a}`]=i.direction,o++}return o>jn&&Wn.log.warn("MAX_LIGHTS exceeded")(),r.directionalLightCount=t.length,r.pointLightCount=e.length,r}function Do(n){let e={pointLights:[],directionalLights:[]};for(let t of n||[])switch(t.type){case"ambient":e.ambientLight=t;break;case"directional":e.directionalLights?.push(t);break;case"point":e.pointLights?.push(t);break;default:}return e}function $t(n={}){let{color:e=[0,0,0],intensity:t=1}=n;return e.map(r=>r*t/Oo)}var Yo=`out vec3 dirlight_vNormal;
363
+ `;var Wn=rt(ke(),1),jn=3,Oo=255,be;(function(n){n[n.POINT=0]="POINT",n[n.DIRECTIONAL=1]="DIRECTIONAL"})(be||(be={}));var Q={name:"lighting",vs:jt,fs:jt,getUniforms(n,e){return Uo(n)},defines:{MAX_LIGHTS:jn},uniformTypes:{enabled:"i32",lightType:"i32",directionalLightCount:"i32",pointLightCount:"i32",ambientLightColor:"vec3<f32>",lightColor0:"vec3<f32>",lightPosition0:"vec3<f32>",lightDirection0:"vec3<f32>",lightAttenuation0:"vec3<f32>",lightColor1:"vec3<f32>",lightPosition1:"vec3<f32>",lightDirection1:"vec3<f32>",lightAttenuation1:"vec3<f32>",lightColor2:"vec3<f32>",lightPosition2:"vec3<f32>",lightDirection2:"vec3<f32>",lightAttenuation2:"vec3<f32>"},defaultUniforms:{enabled:1,lightType:be.POINT,directionalLightCount:0,pointLightCount:0,ambientLightColor:[.1,.1,.1],lightColor0:[1,1,1],lightPosition0:[1,1,2],lightDirection0:[1,1,1],lightAttenuation0:[1,0,0],lightColor1:[1,1,1],lightPosition1:[1,1,2],lightDirection1:[1,1,1],lightAttenuation1:[1,0,0],lightColor2:[1,1,1],lightPosition2:[1,1,2],lightDirection2:[1,1,1],lightAttenuation2:[1,0,0]}};function Uo(n,e={}){if(n=n&&{...n},!n)return{...Q.defaultUniforms};n.lights&&(n={...n,...Do(n.lights),lights:void 0});let{ambientLight:t,pointLights:r,directionalLights:o}=n||{};if(!(t||r&&r.length>0||o&&o.length>0))return{...Q.defaultUniforms,enabled:0};let a={...Q.defaultUniforms,...e,...zo({ambientLight:t,pointLights:r,directionalLights:o})};return n.enabled!==void 0&&(a.enabled=n.enabled?1:0),a}function zo({ambientLight:n,pointLights:e=[],directionalLights:t=[]}){let r={};r.ambientLightColor=$t(n);let o=0;for(let i of e){r.lightType=be.POINT;let a=o;r[`lightColor${a}`]=$t(i),r[`lightPosition${a}`]=i.position,r[`lightAttenuation${a}`]=i.attenuation||[1,0,0],o++}for(let i of t){r.lightType=be.DIRECTIONAL;let a=o;r[`lightColor${a}`]=$t(i),r[`lightDirection${a}`]=i.direction,o++}return o>jn&&Wn.log.warn("MAX_LIGHTS exceeded")(),r.directionalLightCount=t.length,r.pointLightCount=e.length,r}function Do(n){let e={pointLights:[],directionalLights:[]};for(let t of n||[])switch(t.type){case"ambient":e.ambientLight=t;break;case"directional":e.directionalLights?.push(t);break;case"point":e.pointLights?.push(t);break;default:}return e}function $t(n={}){let{color:e=[0,0,0],intensity:t=1}=n;return e.map(r=>r*t/Oo)}var Yo=`out vec3 dirlight_vNormal;
364
364
  void dirlight_setNormal(vec3 normal) {
365
365
  dirlight_vNormal = normalize(normal);
366
366
  }
@@ -416,7 +416,7 @@ lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction,
416
416
  }
417
417
  return lightColor;
418
418
  }
419
- `;var Zt={name:"gouraudMaterial",vs:We.replace("phongMaterial","gouraudMaterial"),fs:Ge.replace("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:1},dependencies:[Q],uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(n){return{...Zt.defaultUniforms,...n}}};var Jt={name:"phongMaterial",vs:Ge,fs:We,defines:{LIGHTING_FRAGMENT:1},dependencies:[Q],uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(n){return{...Jt.defaultUniforms,...n}}};var $n=`uniform projection {
419
+ `;var Zt={name:"gouraudMaterial",vs:We.replace("phongMaterial","gouraudMaterial"),fs:Ge.replace("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:1},dependencies:[Q],uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(n){let e={...n};return e.specularColor&&(e.specularColor=e.specularColor.map(t=>t/255)),{...Zt.defaultUniforms,...e}}};var Jt={name:"phongMaterial",vs:Ge,fs:We,defines:{LIGHTING_FRAGMENT:1},dependencies:[Q],uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(n){let e={...n};return e.specularColor&&(e.specularColor=e.specularColor.map(t=>t/255)),{...Jt.defaultUniforms,...e}}};var $n=`uniform projection {
420
420
  mat4 u_MVPMatrix;
421
421
  mat4 u_ModelMatrix;
422
422
  mat4 u_NormalMatrix;
package/dist/index.cjs CHANGED
@@ -1619,15 +1619,15 @@ var lighting = {
1619
1619
  lightPosition0: [1, 1, 2],
1620
1620
  // TODO - could combine direction and attenuation
1621
1621
  lightDirection0: [1, 1, 1],
1622
- lightAttenuation0: [1, 1, 1],
1622
+ lightAttenuation0: [1, 0, 0],
1623
1623
  lightColor1: [1, 1, 1],
1624
1624
  lightPosition1: [1, 1, 2],
1625
1625
  lightDirection1: [1, 1, 1],
1626
- lightAttenuation1: [1, 1, 1],
1626
+ lightAttenuation1: [1, 0, 0],
1627
1627
  lightColor2: [1, 1, 1],
1628
1628
  lightPosition2: [1, 1, 2],
1629
1629
  lightDirection2: [1, 1, 1],
1630
- lightAttenuation2: [1, 1, 1]
1630
+ lightAttenuation2: [1, 0, 0]
1631
1631
  }
1632
1632
  };
1633
1633
  function getUniforms2(props, prevUniforms = {}) {
@@ -1662,7 +1662,7 @@ function getLightSourceUniforms({ ambientLight, pointLights = [], directionalLig
1662
1662
  const i = currentLight;
1663
1663
  lightSourceUniforms[`lightColor${i}`] = convertColor(pointLight);
1664
1664
  lightSourceUniforms[`lightPosition${i}`] = pointLight.position;
1665
- lightSourceUniforms[`lightAttenuation${i}`] = [pointLight.attenuation || 1, 0, 0];
1665
+ lightSourceUniforms[`lightAttenuation${i}`] = pointLight.attenuation || [1, 0, 0];
1666
1666
  currentLight++;
1667
1667
  }
1668
1668
  for (const directionalLight of directionalLights) {
@@ -1816,7 +1816,11 @@ var gouraudMaterial = {
1816
1816
  specularColor: [0.15, 0.15, 0.15]
1817
1817
  },
1818
1818
  getUniforms(props) {
1819
- return { ...gouraudMaterial.defaultUniforms, ...props };
1819
+ const uniforms = { ...props };
1820
+ if (uniforms.specularColor) {
1821
+ uniforms.specularColor = uniforms.specularColor.map((x) => x / 255);
1822
+ }
1823
+ return { ...gouraudMaterial.defaultUniforms, ...uniforms };
1820
1824
  }
1821
1825
  };
1822
1826
 
@@ -1843,7 +1847,11 @@ var phongMaterial = {
1843
1847
  specularColor: [0.15, 0.15, 0.15]
1844
1848
  },
1845
1849
  getUniforms(props) {
1846
- return { ...phongMaterial.defaultUniforms, ...props };
1850
+ const uniforms = { ...props };
1851
+ if (uniforms.specularColor) {
1852
+ uniforms.specularColor = uniforms.specularColor.map((x) => x / 255);
1853
+ }
1854
+ return { ...phongMaterial.defaultUniforms, ...uniforms };
1847
1855
  }
1848
1856
  };
1849
1857