three-stdlib 2.19.0 → 2.20.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");class t extends e.Mesh{constructor(t,i){this.lightProbe=t,this.size=i;const r=new e.ShaderMaterial({type:"LightProbeHelperMaterial",uniforms:{sh:{value:this.lightProbe.sh.coefficients},intensity:{value:this.lightProbe.intensity}},vertexShader:["varying vec3 vNormal;","void main() {","\tvNormal = normalize( normalMatrix * normal );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#define RECIPROCAL_PI 0.318309886","vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {","\t// matrix is assumed to be orthogonal","\treturn normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );","}","// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf","vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {","\t// normal is assumed to have unit length","\tfloat x = normal.x, y = normal.y, z = normal.z;","\t// band 0","\tvec3 result = shCoefficients[ 0 ] * 0.886227;","\t// band 1","\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;","\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;","\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;","\t// band 2","\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;","\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;","\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );","\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;","\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );","\treturn result;","}","uniform vec3 sh[ 9 ]; // sh coefficients","uniform float intensity; // light probe intensity","varying vec3 vNormal;","void main() {","\tvec3 normal = normalize( vNormal );","\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );","\tvec3 irradiance = shGetIrradianceAt( worldNormal, sh );","\tvec3 outgoingLight = RECIPROCAL_PI * irradiance * intensity;","\tgl_FragColor = linearToOutputTexel( vec4( outgoingLight, 1.0 ) );","}"].join("\n")});super(new e.SphereGeometry(1,32,16),r),this.type="LightProbeHelper",this.onBeforeRender()}dispose(){this.geometry.dispose(),this.material.dispose()}onBeforeRender(){this.position.copy(this.lightProbe.position),this.scale.set(1,1,1).multiplyScalar(this.size),this.material.uniforms.intensity.value=this.lightProbe.intensity}}exports.LightProbeHelper=t;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");class t extends e.Mesh{constructor(t,i){const r=new e.ShaderMaterial({type:"LightProbeHelperMaterial",uniforms:{sh:{value:this.lightProbe.sh.coefficients},intensity:{value:this.lightProbe.intensity}},vertexShader:["varying vec3 vNormal;","void main() {","\tvNormal = normalize( normalMatrix * normal );","\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#define RECIPROCAL_PI 0.318309886","vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {","\t// matrix is assumed to be orthogonal","\treturn normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );","}","// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf","vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {","\t// normal is assumed to have unit length","\tfloat x = normal.x, y = normal.y, z = normal.z;","\t// band 0","\tvec3 result = shCoefficients[ 0 ] * 0.886227;","\t// band 1","\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;","\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;","\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;","\t// band 2","\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;","\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;","\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );","\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;","\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );","\treturn result;","}","uniform vec3 sh[ 9 ]; // sh coefficients","uniform float intensity; // light probe intensity","varying vec3 vNormal;","void main() {","\tvec3 normal = normalize( vNormal );","\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );","\tvec3 irradiance = shGetIrradianceAt( worldNormal, sh );","\tvec3 outgoingLight = RECIPROCAL_PI * irradiance * intensity;","\tgl_FragColor = linearToOutputTexel( vec4( outgoingLight, 1.0 ) );","}"].join("\n")});super(new e.SphereGeometry(1,32,16),r),this.lightProbe=t,this.size=i,this.type="LightProbeHelper",this.onBeforeRender()}dispose(){this.geometry.dispose(),this.material.dispose()}onBeforeRender(){this.position.copy(this.lightProbe.position),this.scale.set(1,1,1).multiplyScalar(this.size),this.material.uniforms.intensity.value=this.lightProbe.intensity}}exports.LightProbeHelper=t;
@@ -2,8 +2,6 @@ import { Mesh, ShaderMaterial, SphereGeometry } from 'three';
2
2
 
3
3
  class LightProbeHelper extends Mesh {
4
4
  constructor(lightProbe, size) {
5
- this.lightProbe = lightProbe;
6
- this.size = size;
7
5
  const material = new ShaderMaterial({
8
6
  type: 'LightProbeHelperMaterial',
9
7
  uniforms: {
@@ -20,6 +18,8 @@ class LightProbeHelper extends Mesh {
20
18
  });
21
19
  const geometry = new SphereGeometry(1, 32, 16);
22
20
  super(geometry, material);
21
+ this.lightProbe = lightProbe;
22
+ this.size = size;
23
23
  this.type = 'LightProbeHelper';
24
24
  this.onBeforeRender();
25
25
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");class t extends e.Line{constructor(t,i,s,n){this.audio=t,this.range=i||1,this.divisionsInnerAngle=s||16,this.divisionsOuterAngle=n||2;const o=new e.BufferGeometry,r=this.divisionsInnerAngle+2*this.divisionsOuterAngle,a=new Float32Array(3*(3*r+3));o.setAttribute("position",new e.BufferAttribute(a,3));const l=new e.LineBasicMaterial({color:65280});super(o,[new e.LineBasicMaterial({color:16776960}),l]),this.type="PositionalAudioHelper",this.update()}update(){const t=this.audio,i=this.range,s=this.divisionsInnerAngle,n=this.divisionsOuterAngle,o=e.MathUtils.degToRad(t.panner.coneInnerAngle),r=e.MathUtils.degToRad(t.panner.coneOuterAngle),a=o/2,l=r/2;let d,h,u=0,c=0;const p=this.geometry,g=p.attributes.position;function A(e,t,s,n){const o=(t-e)/s;for(g.setXYZ(u,0,0,0),c++,d=e;d<t;d+=o)h=u+c,g.setXYZ(h,Math.sin(d)*i,0,Math.cos(d)*i),g.setXYZ(h+1,Math.sin(Math.min(d+o,t))*i,0,Math.cos(Math.min(d+o,t))*i),g.setXYZ(h+2,0,0,0),c+=3;p.addGroup(u,c,n),u+=c,c=0}p.clearGroups(),A(-l,-a,n,0),A(-a,a,s,1),A(a,l,n,0),g.needsUpdate=!0,o===r&&(this.material[0].visible=!1)}dispose(){this.geometry.dispose(),this.material[0].dispose(),this.material[1].dispose()}}exports.PositionalAudioHelper=t;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");class t extends e.Line{constructor(t,i=1,s=16,n=2){const o=new e.BufferGeometry,r=new Float32Array(3*(3*(s+2*n)+3));o.setAttribute("position",new e.BufferAttribute(r,3));const a=new e.LineBasicMaterial({color:65280});super(o,[new e.LineBasicMaterial({color:16776960}),a]),this.type="PositionalAudioHelper",this.audio=t,this.range=i,this.divisionsInnerAngle=s,this.divisionsOuterAngle=n,this.update()}update(){const t=this.audio,i=this.range,s=this.divisionsInnerAngle,n=this.divisionsOuterAngle,o=e.MathUtils.degToRad(t.panner.coneInnerAngle),r=e.MathUtils.degToRad(t.panner.coneOuterAngle),a=o/2,l=r/2;let d,h,u=0,c=0;const p=this.geometry,g=p.attributes.position;function A(e,t,s,n){const o=(t-e)/s;for(g.setXYZ(u,0,0,0),c++,d=e;d<t;d+=o)h=u+c,g.setXYZ(h,Math.sin(d)*i,0,Math.cos(d)*i),g.setXYZ(h+1,Math.sin(Math.min(d+o,t))*i,0,Math.cos(Math.min(d+o,t))*i),g.setXYZ(h+2,0,0,0),c+=3;p.addGroup(u,c,n),u+=c,c=0}p.clearGroups(),A(-l,-a,n,0),A(-a,a,s,1),A(a,l,n,0),g.needsUpdate=!0,o===r&&(this.material[0].visible=!1)}dispose(){this.geometry.dispose(),this.material[0].dispose(),this.material[1].dispose()}}exports.PositionalAudioHelper=t;
@@ -1,13 +1,9 @@
1
1
  import { Line, BufferGeometry, BufferAttribute, LineBasicMaterial, MathUtils } from 'three';
2
2
 
3
3
  class PositionalAudioHelper extends Line {
4
- constructor(audio, range, divisionsInnerAngle, divisionsOuterAngle) {
5
- this.audio = audio;
6
- this.range = range || 1;
7
- this.divisionsInnerAngle = divisionsInnerAngle || 16;
8
- this.divisionsOuterAngle = divisionsOuterAngle || 2;
4
+ constructor(audio, range = 1, divisionsInnerAngle = 16, divisionsOuterAngle = 2) {
9
5
  const geometry = new BufferGeometry();
10
- const divisions = this.divisionsInnerAngle + this.divisionsOuterAngle * 2;
6
+ const divisions = divisionsInnerAngle + divisionsOuterAngle * 2;
11
7
  const positions = new Float32Array((divisions * 3 + 3) * 3);
12
8
  geometry.setAttribute('position', new BufferAttribute(positions, 3));
13
9
  const materialInnerAngle = new LineBasicMaterial({
@@ -18,6 +14,10 @@ class PositionalAudioHelper extends Line {
18
14
  });
19
15
  super(geometry, [materialOuterAngle, materialInnerAngle]);
20
16
  this.type = 'PositionalAudioHelper';
17
+ this.audio = audio;
18
+ this.range = range;
19
+ this.divisionsInnerAngle = divisionsInnerAngle;
20
+ this.divisionsOuterAngle = divisionsOuterAngle;
21
21
  this.update();
22
22
  }
23
23
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three");class e extends t.Line{constructor(e,i){this.light=e,this.color=i;const r=new t.BufferGeometry;r.setAttribute("position",new t.Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere();super(r,new t.LineBasicMaterial({fog:!1})),this.type="RectAreaLightHelper";const s=new t.BufferGeometry;s.setAttribute("position",new t.Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.add(new t.Mesh(s,new t.MeshBasicMaterial({side:t.BackSide,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const t=this.material.color,e=Math.max(t.r,t.g,t.b);e>1&&t.multiplyScalar(1/e),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.copy(this.light.matrixWorld).scale(this.scale),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}exports.RectAreaLightHelper=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three");class e extends t.Line{constructor(e,i){const r=new t.BufferGeometry;r.setAttribute("position",new t.Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),r.computeBoundingSphere();super(r,new t.LineBasicMaterial({fog:!1})),this.type="RectAreaLightHelper",this.light=e,this.color=i;const s=new t.BufferGeometry;s.setAttribute("position",new t.Float32BufferAttribute([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),s.computeBoundingSphere(),this.add(new t.Mesh(s,new t.MeshBasicMaterial({side:t.BackSide,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const t=this.material.color,e=Math.max(t.r,t.g,t.b);e>1&&t.multiplyScalar(1/e),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.copy(this.light.matrixWorld).scale(this.scale),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}exports.RectAreaLightHelper=e;
@@ -6,9 +6,6 @@ import { Line, BufferGeometry, Float32BufferAttribute, LineBasicMaterial, Mesh,
6
6
 
7
7
  class RectAreaLightHelper extends Line {
8
8
  constructor(light, color) {
9
- this.light = light;
10
- this.color = color; // optional hardwired color for the helper
11
-
12
9
  const positions = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0];
13
10
  const geometry = new BufferGeometry();
14
11
  geometry.setAttribute('position', new Float32BufferAttribute(positions, 3));
@@ -17,7 +14,10 @@ class RectAreaLightHelper extends Line {
17
14
  fog: false
18
15
  });
19
16
  super(geometry, material);
20
- this.type = 'RectAreaLightHelper'; //
17
+ this.type = 'RectAreaLightHelper';
18
+ this.light = light;
19
+ this.color = color; // optional hardwired color for the helper
20
+ //
21
21
 
22
22
  const positions2 = [1, 1, 0, -1, 1, 0, -1, -1, 0, 1, 1, 0, -1, -1, 0, 1, -1, 0];
23
23
  const geometry2 = new BufferGeometry();