three-stdlib 2.9.1 → 2.10.2
Sign up to get free protection for your applications and to get access to all the features.
- package/controls/DragControls.cjs.js +1 -1
- package/controls/DragControls.d.ts +2 -1
- package/controls/DragControls.js +2 -0
- package/controls/TransformControls.cjs.js +1 -1
- package/controls/TransformControls.d.ts +1 -0
- package/controls/TransformControls.js +17 -0
- package/index.cjs.js +1 -1
- package/index.js +1 -1
- package/objects/MarchingCubes.cjs.js +1 -1
- package/objects/MarchingCubes.js +49 -109
- package/package.json +1 -1
- package/postprocessing/BloomPass.cjs.js +1 -1
- package/postprocessing/BloomPass.d.ts +12 -10
- package/postprocessing/BloomPass.js +93 -58
- package/postprocessing/BokehPass.cjs.js +1 -1
- package/postprocessing/BokehPass.d.ts +12 -14
- package/postprocessing/BokehPass.js +70 -55
- package/postprocessing/ClearPass.cjs.js +1 -1
- package/postprocessing/ClearPass.d.ts +6 -5
- package/postprocessing/ClearPass.js +21 -12
- package/postprocessing/DotScreenPass.cjs.js +1 -1
- package/postprocessing/DotScreenPass.d.ts +8 -8
- package/postprocessing/DotScreenPass.js +29 -20
- package/postprocessing/FilmPass.cjs.js +1 -1
- package/postprocessing/FilmPass.d.ts +8 -8
- package/postprocessing/FilmPass.js +30 -23
- package/postprocessing/GlitchPass.cjs.js +1 -1
- package/postprocessing/GlitchPass.d.ts +8 -9
- package/postprocessing/GlitchPass.js +15 -1
- package/postprocessing/HalftonePass.cjs.js +1 -1
- package/postprocessing/HalftonePass.d.ts +13 -13
- package/postprocessing/HalftonePass.js +35 -26
- package/postprocessing/OutlinePass.cjs.js +1 -1
- package/postprocessing/OutlinePass.d.ts +15 -26
- package/postprocessing/OutlinePass.js +317 -220
- package/utils/GeometryUtils.cjs.js +1 -1
- package/utils/GeometryUtils.d.ts +5 -26
- package/utils/GeometryUtils.js +29 -43
- package/utils/SceneUtils.cjs.js +1 -1
- package/utils/SceneUtils.d.ts +9 -12
- package/utils/SceneUtils.js +7 -7
package/index.js
CHANGED
@@ -52,7 +52,7 @@ export { Sky } from './objects/Sky.js';
|
|
52
52
|
export { Water2 } from './objects/Water2.js';
|
53
53
|
export { SceneUtils } from './utils/SceneUtils.js';
|
54
54
|
export { UVsDebug } from './utils/UVsDebug.js';
|
55
|
-
export {
|
55
|
+
export { GeometryUtils } from './utils/GeometryUtils.js';
|
56
56
|
export { RoughnessMipmapper } from './utils/RoughnessMipmapper.js';
|
57
57
|
export { SkeletonUtils } from './utils/SkeletonUtils.js';
|
58
58
|
export { ShadowMapViewer } from './utils/ShadowMapViewer.js';
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three");class s extends t.ImmediateRenderObject{constructor(s,r,o,a){super(r);const n=this,l=new Float32Array(36),h=new Float32Array(36),c=new Float32Array(36);function f(t,s,e){return t+(s-t)*e}function y(t,s,e,i,r,o,a,y,u,A){const d=(e-a)/(y-a),z=n.normal_cache;l[s+0]=i+d*n.delta,l[s+1]=r,l[s+2]=o,h[s+0]=f(z[t+0],z[t+3],d),h[s+1]=f(z[t+1],z[t+4],d),h[s+2]=f(z[t+2],z[t+5],d),c[s+0]=f(n.palette[3*u+0],n.palette[3*A+0],d),c[s+1]=f(n.palette[3*u+1],n.palette[3*A+1],d),c[s+2]=f(n.palette[3*u+2],n.palette[3*A+2],d)}function u(t,s,e,i,r,o,a,y,u,A){const d=(e-a)/(y-a),z=n.normal_cache;l[s+0]=i,l[s+1]=r+d*n.delta,l[s+2]=o;const m=t+3*n.yd;h[s+0]=f(z[t+0],z[m+0],d),h[s+1]=f(z[t+1],z[m+1],d),h[s+2]=f(z[t+2],z[m+2],d),c[s+0]=f(n.palette[3*u+0],n.palette[3*A+0],d),c[s+1]=f(n.palette[3*u+1],n.palette[3*A+1],d),c[s+2]=f(n.palette[3*u+2],n.palette[3*A+2],d)}function A(t,s,e,i,r,o,a,y,u,A){const d=(e-a)/(y-a),z=n.normal_cache;l[s+0]=i,l[s+1]=r,l[s+2]=o+d*n.delta;const m=t+3*n.zd;h[s+0]=f(z[t+0],z[m+0],d),h[s+1]=f(z[t+1],z[m+1],d),h[s+2]=f(z[t+2],z[m+2],d),c[s+0]=f(n.palette[3*u+0],n.palette[3*A+0],d),c[s+1]=f(n.palette[3*u+1],n.palette[3*A+1],d),c[s+2]=f(n.palette[3*u+2],n.palette[3*A+2],d)}function d(t){const s=3*t;0===n.normal_cache[s]&&(n.normal_cache[s+0]=n.field[t-1]-n.field[t+1],n.normal_cache[s+1]=n.field[t-n.yd]-n.field[t+n.yd],n.normal_cache[s+2]=n.field[t-n.zd]-n.field[t+n.zd])}function z(t,s,r,o,a,f){const z=o+1,p=o+n.yd,b=o+n.zd,C=z+n.yd,w=z+n.zd,v=o+n.yd+n.zd,M=z+n.yd+n.zd;let g=0;const F=n.field[o],x=n.field[z],U=n.field[p],_=n.field[C],P=n.field[b],B=n.field[w],N=n.field[v],q=n.field[M];F<a&&(g|=1),x<a&&(g|=2),U<a&&(g|=8),_<a&&(g|=4),P<a&&(g|=16),B<a&&(g|=32),N<a&&(g|=128),q<a&&(g|=64);const G=e[g];if(0===G)return 0;const I=n.delta,T=t+I,j=s+I,E=r+I;1&G&&(d(o),d(z),y(3*o,0,a,t,s,r,F,x,o,z)),2&G&&(d(z),d(C),u(3*z,3,a,T,s,r,x,_,z,C)),4&G&&(d(p),d(C),y(3*p,6,a,t,j,r,U,_,p,C)),8&G&&(d(o),d(p),u(3*o,9,a,t,s,r,F,U,o,p)),16&G&&(d(b),d(w),y(3*b,12,a,t,s,E,P,B,b,w)),32&G&&(d(w),d(M),u(3*w,15,a,T,s,E,B,q,w,M)),64&G&&(d(v),d(M),y(3*v,18,a,t,j,E,N,q,v,M)),128&G&&(d(b),d(v),u(3*b,21,a,t,s,E,P,N,b,v)),256&G&&(d(o),d(b),A(3*o,24,a,t,s,r,F,P,o,b)),512&G&&(d(z),d(w),A(3*z,27,a,T,s,r,x,B,z,w)),1024&G&&(d(C),d(M),A(3*C,30,a,T,j,r,_,q,C,M)),2048&G&&(d(p),d(v),A(3*p,33,a,t,j,r,U,N,p,v)),g<<=4;let O,R,H,S=0,X=0;for(;-1!=i[g+X];)O=g+X,R=O+1,H=O+2,m(l,h,c,3*i[O],3*i[R],3*i[H],f),X+=3,S++;return S}function m(t,s,e,i,r,o,a){const l=3*n.count;if(n.positionArray[l+0]=t[i],n.positionArray[l+1]=t[i+1],n.positionArray[l+2]=t[i+2],n.positionArray[l+3]=t[r],n.positionArray[l+4]=t[r+1],n.positionArray[l+5]=t[r+2],n.positionArray[l+6]=t[o],n.positionArray[l+7]=t[o+1],n.positionArray[l+8]=t[o+2],!0===n.material.flatShading){const t=(s[i+0]+s[r+0]+s[o+0])/3,e=(s[i+1]+s[r+1]+s[o+1])/3,a=(s[i+2]+s[r+2]+s[o+2])/3;n.normalArray[l+0]=t,n.normalArray[l+1]=e,n.normalArray[l+2]=a,n.normalArray[l+3]=t,n.normalArray[l+4]=e,n.normalArray[l+5]=a,n.normalArray[l+6]=t,n.normalArray[l+7]=e,n.normalArray[l+8]=a}else n.normalArray[l+0]=s[i+0],n.normalArray[l+1]=s[i+1],n.normalArray[l+2]=s[i+2],n.normalArray[l+3]=s[r+0],n.normalArray[l+4]=s[r+1],n.normalArray[l+5]=s[r+2],n.normalArray[l+6]=s[o+0],n.normalArray[l+7]=s[o+1],n.normalArray[l+8]=s[o+2];if(n.enableUvs){const s=2*n.count;n.uvArray[s+0]=t[i+0],n.uvArray[s+1]=t[i+2],n.uvArray[s+2]=t[r+0],n.uvArray[s+3]=t[r+2],n.uvArray[s+4]=t[o+0],n.uvArray[s+5]=t[o+2]}n.enableColors&&(n.colorArray[l+0]=e[i+0],n.colorArray[l+1]=e[i+1],n.colorArray[l+2]=e[i+2],n.colorArray[l+3]=e[r+0],n.colorArray[l+4]=e[r+1],n.colorArray[l+5]=e[r+2],n.colorArray[l+6]=e[o+0],n.colorArray[l+7]=e[o+1],n.colorArray[l+8]=e[o+2]),n.count+=3,n.count>=n.maxCount-3&&(n.hasPositions=!0,n.hasNormals=!0,n.enableUvs&&(n.hasUvs=!0),n.enableColors&&(n.hasColors=!0),a(n))}function p(t,s,e){const i=new Float32Array(t.length+e);return i.set(t,0),i.set(s.slice(0,e),t.length),i}this.enableUvs=void 0!==o&&o,this.enableColors=void 0!==a&&a,this.init=function(t){this.resolution=t,this.isolation=80,this.size=t,this.size2=this.size*this.size,this.size3=this.size2*this.size,this.halfsize=this.size/2,this.delta=2/this.size,this.yd=this.size,this.zd=this.size2,this.field=new Float32Array(this.size3),this.normal_cache=new Float32Array(3*this.size3),this.palette=new Float32Array(3*this.size3),this.maxCount=4096,this.count=0,this.hasPositions=!1,this.hasNormals=!1,this.hasColors=!1,this.hasUvs=!1,this.positionArray=new Float32Array(3*this.maxCount),this.normalArray=new Float32Array(3*this.maxCount),this.enableUvs&&(this.uvArray=new Float32Array(2*this.maxCount)),this.enableColors&&(this.colorArray=new Float32Array(3*this.maxCount))},this.begin=function(){this.count=0,this.hasPositions=!1,this.hasNormals=!1,this.hasUvs=!1,this.hasColors=!1},this.end=function(s){if(0!==this.count){for(let t=3*this.count;t<this.positionArray.length;t++)this.positionArray[t]=0;this.hasPositions=!0,this.hasNormals=!0,this.enableUvs&&this.material.map&&(this.hasUvs=!0),this.enableColors&&this.material.vertexColors!==t.NoColors&&(this.hasColors=!0),s(this)}},this.addBall=function(s,e,i,r,o,a){const n=Math.sign(r);r=Math.abs(r);const l=!(null==a);let h=new t.Color(s,e,i);if(l)try{h=a instanceof t.Color?a:Array.isArray(a)?new t.Color(Math.min(Math.abs(a[0]),1),Math.min(Math.abs(a[1]),1),Math.min(Math.abs(a[2]),1)):new t.Color(a)}catch(r){h=new t.Color(s,e,i)}const c=this.size*Math.sqrt(r/o),f=i*this.size,y=e*this.size,u=s*this.size;let A=Math.floor(f-c);A<1&&(A=1);let d=Math.floor(f+c);d>this.size-1&&(d=this.size-1);let z=Math.floor(y-c);z<1&&(z=1);let m=Math.floor(y+c);m>this.size-1&&(m=this.size-1);let p=Math.floor(u-c);p<1&&(p=1);let b,C,w,v,M,g,F,x,U,_,P,B=Math.floor(u+c);for(B>this.size-1&&(B=this.size-1),w=A;w<d;w++)for(M=this.size2*w,x=w/this.size-i,U=x*x,C=z;C<m;C++)for(v=M+this.size*C,F=C/this.size-e,_=F*F,b=p;b<B;b++)if(g=b/this.size-s,P=r/(1e-6+g*g+_+U)-o,P>0){this.field[v+b]+=P*n;const t=Math.sqrt((b-u)*(b-u)+(C-y)*(C-y)+(w-f)*(w-f))/c,s=1-t*t*t*(t*(6*t-15)+10);this.palette[3*(v+b)+0]+=h.r*s,this.palette[3*(v+b)+1]+=h.g*s,this.palette[3*(v+b)+2]+=h.b*s}},this.addPlaneX=function(t,s){const e=this.size,i=this.yd,r=this.zd,o=this.field;let a,n,l,h,c,f,y,u=e*Math.sqrt(t/s);for(u>e&&(u=e),a=0;a<u;a++)if(f=a/e,h=f*f,c=t/(1e-4+h)-s,c>0)for(n=0;n<e;n++)for(y=a+n*i,l=0;l<e;l++)o[r*l+y]+=c},this.addPlaneY=function(t,s){const e=this.size,i=this.yd,r=this.zd,o=this.field;let a,n,l,h,c,f,y,u,A=e*Math.sqrt(t/s);for(A>e&&(A=e),n=0;n<A;n++)if(f=n/e,h=f*f,c=t/(1e-4+h)-s,c>0)for(y=n*i,a=0;a<e;a++)for(u=y+a,l=0;l<e;l++)o[r*l+u]+=c},this.addPlaneZ=function(t,s){const e=this.size,i=this.yd,r=this.zd,o=this.field;let a,n,l,h,c,f,y,u,A=e*Math.sqrt(t/s);for(A>e&&(A=e),l=0;l<A;l++)if(f=l/e,h=f*f,c=t/(1e-4+h)-s,c>0)for(y=r*l,n=0;n<e;n++)for(u=y+n*i,a=0;a<e;a++)o[u+a]+=c},this.setCell=function(t,s,e,i){const r=this.size2*e+this.size*s+t;this.field[r]=i},this.getCell=function(t,s,e){const i=this.size2*e+this.size*s+t;return this.field[i]},this.blur=function(t=1){const s=this.field,e=s.slice(),i=this.size,r=this.size2;for(let o=0;o<i;o++)for(let a=0;a<i;a++)for(let n=0;n<i;n++){const l=r*n+i*a+o;let h=e[l],c=1;for(let s=-1;s<=1;s+=2){const l=s+o;if(!(l<0||l>=i))for(let s=-1;s<=1;s+=2){const o=s+a;if(!(o<0||o>=i))for(let s=-1;s<=1;s+=2){const a=s+n;if(a<0||a>=i)continue;const f=e[r*a+i*o+l];c++,h+=t*(f-h)/c}}}s[l]=h}},this.reset=function(){for(let t=0;t<this.size3;t++)this.normal_cache[3*t]=0,this.field[t]=0,this.palette[3*t]=this.palette[3*t+1]=this.palette[3*t+2]=0},this.render=function(t){this.begin();const s=this.size-2;for(let e=1;e<s;e++){const i=this.size2*e,r=(e-this.halfsize)/this.halfsize;for(let e=1;e<s;e++){const o=i+this.size*e,a=(e-this.halfsize)/this.halfsize;for(let e=1;e<s;e++){z((e-this.halfsize)/this.halfsize,a,r,o+e,this.isolation,t)}}}this.end(t)},this.generateGeometry=function(){return console.warn("THREE.MarchingCubes: generateGeometry() now returns BufferGeometry"),this.generateBufferGeometry()},this.generateBufferGeometry=function(){const s=new t.BufferGeometry;let e=new Float32Array,i=new Float32Array,r=new Float32Array,o=new Float32Array;const a=this;return this.render((function(t){a.hasPositions&&(e=p(e,t.positionArray,3*t.count)),a.hasNormals&&(i=p(i,t.normalArray,3*t.count)),a.hasColors&&(r=p(r,t.colorArray,3*t.count)),a.hasUvs&&(o=p(o,t.uvArray,2*t.count)),t.count=0})),this.hasPositions&&s.setAttribute("position",new t.BufferAttribute(e,3)),this.hasNormals&&s.setAttribute("normal",new t.BufferAttribute(i,3)),this.hasColors&&s.setAttribute("color",new t.BufferAttribute(r,3)),this.hasUvs&&s.setAttribute("uv",new t.BufferAttribute(o,2)),s},this.init(s)}}s.prototype.isMarchingCubes=!0;const e=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]),i=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,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-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);exports.MarchingCubes=s,exports.edgeTable=e,exports.triTable=i;
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("three");class e extends t.Mesh{constructor(e,s,o=!1,a=!1,n=1e4){const l=new t.BufferGeometry;super(l,s);const h=this,c=new Float32Array(36),f=new Float32Array(36),y=new Float32Array(36);function A(t,e,i){return t+(e-t)*i}function d(t,e,i,r,s,o,a,n,l,d){const u=(i-a)/(n-a),z=h.normal_cache;c[e+0]=r+u*h.delta,c[e+1]=s,c[e+2]=o,f[e+0]=A(z[t+0],z[t+3],u),f[e+1]=A(z[t+1],z[t+4],u),f[e+2]=A(z[t+2],z[t+5],u),y[e+0]=A(h.palette[3*l+0],h.palette[3*d+0],u),y[e+1]=A(h.palette[3*l+1],h.palette[3*d+1],u),y[e+2]=A(h.palette[3*l+2],h.palette[3*d+2],u)}function u(t,e,i,r,s,o,a,n,l,d){const u=(i-a)/(n-a),z=h.normal_cache;c[e+0]=r,c[e+1]=s+u*h.delta,c[e+2]=o;const p=t+3*h.yd;f[e+0]=A(z[t+0],z[p+0],u),f[e+1]=A(z[t+1],z[p+1],u),f[e+2]=A(z[t+2],z[p+2],u),y[e+0]=A(h.palette[3*l+0],h.palette[3*d+0],u),y[e+1]=A(h.palette[3*l+1],h.palette[3*d+1],u),y[e+2]=A(h.palette[3*l+2],h.palette[3*d+2],u)}function z(t,e,i,r,s,o,a,n,l,d){const u=(i-a)/(n-a),z=h.normal_cache;c[e+0]=r,c[e+1]=s,c[e+2]=o+u*h.delta;const p=t+3*h.zd;f[e+0]=A(z[t+0],z[p+0],u),f[e+1]=A(z[t+1],z[p+1],u),f[e+2]=A(z[t+2],z[p+2],u),y[e+0]=A(h.palette[3*l+0],h.palette[3*d+0],u),y[e+1]=A(h.palette[3*l+1],h.palette[3*d+1],u),y[e+2]=A(h.palette[3*l+2],h.palette[3*d+2],u)}function p(t){const e=3*t;0===h.normal_cache[e]&&(h.normal_cache[e+0]=h.field[t-1]-h.field[t+1],h.normal_cache[e+1]=h.field[t-h.yd]-h.field[t+h.yd],h.normal_cache[e+2]=h.field[t-h.zd]-h.field[t+h.zd])}function m(t,e,s,o,a){const n=o+1,l=o+h.yd,A=o+h.zd,m=n+h.yd,w=n+h.zd,M=o+h.yd+h.zd,g=n+h.yd+h.zd;let v=0;const U=h.field[o],C=h.field[n],_=h.field[l],F=h.field[m],D=h.field[A],B=h.field[w],q=h.field[M],x=h.field[g];U<a&&(v|=1),C<a&&(v|=2),_<a&&(v|=8),F<a&&(v|=4),D<a&&(v|=16),B<a&&(v|=32),q<a&&(v|=128),x<a&&(v|=64);const P=i[v];if(0===P)return 0;const G=h.delta,I=t+G,T=e+G,j=s+G;1&P&&(p(o),p(n),d(3*o,0,a,t,e,s,U,C,o,n)),2&P&&(p(n),p(m),u(3*n,3,a,I,e,s,C,F,n,m)),4&P&&(p(l),p(m),d(3*l,6,a,t,T,s,_,F,l,m)),8&P&&(p(o),p(l),u(3*o,9,a,t,e,s,U,_,o,l)),16&P&&(p(A),p(w),d(3*A,12,a,t,e,j,D,B,A,w)),32&P&&(p(w),p(g),u(3*w,15,a,I,e,j,B,x,w,g)),64&P&&(p(M),p(g),d(3*M,18,a,t,T,j,q,x,M,g)),128&P&&(p(A),p(M),u(3*A,21,a,t,e,j,D,q,A,M)),256&P&&(p(o),p(A),z(3*o,24,a,t,e,s,U,D,o,A)),512&P&&(p(n),p(w),z(3*n,27,a,I,e,s,C,B,n,w)),1024&P&&(p(m),p(g),z(3*m,30,a,I,T,s,F,x,m,g)),2048&P&&(p(l),p(M),z(3*l,33,a,t,T,s,_,q,l,M)),v<<=4;let O,R,S,X=0,Y=0;for(;-1!=r[v+Y];)O=v+Y,R=O+1,S=O+2,b(c,f,y,3*r[O],3*r[R],3*r[S]),Y+=3,X++;return X}function b(t,e,i,r,s,o){const a=3*h.count;if(h.positionArray[a+0]=t[r],h.positionArray[a+1]=t[r+1],h.positionArray[a+2]=t[r+2],h.positionArray[a+3]=t[s],h.positionArray[a+4]=t[s+1],h.positionArray[a+5]=t[s+2],h.positionArray[a+6]=t[o],h.positionArray[a+7]=t[o+1],h.positionArray[a+8]=t[o+2],!0===h.material.flatShading){const t=(e[r+0]+e[s+0]+e[o+0])/3,i=(e[r+1]+e[s+1]+e[o+1])/3,n=(e[r+2]+e[s+2]+e[o+2])/3;h.normalArray[a+0]=t,h.normalArray[a+1]=i,h.normalArray[a+2]=n,h.normalArray[a+3]=t,h.normalArray[a+4]=i,h.normalArray[a+5]=n,h.normalArray[a+6]=t,h.normalArray[a+7]=i,h.normalArray[a+8]=n}else h.normalArray[a+0]=e[r+0],h.normalArray[a+1]=e[r+1],h.normalArray[a+2]=e[r+2],h.normalArray[a+3]=e[s+0],h.normalArray[a+4]=e[s+1],h.normalArray[a+5]=e[s+2],h.normalArray[a+6]=e[o+0],h.normalArray[a+7]=e[o+1],h.normalArray[a+8]=e[o+2];if(h.enableUvs){const e=2*h.count;h.uvArray[e+0]=t[r+0],h.uvArray[e+1]=t[r+2],h.uvArray[e+2]=t[s+0],h.uvArray[e+3]=t[s+2],h.uvArray[e+4]=t[o+0],h.uvArray[e+5]=t[o+2]}h.enableColors&&(h.colorArray[a+0]=i[r+0],h.colorArray[a+1]=i[r+1],h.colorArray[a+2]=i[r+2],h.colorArray[a+3]=i[s+0],h.colorArray[a+4]=i[s+1],h.colorArray[a+5]=i[s+2],h.colorArray[a+6]=i[o+0],h.colorArray[a+7]=i[o+1],h.colorArray[a+8]=i[o+2]),h.count+=3}this.enableUvs=o,this.enableColors=a,this.init=function(e){this.resolution=e,this.isolation=80,this.size=e,this.size2=this.size*this.size,this.size3=this.size2*this.size,this.halfsize=this.size/2,this.delta=2/this.size,this.yd=this.size,this.zd=this.size2,this.field=new Float32Array(this.size3),this.normal_cache=new Float32Array(3*this.size3),this.palette=new Float32Array(3*this.size3),this.count=0;const i=3*n;this.positionArray=new Float32Array(3*i);const r=new t.BufferAttribute(this.positionArray,3);r.setUsage(t.DynamicDrawUsage),l.setAttribute("position",r),this.normalArray=new Float32Array(3*i);const s=new t.BufferAttribute(this.normalArray,3);if(s.setUsage(t.DynamicDrawUsage),l.setAttribute("normal",s),this.enableUvs){this.uvArray=new Float32Array(2*i);const e=new t.BufferAttribute(this.uvArray,2);e.setUsage(t.DynamicDrawUsage),l.setAttribute("uv",e)}if(this.enableColors){this.colorArray=new Float32Array(3*i);const e=new t.BufferAttribute(this.colorArray,3);e.setUsage(t.DynamicDrawUsage),l.setAttribute("color",e)}},this.addBall=function(e,i,r,s,o,a){const n=Math.sign(s);s=Math.abs(s);const l=!(null==a);let h=new t.Color(e,i,r);if(l)try{h=a instanceof t.Color?a:Array.isArray(a)?new t.Color(Math.min(Math.abs(a[0]),1),Math.min(Math.abs(a[1]),1),Math.min(Math.abs(a[2]),1)):new t.Color(a)}catch(s){h=new t.Color(e,i,r)}const c=this.size*Math.sqrt(s/o),f=r*this.size,y=i*this.size,A=e*this.size;let d=Math.floor(f-c);d<1&&(d=1);let u=Math.floor(f+c);u>this.size-1&&(u=this.size-1);let z=Math.floor(y-c);z<1&&(z=1);let p=Math.floor(y+c);p>this.size-1&&(p=this.size-1);let m=Math.floor(A-c);m<1&&(m=1);let b,w,M,g,v,U,C,_,F,D,B,q=Math.floor(A+c);for(q>this.size-1&&(q=this.size-1),M=d;M<u;M++)for(v=this.size2*M,_=M/this.size-r,F=_*_,w=z;w<p;w++)for(g=v+this.size*w,C=w/this.size-i,D=C*C,b=m;b<q;b++)if(U=b/this.size-e,B=s/(1e-6+U*U+D+F)-o,B>0){this.field[g+b]+=B*n;const t=Math.sqrt((b-A)*(b-A)+(w-y)*(w-y)+(M-f)*(M-f))/c,e=1-t*t*t*(t*(6*t-15)+10);this.palette[3*(g+b)+0]+=h.r*e,this.palette[3*(g+b)+1]+=h.g*e,this.palette[3*(g+b)+2]+=h.b*e}},this.addPlaneX=function(t,e){const i=this.size,r=this.yd,s=this.zd,o=this.field;let a,n,l,h,c,f,y,A=i*Math.sqrt(t/e);for(A>i&&(A=i),a=0;a<A;a++)if(f=a/i,h=f*f,c=t/(1e-4+h)-e,c>0)for(n=0;n<i;n++)for(y=a+n*r,l=0;l<i;l++)o[s*l+y]+=c},this.addPlaneY=function(t,e){const i=this.size,r=this.yd,s=this.zd,o=this.field;let a,n,l,h,c,f,y,A,d=i*Math.sqrt(t/e);for(d>i&&(d=i),n=0;n<d;n++)if(f=n/i,h=f*f,c=t/(1e-4+h)-e,c>0)for(y=n*r,a=0;a<i;a++)for(A=y+a,l=0;l<i;l++)o[s*l+A]+=c},this.addPlaneZ=function(t,e){const i=this.size,r=this.yd,s=this.zd,o=this.field;let a,n,l,h,c,f,y,A,d=i*Math.sqrt(t/e);for(d>i&&(d=i),l=0;l<d;l++)if(f=l/i,h=f*f,c=t/(1e-4+h)-e,c>0)for(y=s*l,n=0;n<i;n++)for(A=y+n*r,a=0;a<i;a++)o[A+a]+=c},this.setCell=function(t,e,i,r){const s=this.size2*i+this.size*e+t;this.field[s]=r},this.getCell=function(t,e,i){const r=this.size2*i+this.size*e+t;return this.field[r]},this.blur=function(t=1){const e=this.field,i=e.slice(),r=this.size,s=this.size2;for(let o=0;o<r;o++)for(let a=0;a<r;a++)for(let n=0;n<r;n++){const l=s*n+r*a+o;let h=i[l],c=1;for(let e=-1;e<=1;e+=2){const l=e+o;if(!(l<0||l>=r))for(let e=-1;e<=1;e+=2){const o=e+a;if(!(o<0||o>=r))for(let e=-1;e<=1;e+=2){const a=e+n;if(a<0||a>=r)continue;const f=i[s*a+r*o+l];c++,h+=t*(f-h)/c}}}e[l]=h}},this.reset=function(){for(let t=0;t<this.size3;t++)this.normal_cache[3*t]=0,this.field[t]=0,this.palette[3*t]=this.palette[3*t+1]=this.palette[3*t+2]=0},this.onBeforeRender=function(){this.count=0;const t=this.size-2;for(let e=1;e<t;e++){const i=this.size2*e,r=(e-this.halfsize)/this.halfsize;for(let e=1;e<t;e++){const s=i+this.size*e,o=(e-this.halfsize)/this.halfsize;for(let e=1;e<t;e++){m((e-this.halfsize)/this.halfsize,o,r,s+e,this.isolation)}}}for(let t=3*this.count;t<this.positionArray.length;t++)this.positionArray[t]=0;l.getAttribute("position").needsUpdate=!0,l.getAttribute("normal").needsUpdate=!0,this.enableUvs&&(l.getAttribute("uv").needsUpdate=!0),this.enableColors&&(l.getAttribute("color").needsUpdate=!0),this.count/3>n&&console.warn("MarchingCubes: Geometry buffers too small for rendering. Please create an instance with a higher poly count.")},this.init(e)}}e.prototype.isMarchingCubes=!0;const i=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]),r=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,8,3,9,8,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,1,2,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,2,10,0,2,9,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,8,3,2,10,8,10,9,8,-1,-1,-1,-1,-1,-1,-1,3,11,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,11,2,8,11,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,9,0,2,3,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,11,2,1,9,11,9,8,11,-1,-1,-1,-1,-1,-1,-1,3,10,1,11,10,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,10,1,0,8,10,8,11,10,-1,-1,-1,-1,-1,-1,-1,3,9,0,3,11,9,11,10,9,-1,-1,-1,-1,-1,-1,-1,9,8,10,10,8,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,7,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,3,0,7,3,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,1,9,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,1,9,4,7,1,7,3,1,-1,-1,-1,-1,-1,-1,-1,1,2,10,8,4,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,4,7,3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-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);exports.MarchingCubes=e,exports.edgeTable=i,exports.triTable=r;
|
package/objects/MarchingCubes.js
CHANGED
@@ -1,19 +1,20 @@
|
|
1
|
-
import {
|
1
|
+
import { Mesh, BufferGeometry, BufferAttribute, DynamicDrawUsage, Color } from 'three';
|
2
2
|
|
3
3
|
/**
|
4
4
|
* Port of http://webglsamples.org/blob/blob.html
|
5
5
|
*/
|
6
6
|
|
7
|
-
class MarchingCubes extends
|
8
|
-
constructor(resolution, material, enableUvs, enableColors) {
|
9
|
-
|
7
|
+
class MarchingCubes extends Mesh {
|
8
|
+
constructor(resolution, material, enableUvs = false, enableColors = false, maxPolyCount = 10000) {
|
9
|
+
const geometry = new BufferGeometry();
|
10
|
+
super(geometry, material);
|
10
11
|
const scope = this; // temp buffers used in polygonize
|
11
12
|
|
12
13
|
const vlist = new Float32Array(12 * 3);
|
13
14
|
const nlist = new Float32Array(12 * 3);
|
14
15
|
const clist = new Float32Array(12 * 3);
|
15
|
-
this.enableUvs = enableUvs
|
16
|
-
this.enableColors = enableColors
|
16
|
+
this.enableUvs = enableUvs;
|
17
|
+
this.enableColors = enableColors; // functions have to be object properties
|
17
18
|
// prototype functions kill performance
|
18
19
|
// (tested and it was 4x slower !!!)
|
19
20
|
|
@@ -32,24 +33,31 @@ class MarchingCubes extends ImmediateRenderObject {
|
|
32
33
|
this.zd = this.size2;
|
33
34
|
this.field = new Float32Array(this.size3);
|
34
35
|
this.normal_cache = new Float32Array(this.size3 * 3);
|
35
|
-
this.palette = new Float32Array(this.size3 * 3); //
|
36
|
-
|
37
|
-
this.maxCount = 4096; // TODO: find the fastest size for this buffer
|
36
|
+
this.palette = new Float32Array(this.size3 * 3); //
|
38
37
|
|
39
38
|
this.count = 0;
|
40
|
-
|
41
|
-
this.
|
42
|
-
this.
|
43
|
-
|
44
|
-
|
45
|
-
this.normalArray = new Float32Array(
|
39
|
+
const maxVertexCount = maxPolyCount * 3;
|
40
|
+
this.positionArray = new Float32Array(maxVertexCount * 3);
|
41
|
+
const positionAttribute = new BufferAttribute(this.positionArray, 3);
|
42
|
+
positionAttribute.setUsage(DynamicDrawUsage);
|
43
|
+
geometry.setAttribute('position', positionAttribute);
|
44
|
+
this.normalArray = new Float32Array(maxVertexCount * 3);
|
45
|
+
const normalAttribute = new BufferAttribute(this.normalArray, 3);
|
46
|
+
normalAttribute.setUsage(DynamicDrawUsage);
|
47
|
+
geometry.setAttribute('normal', normalAttribute);
|
46
48
|
|
47
49
|
if (this.enableUvs) {
|
48
|
-
this.uvArray = new Float32Array(
|
50
|
+
this.uvArray = new Float32Array(maxVertexCount * 2);
|
51
|
+
const uvAttribute = new BufferAttribute(this.uvArray, 2);
|
52
|
+
uvAttribute.setUsage(DynamicDrawUsage);
|
53
|
+
geometry.setAttribute('uv', uvAttribute);
|
49
54
|
}
|
50
55
|
|
51
56
|
if (this.enableColors) {
|
52
|
-
this.colorArray = new Float32Array(
|
57
|
+
this.colorArray = new Float32Array(maxVertexCount * 3);
|
58
|
+
const colorAttribute = new BufferAttribute(this.colorArray, 3);
|
59
|
+
colorAttribute.setUsage(DynamicDrawUsage);
|
60
|
+
geometry.setAttribute('color', colorAttribute);
|
53
61
|
}
|
54
62
|
}; ///////////////////////
|
55
63
|
// Polygonization
|
@@ -116,7 +124,7 @@ class MarchingCubes extends ImmediateRenderObject {
|
|
116
124
|
// (this is where most of time is spent - it's inner work of O(n3) loop )
|
117
125
|
|
118
126
|
|
119
|
-
function polygonize(fx, fy, fz, q, isol
|
127
|
+
function polygonize(fx, fy, fz, q, isol) {
|
120
128
|
// cache indices
|
121
129
|
const q1 = q + 1,
|
122
130
|
qy = q + scope.yd,
|
@@ -236,18 +244,15 @@ class MarchingCubes extends ImmediateRenderObject {
|
|
236
244
|
o1 = cubeindex + i;
|
237
245
|
o2 = o1 + 1;
|
238
246
|
o3 = o1 + 2;
|
239
|
-
posnormtriv(vlist, nlist, clist, 3 * triTable[o1], 3 * triTable[o2], 3 * triTable[o3]
|
247
|
+
posnormtriv(vlist, nlist, clist, 3 * triTable[o1], 3 * triTable[o2], 3 * triTable[o3]);
|
240
248
|
i += 3;
|
241
249
|
numtris++;
|
242
250
|
}
|
243
251
|
|
244
252
|
return numtris;
|
245
|
-
}
|
246
|
-
// Immediate render mode simulator
|
247
|
-
/////////////////////////////////////
|
248
|
-
|
253
|
+
}
|
249
254
|
|
250
|
-
function posnormtriv(pos, norm, colors, o1, o2, o3
|
255
|
+
function posnormtriv(pos, norm, colors, o1, o2, o3) {
|
251
256
|
const c = scope.count * 3; // positions
|
252
257
|
|
253
258
|
scope.positionArray[c + 0] = pos[o1];
|
@@ -310,51 +315,7 @@ class MarchingCubes extends ImmediateRenderObject {
|
|
310
315
|
}
|
311
316
|
|
312
317
|
scope.count += 3;
|
313
|
-
|
314
|
-
if (scope.count >= scope.maxCount - 3) {
|
315
|
-
scope.hasPositions = true;
|
316
|
-
scope.hasNormals = true;
|
317
|
-
|
318
|
-
if (scope.enableUvs) {
|
319
|
-
scope.hasUvs = true;
|
320
|
-
}
|
321
|
-
|
322
|
-
if (scope.enableColors) {
|
323
|
-
scope.hasColors = true;
|
324
|
-
}
|
325
|
-
|
326
|
-
renderCallback(scope);
|
327
|
-
}
|
328
|
-
}
|
329
|
-
|
330
|
-
this.begin = function () {
|
331
|
-
this.count = 0;
|
332
|
-
this.hasPositions = false;
|
333
|
-
this.hasNormals = false;
|
334
|
-
this.hasUvs = false;
|
335
|
-
this.hasColors = false;
|
336
|
-
};
|
337
|
-
|
338
|
-
this.end = function (renderCallback) {
|
339
|
-
if (this.count === 0) return;
|
340
|
-
|
341
|
-
for (let i = this.count * 3; i < this.positionArray.length; i++) {
|
342
|
-
this.positionArray[i] = 0.0;
|
343
|
-
}
|
344
|
-
|
345
|
-
this.hasPositions = true;
|
346
|
-
this.hasNormals = true;
|
347
|
-
|
348
|
-
if (this.enableUvs && this.material.map) {
|
349
|
-
this.hasUvs = true;
|
350
|
-
}
|
351
|
-
|
352
|
-
if (this.enableColors && this.material.vertexColors !== NoColors) {
|
353
|
-
this.hasColors = true;
|
354
|
-
}
|
355
|
-
|
356
|
-
renderCallback(this);
|
357
|
-
}; /////////////////////////////////////
|
318
|
+
} /////////////////////////////////////
|
358
319
|
// Metaballs
|
359
320
|
/////////////////////////////////////
|
360
321
|
// Adds a reciprocal ball (nice and blobby) that, to be fast, fades to zero after
|
@@ -591,8 +552,8 @@ class MarchingCubes extends ImmediateRenderObject {
|
|
591
552
|
}
|
592
553
|
};
|
593
554
|
|
594
|
-
this.
|
595
|
-
this.
|
555
|
+
this.onBeforeRender = function () {
|
556
|
+
this.count = 0; // Triangulate. Yeah, this is slow.
|
596
557
|
|
597
558
|
const smin2 = this.size - 2;
|
598
559
|
|
@@ -608,48 +569,25 @@ class MarchingCubes extends ImmediateRenderObject {
|
|
608
569
|
const fx = (x - this.halfsize) / this.halfsize; //+ 1
|
609
570
|
|
610
571
|
const q = y_offset + x;
|
611
|
-
polygonize(fx, fy, fz, q, this.isolation
|
572
|
+
polygonize(fx, fy, fz, q, this.isolation);
|
612
573
|
}
|
613
574
|
}
|
614
|
-
}
|
575
|
+
} // reset unneeded data
|
615
576
|
|
616
|
-
this.end(renderCallback);
|
617
|
-
};
|
618
577
|
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
};
|
578
|
+
for (let i = this.count * 3; i < this.positionArray.length; i++) {
|
579
|
+
this.positionArray[i] = 0.0;
|
580
|
+
} // update geometry data
|
623
581
|
|
624
|
-
function concatenate(a, b, length) {
|
625
|
-
const result = new Float32Array(a.length + length);
|
626
|
-
result.set(a, 0);
|
627
|
-
result.set(b.slice(0, length), a.length);
|
628
|
-
return result;
|
629
|
-
}
|
630
582
|
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
const geo_callback = function (object) {
|
640
|
-
if (scope.hasPositions) posArray = concatenate(posArray, object.positionArray, object.count * 3);
|
641
|
-
if (scope.hasNormals) normArray = concatenate(normArray, object.normalArray, object.count * 3);
|
642
|
-
if (scope.hasColors) colorArray = concatenate(colorArray, object.colorArray, object.count * 3);
|
643
|
-
if (scope.hasUvs) uvArray = concatenate(uvArray, object.uvArray, object.count * 2);
|
644
|
-
object.count = 0;
|
645
|
-
};
|
646
|
-
|
647
|
-
this.render(geo_callback);
|
648
|
-
if (this.hasPositions) geo.setAttribute('position', new BufferAttribute(posArray, 3));
|
649
|
-
if (this.hasNormals) geo.setAttribute('normal', new BufferAttribute(normArray, 3));
|
650
|
-
if (this.hasColors) geo.setAttribute('color', new BufferAttribute(colorArray, 3));
|
651
|
-
if (this.hasUvs) geo.setAttribute('uv', new BufferAttribute(uvArray, 2));
|
652
|
-
return geo;
|
583
|
+
geometry.getAttribute('position').needsUpdate = true;
|
584
|
+
geometry.getAttribute('normal').needsUpdate = true;
|
585
|
+
if (this.enableUvs) geometry.getAttribute('uv').needsUpdate = true;
|
586
|
+
if (this.enableColors) geometry.getAttribute('color').needsUpdate = true; // safety check
|
587
|
+
|
588
|
+
if (this.count / 3 > maxPolyCount) {
|
589
|
+
console.warn('MarchingCubes: Geometry buffers too small for rendering. Please create an instance with a higher poly count.');
|
590
|
+
}
|
653
591
|
};
|
654
592
|
|
655
593
|
this.init(resolution);
|
@@ -661,10 +599,12 @@ MarchingCubes.prototype.isMarchingCubes = true; ////////////////////////////////
|
|
661
599
|
// Marching cubes lookup tables
|
662
600
|
/////////////////////////////////////
|
663
601
|
// These tables are straight from Paul Bourke's page:
|
664
|
-
// http://
|
602
|
+
// http://paulbourke.net/geometry/polygonise/
|
665
603
|
// who in turn got them from Cory Gene Bloyd.
|
604
|
+
// prettier-ignore
|
605
|
+
|
606
|
+
const edgeTable = new Int32Array([0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00, 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c, 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90, 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c, 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30, 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac, 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0, 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c, 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60, 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc, 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0, 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c, 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950, 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc, 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0, 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc, 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0, 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650, 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc, 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0, 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c, 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460, 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac, 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0, 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230, 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c, 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190, 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0]); // prettier-ignore
|
666
607
|
|
667
|
-
const edgeTable = new Int32Array([0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00, 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c, 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90, 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c, 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30, 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac, 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0, 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c, 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60, 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc, 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0, 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c, 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950, 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc, 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0, 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc, 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0, 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650, 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc, 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0, 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c, 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460, 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac, 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0, 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230, 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c, 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190, 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0]);
|
668
608
|
const triTable = new Int32Array([-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1, 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1, 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1, 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1, 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1, 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1, 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1, 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1, 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1, 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1, 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1, 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1, 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1, 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1, 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1, 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1, 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1, 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1, 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1, 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1, 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1, 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1, 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1, 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1, 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1, 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1, 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1, 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1, 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1, 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1, 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1, 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1, 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1, 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1, 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1, 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1, 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1, 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1, 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1, 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1, 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1, 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1, 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1, 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1, 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1, 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1, 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1, 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1, 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1, 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1, 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1, 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1, 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1, 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1, 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1, 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1, 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1, 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1, 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1, 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1, 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1, 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1, 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1, 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1, 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1, 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1, 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1, 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1, 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1, 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1, 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1, 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1, 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1, 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1, 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1, 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1, 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1, 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1, 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1, 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1, 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1, 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1, 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1, 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1, 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1, 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1, 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1, 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1, 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1, 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1, 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1, 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1, 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1, 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1, 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1, 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1, 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1, 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1, 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1, 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1, 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1, 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1, 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1, 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1, 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1, 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1, 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1, 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1, 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1, 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1, 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1, 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1, 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1, 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1, 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1, 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1, 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1, 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1, 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1, 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1, 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1, 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1, 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1, 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1, 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1, 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1, 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1, 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1, 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1, 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1, 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1, 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1, 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1, 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1, 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1, 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1, 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1, 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1, 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1, 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1, 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1, 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1, 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1, 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1, 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1, 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1, 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1, 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1, 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1, 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1, 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1, 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1, 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1, 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1, 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1, 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1, 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]);
|
669
609
|
|
670
610
|
export { MarchingCubes, edgeTable, triTable };
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("./Pass.cjs.js"),r=require("three"),n=require("../shaders/ConvolutionShader.cjs.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(e);class o extends t.Pass{constructor(e=1,i=25,o=4,l=256){super(),s.default(this,"renderTargetX",void 0),s.default(this,"renderTargetY",void 0),s.default(this,"materialCombine",void 0),s.default(this,"materialConvolution",void 0),s.default(this,"fsQuad",void 0),s.default(this,"combineUniforms",void 0),s.default(this,"convolutionUniforms",void 0),s.default(this,"blurX",new r.Vector2(.001953125,0)),s.default(this,"blurY",new r.Vector2(0,.001953125)),this.renderTargetX=new r.WebGLRenderTarget(l,l),this.renderTargetX.texture.name="BloomPass.x",this.renderTargetY=new r.WebGLRenderTarget(l,l),this.renderTargetY.texture.name="BloomPass.y",this.combineUniforms=r.UniformsUtils.clone(a.uniforms),this.combineUniforms.strength.value=e,this.materialCombine=new r.ShaderMaterial({uniforms:this.combineUniforms,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader,blending:r.AdditiveBlending,transparent:!0}),void 0===n.ConvolutionShader&&console.error("BloomPass relies on ConvolutionShader");const u=n.ConvolutionShader;this.convolutionUniforms=r.UniformsUtils.clone(u.uniforms),this.convolutionUniforms.uImageIncrement.value=this.blurX,this.convolutionUniforms.cKernel.value=n.ConvolutionShader.buildKernel(o),this.materialConvolution=new r.ShaderMaterial({uniforms:this.convolutionUniforms,vertexShader:u.vertexShader,fragmentShader:u.fragmentShader,defines:{KERNEL_SIZE_FLOAT:i.toFixed(1),KERNEL_SIZE_INT:i.toFixed(0)}}),this.needsSwap=!1,this.fsQuad=new t.FullScreenQuad(this.materialConvolution)}render(e,t,r,n,i){i&&e.state.buffers.stencil.setTest(!1),this.fsQuad.material=this.materialConvolution,this.convolutionUniforms.tDiffuse.value=r.texture,this.convolutionUniforms.uImageIncrement.value=this.blurX,e.setRenderTarget(this.renderTargetX),e.clear(),this.fsQuad.render(e),this.convolutionUniforms.tDiffuse.value=this.renderTargetX.texture,this.convolutionUniforms.uImageIncrement.value=this.blurY,e.setRenderTarget(this.renderTargetY),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.materialCombine,this.combineUniforms.tDiffuse.value=this.renderTargetY.texture,i&&e.state.buffers.stencil.setTest(!0),e.setRenderTarget(r),this.clear&&e.clear(),this.fsQuad.render(e)}}const a={uniforms:{tDiffuse:{value:null},strength:{value:1}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"\n uniform float strength;\n uniform sampler2D tDiffuse;\n varying vec2 vUv;\n void main() {\n vec4 texel = texture2D( tDiffuse, vUv );\n gl_FragColor = strength * texel;\n }"};exports.BloomPass=o;
|
@@ -1,14 +1,16 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
export class BloomPass extends Pass {
|
6
|
-
constructor(strength?: number, kernelSize?: number, sigma?: number, resolution?: number);
|
1
|
+
import { Pass, FullScreenQuad } from './Pass';
|
2
|
+
import { ShaderMaterial, Vector2, WebGLRenderer, WebGLRenderTarget } from 'three';
|
3
|
+
declare class BloomPass extends Pass {
|
7
4
|
renderTargetX: WebGLRenderTarget;
|
8
5
|
renderTargetY: WebGLRenderTarget;
|
9
|
-
|
10
|
-
materialCopy: ShaderMaterial;
|
11
|
-
convolutionUniforms: object;
|
6
|
+
materialCombine: ShaderMaterial;
|
12
7
|
materialConvolution: ShaderMaterial;
|
13
|
-
fsQuad:
|
8
|
+
fsQuad: FullScreenQuad;
|
9
|
+
combineUniforms: any;
|
10
|
+
convolutionUniforms: any;
|
11
|
+
blurX: Vector2;
|
12
|
+
blurY: Vector2;
|
13
|
+
constructor(strength?: number, kernelSize?: number, sigma?: number, resolution?: number);
|
14
|
+
render(renderer: WebGLRenderer, writeBuffer: WebGLRenderTarget, readBuffer: WebGLRenderTarget, deltaTime: number, maskActive: boolean): void;
|
14
15
|
}
|
16
|
+
export { BloomPass };
|
@@ -1,81 +1,116 @@
|
|
1
|
-
import
|
2
|
-
import {
|
3
|
-
import {
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
2
|
+
import { Pass, FullScreenQuad } from './Pass.js';
|
3
|
+
import { Vector2, WebGLRenderTarget, UniformsUtils, ShaderMaterial, AdditiveBlending } from 'three';
|
4
4
|
import { ConvolutionShader } from '../shaders/ConvolutionShader.js';
|
5
5
|
|
6
|
-
|
7
|
-
strength =
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
this.copyUniforms['opacity'].value = strength;
|
26
|
-
this.materialCopy = new ShaderMaterial({
|
27
|
-
uniforms: this.copyUniforms,
|
28
|
-
vertexShader: copyShader.vertexShader,
|
29
|
-
fragmentShader: copyShader.fragmentShader,
|
30
|
-
blending: AdditiveBlending,
|
31
|
-
transparent: true
|
32
|
-
}); // convolution material
|
33
|
-
|
34
|
-
if (ConvolutionShader === undefined) console.error('THREE.BloomPass relies on ConvolutionShader');
|
35
|
-
var convolutionShader = ConvolutionShader;
|
36
|
-
this.convolutionUniforms = UniformsUtils.clone(convolutionShader.uniforms);
|
37
|
-
this.convolutionUniforms['uImageIncrement'].value = BloomPass.blurX;
|
38
|
-
this.convolutionUniforms['cKernel'].value = ConvolutionShader.buildKernel(sigma);
|
39
|
-
this.materialConvolution = new ShaderMaterial({
|
40
|
-
uniforms: this.convolutionUniforms,
|
41
|
-
vertexShader: convolutionShader.vertexShader,
|
42
|
-
fragmentShader: convolutionShader.fragmentShader,
|
43
|
-
defines: {
|
44
|
-
KERNEL_SIZE_FLOAT: kernelSize.toFixed(1),
|
45
|
-
KERNEL_SIZE_INT: kernelSize.toFixed(0)
|
46
|
-
}
|
47
|
-
});
|
48
|
-
this.needsSwap = false;
|
49
|
-
this.fsQuad = new FullScreenQuad(null);
|
50
|
-
};
|
6
|
+
class BloomPass extends Pass {
|
7
|
+
constructor(strength = 1, kernelSize = 25, sigma = 4, resolution = 256) {
|
8
|
+
super(); // render targets
|
9
|
+
|
10
|
+
_defineProperty(this, "renderTargetX", void 0);
|
11
|
+
|
12
|
+
_defineProperty(this, "renderTargetY", void 0);
|
13
|
+
|
14
|
+
_defineProperty(this, "materialCombine", void 0);
|
15
|
+
|
16
|
+
_defineProperty(this, "materialConvolution", void 0);
|
17
|
+
|
18
|
+
_defineProperty(this, "fsQuad", void 0);
|
19
|
+
|
20
|
+
_defineProperty(this, "combineUniforms", void 0);
|
21
|
+
|
22
|
+
_defineProperty(this, "convolutionUniforms", void 0);
|
23
|
+
|
24
|
+
_defineProperty(this, "blurX", new Vector2(0.001953125, 0.0));
|
51
25
|
|
52
|
-
|
53
|
-
|
54
|
-
|
26
|
+
_defineProperty(this, "blurY", new Vector2(0.0, 0.001953125));
|
27
|
+
|
28
|
+
this.renderTargetX = new WebGLRenderTarget(resolution, resolution);
|
29
|
+
this.renderTargetX.texture.name = 'BloomPass.x';
|
30
|
+
this.renderTargetY = new WebGLRenderTarget(resolution, resolution);
|
31
|
+
this.renderTargetY.texture.name = 'BloomPass.y'; // combine material
|
32
|
+
|
33
|
+
this.combineUniforms = UniformsUtils.clone(CombineShader.uniforms);
|
34
|
+
this.combineUniforms['strength'].value = strength;
|
35
|
+
this.materialCombine = new ShaderMaterial({
|
36
|
+
uniforms: this.combineUniforms,
|
37
|
+
vertexShader: CombineShader.vertexShader,
|
38
|
+
fragmentShader: CombineShader.fragmentShader,
|
39
|
+
blending: AdditiveBlending,
|
40
|
+
transparent: true
|
41
|
+
}); // convolution material
|
42
|
+
|
43
|
+
if (ConvolutionShader === undefined) console.error('BloomPass relies on ConvolutionShader');
|
44
|
+
const convolutionShader = ConvolutionShader;
|
45
|
+
this.convolutionUniforms = UniformsUtils.clone(convolutionShader.uniforms);
|
46
|
+
this.convolutionUniforms['uImageIncrement'].value = this.blurX;
|
47
|
+
this.convolutionUniforms['cKernel'].value = ConvolutionShader.buildKernel(sigma);
|
48
|
+
this.materialConvolution = new ShaderMaterial({
|
49
|
+
uniforms: this.convolutionUniforms,
|
50
|
+
vertexShader: convolutionShader.vertexShader,
|
51
|
+
fragmentShader: convolutionShader.fragmentShader,
|
52
|
+
defines: {
|
53
|
+
KERNEL_SIZE_FLOAT: kernelSize.toFixed(1),
|
54
|
+
KERNEL_SIZE_INT: kernelSize.toFixed(0)
|
55
|
+
}
|
56
|
+
});
|
57
|
+
this.needsSwap = false;
|
58
|
+
this.fsQuad = new FullScreenQuad(this.materialConvolution);
|
59
|
+
}
|
60
|
+
|
61
|
+
render(renderer, writeBuffer, readBuffer, deltaTime, maskActive) {
|
55
62
|
if (maskActive) renderer.state.buffers.stencil.setTest(false); // Render quad with blured scene into texture (convolution pass 1)
|
56
63
|
|
57
64
|
this.fsQuad.material = this.materialConvolution;
|
58
65
|
this.convolutionUniforms['tDiffuse'].value = readBuffer.texture;
|
59
|
-
this.convolutionUniforms['uImageIncrement'].value =
|
66
|
+
this.convolutionUniforms['uImageIncrement'].value = this.blurX;
|
60
67
|
renderer.setRenderTarget(this.renderTargetX);
|
61
68
|
renderer.clear();
|
62
69
|
this.fsQuad.render(renderer); // Render quad with blured scene into texture (convolution pass 2)
|
63
70
|
|
64
71
|
this.convolutionUniforms['tDiffuse'].value = this.renderTargetX.texture;
|
65
|
-
this.convolutionUniforms['uImageIncrement'].value =
|
72
|
+
this.convolutionUniforms['uImageIncrement'].value = this.blurY;
|
66
73
|
renderer.setRenderTarget(this.renderTargetY);
|
67
74
|
renderer.clear();
|
68
75
|
this.fsQuad.render(renderer); // Render original scene with superimposed blur to texture
|
69
76
|
|
70
|
-
this.fsQuad.material = this.
|
71
|
-
this.
|
77
|
+
this.fsQuad.material = this.materialCombine;
|
78
|
+
this.combineUniforms['tDiffuse'].value = this.renderTargetY.texture;
|
72
79
|
if (maskActive) renderer.state.buffers.stencil.setTest(true);
|
73
80
|
renderer.setRenderTarget(readBuffer);
|
74
81
|
if (this.clear) renderer.clear();
|
75
82
|
this.fsQuad.render(renderer);
|
76
83
|
}
|
77
|
-
|
78
|
-
|
79
|
-
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
const CombineShader = {
|
88
|
+
uniforms: {
|
89
|
+
tDiffuse: {
|
90
|
+
value: null
|
91
|
+
},
|
92
|
+
strength: {
|
93
|
+
value: 1.0
|
94
|
+
}
|
95
|
+
},
|
96
|
+
vertexShader:
|
97
|
+
/* glsl */
|
98
|
+
`
|
99
|
+
varying vec2 vUv;
|
100
|
+
void main() {
|
101
|
+
vUv = uv;
|
102
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
103
|
+
}`,
|
104
|
+
fragmentShader:
|
105
|
+
/* glsl */
|
106
|
+
`
|
107
|
+
uniform float strength;
|
108
|
+
uniform sampler2D tDiffuse;
|
109
|
+
varying vec2 vUv;
|
110
|
+
void main() {
|
111
|
+
vec4 texel = texture2D( tDiffuse, vUv );
|
112
|
+
gl_FragColor = strength * texel;
|
113
|
+
}`
|
114
|
+
};
|
80
115
|
|
81
116
|
export { BloomPass };
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("./Pass.cjs.js"),t=require("three"),a=require("../shaders/BokehShader.cjs.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=s(e);class l extends r.Pass{constructor(e,s,l){super(),i.default(this,"scene",void 0),i.default(this,"camera",void 0),i.default(this,"renderTargetDepth",void 0),i.default(this,"materialDepth",void 0),i.default(this,"materialBokeh",void 0),i.default(this,"fsQuad",void 0),i.default(this,"_oldClearColor",void 0),i.default(this,"uniforms",void 0),this.scene=e,this.camera=s;const h=void 0!==l.focus?l.focus:1,o=void 0!==l.aspect?l.aspect:s.aspect,n=void 0!==l.aperture?l.aperture:.025,d=void 0!==l.maxblur?l.maxblur:1,u=l.width||window.innerWidth||1,c=l.height||window.innerHeight||1;this.renderTargetDepth=new t.WebGLRenderTarget(u,c,{minFilter:t.NearestFilter,magFilter:t.NearestFilter}),this.renderTargetDepth.texture.name="BokehPass.depth",this.materialDepth=new t.MeshDepthMaterial,this.materialDepth.depthPacking=t.RGBADepthPacking,this.materialDepth.blending=t.NoBlending,void 0===a.BokehShader&&console.error("BokehPass relies on BokehShader");const f=a.BokehShader,p=t.UniformsUtils.clone(f.uniforms);p.tDepth.value=this.renderTargetDepth.texture,p.focus.value=h,p.aspect.value=o,p.aperture.value=n,p.maxblur.value=d,p.nearClip.value=s.near,p.farClip.value=s.far,this.materialBokeh=new t.ShaderMaterial({defines:Object.assign({},f.defines),uniforms:p,vertexShader:f.vertexShader,fragmentShader:f.fragmentShader}),this.uniforms=p,this.needsSwap=!1,this.fsQuad=new r.FullScreenQuad(this.materialBokeh),this._oldClearColor=new t.Color}render(e,r,t){this.scene.overrideMaterial=this.materialDepth,e.getClearColor(this._oldClearColor);const a=e.getClearAlpha(),s=e.autoClear;e.autoClear=!1,e.setClearColor(16777215),e.setClearAlpha(1),e.setRenderTarget(this.renderTargetDepth),e.clear(),e.render(this.scene,this.camera),this.uniforms.tColor.value=t.texture,this.uniforms.nearClip.value=this.camera.near,this.uniforms.farClip.value=this.camera.far,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(r),e.clear(),this.fsQuad.render(e)),this.scene.overrideMaterial=null,e.setClearColor(this._oldClearColor),e.setClearAlpha(a),e.autoClear=s}}exports.BokehPass=l;
|