three-stdlib 2.14.3 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. package/csm/CSM.cjs.js +1 -1
  2. package/csm/CSM.js +8 -8
  3. package/csm/CSMFrustum.cjs.js +1 -0
  4. package/csm/CSMFrustum.d.ts +19 -0
  5. package/csm/{Frustum.js → CSMFrustum.js} +8 -7
  6. package/csm/CSMShader.cjs.js +1 -0
  7. package/csm/CSMShader.d.ts +4 -0
  8. package/csm/{Shader.js → CSMShader.js} +52 -36
  9. package/curves/CurveExtras.d.ts +52 -54
  10. package/geometries/ParametricGeometries.cjs.js +1 -1
  11. package/geometries/ParametricGeometries.js +91 -99
  12. package/geometries/ParametricGeometry.cjs.js +1 -0
  13. package/geometries/ParametricGeometry.d.ts +18 -0
  14. package/geometries/ParametricGeometry.js +87 -0
  15. package/index.cjs.js +1 -1
  16. package/index.d.ts +3 -77
  17. package/index.js +4 -1
  18. package/interactive/InteractiveGroup.cjs.js +1 -0
  19. package/interactive/InteractiveGroup.d.ts +5 -0
  20. package/interactive/InteractiveGroup.js +87 -0
  21. package/loaders/GLTFLoader.d.ts +2 -9
  22. package/loaders/LUT3dlLoader.d.ts +2 -2
  23. package/loaders/LUTCubeLoader.d.ts +2 -2
  24. package/loaders/VOXLoader.d.ts +2 -2
  25. package/objects/Reflector.d.ts +1 -0
  26. package/objects/ReflectorForSSRPass.d.ts +4 -4
  27. package/objects/Refractor.d.ts +1 -0
  28. package/objects/Water2.d.ts +1 -1
  29. package/package.json +2 -1
  30. package/postprocessing/LUTPass.d.ts +3 -3
  31. package/postprocessing/SSAARenderPass.d.ts +1 -1
  32. package/postprocessing/SSRPass.d.ts +3 -3
  33. package/shaders/BokehShader2.d.ts +27 -72
  34. package/shaders/BokehShader2.js +0 -1
  35. package/shaders/index.cjs.js +1 -1
  36. package/shaders/index.d.ts +2 -1
  37. package/shaders/index.js +1 -1
  38. package/csm/Frustum.cjs.js +0 -1
  39. package/csm/Shader.cjs.js +0 -1
  40. package/loaders/VRMLoader.d.ts +0 -19
  41. package/nodes/Nodes.d.ts +0 -106
  42. package/nodes/accessors/CameraNode.d.ts +0 -29
  43. package/nodes/accessors/NormalNode.d.ts +0 -13
  44. package/nodes/accessors/PositionNode.d.ts +0 -15
  45. package/nodes/accessors/ReflectNode.d.ts +0 -12
  46. package/nodes/accessors/UVNode.d.ts +0 -10
  47. package/nodes/core/AttributeNode.d.ts +0 -13
  48. package/nodes/core/ConstNode.d.ts +0 -22
  49. package/nodes/core/ExpressionNode.d.ts +0 -5
  50. package/nodes/core/FunctionCallNode.d.ts +0 -17
  51. package/nodes/core/FunctionNode.d.ts +0 -28
  52. package/nodes/core/InputNode.d.ts +0 -12
  53. package/nodes/core/Node.d.ts +0 -34
  54. package/nodes/core/NodeBuilder.d.ts +0 -149
  55. package/nodes/core/NodeFrame.d.ts +0 -17
  56. package/nodes/core/NodeUniform.d.ts +0 -17
  57. package/nodes/core/NodeUtils.d.ts +0 -7
  58. package/nodes/core/TempNode.d.ts +0 -23
  59. package/nodes/core/VarNode.d.ts +0 -12
  60. package/nodes/materials/MeshStandardNodeMaterial.d.ts +0 -21
  61. package/nodes/materials/NodeMaterial.d.ts +0 -28
  62. package/nodes/math/CondNode.d.ts +0 -26
  63. package/nodes/math/MathNode.d.ts +0 -57
  64. package/nodes/math/OperatorNode.d.ts +0 -17
  65. package/nodes/procedural/CheckerNode.d.ts +0 -17
  66. package/nodes/utils/JoinNode.d.ts +0 -15
  67. package/nodes/utils/TimerNode.d.ts +0 -19
  68. package/objects/ReflectorRTT.d.ts +0 -6
package/csm/CSM.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three"),e=require("./Frustum.cjs.js"),s=require("./Shader.cjs.js");const a=new t.Matrix4,i=new e,r=new t.Vector3,h=new t.Box3,n=[],o=[];exports.CSM=class{constructor(s){s=s||{},this.camera=s.camera,this.parent=s.parent,this.cascades=s.cascades||3,this.maxFar=s.maxFar||1e5,this.mode=s.mode||"practical",this.shadowMapSize=s.shadowMapSize||2048,this.shadowBias=s.shadowBias||1e-6,this.lightDirection=s.lightDirection||new t.Vector3(1,-1,1).normalize(),this.lightIntensity=s.lightIntensity||1,this.lightNear=s.lightNear||1,this.lightFar=s.lightFar||2e3,this.lightMargin=s.lightMargin||200,this.customSplitsCallback=s.customSplitsCallback,this.fade=!1,this.mainFrustum=new e,this.frustums=[],this.breaks=[],this.lights=[],this.shaders=new Map,this.createLights(),this.updateFrustums(),this.injectInclude()}createLights(){for(let e=0;e<this.cascades;e++){const e=new t.DirectionalLight(16777215,this.lightIntensity);e.castShadow=!0,e.shadow.mapSize.width=this.shadowMapSize,e.shadow.mapSize.height=this.shadowMapSize,e.shadow.camera.near=this.lightNear,e.shadow.camera.far=this.lightFar,e.shadow.bias=this.shadowBias,this.parent.add(e),this.parent.add(e.target),this.lights.push(e)}}initCascades(){const t=this.camera;t.updateProjectionMatrix(),this.mainFrustum.setFromProjectionMatrix(t.projectionMatrix,this.maxFar),this.mainFrustum.split(this.breaks,this.frustums)}updateShadowBounds(){const t=this.frustums;for(let e=0;e<t.length;e++){const t=this.lights[e].shadow.camera,s=this.frustums[e],a=s.vertices.near,i=s.vertices.far,r=i[0];let h;h=r.distanceTo(i[2])>r.distanceTo(a[2])?i[2]:a[2];let n=r.distanceTo(h);if(this.fade){const t=this.camera,e=Math.max(t.far,this.maxFar),a=s.vertices.far[0].z/(e-t.near);n+=.25*Math.pow(a,2)*(e-t.near)}t.left=-n/2,t.right=n/2,t.top=n/2,t.bottom=-n/2,t.updateProjectionMatrix()}}getBreaks(){const e=this.camera,s=Math.min(e.far,this.maxFar);switch(this.breaks.length=0,this.mode){case"uniform":a(this.cascades,e.near,s,this.breaks);break;case"logarithmic":i(this.cascades,e.near,s,this.breaks);break;case"practical":!function(e,s,r,h,c){n.length=0,o.length=0,i(e,s,r,o),a(e,s,r,n);for(let s=1;s<e;s++)c.push(t.MathUtils.lerp(n[s-1],o[s-1],h));c.push(1)}(this.cascades,e.near,s,.5,this.breaks);break;case"custom":void 0===this.customSplitsCallback&&console.error("CSM: Custom split scheme callback not defined."),this.customSplitsCallback(this.cascades,e.near,s,this.breaks)}function a(t,e,s,a){for(let i=1;i<t;i++)a.push((e+(s-e)*i/t)/s);a.push(1)}function i(t,e,s,a){for(let i=1;i<t;i++)a.push(e*(s/e)**(i/t)/s);a.push(1)}}update(){const t=this.camera,e=this.frustums;for(let s=0;s<e.length;s++){const n=this.lights[s],o=n.shadow.camera,c=(o.right-o.left)/this.shadowMapSize,d=(o.top-o.bottom)/this.shadowMapSize;n.shadow.camera.updateMatrixWorld(!0),a.multiplyMatrices(n.shadow.camera.matrixWorldInverse,t.matrixWorld),e[s].toSpace(a,i);const l=i.vertices.near,m=i.vertices.far;h.makeEmpty();for(let t=0;t<4;t++)h.expandByPoint(l[t]),h.expandByPoint(m[t]);h.getCenter(r),r.z=h.max.z+this.lightMargin,r.x=Math.floor(r.x/c)*c,r.y=Math.floor(r.y/d)*d,r.applyMatrix4(n.shadow.camera.matrixWorld),n.position.copy(r),n.target.position.copy(r),n.target.position.x+=this.lightDirection.x,n.target.position.y+=this.lightDirection.y,n.target.position.z+=this.lightDirection.z}}injectInclude(){t.ShaderChunk.lights_fragment_begin=s.lights_fragment_begin,t.ShaderChunk.lights_pars_begin=s.lights_pars_begin}setupMaterial(t){t.defines=t.defines||{},t.defines.USE_CSM=1,t.defines.CSM_CASCADES=this.cascades,this.fade&&(t.defines.CSM_FADE="");const e=[],s=this,a=this.shaders;t.onBeforeCompile=i=>{const r=Math.min(s.camera.far,s.maxFar);s.getExtendedBreaks(e),i.uniforms.CSM_cascades={value:e},i.uniforms.cameraNear={value:s.camera.near},i.uniforms.shadowFar={value:r},a.set(t,i)},a.set(t,null)}updateUniforms(){const t=Math.min(this.camera.far,this.maxFar);this.shaders.forEach((function(e,s){if(null!==e){const s=e.uniforms;this.getExtendedBreaks(s.CSM_cascades.value),s.cameraNear.value=this.camera.near,s.shadowFar.value=t}!this.fade&&"CSM_FADE"in s.defines?(delete s.defines.CSM_FADE,s.needsUpdate=!0):this.fade&&!("CSM_FADE"in s.defines)&&(s.defines.CSM_FADE="",s.needsUpdate=!0)}),this)}getExtendedBreaks(e){for(;e.length<this.breaks.length;)e.push(new t.Vector2);e.length=this.breaks.length;for(let t=0;t<this.cascades;t++){const s=this.breaks[t],a=this.breaks[t-1]||0;e[t].x=a,e[t].y=s}}updateFrustums(){this.getBreaks(),this.initCascades(),this.updateShadowBounds(),this.updateUniforms()}remove(){for(let t=0;t<this.lights.length;t++)this.parent.remove(this.lights[t])}dispose(){const t=this.shaders;t.forEach(((t,e)=>{delete e.onBeforeCompile,delete e.defines.USE_CSM,delete e.defines.CSM_CASCADES,delete e.defines.CSM_FADE,null!==t&&(delete t.uniforms.CSM_cascades,delete t.uniforms.cameraNear,delete t.uniforms.shadowFar),e.needsUpdate=!0})),t.clear()}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three"),e=require("./CSMFrustum.cjs.js"),s=require("./CSMShader.cjs.js");const a=new t.Matrix4,i=new e.CSMFrustum,r=new t.Vector3,h=new t.Box3,n=[],o=[];exports.CSM=class{constructor(s){s=s||{},this.camera=s.camera,this.parent=s.parent,this.cascades=s.cascades||3,this.maxFar=s.maxFar||1e5,this.mode=s.mode||"practical",this.shadowMapSize=s.shadowMapSize||2048,this.shadowBias=s.shadowBias||1e-6,this.lightDirection=s.lightDirection||new t.Vector3(1,-1,1).normalize(),this.lightIntensity=s.lightIntensity||1,this.lightNear=s.lightNear||1,this.lightFar=s.lightFar||2e3,this.lightMargin=s.lightMargin||200,this.customSplitsCallback=s.customSplitsCallback,this.fade=!1,this.mainFrustum=new e.CSMFrustum,this.frustums=[],this.breaks=[],this.lights=[],this.shaders=new Map,this.createLights(),this.updateFrustums(),this.injectInclude()}createLights(){for(let e=0;e<this.cascades;e++){const e=new t.DirectionalLight(16777215,this.lightIntensity);e.castShadow=!0,e.shadow.mapSize.width=this.shadowMapSize,e.shadow.mapSize.height=this.shadowMapSize,e.shadow.camera.near=this.lightNear,e.shadow.camera.far=this.lightFar,e.shadow.bias=this.shadowBias,this.parent.add(e),this.parent.add(e.target),this.lights.push(e)}}initCascades(){const t=this.camera;t.updateProjectionMatrix(),this.mainFrustum.setFromProjectionMatrix(t.projectionMatrix,this.maxFar),this.mainFrustum.split(this.breaks,this.frustums)}updateShadowBounds(){const t=this.frustums;for(let e=0;e<t.length;e++){const t=this.lights[e].shadow.camera,s=this.frustums[e],a=s.vertices.near,i=s.vertices.far,r=i[0];let h;h=r.distanceTo(i[2])>r.distanceTo(a[2])?i[2]:a[2];let n=r.distanceTo(h);if(this.fade){const t=this.camera,e=Math.max(t.far,this.maxFar),a=s.vertices.far[0].z/(e-t.near);n+=.25*Math.pow(a,2)*(e-t.near)}t.left=-n/2,t.right=n/2,t.top=n/2,t.bottom=-n/2,t.updateProjectionMatrix()}}getBreaks(){const e=this.camera,s=Math.min(e.far,this.maxFar);switch(this.breaks.length=0,this.mode){case"uniform":a(this.cascades,e.near,s,this.breaks);break;case"logarithmic":i(this.cascades,e.near,s,this.breaks);break;case"practical":!function(e,s,r,h,c){n.length=0,o.length=0,i(e,s,r,o),a(e,s,r,n);for(let s=1;s<e;s++)c.push(t.MathUtils.lerp(n[s-1],o[s-1],h));c.push(1)}(this.cascades,e.near,s,.5,this.breaks);break;case"custom":void 0===this.customSplitsCallback&&console.error("CSM: Custom split scheme callback not defined."),this.customSplitsCallback(this.cascades,e.near,s,this.breaks)}function a(t,e,s,a){for(let i=1;i<t;i++)a.push((e+(s-e)*i/t)/s);a.push(1)}function i(t,e,s,a){for(let i=1;i<t;i++)a.push(e*(s/e)**(i/t)/s);a.push(1)}}update(){const t=this.camera,e=this.frustums;for(let s=0;s<e.length;s++){const n=this.lights[s],o=n.shadow.camera,c=(o.right-o.left)/this.shadowMapSize,d=(o.top-o.bottom)/this.shadowMapSize;n.shadow.camera.updateMatrixWorld(!0),a.multiplyMatrices(n.shadow.camera.matrixWorldInverse,t.matrixWorld),e[s].toSpace(a,i);const l=i.vertices.near,u=i.vertices.far;h.makeEmpty();for(let t=0;t<4;t++)h.expandByPoint(l[t]),h.expandByPoint(u[t]);h.getCenter(r),r.z=h.max.z+this.lightMargin,r.x=Math.floor(r.x/c)*c,r.y=Math.floor(r.y/d)*d,r.applyMatrix4(n.shadow.camera.matrixWorld),n.position.copy(r),n.target.position.copy(r),n.target.position.x+=this.lightDirection.x,n.target.position.y+=this.lightDirection.y,n.target.position.z+=this.lightDirection.z}}injectInclude(){t.ShaderChunk.lights_fragment_begin=s.CSMShader.lights_fragment_begin,t.ShaderChunk.lights_pars_begin=s.CSMShader.lights_pars_begin}setupMaterial(t){t.defines=t.defines||{},t.defines.USE_CSM=1,t.defines.CSM_CASCADES=this.cascades,this.fade&&(t.defines.CSM_FADE="");const e=[],s=this,a=this.shaders;t.onBeforeCompile=function(i){const r=Math.min(s.camera.far,s.maxFar);s.getExtendedBreaks(e),i.uniforms.CSM_cascades={value:e},i.uniforms.cameraNear={value:s.camera.near},i.uniforms.shadowFar={value:r},a.set(t,i)},a.set(t,null)}updateUniforms(){const t=Math.min(this.camera.far,this.maxFar);this.shaders.forEach((function(e,s){if(null!==e){const s=e.uniforms;this.getExtendedBreaks(s.CSM_cascades.value),s.cameraNear.value=this.camera.near,s.shadowFar.value=t}!this.fade&&"CSM_FADE"in s.defines?(delete s.defines.CSM_FADE,s.needsUpdate=!0):this.fade&&!("CSM_FADE"in s.defines)&&(s.defines.CSM_FADE="",s.needsUpdate=!0)}),this)}getExtendedBreaks(e){for(;e.length<this.breaks.length;)e.push(new t.Vector2);e.length=this.breaks.length;for(let t=0;t<this.cascades;t++){const s=this.breaks[t],a=this.breaks[t-1]||0;e[t].x=a,e[t].y=s}}updateFrustums(){this.getBreaks(),this.initCascades(),this.updateShadowBounds(),this.updateUniforms()}remove(){for(let t=0;t<this.lights.length;t++)this.parent.remove(this.lights[t])}dispose(){const t=this.shaders;t.forEach((function(t,e){delete e.onBeforeCompile,delete e.defines.USE_CSM,delete e.defines.CSM_CASCADES,delete e.defines.CSM_FADE,null!==t&&(delete t.uniforms.CSM_cascades,delete t.uniforms.cameraNear,delete t.uniforms.shadowFar),e.needsUpdate=!0})),t.clear()}};
package/csm/CSM.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { Matrix4, Vector3, Box3, DirectionalLight, MathUtils, ShaderChunk, Vector2 } from 'three';
2
- import Frustum from './Frustum.js';
3
- import Shader from './Shader.js';
2
+ import { CSMFrustum } from './CSMFrustum.js';
3
+ import { CSMShader } from './CSMShader.js';
4
4
 
5
5
  const _cameraToLightMatrix = new Matrix4();
6
6
 
7
- const _lightSpaceFrustum = new Frustum();
7
+ const _lightSpaceFrustum = new CSMFrustum();
8
8
 
9
9
  const _center = new Vector3();
10
10
 
@@ -29,7 +29,7 @@ class CSM {
29
29
  this.lightMargin = data.lightMargin || 200;
30
30
  this.customSplitsCallback = data.customSplitsCallback;
31
31
  this.fade = false;
32
- this.mainFrustum = new Frustum();
32
+ this.mainFrustum = new CSMFrustum();
33
33
  this.frustums = [];
34
34
  this.breaks = [];
35
35
  this.lights = [];
@@ -197,8 +197,8 @@ class CSM {
197
197
  }
198
198
 
199
199
  injectInclude() {
200
- ShaderChunk.lights_fragment_begin = Shader.lights_fragment_begin;
201
- ShaderChunk.lights_pars_begin = Shader.lights_pars_begin;
200
+ ShaderChunk.lights_fragment_begin = CSMShader.lights_fragment_begin;
201
+ ShaderChunk.lights_pars_begin = CSMShader.lights_pars_begin;
202
202
  }
203
203
 
204
204
  setupMaterial(material) {
@@ -214,7 +214,7 @@ class CSM {
214
214
  const scope = this;
215
215
  const shaders = this.shaders;
216
216
 
217
- material.onBeforeCompile = shader => {
217
+ material.onBeforeCompile = function (shader) {
218
218
  const far = Math.min(scope.camera.far, scope.maxFar);
219
219
  scope.getExtendedBreaks(breaksVec2);
220
220
  shader.uniforms.CSM_cascades = {
@@ -283,7 +283,7 @@ class CSM {
283
283
 
284
284
  dispose() {
285
285
  const shaders = this.shaders;
286
- shaders.forEach((shader, material) => {
286
+ shaders.forEach(function (shader, material) {
287
287
  delete material.onBeforeCompile;
288
288
  delete material.defines.USE_CSM;
289
289
  delete material.defines.CSM_CASCADES;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("three");const t=new e.Matrix4;class r{constructor(t){t=t||{},this.vertices={near:[new e.Vector3,new e.Vector3,new e.Vector3,new e.Vector3],far:[new e.Vector3,new e.Vector3,new e.Vector3,new e.Vector3]},void 0!==t.projectionMatrix&&this.setFromProjectionMatrix(t.projectionMatrix,t.maxFar||1e4)}setFromProjectionMatrix(e,r){const s=0===e.elements[11];return t.copy(e).invert(),this.vertices.near[0].set(1,1,-1),this.vertices.near[1].set(1,-1,-1),this.vertices.near[2].set(-1,-1,-1),this.vertices.near[3].set(-1,1,-1),this.vertices.near.forEach((function(e){e.applyMatrix4(t)})),this.vertices.far[0].set(1,1,1),this.vertices.far[1].set(1,-1,1),this.vertices.far[2].set(-1,-1,1),this.vertices.far[3].set(-1,1,1),this.vertices.far.forEach((function(e){e.applyMatrix4(t);const i=Math.abs(e.z);s?e.z*=Math.min(r/i,1):e.multiplyScalar(Math.min(r/i,1))})),this.vertices}split(e,t){for(;e.length>t.length;)t.push(new r);t.length=e.length;for(let r=0;r<e.length;r++){const s=t[r];if(0===r)for(let e=0;e<4;e++)s.vertices.near[e].copy(this.vertices.near[e]);else for(let t=0;t<4;t++)s.vertices.near[t].lerpVectors(this.vertices.near[t],this.vertices.far[t],e[r-1]);if(r===e.length-1)for(let e=0;e<4;e++)s.vertices.far[e].copy(this.vertices.far[e]);else for(let t=0;t<4;t++)s.vertices.far[t].lerpVectors(this.vertices.near[t],this.vertices.far[t],e[r])}}toSpace(e,t){for(let r=0;r<4;r++)t.vertices.near[r].copy(this.vertices.near[r]).applyMatrix4(e),t.vertices.far[r].copy(this.vertices.far[r]).applyMatrix4(e)}}exports.CSMFrustum=r;
@@ -0,0 +1,19 @@
1
+ import { Matrix4, Vector3 } from 'three';
2
+
3
+ export interface CSMFrustumVerticies {
4
+ near: Vector3[];
5
+ far: Vector3[];
6
+ }
7
+
8
+ export interface CSMFrustumParameters {
9
+ projectionMatrix?: Matrix4;
10
+ maxFar?: number;
11
+ }
12
+
13
+ export default class CSMFrustum {
14
+ constructor(data?: CSMFrustumParameters);
15
+ vertices: CSMFrustumVerticies;
16
+ setFromProjectionMatrix(projectionMatrix: Matrix4, maxFar: number): CSMFrustumVerticies;
17
+ split(breaks: number[], target: CSMFrustum[]): void;
18
+ toSpace(cameraMatrix: Matrix4, target: CSMFrustum): void;
19
+ }
@@ -1,7 +1,8 @@
1
- import { Vector3, Matrix4 } from 'three';
1
+ import { Matrix4, Vector3 } from 'three';
2
2
 
3
3
  const inverseProjectionMatrix = new Matrix4();
4
- class Frustum {
4
+
5
+ class CSMFrustum {
5
6
  constructor(data) {
6
7
  data = data || {};
7
8
  this.vertices = {
@@ -25,14 +26,14 @@ class Frustum {
25
26
  this.vertices.near[1].set(1, -1, -1);
26
27
  this.vertices.near[2].set(-1, -1, -1);
27
28
  this.vertices.near[3].set(-1, 1, -1);
28
- this.vertices.near.forEach(v => {
29
+ this.vertices.near.forEach(function (v) {
29
30
  v.applyMatrix4(inverseProjectionMatrix);
30
31
  });
31
32
  this.vertices.far[0].set(1, 1, 1);
32
33
  this.vertices.far[1].set(1, -1, 1);
33
34
  this.vertices.far[2].set(-1, -1, 1);
34
35
  this.vertices.far[3].set(-1, 1, 1);
35
- this.vertices.far.forEach(v => {
36
+ this.vertices.far.forEach(function (v) {
36
37
  v.applyMatrix4(inverseProjectionMatrix);
37
38
  const absZ = Math.abs(v.z);
38
39
 
@@ -47,7 +48,7 @@ class Frustum {
47
48
 
48
49
  split(breaks, target) {
49
50
  while (breaks.length > target.length) {
50
- target.push(new Frustum());
51
+ target.push(new CSMFrustum());
51
52
  }
52
53
 
53
54
  target.length = breaks.length;
@@ -65,7 +66,7 @@ class Frustum {
65
66
  }
66
67
  }
67
68
 
68
- if (i === breaks - 1) {
69
+ if (i === breaks.length - 1) {
69
70
  for (let j = 0; j < 4; j++) {
70
71
  cascade.vertices.far[j].copy(this.vertices.far[j]);
71
72
  }
@@ -86,4 +87,4 @@ class Frustum {
86
87
 
87
88
  }
88
89
 
89
- export default Frustum;
90
+ export { CSMFrustum };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t={lights_fragment_begin:"\nGeometricContext geometry;\n\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n#ifdef CLEARCOAT\n\n\tgeometry.clearcoatNormal = clearcoatNormal;\n\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tpointLight = pointLights[ i ];\n\n\t\tgetPointLightInfo( pointLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tspotLight = spotLights[ i ];\n\n\t\tgetSpotLightInfo( spotLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0) && defined( RE_Direct ) && defined( USE_CSM ) && defined( CSM_CASCADES )\n\n\tDirectionalLight directionalLight;\n\tfloat linearDepth = (vViewPosition.z) / (shadowFar - cameraNear);\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#if defined( USE_SHADOWMAP ) && defined( CSM_FADE )\n\tvec2 cascade;\n\tfloat cascadeCenter;\n\tfloat closestEdge;\n\tfloat margin;\n\tfloat csmx;\n\tfloat csmy;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\n\t \t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\t\t// NOTE: Depth gets larger away from the camera.\n\t\t\t// cascade.x is closer, cascade.y is further\n\t\t\tcascade = CSM_cascades[ i ];\n\t\t\tcascadeCenter = ( cascade.x + cascade.y ) / 2.0;\n\t\t\tclosestEdge = linearDepth < cascadeCenter ? cascade.x : cascade.y;\n\t\t\tmargin = 0.25 * pow( closestEdge, 2.0 );\n\t\t\tcsmx = cascade.x - margin / 2.0;\n\t\t\tcsmy = cascade.y + margin / 2.0;\n\t\t\tif( linearDepth >= csmx && ( linearDepth < csmy || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 ) ) {\n\n\t\t\t\tfloat dist = min( linearDepth - csmx, csmy - linearDepth );\n\t\t\t\tfloat ratio = clamp( dist / margin, 0.0, 1.0 );\n\n\t\t\t\tvec3 prevColor = directLight.color;\n\t\t\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\t\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t\t\t\tbool shouldFadeLastCascade = UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth > cascadeCenter;\n\t\t\t\tdirectLight.color = mix( prevColor, directLight.color, shouldFadeLastCascade ? ratio : 1.0 );\n\n\t\t\t\tReflectedLight prevLight = reflectedLight;\n\t\t\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t\t\t\tbool shouldBlend = UNROLLED_LOOP_INDEX != CSM_CASCADES - 1 || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth < cascadeCenter;\n\t\t\t\tfloat blendRatio = shouldBlend ? ratio : 1.0;\n\n\t\t\t\treflectedLight.directDiffuse = mix( prevLight.directDiffuse, reflectedLight.directDiffuse, blendRatio );\n\t\t\t\treflectedLight.directSpecular = mix( prevLight.directSpecular, reflectedLight.directSpecular, blendRatio );\n\t\t\t\treflectedLight.indirectDiffuse = mix( prevLight.indirectDiffuse, reflectedLight.indirectDiffuse, blendRatio );\n\t\t\t\treflectedLight.indirectSpecular = mix( prevLight.indirectSpecular, reflectedLight.indirectSpecular, blendRatio );\n\n\t\t\t}\n\t \t#endif\n\n\t}\n\t#pragma unroll_loop_end\n\t#else\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\t\tdirectionalLight = directionalLights[ i ];\n\t\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\n\t\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\n\t\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\t\tif(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y) directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t\t\tif(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && (linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1)) RE_Direct( directLight, geometry, material, reflectedLight );\n\n\t\t\t#endif\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if ( NUM_DIR_LIGHTS > NUM_DIR_LIGHT_SHADOWS)\n\t\t// compute the lights not casting shadows (if any)\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = NUM_DIR_LIGHT_SHADOWS; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\t\tdirectionalLight = directionalLights[ i ];\n\n\t\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\n\t\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) && !defined( USE_CSM ) && !defined( CSM_CASCADES )\n\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\n\t\tgetDirectionalLightInfo( directionalLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n\tRectAreaLight rectAreaLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n\tvec3 iblIrradiance = vec3( 0.0 );\n\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry.normal );\n\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n",lights_pars_begin:"\n#if defined( USE_CSM ) && defined( CSM_CASCADES )\nuniform vec2 CSM_cascades[CSM_CASCADES];\nuniform float cameraNear;\nuniform float shadowFar;\n#endif\n\t"+require("three").ShaderChunk.lights_pars_begin};exports.CSMShader=t;
@@ -0,0 +1,4 @@
1
+ export interface CSMShader {
2
+ lights_fragment_begin: string;
3
+ lights_pars_begin: string;
4
+ }
@@ -1,6 +1,6 @@
1
1
  import { ShaderChunk } from 'three';
2
2
 
3
- var Shader = {
3
+ const CSMShader = {
4
4
  lights_fragment_begin:
5
5
  /* glsl */
6
6
  `
@@ -92,19 +92,19 @@ IncidentLight directLight;
92
92
  directionalLight = directionalLights[ i ];
93
93
  getDirectionalLightInfo( directionalLight, geometry, directLight );
94
94
 
95
- // NOTE: Depth gets larger away from the camera.
96
- // cascade.x is closer, cascade.y is further
97
- cascade = CSM_cascades[ i ];
98
- cascadeCenter = ( cascade.x + cascade.y ) / 2.0;
99
- closestEdge = linearDepth < cascadeCenter ? cascade.x : cascade.y;
100
- margin = 0.25 * pow( closestEdge, 2.0 );
101
- csmx = cascade.x - margin / 2.0;
102
- csmy = cascade.y + margin / 2.0;
103
- if( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS && linearDepth >= csmx && ( linearDepth < csmy || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 ) ) {
95
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
96
+ // NOTE: Depth gets larger away from the camera.
97
+ // cascade.x is closer, cascade.y is further
98
+ cascade = CSM_cascades[ i ];
99
+ cascadeCenter = ( cascade.x + cascade.y ) / 2.0;
100
+ closestEdge = linearDepth < cascadeCenter ? cascade.x : cascade.y;
101
+ margin = 0.25 * pow( closestEdge, 2.0 );
102
+ csmx = cascade.x - margin / 2.0;
103
+ csmy = cascade.y + margin / 2.0;
104
+ if( linearDepth >= csmx && ( linearDepth < csmy || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 ) ) {
104
105
 
105
- float dist = min( linearDepth - csmx, csmy - linearDepth );
106
- float ratio = clamp( dist / margin, 0.0, 1.0 );
107
- if( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) {
106
+ float dist = min( linearDepth - csmx, csmy - linearDepth );
107
+ float ratio = clamp( dist / margin, 0.0, 1.0 );
108
108
 
109
109
  vec3 prevColor = directLight.color;
110
110
  directionalLightShadow = directionalLightShadows[ i ];
@@ -113,42 +113,58 @@ IncidentLight directLight;
113
113
  bool shouldFadeLastCascade = UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth > cascadeCenter;
114
114
  directLight.color = mix( prevColor, directLight.color, shouldFadeLastCascade ? ratio : 1.0 );
115
115
 
116
- }
117
-
118
- ReflectedLight prevLight = reflectedLight;
119
- RE_Direct( directLight, geometry, material, reflectedLight );
116
+ ReflectedLight prevLight = reflectedLight;
117
+ RE_Direct( directLight, geometry, material, reflectedLight );
120
118
 
121
- bool shouldBlend = UNROLLED_LOOP_INDEX != CSM_CASCADES - 1 || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth < cascadeCenter;
122
- float blendRatio = shouldBlend ? ratio : 1.0;
119
+ bool shouldBlend = UNROLLED_LOOP_INDEX != CSM_CASCADES - 1 || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1 && linearDepth < cascadeCenter;
120
+ float blendRatio = shouldBlend ? ratio : 1.0;
123
121
 
124
- reflectedLight.directDiffuse = mix( prevLight.directDiffuse, reflectedLight.directDiffuse, blendRatio );
125
- reflectedLight.directSpecular = mix( prevLight.directSpecular, reflectedLight.directSpecular, blendRatio );
126
- reflectedLight.indirectDiffuse = mix( prevLight.indirectDiffuse, reflectedLight.indirectDiffuse, blendRatio );
127
- reflectedLight.indirectSpecular = mix( prevLight.indirectSpecular, reflectedLight.indirectSpecular, blendRatio );
122
+ reflectedLight.directDiffuse = mix( prevLight.directDiffuse, reflectedLight.directDiffuse, blendRatio );
123
+ reflectedLight.directSpecular = mix( prevLight.directSpecular, reflectedLight.directSpecular, blendRatio );
124
+ reflectedLight.indirectDiffuse = mix( prevLight.indirectDiffuse, reflectedLight.indirectDiffuse, blendRatio );
125
+ reflectedLight.indirectSpecular = mix( prevLight.indirectSpecular, reflectedLight.indirectSpecular, blendRatio );
128
126
 
129
- }
127
+ }
128
+ #endif
130
129
 
131
130
  }
132
131
  #pragma unroll_loop_end
133
132
  #else
134
133
 
135
- #pragma unroll_loop_start
136
- for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
134
+ #pragma unroll_loop_start
135
+ for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
137
136
 
138
- directionalLight = directionalLights[ i ];
139
- getDirectionalLightInfo( directionalLight, geometry, directLight );
137
+ directionalLight = directionalLights[ i ];
138
+ getDirectionalLightInfo( directionalLight, geometry, directLight );
140
139
 
141
- #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
140
+ #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
142
141
 
143
- directionalLightShadow = directionalLightShadows[ i ];
144
- if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y) directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
142
+ directionalLightShadow = directionalLightShadows[ i ];
143
+ if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y) directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
145
144
 
146
- #endif
145
+ if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && (linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1)) RE_Direct( directLight, geometry, material, reflectedLight );
147
146
 
148
- if(linearDepth >= CSM_cascades[UNROLLED_LOOP_INDEX].x && (linearDepth < CSM_cascades[UNROLLED_LOOP_INDEX].y || UNROLLED_LOOP_INDEX == CSM_CASCADES - 1)) RE_Direct( directLight, geometry, material, reflectedLight );
147
+ #endif
149
148
 
150
- }
151
- #pragma unroll_loop_end
149
+ }
150
+ #pragma unroll_loop_end
151
+
152
+ #endif
153
+
154
+ #if ( NUM_DIR_LIGHTS > NUM_DIR_LIGHT_SHADOWS)
155
+ // compute the lights not casting shadows (if any)
156
+
157
+ #pragma unroll_loop_start
158
+ for ( int i = NUM_DIR_LIGHT_SHADOWS; i < NUM_DIR_LIGHTS; i ++ ) {
159
+
160
+ directionalLight = directionalLights[ i ];
161
+
162
+ getDirectionalLightInfo( directionalLight, geometry, directLight );
163
+
164
+ RE_Direct( directLight, geometry, material, reflectedLight );
165
+
166
+ }
167
+ #pragma unroll_loop_end
152
168
 
153
169
  #endif
154
170
 
@@ -236,4 +252,4 @@ uniform float shadowFar;
236
252
  ` + ShaderChunk.lights_pars_begin
237
253
  };
238
254
 
239
- export default Shader;
255
+ export { CSMShader };
@@ -1,70 +1,68 @@
1
1
  import { Curve, Vector3 } from 'three';
2
2
 
3
- export namespace Curves {
4
- class GrannyKnot extends Curve<Vector3> {
5
- constructor();
6
- }
3
+ export class GrannyKnot extends Curve<Vector3> {
4
+ constructor();
5
+ }
7
6
 
8
- class HeartCurve extends Curve<Vector3> {
9
- constructor(scale?: number);
10
- scale: number;
11
- }
7
+ export class HeartCurve extends Curve<Vector3> {
8
+ constructor(scale?: number);
9
+ scale: number;
10
+ }
12
11
 
13
- class VivianiCurve extends Curve<Vector3> {
14
- constructor(scale?: number);
15
- scale: number;
16
- }
12
+ export class VivianiCurve extends Curve<Vector3> {
13
+ constructor(scale?: number);
14
+ scale: number;
15
+ }
17
16
 
18
- class KnotCurve extends Curve<Vector3> {
19
- constructor();
20
- }
17
+ export class KnotCurve extends Curve<Vector3> {
18
+ constructor();
19
+ }
21
20
 
22
- class HelixCurve extends Curve<Vector3> {
23
- constructor();
24
- }
21
+ export class HelixCurve extends Curve<Vector3> {
22
+ constructor();
23
+ }
25
24
 
26
- class TrefoilKnot extends Curve<Vector3> {
27
- constructor(scale?: number);
28
- scale: number;
29
- }
25
+ export class TrefoilKnot extends Curve<Vector3> {
26
+ constructor(scale?: number);
27
+ scale: number;
28
+ }
30
29
 
31
- class TorusKnot extends Curve<Vector3> {
32
- constructor(scale?: number);
33
- scale: number;
34
- }
30
+ export class TorusKnot extends Curve<Vector3> {
31
+ constructor(scale?: number);
32
+ scale: number;
33
+ }
35
34
 
36
- class CinquefoilKnot extends Curve<Vector3> {
37
- constructor(scale?: number);
38
- scale: number;
39
- }
35
+ export class CinquefoilKnot extends Curve<Vector3> {
36
+ constructor(scale?: number);
37
+ scale: number;
38
+ }
40
39
 
41
- class TrefoilPolynomialKnot extends Curve<Vector3> {
42
- constructor(scale?: number);
43
- scale: number;
44
- }
40
+ export class TrefoilPolynomialKnot extends Curve<Vector3> {
41
+ constructor(scale?: number);
42
+ scale: number;
43
+ }
45
44
 
46
- class FigureEightPolynomialKnot extends Curve<Vector3> {
47
- constructor(scale?: number);
48
- scale: number;
49
- }
45
+ export class FigureEightPolynomialKnot extends Curve<Vector3> {
46
+ constructor(scale?: number);
47
+ scale: number;
48
+ }
50
49
 
51
- class DecoratedTorusKnot4a extends Curve<Vector3> {
52
- constructor(scale?: number);
53
- scale: number;
54
- }
50
+ export class DecoratedTorusKnot4a extends Curve<Vector3> {
51
+ constructor(scale?: number);
52
+ scale: number;
53
+ }
55
54
 
56
- class DecoratedTorusKnot4b extends Curve<Vector3> {
57
- constructor(scale?: number);
58
- scale: number;
59
- }
55
+ export class DecoratedTorusKnot4b extends Curve<Vector3> {
56
+ constructor(scale?: number);
57
+ scale: number;
58
+ }
60
59
 
61
- class DecoratedTorusKnot5a extends Curve<Vector3> {
62
- constructor(scale?: number);
63
- scale: number;
64
- }
60
+ export class DecoratedTorusKnot5a extends Curve<Vector3> {
61
+ constructor(scale?: number);
62
+ scale: number;
63
+ }
65
64
 
66
- class DecoratedTorusKnot5c extends Curve<Vector3> {
67
- constructor(scale?: number);
68
- scale: number;
69
- }
65
+ export class DecoratedTorusKnot5c extends Curve<Vector3> {
66
+ constructor(scale?: number);
67
+ scale: number;
70
68
  }
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three");const e={klein:function(t,e,o){let s,r,a;e*=Math.PI,t*=2*Math.PI,(e*=2)<Math.PI?(s=3*Math.cos(e)*(1+Math.sin(e))+2*(1-Math.cos(e)/2)*Math.cos(e)*Math.cos(t),a=-8*Math.sin(e)-2*(1-Math.cos(e)/2)*Math.sin(e)*Math.cos(t)):(s=3*Math.cos(e)*(1+Math.sin(e))+2*(1-Math.cos(e)/2)*Math.cos(t+Math.PI),a=-8*Math.sin(e)),r=-2*(1-Math.cos(e)/2)*Math.sin(t),o.set(s,r,a)},plane:function(t,e){return(o,s,r)=>{const a=o*t,n=s*e;r.set(a,0,n)}},mobius:function(t,e,o){t-=.5;const s=2*Math.PI*e;let r,a,n;r=Math.cos(s)*(2+t*Math.cos(s/2)),a=Math.sin(s)*(2+t*Math.cos(s/2)),n=t*Math.sin(s/2),o.set(r,a,n)},mobius3d:function(t,e,o){t*=Math.PI,e*=2*Math.PI;const s=(t*=2)/2;let r,a,n;r=.125*Math.cos(e)*Math.cos(s)-.65*Math.sin(e)*Math.sin(s),n=.125*Math.cos(e)*Math.sin(s)+.65*Math.sin(e)*Math.cos(s),a=(2.25+r)*Math.sin(t),r=(2.25+r)*Math.cos(t),o.set(r,a,n)},TubeGeometry:function(e,o,s,r,a){this.path=e,this.segments=o||64,this.radius=s||1,this.segmentsRadius=r||8,this.closed=a||!1;const n=this,c=this.segments+1,h=e.computeFrenetFrames(o,a),i=h.tangents,M=h.normals,u=h.binormals;this.tangents=i,this.normals=M,this.binormals=u;const m=new t.Vector3;t.ParametricGeometry.call(this,((t,o,s)=>{o*=2*Math.PI;let r=t*(c-1);r=Math.floor(r),e.getPointAt(t,m);const a=M[r],h=u[r],i=-n.radius*Math.cos(o),y=n.radius*Math.sin(o);m.x+=i*a.x+y*h.x,m.y+=i*a.y+y*h.y,m.z+=i*a.z+y*h.z,s.copy(m)}),o,r)}};e.TubeGeometry.prototype=Object.create(t.BufferGeometry.prototype),e.TubeGeometry.prototype.constructor=e.TubeGeometry,e.TorusKnotGeometry=function(o,s,r,a,n,c){this.radius=o||200,this.tube=s||40,this.segmentsT=r||64,this.segmentsR=a||8,this.p=n||2,this.q=c||3;class h extends t.Curve{constructor(){super()}getPoint(e,s){const r=s||new t.Vector3;e*=2*Math.PI;const a=(1+.5*Math.cos(c*e))*Math.cos(n*e),h=(1+.5*Math.cos(c*e))*Math.sin(n*e),i=.5*Math.sin(c*e);return r.set(a,h,i).multiplyScalar(o)}}const i=r,M=a,u=new h;e.TubeGeometry.call(this,u,i,s,M,!0,!1)},e.TorusKnotGeometry.prototype=Object.create(t.BufferGeometry.prototype),e.TorusKnotGeometry.prototype.constructor=e.TorusKnotGeometry,e.SphereGeometry=function(e,o,s){t.ParametricGeometry.call(this,(function(t,o,s){t*=Math.PI,o*=2*Math.PI;const r=e*Math.sin(t)*Math.cos(o),a=e*Math.sin(t)*Math.sin(o),n=e*Math.cos(t);s.set(r,a,n)}),o,s)},e.SphereGeometry.prototype=Object.create(t.BufferGeometry.prototype),e.SphereGeometry.prototype.constructor=e.SphereGeometry,e.PlaneGeometry=function(e,o,s,r){t.ParametricGeometry.call(this,(function(t,s,r){const a=t*e,n=s*o;r.set(a,0,n)}),s,r)},e.PlaneGeometry.prototype=Object.create(t.BufferGeometry.prototype),e.PlaneGeometry.prototype.constructor=e.PlaneGeometry,exports.ParametricGeometries=e;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three"),s=require("./ParametricGeometry.cjs.js");const e={klein:function(t,s,e){let a,o;s*=Math.PI,t*=2*Math.PI,(s*=2)<Math.PI?(a=3*Math.cos(s)*(1+Math.sin(s))+2*(1-Math.cos(s)/2)*Math.cos(s)*Math.cos(t),o=-8*Math.sin(s)-2*(1-Math.cos(s)/2)*Math.sin(s)*Math.cos(t)):(a=3*Math.cos(s)*(1+Math.sin(s))+2*(1-Math.cos(s)/2)*Math.cos(t+Math.PI),o=-8*Math.sin(s));const n=-2*(1-Math.cos(s)/2)*Math.sin(t);e.set(a,n,o)},plane:function(t,s){return function(e,a,o){const n=e*t,c=a*s;o.set(n,0,c)}},mobius:function(t,s,e){t-=.5;const a=2*Math.PI*s,o=Math.cos(a)*(2+t*Math.cos(a/2)),n=Math.sin(a)*(2+t*Math.cos(a/2)),c=t*Math.sin(a/2);e.set(o,n,c)},mobius3d:function(t,s,e){t*=Math.PI,s*=2*Math.PI;const a=(t*=2)/2;let o=.125*Math.cos(s)*Math.cos(a)-.65*Math.sin(s)*Math.sin(a);const n=.125*Math.cos(s)*Math.sin(a)+.65*Math.sin(s)*Math.cos(a),c=(2.25+o)*Math.sin(t);o=(2.25+o)*Math.cos(t),e.set(o,c,n)}};e.TubeGeometry=class extends s.ParametricGeometry{constructor(s,e=64,a=1,o=8,n=!1){const c=e+1,h=s.computeFrenetFrames(e,n),i=h.tangents,r=h.normals,M=h.binormals,u=new t.Vector3;super((function(t,e,o){e*=2*Math.PI;const n=Math.floor(t*(c-1));s.getPointAt(t,u);const h=r[n],i=M[n],m=-a*Math.cos(e),l=a*Math.sin(e);u.x+=m*h.x+l*i.x,u.y+=m*h.y+l*i.y,u.z+=m*h.z+l*i.z,o.copy(u)}),e,o),this.tangents=i,this.normals=r,this.binormals=M,this.path=s,this.segments=e,this.radius=a,this.segmentsRadius=o,this.closed=n}},e.TorusKnotGeometry=class extends e.TubeGeometry{constructor(s=200,e=40,a=64,o=8,n=2,c=3){class h extends t.Curve{getPoint(e,a=new t.Vector3){const o=a;e*=2*Math.PI;const h=(1+.5*Math.cos(c*e))*Math.cos(n*e),i=(1+.5*Math.cos(c*e))*Math.sin(n*e),r=.5*Math.sin(c*e);return o.set(h,i,r).multiplyScalar(s)}}const i=a,r=o;super(new h,i,e,r,!0,!1),this.radius=s,this.tube=e,this.segmentsT=a,this.segmentsR=o,this.p=n,this.q=c}},e.SphereGeometry=class extends s.ParametricGeometry{constructor(t,s,e){super((function(s,e,a){s*=Math.PI,e*=2*Math.PI;const o=t*Math.sin(s)*Math.cos(e),n=t*Math.sin(s)*Math.sin(e),c=t*Math.cos(s);a.set(o,n,c)}),s,e)}},e.PlaneGeometry=class extends s.ParametricGeometry{constructor(t,s,e,a){super((function(e,a,o){const n=e*t,c=a*s;o.set(n,0,c)}),e,a)}},exports.ParametricGeometries=e;