three-stdlib 2.18.1 → 2.19.1

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 t=require("@babel/runtime/helpers/defineProperty"),e=require("three");function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o=i(t);class r extends e.Object3D{constructor(t,i=[]){function r(t){return new e.Line(function(t){const i=new e.BufferGeometry,o=new Float32Array(3*(2+t.links.length));return i.setAttribute("position",new e.BufferAttribute(o,3)),i}(t),scope.lineMaterial)}super(),o.default(this,"_m",new e.Matrix4),o.default(this,"_v",new e.Vector3),this.root=t,this.iks=i,this.matrix.copy(t.matrixWorld),this.matrixAutoUpdate=!1,this.sphereGeometry=new e.SphereGeometry(.25,16,8),this.targetSphereMaterial=new e.MeshBasicMaterial({color:new e.Color(16746632),depthTest:!1,depthWrite:!1,transparent:!0}),this.effectorSphereMaterial=new e.MeshBasicMaterial({color:new e.Color(8978312),depthTest:!1,depthWrite:!1,transparent:!0}),this.linkSphereMaterial=new e.MeshBasicMaterial({color:new e.Color(8947967),depthTest:!1,depthWrite:!1,transparent:!0}),this.lineMaterial=new e.LineBasicMaterial({color:new e.Color(16711680),depthTest:!1,depthWrite:!1,transparent:!0});for(let t=0,o=i.length;t<o;t++){const o=i[t];this.add(new e.Mesh(scope.sphereGeometry,scope.targetSphereMaterial)),this.add(new e.Mesh(scope.sphereGeometry,scope.effectorSphereMaterial));for(let t=0,i=o.links.length;t<i;t++)this.add(new e.Mesh(scope.sphereGeometry,scope.linkSphereMaterial));this.add(r(o))}}_getPosition(t,e){return this._v.setFromMatrixPosition(t.matrixWorld).applyMatrix4(e)}_setPositionOfBoneToAttributeArray(t,e,i,o){const r=this._getPosition(i,o);t[3*e+0]=r.x,t[3*e+1]=r.y,t[3*e+2]=r.z}updateMatrixWorld(t){const e=this.root;if(this.visible){let t=0;const i=this.iks,o=e.skeleton.bones;this._m.copy(e.matrixWorld).invert();for(let e=0,r=i.length;e<r;e++){const r=i[e],s=o[r.target],n=o[r.effector],a=this.children[t++],h=this.children[t++];a.position.copy(this._getPosition(s,this._m)),h.position.copy(this._getPosition(n,this._m));for(let e=0,i=r.links.length;e<i;e++){const i=o[r.links[e].index];this.children[t++].position.copy(this._getPosition(i,this._m))}const l=this.children[t++],c=l.geometry.attributes.position.array;this._setPositionOfBoneToAttributeArray(c,0,s,this._m),this._setPositionOfBoneToAttributeArray(c,1,n,this._m);for(let t=0,e=r.links.length;t<e;t++){const e=o[r.links[t].index];this._setPositionOfBoneToAttributeArray(c,t+2,e,this._m)}l.geometry.attributes.position.needsUpdate=!0}}this.matrix.copy(e.matrixWorld),super.updateMatrixWorld(t)}}exports.CCDIKHelper=r,exports.CCDIKSolver=class{constructor(t,i){o.default(this,"q",new e.Quaternion),o.default(this,"targetPos",new e.Vector3),o.default(this,"targetVec",new e.Vector3),o.default(this,"effectorPos",new e.Vector3),o.default(this,"effectorVec",new e.Vector3),o.default(this,"linkPos",new e.Vector3),o.default(this,"invLinkQ",new e.Quaternion),o.default(this,"linkScale",new e.Vector3),o.default(this,"axis",new e.Vector3),o.default(this,"vector",new e.Vector3),this.mesh=t,this.iks=i;const r=this.mesh.skeleton.bones;for(let t=0,e=this.iks.length;t<e;t++){const e=this.iks[t],i=r[e.effector],o=e.links;let s,n;s=i;for(let t=0,e=o.length;t<e;t++)n=r[o[t].index],s.parent!==n&&console.warn(`THREE.CCDIKSolver: bone ${s.name} is not the child of bone ${n.name}`),s=n}}update(){const t=this.mesh.skeleton.bones,e=this.iks,i=Math;for(let o=0,r=e.length;o<r;o++){const r=e[o],s=t[r.effector],n=t[r.target];this.targetPos.setFromMatrixPosition(n.matrixWorld);const a=r.links,h=void 0!==r.iteration?r.iteration:1;for(let e=0;e<h;e++){let e=!1;for(let o=0,n=a.length;o<n;o++){const n=t[a[o].index];if(!1===a[o].enabled)break;const h=a[o].limitation,l=a[o].rotationMin,c=a[o].rotationMax;n.matrixWorld.decompose(this.linkPos,this.invLinkQ,this.linkScale),this.invLinkQ.invert(),this.effectorPos.setFromMatrixPosition(s.matrixWorld),this.effectorVec.subVectors(this.effectorPos,this.linkPos),this.effectorVec.applyQuaternion(this.invLinkQ),this.effectorVec.normalize(),this.targetVec.subVectors(this.targetPos,this.linkPos),this.targetVec.applyQuaternion(this.invLinkQ),this.targetVec.normalize();let f=this.targetVec.dot(this.effectorVec);if(f>1?f=1:f<-1&&(f=-1),f=i.acos(f),!(f<1e-5)){if(void 0!==r.minAngle&&f<r.minAngle&&(f=r.minAngle),void 0!==r.maxAngle&&f>r.maxAngle&&(f=r.maxAngle),this.axis.crossVectors(this.effectorVec,this.targetVec),this.axis.normalize(),this.q.setFromAxisAngle(this.axis,f),n.quaternion.multiply(this.q),void 0!==h){let t=n.quaternion.w;t>1&&(t=1);const e=i.sqrt(1-t*t);n.quaternion.set(h.x*e,h.y*e,h.z*e,t)}void 0!==l&&n.rotation.setFromVector3(this.vector.setFromEuler(n.rotation).max(l)),void 0!==c&&n.rotation.setFromVector3(this.vector.setFromEuler(n.rotation).min(c)),n.updateMatrixWorld(!0),e=!0}}if(!e)break}}return this}createHelper(){return new r(this.mesh,this.mesh.geometry.userData.MMD.iks)}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@babel/runtime/helpers/defineProperty"),e=require("three");function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var r=i(t);class s extends e.Object3D{constructor(t,i=[],s=.25){super(),r.default(this,"_m",new e.Matrix4),r.default(this,"_v",new e.Vector3),this.root=t,this.iks=i,this.matrix.copy(t.matrixWorld),this.matrixAutoUpdate=!1,this.sphereGeometry=new e.SphereGeometry(s,16,8),this.targetSphereMaterial=new e.MeshBasicMaterial({color:new e.Color(16746632),depthTest:!1,depthWrite:!1,transparent:!0}),this.effectorSphereMaterial=new e.MeshBasicMaterial({color:new e.Color(8978312),depthTest:!1,depthWrite:!1,transparent:!0}),this.linkSphereMaterial=new e.MeshBasicMaterial({color:new e.Color(8947967),depthTest:!1,depthWrite:!1,transparent:!0}),this.lineMaterial=new e.LineBasicMaterial({color:new e.Color(16711680),depthTest:!1,depthWrite:!1,transparent:!0});const o=this;function n(t){return new e.Line(function(t){const i=new e.BufferGeometry,r=new Float32Array(3*(2+t.links.length));return i.setAttribute("position",new e.BufferAttribute(r,3)),i}(t),o.lineMaterial)}for(let t=0,r=i.length;t<r;t++){const r=i[t];this.add(new e.Mesh(o.sphereGeometry,o.targetSphereMaterial)),this.add(new e.Mesh(o.sphereGeometry,o.effectorSphereMaterial));for(let t=0,i=r.links.length;t<i;t++)this.add(new e.Mesh(o.sphereGeometry,o.linkSphereMaterial));this.add(n(r))}}_getPosition(t,e){return this._v.setFromMatrixPosition(t.matrixWorld).applyMatrix4(e)}_setPositionOfBoneToAttributeArray(t,e,i,r){const s=this._getPosition(i,r);t[3*e+0]=s.x,t[3*e+1]=s.y,t[3*e+2]=s.z}updateMatrixWorld(t){const e=this.root;if(this.visible){let t=0;const i=this.iks,r=e.skeleton.bones;this._m.copy(e.matrixWorld).invert();for(let e=0,s=i.length;e<s;e++){const s=i[e],o=r[s.target],n=r[s.effector],a=this.children[t++],h=this.children[t++];a.position.copy(this._getPosition(o,this._m)),h.position.copy(this._getPosition(n,this._m));for(let e=0,i=s.links.length;e<i;e++){const i=r[s.links[e].index];this.children[t++].position.copy(this._getPosition(i,this._m))}const l=this.children[t++],c=l.geometry.attributes.position.array;this._setPositionOfBoneToAttributeArray(c,0,o,this._m),this._setPositionOfBoneToAttributeArray(c,1,n,this._m);for(let t=0,e=s.links.length;t<e;t++){const e=r[s.links[t].index];this._setPositionOfBoneToAttributeArray(c,t+2,e,this._m)}l.geometry.attributes.position.needsUpdate=!0}}this.matrix.copy(e.matrixWorld),super.updateMatrixWorld(t)}}exports.CCDIKHelper=s,exports.CCDIKSolver=class{constructor(t,i){r.default(this,"q",new e.Quaternion),r.default(this,"targetPos",new e.Vector3),r.default(this,"targetVec",new e.Vector3),r.default(this,"effectorPos",new e.Vector3),r.default(this,"effectorVec",new e.Vector3),r.default(this,"linkPos",new e.Vector3),r.default(this,"invLinkQ",new e.Quaternion),r.default(this,"linkScale",new e.Vector3),r.default(this,"axis",new e.Vector3),r.default(this,"vector",new e.Vector3),this.mesh=t,this.iks=i;const s=this.mesh.skeleton.bones;for(let t=0,e=this.iks.length;t<e;t++){const e=this.iks[t],i=s[e.effector],r=e.links;let o,n;o=i;for(let t=0,e=r.length;t<e;t++)n=s[r[t].index],o.parent!==n&&console.warn(`THREE.CCDIKSolver: bone ${o.name} is not the child of bone ${n.name}`),o=n}}update(){const t=this.mesh.skeleton.bones,e=this.iks,i=Math;for(let r=0,s=e.length;r<s;r++){const s=e[r],o=t[s.effector],n=t[s.target];this.targetPos.setFromMatrixPosition(n.matrixWorld);const a=s.links,h=void 0!==s.iteration?s.iteration:1;for(let e=0;e<h;e++){let e=!1;for(let r=0,n=a.length;r<n;r++){const n=t[a[r].index];if(!1===a[r].enabled)break;const h=a[r].limitation,l=a[r].rotationMin,c=a[r].rotationMax;n.matrixWorld.decompose(this.linkPos,this.invLinkQ,this.linkScale),this.invLinkQ.invert(),this.effectorPos.setFromMatrixPosition(o.matrixWorld),this.effectorVec.subVectors(this.effectorPos,this.linkPos),this.effectorVec.applyQuaternion(this.invLinkQ),this.effectorVec.normalize(),this.targetVec.subVectors(this.targetPos,this.linkPos),this.targetVec.applyQuaternion(this.invLinkQ),this.targetVec.normalize();let f=this.targetVec.dot(this.effectorVec);if(f>1?f=1:f<-1&&(f=-1),f=i.acos(f),!(f<1e-5)){if(void 0!==s.minAngle&&f<s.minAngle&&(f=s.minAngle),void 0!==s.maxAngle&&f>s.maxAngle&&(f=s.maxAngle),this.axis.crossVectors(this.effectorVec,this.targetVec),this.axis.normalize(),this.q.setFromAxisAngle(this.axis,f),n.quaternion.multiply(this.q),void 0!==h){let t=n.quaternion.w;t>1&&(t=1);const e=i.sqrt(1-t*t);n.quaternion.set(h.x*e,h.y*e,h.z*e,t)}void 0!==l&&n.rotation.setFromVector3(this.vector.setFromEuler(n.rotation).max(l)),void 0!==c&&n.rotation.setFromVector3(this.vector.setFromEuler(n.rotation).min(c)),n.updateMatrixWorld(!0),e=!0}}if(!e)break}}return this}createHelper(){return new s(this.mesh,this.mesh.geometry.userData.MMD.iks)}};
@@ -2,7 +2,7 @@ import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
2
2
  import { Object3D, Matrix4, Vector3, SphereGeometry, MeshBasicMaterial, Color, LineBasicMaterial, Mesh, Line, Quaternion, BufferGeometry, BufferAttribute } from 'three';
3
3
 
4
4
  class CCDIKHelper extends Object3D {
5
- constructor(mesh, iks = []) {
5
+ constructor(mesh, iks = [], sphereSize = 0.25) {
6
6
  super();
7
7
 
8
8
  _defineProperty(this, "_m", new Matrix4());
@@ -13,7 +13,7 @@ class CCDIKHelper extends Object3D {
13
13
  this.iks = iks;
14
14
  this.matrix.copy(mesh.matrixWorld);
15
15
  this.matrixAutoUpdate = false;
16
- this.sphereGeometry = new SphereGeometry(0.25, 16, 8);
16
+ this.sphereGeometry = new SphereGeometry(sphereSize, 16, 8);
17
17
  this.targetSphereMaterial = new MeshBasicMaterial({
18
18
  color: new Color(0xff8888),
19
19
  depthTest: false,
@@ -46,6 +46,8 @@ class CCDIKHelper extends Object3D {
46
46
  return geometry;
47
47
  }
48
48
 
49
+ const scope = this;
50
+
49
51
  function createTargetMesh() {
50
52
  return new Mesh(scope.sphereGeometry, scope.targetSphereMaterial);
51
53
  }
@@ -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();