diff --git a/build/three.js b/build/three.js index fdc6db44cfb1f31f06a80482e75057f1c4c887ce..07d60eb1e34c9326fa0815dfaef07c2a10ec2b69 100644 --- a/build/three.js +++ b/build/three.js @@ -6079,7 +6079,7 @@ var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );"; - var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}"; + var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}"; var envmap_fragment = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif"; @@ -12026,6 +12026,33 @@ toNonIndexed: function () { + function convertBufferAttribute( attribute, indices ) { + + var array = attribute.array; + var itemSize = attribute.itemSize; + + var array2 = new array.constructor( indices.length * itemSize ); + + var index = 0, index2 = 0; + + for ( var i = 0, l = indices.length; i < l; i ++ ) { + + index = indices[ i ] * itemSize; + + for ( var j = 0; j < itemSize; j ++ ) { + + array2[ index2 ++ ] = array[ index ++ ]; + + } + + } + + return new BufferAttribute( array2, itemSize ); + + } + + // + if ( this.index === null ) { console.warn( 'THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed.' ); @@ -12038,33 +12065,43 @@ var indices = this.index.array; var attributes = this.attributes; + // attributes + for ( var name in attributes ) { var attribute = attributes[ name ]; - var array = attribute.array; - var itemSize = attribute.itemSize; + var newAttribute = convertBufferAttribute( attribute, indices ); - var array2 = new array.constructor( indices.length * itemSize ); + geometry2.addAttribute( name, newAttribute ); - var index = 0, index2 = 0; + } - for ( var i = 0, l = indices.length; i < l; i ++ ) { + // morph attributes - index = indices[ i ] * itemSize; + var morphAttributes = this.morphAttributes; - for ( var j = 0; j < itemSize; j ++ ) { + for ( name in morphAttributes ) { - array2[ index2 ++ ] = array[ index ++ ]; + var morphArray = []; + var morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes - } + for ( var i = 0, il = morphAttribute.length; i < il; i ++ ) { + + var attribute = morphAttribute[ i ]; + + var newAttribute = convertBufferAttribute( attribute, indices ); + + morphArray.push( newAttribute ); } - geometry2.addAttribute( name, new BufferAttribute( array2, itemSize ) ); + geometry2.morphAttributes[ name ] = morphArray; } + // groups + var groups = this.groups; for ( var i = 0, l = groups.length; i < l; i ++ ) { @@ -18687,12 +18724,10 @@ if ( lights.length === 0 ) return; - // TODO Clean up (needed in case of contextlost) - var _gl = _renderer.context; var _state = _renderer.state; // Set GL state for depth map. - _state.disable( 3042 ); + _state.setBlending( NoBlending ); _state.buffers.color.setClear( 1, 1, 1, 1 ); _state.buffers.depth.setTest( true ); _state.setScissorTest( false ); @@ -44660,7 +44695,7 @@ geometry2.addAttribute( 'position', new Float32BufferAttribute( positions2, 3 ) ); geometry2.computeBoundingSphere(); - this.add( new Mesh( geometry2, new MeshBasicMaterial( { side: THREE.BackSide, fog: false } ) ) ); + this.add( new Mesh( geometry2, new MeshBasicMaterial( { side: BackSide, fog: false } ) ) ); this.update(); @@ -45552,8 +45587,8 @@ Object3D.call( this ); - if ( dir === undefined ) dir = new THREE.Vector3( 0, 0, 1 ); - if ( origin === undefined ) origin = new THREE.Vector3( 0, 0, 0 ); + if ( dir === undefined ) dir = new Vector3( 0, 0, 1 ); + if ( origin === undefined ) origin = new Vector3( 0, 0, 0 ); if ( length === undefined ) length = 1; if ( color === undefined ) color = 0xffff00; if ( headLength === undefined ) headLength = 0.2 * length; diff --git a/build/three.min.js b/build/three.min.js index fdbd2807507cf130b465960b3bb31a5639da1a14..d54a5ff870e2ea1b1eca406d5aa5dbd6cf374f3e 100644 --- a/build/three.min.js +++ b/build/three.min.js @@ -32,7 +32,7 @@ return}k[d.isWebGL2?"drawArraysInstanced":"drawArraysInstancedANGLE"](e,g,h,f.ma a instanceof WebGL2RenderingContext,g=void 0!==c.precision?c.precision:"highp",h=d(g);h!==g&&(console.warn("THREE.WebGLRenderer:",g,"not supported, using",h,"instead."),g=h);c=!0===c.logarithmicDepthBuffer;h=a.getParameter(34930);var k=a.getParameter(35660),m=a.getParameter(3379),q=a.getParameter(34076),p=a.getParameter(34921),t=a.getParameter(36347),x=a.getParameter(36348),l=a.getParameter(36349),u=0w;w++)u[w]=t||x?x?b.image[w].image:b.image[w]:h(b.image[w],!1,!0,e.maxCubemapSize); -var v=u[0],B=k(v),y=f.convert(b.format),H=f.convert(b.type),z=p(y,H);n(34067,b,B);for(w=0;6>w;w++)if(t)for(var la,R=u[w].mipmaps,fa=0,A=R.length;faw;w++)if(t)for(var la,R=u[w].mipmaps,fa=0,A=R.length;fax;x++)h.__webglFramebuffer[x]=a.createFramebuffer();else if(h.__webglFramebuffer=a.createFramebuffer(),x)if(e.isWebGL2){h.__webglMultisampledFramebuffer=a.createFramebuffer();h.__webglColorRenderbuffer=a.createRenderbuffer();a.bindRenderbuffer(36161,h.__webglColorRenderbuffer);x=f.convert(b.texture.format);var B=f.convert(b.texture.type); x=p(x,B);B=y(b);a.renderbufferStorageMultisample(36161,B,x,b.width,b.height);a.bindFramebuffer(36160,h.__webglMultisampledFramebuffer);a.framebufferRenderbuffer(36160,36064,36161,h.__webglColorRenderbuffer);a.bindRenderbuffer(36161,null);b.depthBuffer&&(h.__webglDepthRenderbuffer=a.createRenderbuffer(),H(h.__webglDepthRenderbuffer,b,!0));a.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");if(l){c.bindTexture(34067,t.__webglTexture); n(34067,b.texture,w);for(x=0;6>x;x++)v(h.__webglFramebuffer[x],b,36064,34069+x);m(b.texture,w)&&q(34067,b.texture,b.width,b.height);c.bindTexture(34067,null)}else c.bindTexture(3553,t.__webglTexture),n(3553,b.texture,w),v(h.__webglFramebuffer,b,36064,3553),m(b.texture,w)&&q(3553,b.texture,b.width,b.height),c.bindTexture(3553,null);if(b.depthBuffer){h=d.get(b);t=!0===b.isWebGLRenderTargetCube;if(b.depthTexture){if(t)throw Error("target.depthTexture not supported in Cube render targets");if(b&&b.isWebGLRenderTargetCube)throw Error("Depth Texture with cube render targets is not supported"); @@ -225,8 +225,8 @@ this.parameters={radius:a,detail:b}}function Qc(a,b,c,d,e,f){Q.call(this);this.t t/d*Math.PI*2,p=Math.sin(m);m=-Math.cos(m);k.x=m*f.x+p*e.x;k.y=m*f.y+p*e.y;k.z=m*f.z+p*e.z;k.normalize();r.push(k.x,k.y,k.z);h.x=q.x+c*k.x;h.y=q.y+c*k.y;h.z=q.z+c*k.z;l.push(h.x,h.y,h.z)}}D.call(this);this.type="TubeBufferGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e};b=b||64;c=c||1;d=d||8;e=e||!1;var g=a.computeFrenetFrames(b,e);this.tangents=g.tangents;this.normals=g.normals;this.binormals=g.binormals;var h=new n,k=new n,m=new A,q=new n,p,t,l=[],r=[],u=[], w=[];for(p=0;p=b;e-=d)f=of(e,a[e],a[e+1],f);f&&ub(f,f.next)&&(Tc(f),f=f.next);return f} function Uc(a,b){if(!a)return a;b||(b=a);do{var c=!1;if(a.steiner||!ub(a,a.next)&&0!==qa(a.prev,a,a.next))a=a.next;else{Tc(a);a=b=a.prev;if(a===a.next)break;c=!0}}while(c||a!==b);return b}function Vc(a,b,c,d,e,f,g){if(a){if(!g&&f){var h=a,k=h;do null===k.z&&(k.z=ge(k.x,k.y,d,e,f)),k.prevZ=k.prev,k=k.nextZ=k.next;while(k!==h);k.prevZ.nextZ=null;k.prevZ=null;h=k;var m,q,p,l,x=1;do{k=h;var r=h=null;for(q=0;k;){q++;var n=k;for(m=p=0;mq;q++){var l=m[f[q]];var t=m[f[(q+1)%3]];d[0]=Math.min(l,t);d[1]=Math.max(l,t);l=d[0]+","+d[1];void 0===e[l]?e[l]={index1:d[0],index2:d[1], -face1:h,face2:void 0}:e[l].face2=h}for(l in e)if(d=e[l],void 0===d.face2||g[d.face1].normal.dot(g[d.face2].normal)<=b)f=a[d.index1],c.push(f.x,f.y,f.z),f=a[d.index2],c.push(f.x,f.y,f.z);this.addAttribute("position",new C(c,3))}function zb(a,b,c,d,e,f,g,h){Q.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f,thetaStart:g,thetaLength:h};this.fromBufferGeometry(new ab(a,b,c,d,e,f,g,h));this.mergeVertices()}function ab(a, +return b}function fc(a,b){D.call(this);this.type="EdgesGeometry";this.parameters={thresholdAngle:b};var c=[];b=Math.cos(F.DEG2RAD*(void 0!==b?b:1));var d=[0,0],e={},f=["a","b","c"];if(a.isBufferGeometry){var g=new Q;g.fromBufferGeometry(a)}else g=a.clone();g.mergeVertices();g.computeFaceNormals();a=g.vertices;g=g.faces;for(var h=0,k=g.length;hq;q++){var p=m[f[q]];var l=m[f[(q+1)%3]];d[0]=Math.min(p,l);d[1]=Math.max(p,l);p=d[0]+","+d[1];void 0===e[p]?e[p]={index1:d[0],index2:d[1], +face1:h,face2:void 0}:e[p].face2=h}for(p in e)if(d=e[p],void 0===d.face2||g[d.face1].normal.dot(g[d.face2].normal)<=b)f=a[d.index1],c.push(f.x,f.y,f.z),f=a[d.index2],c.push(f.x,f.y,f.z);this.addAttribute("position",new C(c,3))}function zb(a,b,c,d,e,f,g,h){Q.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f,thetaStart:g,thetaLength:h};this.fromBufferGeometry(new ab(a,b,c,d,e,f,g,h));this.mergeVertices()}function ab(a, b,c,d,e,f,g,h){function k(c){var e,f=new A,k=new n,p=0,v=!0===c?a:b,u=!0===c?1:-1;var C=r;for(e=1;e<=d;e++)l.push(0,w*u,0),t.push(0,u,0),x.push(.5,.5),r++;var E=r;for(e=0;e<=d;e++){var D=e/d*h+g,F=Math.cos(D);D=Math.sin(D);k.x=v*D;k.y=w*u;k.z=v*F;l.push(k.x,k.y,k.z);t.push(0,u,0);f.x=.5*F+.5;f.y=.5*D*u+.5;x.push(f.x,f.y);r++}for(e=0;ec;c++,d++){var e=c/32*Math.PI*2,f=d/32*Math.PI*2;b.push(Math.cos(e),Math.sin(e),1,Math.cos(f),Math.sin(f),1)}a.addAttribute("position",new C(b,3));b=new W({fog:!1});this.cone=new U(a,b);this.add(this.cone);this.update()}function Hf(a){var b=[];a&&a.isBone&&b.push(a);for(var c=0;ca?-1:0b;b++)a[b]=(16>b?"0":"")+b.toString(16); @@ -333,16 +333,16 @@ c=new n;return function(d,e,f){var g=this.elements;c.subVectors(d,e);0===c.lengt this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},premultiply:function(a){return this.multiplyMatrices(a,this)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements;b=this.elements;a=c[0];var e=c[4],f=c[8],g=c[12],h=c[1],k=c[5],m=c[9],q=c[13],l=c[2],t=c[6],n=c[10],r=c[14],u=c[3],w=c[7],z=c[11];c=c[15];var v=d[0],H=d[4],y=d[8],A=d[12],C=d[1],B=d[5],E=d[9],D=d[13],F=d[2],G=d[6],J=d[10],L=d[14],I=d[3],K=d[7],O=d[11];d=d[15];b[0]=a*v+e*C+f*F+g*I;b[4]=a*H+e*B+f*G+g*K;b[8]=a*y+e*E+f*J+ g*O;b[12]=a*A+e*D+f*L+g*d;b[1]=h*v+k*C+m*F+q*I;b[5]=h*H+k*B+m*G+q*K;b[9]=h*y+k*E+m*J+q*O;b[13]=h*A+k*D+m*L+q*d;b[2]=l*v+t*C+n*F+r*I;b[6]=l*H+t*B+n*G+r*K;b[10]=l*y+t*E+n*J+r*O;b[14]=l*A+t*D+n*L+r*d;b[3]=u*v+w*C+z*F+c*I;b[7]=u*H+w*B+z*G+c*K;b[11]=u*y+w*E+z*J+c*O;b[15]=u*A+w*D+z*L+c*d;return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[4]*=a;b[8]*=a;b[12]*=a;b[1]*=a;b[5]*=a;b[9]*=a;b[13]*=a;b[2]*=a;b[6]*=a;b[10]*=a;b[14]*=a;b[3]*=a;b[7]*=a;b[11]*=a;b[15]*=a;return this},applyToBufferAttribute:function(){var a= new n;return function(b){for(var c=0,d=b.count;cthis.determinant()&&(g=-g);c.x=f[12];c.y=f[13];c.z=f[14];b.copy(this);c=1/g;f=1/h;var m=1/k;b.elements[0]*=c;b.elements[1]*=c;b.elements[2]*=c;b.elements[4]*=f;b.elements[5]*=f;b.elements[6]*=f;b.elements[8]*=m;b.elements[9]*=m;b.elements[10]*=m;d.setFromRotationMatrix(b);e.x=g;e.y=h;e.z=k;return this}}(),makePerspective:function(a,b,c,d,e,f){void 0===f&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs."); var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(c-d);g[9]=(c+d)/(c-d);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=1/(b-a),k=1/(c-d),m=1/(f-e);g[0]=2*h;g[4]=0;g[8]=0;g[12]=-((b+a)*h);g[1]=0;g[5]=2*k;g[9]=0;g[13]=-((c+d)*k);g[2]=0;g[6]=0;g[10]=-2*m;g[14]=-((f+e)*m);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},equals:function(a){var b=this.elements; a=a.elements;for(var c=0;16>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;16>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=c[10];a[b+11]=c[11];a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a}});Object.assign(ka,{slerp:function(a,b,c,d){return c.copy(a).slerp(b, -d)},slerpFlat:function(a,b,c,d,e,f,g){var h=c[d+0],k=c[d+1],m=c[d+2];c=c[d+3];d=e[f+0];var l=e[f+1],p=e[f+2];e=e[f+3];if(c!==e||h!==d||k!==l||m!==p){f=1-g;var t=h*d+k*l+m*p+c*e,n=0<=t?1:-1,r=1-t*t;r>Number.EPSILON&&(r=Math.sqrt(r),t=Math.atan2(r,t*n),f=Math.sin(f*t)/r,g=Math.sin(g*t)/r);n*=g;h=h*f+d*n;k=k*f+l*n;m=m*f+p*n;c=c*f+e*n;f===1-g&&(g=1/Math.sqrt(h*h+k*k+m*m+c*c),h*=g,k*=g,m*=g,c*=g)}a[b]=h;a[b+1]=k;a[b+2]=m;a[b+3]=c}});Object.defineProperties(ka.prototype,{x:{get:function(){return this._x}, +d)},slerpFlat:function(a,b,c,d,e,f,g){var h=c[d+0],k=c[d+1],m=c[d+2];c=c[d+3];d=e[f+0];var q=e[f+1],l=e[f+2];e=e[f+3];if(c!==e||h!==d||k!==q||m!==l){f=1-g;var t=h*d+k*q+m*l+c*e,n=0<=t?1:-1,r=1-t*t;r>Number.EPSILON&&(r=Math.sqrt(r),t=Math.atan2(r,t*n),f=Math.sin(f*t)/r,g=Math.sin(g*t)/r);n*=g;h=h*f+d*n;k=k*f+q*n;m=m*f+l*n;c=c*f+e*n;f===1-g&&(g=1/Math.sqrt(h*h+k*k+m*m+c*c),h*=g,k*=g,m*=g,c*=g)}a[b]=h;a[b+1]=k;a[b+2]=m;a[b+3]=c}});Object.defineProperties(ka.prototype,{x:{get:function(){return this._x}, set:function(a){this._x=a;this.onChangeCallback()}},y:{get:function(){return this._y},set:function(a){this._y=a;this.onChangeCallback()}},z:{get:function(){return this._z},set:function(a){this._z=a;this.onChangeCallback()}},w:{get:function(){return this._w},set:function(a){this._w=a;this.onChangeCallback()}}});Object.assign(ka.prototype,{isQuaternion:!0,set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._w=d;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x, this._y,this._z,this._w)},copy:function(a){this._x=a.x;this._y=a.y;this._z=a.z;this._w=a.w;this.onChangeCallback();return this},setFromEuler:function(a,b){if(!a||!a.isEuler)throw Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var c=a._x,d=a._y,e=a._z;a=a.order;var f=Math.cos,g=Math.sin,h=f(c/2),k=f(d/2);f=f(e/2);c=g(c/2);d=g(d/2);e=g(e/2);"XYZ"===a?(this._x=c*k*f+h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f-c*d*e):"YXZ"===a? (this._x=c*k*f+h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f+c*d*e):"ZXY"===a?(this._x=c*k*f-h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f-c*d*e):"ZYX"===a?(this._x=c*k*f-h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f+c*d*e):"YZX"===a?(this._x=c*k*f+h*d*e,this._y=h*d*f+c*k*e,this._z=h*k*e-c*d*f,this._w=h*k*f-c*d*e):"XZY"===a&&(this._x=c*k*f-h*d*e,this._y=h*d*f-c*k*e,this._z=h*k*e+c*d*f,this._w=h*k*f+c*d*e);if(!1!==b)this.onChangeCallback();return this},setFromAxisAngle:function(a, @@ -369,9 +369,9 @@ d*Math.sin(c);this.y=Math.cos(b)*a;this.z=d*Math.cos(c);return this},setFromCyli 2).length();this.x=b;this.y=c;this.z=a;return this},setFromMatrixColumn:function(a,b){return this.fromArray(a.elements,4*b)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."); this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b);return this}});Object.assign(ta.prototype,{isMatrix3:!0,set:function(a,b,c,d,e,f,g,h,k){var m=this.elements;m[0]=a;m[1]=d;m[2]=g;m[3]=b;m[4]=e;m[5]=h;m[6]=c;m[7]=f;m[8]=k;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(a){var b=this.elements;a=a.elements;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]= a[8];return this},setFromMatrix4:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[1],a[5],a[9],a[2],a[6],a[10]);return this},applyToBufferAttribute:function(){var a=new n;return function(b){for(var c=0,d=b.count;cc;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;9>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8]; return a}});var sc,kb={getDataURL:function(a){if("undefined"==typeof HTMLCanvasElement)return a.src;if(!(a instanceof HTMLCanvasElement)){void 0===sc&&(sc=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"));sc.width=a.width;sc.height=a.height;var b=sc.getContext("2d");a instanceof ImageData?b.putImageData(a,0,0):b.drawImage(a,0,0,a.width,a.height);a=sc}return 2048 0\n\t#if ! defined( PHY color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}", cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif", defaultnormal_vertex:"vec3 transformedNormal = normalMatrix * objectNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif", -emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}", +emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}", envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif", envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntensity;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif", envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent ));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif", @@ -577,126 +577,126 @@ this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.bounding a.getCenter(d);for(var e=0,f=0,g=c.count;fthis.opacity&& -(d.opacity=this.opacity);!0===this.transparent&&(d.transparent=this.transparent);d.depthFunc=this.depthFunc;d.depthTest=this.depthTest;d.depthWrite=this.depthWrite;0!==this.rotation&&(d.rotation=this.rotation);!0===this.polygonOffset&&(d.polygonOffset=!0);0!==this.polygonOffsetFactor&&(d.polygonOffsetFactor=this.polygonOffsetFactor);0!==this.polygonOffsetUnits&&(d.polygonOffsetUnits=this.polygonOffsetUnits);1!==this.linewidth&&(d.linewidth=this.linewidth);void 0!==this.dashSize&&(d.dashSize=this.dashSize); -void 0!==this.gapSize&&(d.gapSize=this.gapSize);void 0!==this.scale&&(d.scale=this.scale);!0===this.dithering&&(d.dithering=!0);0a?b.copy(this.origin):b.copy(this.direction).multiplyScalar(a).add(this.origin)},distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(){var a=new n;return function(b){var c=a.subVectors(b,this.origin).dot(this.direction);if(0>c)return this.origin.distanceToSquared(b);a.copy(this.direction).multiplyScalar(c).add(this.origin);return a.distanceToSquared(b)}}(),distanceSqToSegment:function(){var a=new n,b=new n,c=new n;return function(d,e,f,g){a.copy(d).add(e).multiplyScalar(.5); -b.copy(e).sub(d).normalize();c.copy(this.origin).sub(a);var h=.5*d.distanceTo(e),k=-this.direction.dot(b),m=c.dot(this.direction),l=-c.dot(b),p=c.lengthSq(),n=Math.abs(1-k*k);if(0=-x?e<=x?(h=1/n,d*=h,e*=h,k=d*(d+k*e+2*m)+e*(k*d+e+2*l)+p):(e=h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+p):(e=-h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+p):e<=-x?(d=Math.max(0,-(-k*h+m)),e=0b)return null;b=Math.sqrt(b-e);e=d-b;d+=b;return 0>e&&0>d?null:0>e?this.at(d, -c):this.at(e,c)}}(),intersectsSphere:function(a){return this.distanceSqToPoint(a.center)<=a.radius*a.radius},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distanceToPoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<=a?a:null},intersectPlane:function(a,b){a=this.distanceToPlane(a);return null===a?null:this.at(a,b)},intersectsPlane:function(a){var b=a.distanceToPoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b?!0:!1}, -intersectBox:function(a,b){var c=1/this.direction.x;var d=1/this.direction.y;var e=1/this.direction.z,f=this.origin;if(0<=c){var g=(a.min.x-f.x)*c;c*=a.max.x-f.x}else g=(a.max.x-f.x)*c,c*=a.min.x-f.x;if(0<=d){var h=(a.min.y-f.y)*d;d*=a.max.y-f.y}else h=(a.max.y-f.y)*d,d*=a.min.y-f.y;if(g>d||h>c)return null;if(h>g||g!==g)g=h;if(da||h>c)return null;if(h>g||g!==g)g=h;if(ac?null: -this.at(0<=g?g:c,b)},intersectsBox:function(){var a=new n;return function(b){return null!==this.intersectBox(b,a)}}(),intersectTriangle:function(){var a=new n,b=new n,c=new n,d=new n;return function(e,f,g,h,k){b.subVectors(f,e);c.subVectors(g,e);d.crossVectors(b,c);f=this.direction.dot(d);if(0f)h=-1,f=-f;else return null;a.subVectors(this.origin,e);e=h*this.direction.dot(c.crossVectors(a,c));if(0>e)return null;g=h*this.direction.dot(b.cross(a));if(0>g||e+g>f)return null; -e=-h*a.dot(d);return 0>e?null:this.at(e/f,k)}}(),applyMatrix4:function(a){this.origin.applyMatrix4(a);this.direction.transformDirection(a);return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}});Object.assign(da,{getNormal:function(){var a=new n;return function(b,c,d,e){void 0===e&&(console.warn("THREE.Triangle: .getNormal() target is now required"),e=new n);e.subVectors(d,c);a.subVectors(b,c);e.cross(a);b=e.lengthSq();return 0=a.x+a.y}}(),getUV:function(){var a=new n;return function(b,c,d,e,f,g,h,k){this.getBarycoord(b,c,d,e,a);k.set(0,0);k.addScaledVector(f,a.x);k.addScaledVector(g,a.y);k.addScaledVector(h,a.z);return k}}()});Object.assign(da.prototype,{set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},clone:function(){return(new this.constructor).copy(this)}, -copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},getArea:function(){var a=new n,b=new n;return function(){a.subVectors(this.c,this.b);b.subVectors(this.a,this.b);return.5*a.cross(b).length()}}(),getMidpoint:function(a){void 0===a&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),a=new n);return a.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(a){return da.getNormal(this.a,this.b,this.c,a)},getPlane:function(a){void 0=== -a&&(console.warn("THREE.Triangle: .getPlane() target is now required"),a=new n);return a.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(a,b){return da.getBarycoord(a,this.a,this.b,this.c,b)},containsPoint:function(a){return da.containsPoint(a,this.a,this.b,this.c)},getUV:function(a,b,c,d,e){return da.getUV(a,this.a,this.b,this.c,b,c,d,e)},intersectsBox:function(a){return a.intersectsTriangle(this)},closestPointToPoint:function(){var a=new n,b=new n,c=new n,d=new n,e=new n,f=new n; -return function(g,h){void 0===h&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),h=new n);var k=this.a,m=this.b,l=this.c;a.subVectors(m,k);b.subVectors(l,k);d.subVectors(g,k);var p=a.dot(d),t=b.dot(d);if(0>=p&&0>=t)return h.copy(k);e.subVectors(g,m);var x=a.dot(e),r=b.dot(e);if(0<=x&&r<=x)return h.copy(m);var u=p*r-x*t;if(0>=u&&0<=p&&0>=x)return m=p/(p-x),h.copy(k).addScaledVector(a,m);f.subVectors(g,l);g=a.dot(f);var w=b.dot(f);if(0<=w&&g<=w)return h.copy(l);p=g*t- -p*w;if(0>=p&&0<=t&&0>=w)return u=t/(t-w),h.copy(k).addScaledVector(b,u);t=x*w-g*r;if(0>=t&&0<=r-x&&0<=g-w)return c.subVectors(l,m),u=(r-x)/(r-x+(g-w)),h.copy(m).addScaledVector(c,u);l=1/(t+p+u);m=p*l;u*=l;return h.copy(k).addScaledVector(a,m).addScaledVector(b,u)}}(),equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)}});xa.prototype=Object.create(L.prototype);xa.prototype.constructor=xa;xa.prototype.isMeshBasicMaterial=!0;xa.prototype.copy=function(a){L.prototype.copy.call(this, -a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning= -a.skinning;this.morphTargets=a.morphTargets;return this};oa.prototype=Object.assign(Object.create(E.prototype),{constructor:oa,isMesh:!0,setDrawMode:function(a){this.drawMode=a},copy:function(a){E.prototype.copy.call(this,a);this.drawMode=a.drawMode;void 0!==a.morphTargetInfluences&&(this.morphTargetInfluences=a.morphTargetInfluences.slice());void 0!==a.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},a.morphTargetDictionary));return this},updateMorphTargets:function(){var a=this.geometry; -if(a.isBufferGeometry){a=a.morphAttributes;var b=Object.keys(a);if(0c.far?null:{distance:b,point:u.clone(),object:a}}function b(b,c,d,e,k,m,l,q,n){f.fromBufferAttribute(k,l);g.fromBufferAttribute(k,q);h.fromBufferAttribute(k,n);if(b=a(b,c,d,e,f,g,h,r))m&&(p.fromBufferAttribute(m,l),t.fromBufferAttribute(m,q),x.fromBufferAttribute(m,n),b.uv=da.getUV(r,f,g,h,p,t,x,new A)),m=new Lb(l, -q,n),da.getNormal(f,g,h,m.normal),b.face=m;return b}var c=new P,d=new rb,e=new Fa,f=new n,g=new n,h=new n,k=new n,m=new n,l=new n,p=new A,t=new A,x=new A,r=new n,u=new n;return function(q,n){var u=this.geometry,w=this.material,y=this.matrixWorld;if(void 0!==w&&(null===u.boundingSphere&&u.computeBoundingSphere(),e.copy(u.boundingSphere),e.applyMatrix4(y),!1!==q.ray.intersectsSphere(e)&&(c.getInverse(y),d.copy(q.ray).applyMatrix4(c),null===u.boundingBox||!1!==d.intersectsBox(u.boundingBox))))if(u.isBufferGeometry){var z= -u.index,C=u.attributes.position,B=u.attributes.uv,E=u.groups;u=u.drawRange;var D;if(null!==z)if(Array.isArray(w)){var F=0;for(D=E.length;Fe.far||f.push({distance:r,point:b.clone(),uv:da.getUV(b,h,k,m,l,p,t,new A),face:null,object:this})}}(),clone:function(){return(new this.constructor(this.material)).copy(this)},copy:function(a){E.prototype.copy.call(this,a);void 0!==a.center&&this.center.copy(a.center);return this}});Gc.prototype=Object.assign(Object.create(E.prototype),{constructor:Gc, -copy:function(a){E.prototype.copy.call(this,a,!1);a=a.levels;for(var b=0,c=a.length;b=d[e].distance)d[e-1].object.visible=!1,d[e].object.visible=!0;else break;for(;ef||(l.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(l),ud.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}else for(g=0,r=x.length/3-1;gf||(l.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(l),ud.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else if(g.isGeometry)for(k=g.vertices,m=k.length,g=0;gf||(l.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(l),ud.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g, -face:null,faceIndex:null,object:this}))}}}(),copy:function(a){E.prototype.copy.call(this,a);this.geometry.copy(a.geometry);this.material.copy(a.material);return this},clone:function(){return(new this.constructor).copy(this)}});U.prototype=Object.assign(Object.create(ua.prototype),{constructor:U,isLineSegments:!0,computeLineDistances:function(){var a=new n,b=new n;return function(){var c=this.geometry;if(c.isBufferGeometry)if(null===c.index){for(var d=c.attributes.position,e=[],f=0,g=d.count;fd.far||e.push({distance:a,distanceToRay:Math.sqrt(f),point:p.clone(),index:c,face:null,object:g}))}var g=this,h=this.geometry,k=this.matrixWorld,m=d.params.Points.threshold;null===h.boundingSphere&&h.computeBoundingSphere();c.copy(h.boundingSphere);c.applyMatrix4(k);c.radius+=m;if(!1!==d.ray.intersectsSphere(c)){a.getInverse(k);b.copy(d.ray).applyMatrix4(a);m/=(this.scale.x+this.scale.y+this.scale.z)/3;var l= -m*m;m=new n;var p=new n;if(h.isBufferGeometry){var t=h.index;h=h.attributes.position.array;if(null!==t){var x=t.array;t=0;for(var r=x.length;t=a.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});Ub.prototype=Object.create(S.prototype);Ub.prototype.constructor=Ub;Ub.prototype.isCompressedTexture=!0;Ic.prototype=Object.create(S.prototype);Ic.prototype.constructor=Ic;Ic.prototype.isCanvasTexture=!0;Jc.prototype=Object.create(S.prototype);Jc.prototype.constructor=Jc;Jc.prototype.isDepthTexture=!0;Vb.prototype=Object.create(D.prototype);Vb.prototype.constructor=Vb;Kc.prototype=Object.create(Q.prototype);Kc.prototype.constructor= -Kc;Wb.prototype=Object.create(D.prototype);Wb.prototype.constructor=Wb;Lc.prototype=Object.create(Q.prototype);Lc.prototype.constructor=Lc;za.prototype=Object.create(D.prototype);za.prototype.constructor=za;Mc.prototype=Object.create(Q.prototype);Mc.prototype.constructor=Mc;Xb.prototype=Object.create(za.prototype);Xb.prototype.constructor=Xb;Nc.prototype=Object.create(Q.prototype);Nc.prototype.constructor=Nc;tb.prototype=Object.create(za.prototype);tb.prototype.constructor=tb;Oc.prototype=Object.create(Q.prototype); -Oc.prototype.constructor=Oc;Yb.prototype=Object.create(za.prototype);Yb.prototype.constructor=Yb;Pc.prototype=Object.create(Q.prototype);Pc.prototype.constructor=Pc;Zb.prototype=Object.create(za.prototype);Zb.prototype.constructor=Zb;Qc.prototype=Object.create(Q.prototype);Qc.prototype.constructor=Qc;$b.prototype=Object.create(D.prototype);$b.prototype.constructor=$b;Rc.prototype=Object.create(Q.prototype);Rc.prototype.constructor=Rc;ac.prototype=Object.create(D.prototype);ac.prototype.constructor= -ac;Sc.prototype=Object.create(Q.prototype);Sc.prototype.constructor=Sc;bc.prototype=Object.create(D.prototype);bc.prototype.constructor=bc;var eh={triangulate:function(a,b,c){c=c||2;var d=b&&b.length,e=d?b[0]*c:a.length,f=nf(a,0,e,c,!0),g=[];if(!f)return g;var h;if(d){var k=c;d=[];var m;var l=0;for(m=b.length;l80*c){var x=h=a[0];var r=d=a[1];for(k=c;kh&&(h=l),b>d&&(d=b);h=Math.max(h-x,d-r);h=0!==h?1/h:0}Vc(f,g,c,x,r,h);return g}},$a={area:function(a){for(var b=a.length,c=0,d=b-1,e=0;e$a.area(a)},triangulateShape:function(a,b){var c=[],d=[],e=[];rf(a);sf(c,a);var f=a.length;b.forEach(rf);for(a=0;aMath.abs(g-k)?[new A(a,1-c),new A(h,1-d),new A(m,1-e),new A(p,1-b)]:[new A(g,1-c),new A(k,1-d),new A(l,1-e),new A(n,1-b)]}};Xc.prototype=Object.create(Q.prototype);Xc.prototype.constructor=Xc;cc.prototype= -Object.create(Ua.prototype);cc.prototype.constructor=cc;Yc.prototype=Object.create(Q.prototype);Yc.prototype.constructor=Yc;wb.prototype=Object.create(D.prototype);wb.prototype.constructor=wb;Zc.prototype=Object.create(Q.prototype);Zc.prototype.constructor=Zc;dc.prototype=Object.create(D.prototype);dc.prototype.constructor=dc;$c.prototype=Object.create(Q.prototype);$c.prototype.constructor=$c;ec.prototype=Object.create(D.prototype);ec.prototype.constructor=ec;xb.prototype=Object.create(Q.prototype); -xb.prototype.constructor=xb;xb.prototype.toJSON=function(){var a=Q.prototype.toJSON.call(this);return uf(this.parameters.shapes,a)};yb.prototype=Object.create(D.prototype);yb.prototype.constructor=yb;yb.prototype.toJSON=function(){var a=D.prototype.toJSON.call(this);return uf(this.parameters.shapes,a)};fc.prototype=Object.create(D.prototype);fc.prototype.constructor=fc;zb.prototype=Object.create(Q.prototype);zb.prototype.constructor=zb;ab.prototype=Object.create(D.prototype);ab.prototype.constructor= -ab;ad.prototype=Object.create(zb.prototype);ad.prototype.constructor=ad;bd.prototype=Object.create(ab.prototype);bd.prototype.constructor=bd;cd.prototype=Object.create(Q.prototype);cd.prototype.constructor=cd;gc.prototype=Object.create(D.prototype);gc.prototype.constructor=gc;var ia=Object.freeze({WireframeGeometry:Vb,ParametricGeometry:Kc,ParametricBufferGeometry:Wb,TetrahedronGeometry:Mc,TetrahedronBufferGeometry:Xb,OctahedronGeometry:Nc,OctahedronBufferGeometry:tb,IcosahedronGeometry:Oc,IcosahedronBufferGeometry:Yb, -DodecahedronGeometry:Pc,DodecahedronBufferGeometry:Zb,PolyhedronGeometry:Lc,PolyhedronBufferGeometry:za,TubeGeometry:Qc,TubeBufferGeometry:$b,TorusKnotGeometry:Rc,TorusKnotBufferGeometry:ac,TorusGeometry:Sc,TorusBufferGeometry:bc,TextGeometry:Xc,TextBufferGeometry:cc,SphereGeometry:Yc,SphereBufferGeometry:wb,RingGeometry:Zc,RingBufferGeometry:dc,PlaneGeometry:zc,PlaneBufferGeometry:qb,LatheGeometry:$c,LatheBufferGeometry:ec,ShapeGeometry:xb,ShapeBufferGeometry:yb,ExtrudeGeometry:vb,ExtrudeBufferGeometry:Ua, -EdgesGeometry:fc,ConeGeometry:ad,ConeBufferGeometry:bd,CylinderGeometry:zb,CylinderBufferGeometry:ab,CircleGeometry:cd,CircleBufferGeometry:gc,BoxGeometry:Mb,BoxBufferGeometry:pb});Ab.prototype=Object.create(L.prototype);Ab.prototype.constructor=Ab;Ab.prototype.isShadowMaterial=!0;Ab.prototype.copy=function(a){L.prototype.copy.call(this,a);this.color.copy(a.color);return this};hc.prototype=Object.create(Ca.prototype);hc.prototype.constructor=hc;hc.prototype.isRawShaderMaterial=!0;Va.prototype=Object.create(L.prototype); -Va.prototype.constructor=Va;Va.prototype.isMeshStandardMaterial=!0;Va.prototype.copy=function(a){L.prototype.copy.call(this,a);this.defines={STANDARD:""};this.color.copy(a.color);this.roughness=a.roughness;this.metalness=a.metalness;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale= -a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.roughnessMap=a.roughnessMap;this.metalnessMap=a.metalnessMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.envMapIntensity=a.envMapIntensity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap= -a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Bb.prototype=Object.create(Va.prototype);Bb.prototype.constructor=Bb;Bb.prototype.isMeshPhysicalMaterial=!0;Bb.prototype.copy=function(a){Va.prototype.copy.call(this,a);this.defines={PHYSICAL:""};this.reflectivity=a.reflectivity;this.clearCoat=a.clearCoat;this.clearCoatRoughness=a.clearCoatRoughness;return this};Ha.prototype=Object.create(L.prototype); -Ha.prototype.constructor=Ha;Ha.prototype.isMeshPhongMaterial=!0;Ha.prototype.copy=function(a){L.prototype.copy.call(this,a);this.color.copy(a.color);this.specular.copy(a.specular);this.shininess=a.shininess;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale; -this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap; -this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Cb.prototype=Object.create(Ha.prototype);Cb.prototype.constructor=Cb;Cb.prototype.isMeshToonMaterial=!0;Cb.prototype.copy=function(a){Ha.prototype.copy.call(this,a);this.gradientMap=a.gradientMap;return this};Db.prototype=Object.create(L.prototype);Db.prototype.constructor=Db;Db.prototype.isMeshNormalMaterial=!0;Db.prototype.copy=function(a){L.prototype.copy.call(this, -a);this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Eb.prototype=Object.create(L.prototype);Eb.prototype.constructor= -Eb;Eb.prototype.isMeshLambertMaterial=!0;Eb.prototype.copy=function(a){L.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity; -this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Fb.prototype=Object.create(L.prototype);Fb.prototype.constructor=Fb;Fb.prototype.isMeshMatcapMaterial=!0;Fb.prototype.copy=function(a){L.prototype.copy.call(this,a);this.defines={MATCAP:""};this.color.copy(a.color); -this.matcap=a.matcap;this.map=a.map;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.alphaMap=a.alphaMap;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Gb.prototype=Object.create(W.prototype);Gb.prototype.constructor= -Gb;Gb.prototype.isLineDashedMaterial=!0;Gb.prototype.copy=function(a){W.prototype.copy.call(this,a);this.scale=a.scale;this.dashSize=a.dashSize;this.gapSize=a.gapSize;return this};var fh=Object.freeze({ShadowMaterial:Ab,SpriteMaterial:ib,RawShaderMaterial:hc,ShaderMaterial:Ca,PointsMaterial:Ga,MeshPhysicalMaterial:Bb,MeshStandardMaterial:Va,MeshPhongMaterial:Ha,MeshToonMaterial:Cb,MeshNormalMaterial:Db,MeshLambertMaterial:Eb,MeshDepthMaterial:fb,MeshDistanceMaterial:gb,MeshBasicMaterial:xa,MeshMatcapMaterial:Fb, -LineDashedMaterial:Gb,LineBasicMaterial:W,Material:L}),sa={arraySlice:function(a,b,c){return sa.isTypedArray(a)?new a.constructor(a.subarray(b,void 0!==c?c:a.length)):a.slice(b,c)},convertArray:function(a,b,c){return!a||!c&&a.constructor===b?a:"number"===typeof b.BYTES_PER_ELEMENT?new b(a):Array.prototype.slice.call(a)},isTypedArray:function(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)},getKeyframeOrder:function(a){for(var b=a.length,c=Array(b),d=0;d!==b;++d)c[d]=d;c.sort(function(b, -c){return a[b]-a[c]});return c},sortedArray:function(a,b,c){for(var d=a.length,e=new a.constructor(d),f=0,g=0;g!==d;++f)for(var h=c[f]*b,k=0;k!==b;++k)e[g++]=a[h+k];return e},flattenJSON:function(a,b,c,d){for(var e=1,f=a[0];void 0!==f&&void 0===f[d];)f=a[e++];if(void 0!==f){var g=f[d];if(void 0!==g)if(Array.isArray(g)){do g=f[d],void 0!==g&&(b.push(f.time),c.push.apply(c,g)),f=a[e++];while(void 0!==f)}else if(void 0!==g.toArray){do g=f[d],void 0!==g&&(b.push(f.time),g.toArray(c,c.length)),f=a[e++]; -while(void 0!==f)}else{do g=f[d],void 0!==g&&(b.push(f.time),c.push(g)),f=a[e++];while(void 0!==f)}}}};Object.assign(wa.prototype,{evaluate:function(a){var b=this.parameterPositions,c=this._cachedIndex,d=b[c],e=b[c-1];a:{b:{c:{d:if(!(a=e)break a;else{f=b[1];a=e)break b}d=c;c=0}}for(;c>>1,ab;)--f;++f;if(0!==e||f!==d)e>=f&&(f=Math.max(f,1),e=f-1),a=this.getValueSize(),this.times=sa.arraySlice(c, -e,f),this.values=sa.arraySlice(this.values,e*a,f*a);return this},validate:function(){var a=!0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),a=!1);var c=this.times;b=this.values;var d=c.length;0===d&&(console.error("THREE.KeyframeTrack: Track is empty.",this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,f,g);a=!1;break}if(null!== -e&&e>g){console.error("THREE.KeyframeTrack: Out of order keys.",this,f,g,e);a=!1;break}e=g}if(void 0!==b&&sa.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,f,d);a=!1;break}return a},optimize:function(){for(var a=this.times,b=this.values,c=this.getValueSize(),d=2302===this.getInterpolation(),e=1,f=a.length-1,g=1;gthis.opacity&&(d.opacity=this.opacity);!0===this.transparent&&(d.transparent=this.transparent);d.depthFunc=this.depthFunc;d.depthTest=this.depthTest;d.depthWrite=this.depthWrite;0!==this.rotation&&(d.rotation=this.rotation);!0===this.polygonOffset&&(d.polygonOffset= +!0);0!==this.polygonOffsetFactor&&(d.polygonOffsetFactor=this.polygonOffsetFactor);0!==this.polygonOffsetUnits&&(d.polygonOffsetUnits=this.polygonOffsetUnits);1!==this.linewidth&&(d.linewidth=this.linewidth);void 0!==this.dashSize&&(d.dashSize=this.dashSize);void 0!==this.gapSize&&(d.gapSize=this.gapSize);void 0!==this.scale&&(d.scale=this.scale);!0===this.dithering&&(d.dithering=!0);0a?b.copy(this.origin):b.copy(this.direction).multiplyScalar(a).add(this.origin)},distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(){var a=new n;return function(b){var c= +a.subVectors(b,this.origin).dot(this.direction);if(0>c)return this.origin.distanceToSquared(b);a.copy(this.direction).multiplyScalar(c).add(this.origin);return a.distanceToSquared(b)}}(),distanceSqToSegment:function(){var a=new n,b=new n,c=new n;return function(d,e,f,g){a.copy(d).add(e).multiplyScalar(.5);b.copy(e).sub(d).normalize();c.copy(this.origin).sub(a);var h=.5*d.distanceTo(e),k=-this.direction.dot(b),m=c.dot(this.direction),l=-c.dot(b),p=c.lengthSq(),t=Math.abs(1-k*k);if(0=-n?e<=n?(h=1/t,d*=h,e*=h,k=d*(d+k*e+2*m)+e*(k*d+e+2*l)+p):(e=h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+p):(e=-h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+p):e<=-n?(d=Math.max(0,-(-k*h+m)),e=0b)return null;b=Math.sqrt(b-e);e=d-b;d+=b;return 0>e&&0>d?null:0>e?this.at(d,c):this.at(e,c)}}(),intersectsSphere:function(a){return this.distanceSqToPoint(a.center)<=a.radius*a.radius},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distanceToPoint(this.origin)? +0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<=a?a:null},intersectPlane:function(a,b){a=this.distanceToPlane(a);return null===a?null:this.at(a,b)},intersectsPlane:function(a){var b=a.distanceToPoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b?!0:!1},intersectBox:function(a,b){var c=1/this.direction.x;var d=1/this.direction.y;var e=1/this.direction.z,f=this.origin;if(0<=c){var g=(a.min.x-f.x)*c;c*=a.max.x-f.x}else g=(a.max.x-f.x)*c,c*=a.min.x-f.x;if(0<=d){var h=(a.min.y- +f.y)*d;d*=a.max.y-f.y}else h=(a.max.y-f.y)*d,d*=a.min.y-f.y;if(g>d||h>c)return null;if(h>g||g!==g)g=h;if(da||h>c)return null;if(h>g||g!==g)g=h;if(ac?null:this.at(0<=g?g:c,b)},intersectsBox:function(){var a=new n;return function(b){return null!==this.intersectBox(b,a)}}(),intersectTriangle:function(){var a=new n,b=new n,c=new n,d=new n;return function(e,f,g,h,k){b.subVectors(f, +e);c.subVectors(g,e);d.crossVectors(b,c);f=this.direction.dot(d);if(0f)h=-1,f=-f;else return null;a.subVectors(this.origin,e);e=h*this.direction.dot(c.crossVectors(a,c));if(0>e)return null;g=h*this.direction.dot(b.cross(a));if(0>g||e+g>f)return null;e=-h*a.dot(d);return 0>e?null:this.at(e/f,k)}}(),applyMatrix4:function(a){this.origin.applyMatrix4(a);this.direction.transformDirection(a);return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}}); +Object.assign(da,{getNormal:function(){var a=new n;return function(b,c,d,e){void 0===e&&(console.warn("THREE.Triangle: .getNormal() target is now required"),e=new n);e.subVectors(d,c);a.subVectors(b,c);e.cross(a);b=e.lengthSq();return 0=a.x+a.y}}(),getUV:function(){var a=new n;return function(b,c,d,e,f,g,h,k){this.getBarycoord(b,c,d,e,a);k.set(0,0);k.addScaledVector(f,a.x);k.addScaledVector(g,a.y);k.addScaledVector(h,a.z);return k}}()});Object.assign(da.prototype, +{set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},getArea:function(){var a=new n,b=new n;return function(){a.subVectors(this.c,this.b);b.subVectors(this.a,this.b);return.5*a.cross(b).length()}}(),getMidpoint:function(a){void 0=== +a&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),a=new n);return a.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(a){return da.getNormal(this.a,this.b,this.c,a)},getPlane:function(a){void 0===a&&(console.warn("THREE.Triangle: .getPlane() target is now required"),a=new n);return a.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(a,b){return da.getBarycoord(a,this.a,this.b,this.c,b)},containsPoint:function(a){return da.containsPoint(a, +this.a,this.b,this.c)},getUV:function(a,b,c,d,e){return da.getUV(a,this.a,this.b,this.c,b,c,d,e)},intersectsBox:function(a){return a.intersectsTriangle(this)},closestPointToPoint:function(){var a=new n,b=new n,c=new n,d=new n,e=new n,f=new n;return function(g,h){void 0===h&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),h=new n);var k=this.a,m=this.b,l=this.c;a.subVectors(m,k);b.subVectors(l,k);d.subVectors(g,k);var p=a.dot(d),t=b.dot(d);if(0>=p&&0>=t)return h.copy(k); +e.subVectors(g,m);var x=a.dot(e),r=b.dot(e);if(0<=x&&r<=x)return h.copy(m);var u=p*r-x*t;if(0>=u&&0<=p&&0>=x)return m=p/(p-x),h.copy(k).addScaledVector(a,m);f.subVectors(g,l);g=a.dot(f);var w=b.dot(f);if(0<=w&&g<=w)return h.copy(l);p=g*t-p*w;if(0>=p&&0<=t&&0>=w)return u=t/(t-w),h.copy(k).addScaledVector(b,u);t=x*w-g*r;if(0>=t&&0<=r-x&&0<=g-w)return c.subVectors(l,m),u=(r-x)/(r-x+(g-w)),h.copy(m).addScaledVector(c,u);l=1/(t+p+u);m=p*l;u*=l;return h.copy(k).addScaledVector(a,m).addScaledVector(b,u)}}(), +equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)}});xa.prototype=Object.create(L.prototype);xa.prototype.constructor=xa;xa.prototype.isMeshBasicMaterial=!0;xa.prototype.copy=function(a){L.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine= +a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;return this};oa.prototype=Object.assign(Object.create(E.prototype),{constructor:oa,isMesh:!0,setDrawMode:function(a){this.drawMode=a},copy:function(a){E.prototype.copy.call(this,a);this.drawMode=a.drawMode; +void 0!==a.morphTargetInfluences&&(this.morphTargetInfluences=a.morphTargetInfluences.slice());void 0!==a.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},a.morphTargetDictionary));return this},updateMorphTargets:function(){var a=this.geometry;if(a.isBufferGeometry){a=a.morphAttributes;var b=Object.keys(a);if(0c.far?null:{distance:b,point:u.clone(),object:a}}function b(b, +c,d,e,k,m,l,q,n){f.fromBufferAttribute(k,l);g.fromBufferAttribute(k,q);h.fromBufferAttribute(k,n);if(b=a(b,c,d,e,f,g,h,r))m&&(p.fromBufferAttribute(m,l),t.fromBufferAttribute(m,q),x.fromBufferAttribute(m,n),b.uv=da.getUV(r,f,g,h,p,t,x,new A)),m=new Lb(l,q,n),da.getNormal(f,g,h,m.normal),b.face=m;return b}var c=new P,d=new rb,e=new Fa,f=new n,g=new n,h=new n,k=new n,m=new n,l=new n,p=new A,t=new A,x=new A,r=new n,u=new n;return function(q,n){var u=this.geometry,w=this.material,y=this.matrixWorld;if(void 0!== +w&&(null===u.boundingSphere&&u.computeBoundingSphere(),e.copy(u.boundingSphere),e.applyMatrix4(y),!1!==q.ray.intersectsSphere(e)&&(c.getInverse(y),d.copy(q.ray).applyMatrix4(c),null===u.boundingBox||!1!==d.intersectsBox(u.boundingBox))))if(u.isBufferGeometry){var z=u.index,C=u.attributes.position,B=u.attributes.uv,E=u.groups;u=u.drawRange;var D;if(null!==z)if(Array.isArray(w)){var F=0;for(D=E.length;Fe.far||f.push({distance:r,point:b.clone(),uv:da.getUV(b,h,k,m,l,p,t,new A),face:null,object:this})}}(),clone:function(){return(new this.constructor(this.material)).copy(this)},copy:function(a){E.prototype.copy.call(this,a);void 0!== +a.center&&this.center.copy(a.center);return this}});Gc.prototype=Object.assign(Object.create(E.prototype),{constructor:Gc,copy:function(a){E.prototype.copy.call(this,a,!1);a=a.levels;for(var b=0,c=a.length;b=d[e].distance)d[e- +1].object.visible=!1,d[e].object.visible=!0;else break;for(;ef||(l.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(l),ud.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}else for(g= +0,r=x.length/3-1;gf||(l.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(l),ud.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else if(g.isGeometry)for(k=g.vertices,m=k.length,g=0;gf||(l.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(l),ud.far||e.push({distance:u, +point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}}(),copy:function(a){E.prototype.copy.call(this,a);this.geometry.copy(a.geometry);this.material.copy(a.material);return this},clone:function(){return(new this.constructor).copy(this)}});U.prototype=Object.assign(Object.create(ua.prototype),{constructor:U,isLineSegments:!0,computeLineDistances:function(){var a=new n,b=new n;return function(){var c=this.geometry;if(c.isBufferGeometry)if(null===c.index){for(var d= +c.attributes.position,e=[],f=0,g=d.count;fd.far||e.push({distance:a,distanceToRay:Math.sqrt(f),point:p.clone(),index:c,face:null,object:g}))}var g=this,h=this.geometry,k=this.matrixWorld,m=d.params.Points.threshold;null===h.boundingSphere&&h.computeBoundingSphere();c.copy(h.boundingSphere);c.applyMatrix4(k);c.radius+=m;if(!1!==d.ray.intersectsSphere(c)){a.getInverse(k);b.copy(d.ray).applyMatrix4(a); +m/=(this.scale.x+this.scale.y+this.scale.z)/3;var l=m*m;m=new n;var p=new n;if(h.isBufferGeometry){var t=h.index;h=h.attributes.position.array;if(null!==t){var x=t.array;t=0;for(var r=x.length;t=a.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}});Ub.prototype=Object.create(S.prototype);Ub.prototype.constructor=Ub;Ub.prototype.isCompressedTexture=!0;Ic.prototype=Object.create(S.prototype);Ic.prototype.constructor=Ic;Ic.prototype.isCanvasTexture=!0;Jc.prototype=Object.create(S.prototype);Jc.prototype.constructor=Jc;Jc.prototype.isDepthTexture=!0;Vb.prototype=Object.create(D.prototype);Vb.prototype.constructor=Vb;Kc.prototype= +Object.create(Q.prototype);Kc.prototype.constructor=Kc;Wb.prototype=Object.create(D.prototype);Wb.prototype.constructor=Wb;Lc.prototype=Object.create(Q.prototype);Lc.prototype.constructor=Lc;za.prototype=Object.create(D.prototype);za.prototype.constructor=za;Mc.prototype=Object.create(Q.prototype);Mc.prototype.constructor=Mc;Xb.prototype=Object.create(za.prototype);Xb.prototype.constructor=Xb;Nc.prototype=Object.create(Q.prototype);Nc.prototype.constructor=Nc;tb.prototype=Object.create(za.prototype); +tb.prototype.constructor=tb;Oc.prototype=Object.create(Q.prototype);Oc.prototype.constructor=Oc;Yb.prototype=Object.create(za.prototype);Yb.prototype.constructor=Yb;Pc.prototype=Object.create(Q.prototype);Pc.prototype.constructor=Pc;Zb.prototype=Object.create(za.prototype);Zb.prototype.constructor=Zb;Qc.prototype=Object.create(Q.prototype);Qc.prototype.constructor=Qc;$b.prototype=Object.create(D.prototype);$b.prototype.constructor=$b;Rc.prototype=Object.create(Q.prototype);Rc.prototype.constructor= +Rc;ac.prototype=Object.create(D.prototype);ac.prototype.constructor=ac;Sc.prototype=Object.create(Q.prototype);Sc.prototype.constructor=Sc;bc.prototype=Object.create(D.prototype);bc.prototype.constructor=bc;var eh={triangulate:function(a,b,c){c=c||2;var d=b&&b.length,e=d?b[0]*c:a.length,f=nf(a,0,e,c,!0),g=[];if(!f)return g;var h;if(d){var k=c;d=[];var m;var l=0;for(m=b.length;l80*c){var x=h=a[0];var r=d=a[1];for(k=c;kh&&(h=l),b>d&&(d=b);h=Math.max(h-x,d-r);h=0!==h?1/h:0}Vc(f,g,c,x,r,h);return g}},$a={area:function(a){for(var b=a.length,c=0,d=b-1,e=0;e$a.area(a)},triangulateShape:function(a,b){var c=[],d=[],e=[];rf(a);sf(c,a);var f=a.length;b.forEach(rf); +for(a=0;aMath.abs(g-k)?[new A(a,1-c),new A(h,1-d),new A(m,1-e),new A(p,1-b)]:[new A(g,1-c),new A(k,1-d),new A(l,1-e),new A(n,1-b)]}};Xc.prototype=Object.create(Q.prototype); +Xc.prototype.constructor=Xc;cc.prototype=Object.create(Ua.prototype);cc.prototype.constructor=cc;Yc.prototype=Object.create(Q.prototype);Yc.prototype.constructor=Yc;wb.prototype=Object.create(D.prototype);wb.prototype.constructor=wb;Zc.prototype=Object.create(Q.prototype);Zc.prototype.constructor=Zc;dc.prototype=Object.create(D.prototype);dc.prototype.constructor=dc;$c.prototype=Object.create(Q.prototype);$c.prototype.constructor=$c;ec.prototype=Object.create(D.prototype);ec.prototype.constructor= +ec;xb.prototype=Object.create(Q.prototype);xb.prototype.constructor=xb;xb.prototype.toJSON=function(){var a=Q.prototype.toJSON.call(this);return uf(this.parameters.shapes,a)};yb.prototype=Object.create(D.prototype);yb.prototype.constructor=yb;yb.prototype.toJSON=function(){var a=D.prototype.toJSON.call(this);return uf(this.parameters.shapes,a)};fc.prototype=Object.create(D.prototype);fc.prototype.constructor=fc;zb.prototype=Object.create(Q.prototype);zb.prototype.constructor=zb;ab.prototype=Object.create(D.prototype); +ab.prototype.constructor=ab;ad.prototype=Object.create(zb.prototype);ad.prototype.constructor=ad;bd.prototype=Object.create(ab.prototype);bd.prototype.constructor=bd;cd.prototype=Object.create(Q.prototype);cd.prototype.constructor=cd;gc.prototype=Object.create(D.prototype);gc.prototype.constructor=gc;var ia=Object.freeze({WireframeGeometry:Vb,ParametricGeometry:Kc,ParametricBufferGeometry:Wb,TetrahedronGeometry:Mc,TetrahedronBufferGeometry:Xb,OctahedronGeometry:Nc,OctahedronBufferGeometry:tb,IcosahedronGeometry:Oc, +IcosahedronBufferGeometry:Yb,DodecahedronGeometry:Pc,DodecahedronBufferGeometry:Zb,PolyhedronGeometry:Lc,PolyhedronBufferGeometry:za,TubeGeometry:Qc,TubeBufferGeometry:$b,TorusKnotGeometry:Rc,TorusKnotBufferGeometry:ac,TorusGeometry:Sc,TorusBufferGeometry:bc,TextGeometry:Xc,TextBufferGeometry:cc,SphereGeometry:Yc,SphereBufferGeometry:wb,RingGeometry:Zc,RingBufferGeometry:dc,PlaneGeometry:zc,PlaneBufferGeometry:qb,LatheGeometry:$c,LatheBufferGeometry:ec,ShapeGeometry:xb,ShapeBufferGeometry:yb,ExtrudeGeometry:vb, +ExtrudeBufferGeometry:Ua,EdgesGeometry:fc,ConeGeometry:ad,ConeBufferGeometry:bd,CylinderGeometry:zb,CylinderBufferGeometry:ab,CircleGeometry:cd,CircleBufferGeometry:gc,BoxGeometry:Mb,BoxBufferGeometry:pb});Ab.prototype=Object.create(L.prototype);Ab.prototype.constructor=Ab;Ab.prototype.isShadowMaterial=!0;Ab.prototype.copy=function(a){L.prototype.copy.call(this,a);this.color.copy(a.color);return this};hc.prototype=Object.create(Ca.prototype);hc.prototype.constructor=hc;hc.prototype.isRawShaderMaterial= +!0;Va.prototype=Object.create(L.prototype);Va.prototype.constructor=Va;Va.prototype.isMeshStandardMaterial=!0;Va.prototype.copy=function(a){L.prototype.copy.call(this,a);this.defines={STANDARD:""};this.color.copy(a.color);this.roughness=a.roughness;this.metalness=a.metalness;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity; +this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.roughnessMap=a.roughnessMap;this.metalnessMap=a.metalnessMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.envMapIntensity=a.envMapIntensity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth= +a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Bb.prototype=Object.create(Va.prototype);Bb.prototype.constructor=Bb;Bb.prototype.isMeshPhysicalMaterial=!0;Bb.prototype.copy=function(a){Va.prototype.copy.call(this,a);this.defines={PHYSICAL:""};this.reflectivity=a.reflectivity;this.clearCoat=a.clearCoat;this.clearCoatRoughness=a.clearCoatRoughness; +return this};Ha.prototype=Object.create(L.prototype);Ha.prototype.constructor=Ha;Ha.prototype.isMeshPhongMaterial=!0;Ha.prototype.copy=function(a){L.prototype.copy.call(this,a);this.color.copy(a.color);this.specular.copy(a.specular);this.shininess=a.shininess;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity; +this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth; +this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Cb.prototype=Object.create(Ha.prototype);Cb.prototype.constructor=Cb;Cb.prototype.isMeshToonMaterial=!0;Cb.prototype.copy=function(a){Ha.prototype.copy.call(this,a);this.gradientMap=a.gradientMap;return this};Db.prototype=Object.create(L.prototype);Db.prototype.constructor=Db;Db.prototype.isMeshNormalMaterial=!0; +Db.prototype.copy=function(a){L.prototype.copy.call(this,a);this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this}; +Eb.prototype=Object.create(L.prototype);Eb.prototype.constructor=Eb;Eb.prototype.isMeshLambertMaterial=!0;Eb.prototype.copy=function(a){L.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap= +a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Fb.prototype=Object.create(L.prototype);Fb.prototype.constructor=Fb;Fb.prototype.isMeshMatcapMaterial=!0;Fb.prototype.copy=function(a){L.prototype.copy.call(this, +a);this.defines={MATCAP:""};this.color.copy(a.color);this.matcap=a.matcap;this.map=a.map;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.alphaMap=a.alphaMap;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};Gb.prototype= +Object.create(W.prototype);Gb.prototype.constructor=Gb;Gb.prototype.isLineDashedMaterial=!0;Gb.prototype.copy=function(a){W.prototype.copy.call(this,a);this.scale=a.scale;this.dashSize=a.dashSize;this.gapSize=a.gapSize;return this};var fh=Object.freeze({ShadowMaterial:Ab,SpriteMaterial:ib,RawShaderMaterial:hc,ShaderMaterial:Ca,PointsMaterial:Ga,MeshPhysicalMaterial:Bb,MeshStandardMaterial:Va,MeshPhongMaterial:Ha,MeshToonMaterial:Cb,MeshNormalMaterial:Db,MeshLambertMaterial:Eb,MeshDepthMaterial:fb, +MeshDistanceMaterial:gb,MeshBasicMaterial:xa,MeshMatcapMaterial:Fb,LineDashedMaterial:Gb,LineBasicMaterial:W,Material:L}),sa={arraySlice:function(a,b,c){return sa.isTypedArray(a)?new a.constructor(a.subarray(b,void 0!==c?c:a.length)):a.slice(b,c)},convertArray:function(a,b,c){return!a||!c&&a.constructor===b?a:"number"===typeof b.BYTES_PER_ELEMENT?new b(a):Array.prototype.slice.call(a)},isTypedArray:function(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)},getKeyframeOrder:function(a){for(var b= +a.length,c=Array(b),d=0;d!==b;++d)c[d]=d;c.sort(function(b,c){return a[b]-a[c]});return c},sortedArray:function(a,b,c){for(var d=a.length,e=new a.constructor(d),f=0,g=0;g!==d;++f)for(var h=c[f]*b,k=0;k!==b;++k)e[g++]=a[h+k];return e},flattenJSON:function(a,b,c,d){for(var e=1,f=a[0];void 0!==f&&void 0===f[d];)f=a[e++];if(void 0!==f){var g=f[d];if(void 0!==g)if(Array.isArray(g)){do g=f[d],void 0!==g&&(b.push(f.time),c.push.apply(c,g)),f=a[e++];while(void 0!==f)}else if(void 0!==g.toArray){do g=f[d], +void 0!==g&&(b.push(f.time),g.toArray(c,c.length)),f=a[e++];while(void 0!==f)}else{do g=f[d],void 0!==g&&(b.push(f.time),c.push(g)),f=a[e++];while(void 0!==f)}}}};Object.assign(wa.prototype,{evaluate:function(a){var b=this.parameterPositions,c=this._cachedIndex,d=b[c],e=b[c-1];a:{b:{c:{d:if(!(a=e)break a;else{f=b[1];a=e)break b}d=c;c=0}}for(;c>>1,ab;)--f;++f;if(0!==e||f!==d)e>=f&&(f=Math.max(f, +1),e=f-1),a=this.getValueSize(),this.times=sa.arraySlice(c,e,f),this.values=sa.arraySlice(this.values,e*a,f*a);return this},validate:function(){var a=!0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),a=!1);var c=this.times;b=this.values;var d=c.length;0===d&&(console.error("THREE.KeyframeTrack: Track is empty.",this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("THREE.KeyframeTrack: Time is not a valid number.", +this,f,g);a=!1;break}if(null!==e&&e>g){console.error("THREE.KeyframeTrack: Out of order keys.",this,f,g,e);a=!1;break}e=g}if(void 0!==b&&sa.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,f,d);a=!1;break}return a},optimize:function(){for(var a=this.times,b=this.values,c=this.getValueSize(),d=2302===this.getInterpolation(),e=1,f=a.length-1,g=1;gNumber.EPSILON){if(0>m&&(g=b[f],k=-k,h=b[e],m=-m),!(a.yh.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e=m*(a.x-g.x)-k*(a.y-g.y);if(0===e)return!0;0>e||(d=!d)}}else if(a.y===g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<=h.x))return!0}return d}var e=$a.isClockWise,f=this.subPaths;if(0===f.length)return[];if(!0===b)return c(f);b=[];if(1===f.length){var g=f[0];var h=new jb;h.curves=g.curves; b.push(h);return b}var k=!e(f[0].getPoints());k=a?!k:k;h=[];var m=[],l=[],p=0;m[p]=void 0;l[p]=[];for(var n=0,x=f.length;nl.opacity&&(l.transparent=!0);d.setTextures(k);return d.parse(l)}}()});var Wd,ue={getContext:function(){void 0===Wd&&(Wd=new (window.AudioContext||window.webkitAudioContext));return Wd},setContext:function(a){Wd=a}};Object.assign(re.prototype,{load:function(a,b,c,d){var e=new Ja(this.manager);e.setResponseType("arraybuffer");e.setPath(this.path);e.load(a,function(a){a=a.slice(0);ue.getContext().decodeAudioData(a,function(a){b(a)})},c,d)},setPath:function(a){this.path=a; -return this}});Object.assign(zf.prototype,{update:function(){var a,b,c,d,e,f,g,h,k=new P,l=new P;return function(m){if(a!==this||b!==m.focus||c!==m.fov||d!==m.aspect*this.aspect||e!==m.near||f!==m.far||g!==m.zoom||h!==this.eyeSep){a=this;b=m.focus;c=m.fov;d=m.aspect*this.aspect;e=m.near;f=m.far;g=m.zoom;var n=m.projectionMatrix.clone();h=this.eyeSep/2;var q=h*e/b,x=e*Math.tan(F.DEG2RAD*c*.5)/g;l.elements[12]=-h;k.elements[12]=h;var r=-x*d+q;var u=x*d+q;n.elements[0]=2*e/(u-r);n.elements[8]=(u+r)/ -(u-r);this.cameraL.projectionMatrix.copy(n);r=-x*d-q;u=x*d-q;n.elements[0]=2*e/(u-r);n.elements[8]=(u+r)/(u-r);this.cameraR.projectionMatrix.copy(n)}this.cameraL.matrixWorld.copy(m.matrixWorld).multiply(l);this.cameraR.matrixWorld.copy(m.matrixWorld).multiply(k)}}()});kd.prototype=Object.create(E.prototype);kd.prototype.constructor=kd;Object.assign(se.prototype,{start:function(){this.oldTime=this.startTime=("undefined"===typeof performance?Date:performance).now();this.elapsedTime=0;this.running=!0}, +{NoBlending:0,NormalBlending:1,AdditiveBlending:2,SubtractiveBlending:3,MultiplyBlending:4,CustomBlending:5},b=new J,c=new Id,d=new Rd;return function(e,f,g){function h(a,b,d,e,h){a=f+a;var m=jd.Handlers.get(a);null!==m?a=m.load(a):(c.setCrossOrigin(g),a=c.load(a));void 0!==b&&(a.repeat.fromArray(b),1!==b[0]&&(a.wrapS=1E3),1!==b[1]&&(a.wrapT=1E3));void 0!==d&&a.offset.fromArray(d);void 0!==e&&("repeat"===e[0]&&(a.wrapS=1E3),"mirror"===e[0]&&(a.wrapS=1002),"repeat"===e[1]&&(a.wrapT=1E3),"mirror"=== +e[1]&&(a.wrapT=1002));void 0!==h&&(a.anisotropy=h);b=F.generateUUID();k[b]=a;return b}var k={},m={uuid:F.generateUUID(),type:"MeshLambertMaterial"},l;for(l in e){var n=e[l];switch(l){case "DbgColor":case "DbgIndex":case "opticalDensity":case "illumination":break;case "DbgName":m.name=n;break;case "blending":m.blending=a[n];break;case "colorAmbient":case "mapAmbient":console.warn("THREE.Loader.createMaterial:",l,"is no longer supported.");break;case "colorDiffuse":m.color=b.fromArray(n).getHex();break; +case "colorSpecular":m.specular=b.fromArray(n).getHex();break;case "colorEmissive":m.emissive=b.fromArray(n).getHex();break;case "specularCoef":m.shininess=n;break;case "shading":"basic"===n.toLowerCase()&&(m.type="MeshBasicMaterial");"phong"===n.toLowerCase()&&(m.type="MeshPhongMaterial");"standard"===n.toLowerCase()&&(m.type="MeshStandardMaterial");break;case "mapDiffuse":m.map=h(n,e.mapDiffuseRepeat,e.mapDiffuseOffset,e.mapDiffuseWrap,e.mapDiffuseAnisotropy);break;case "mapDiffuseRepeat":case "mapDiffuseOffset":case "mapDiffuseWrap":case "mapDiffuseAnisotropy":break; +case "mapEmissive":m.emissiveMap=h(n,e.mapEmissiveRepeat,e.mapEmissiveOffset,e.mapEmissiveWrap,e.mapEmissiveAnisotropy);break;case "mapEmissiveRepeat":case "mapEmissiveOffset":case "mapEmissiveWrap":case "mapEmissiveAnisotropy":break;case "mapLight":m.lightMap=h(n,e.mapLightRepeat,e.mapLightOffset,e.mapLightWrap,e.mapLightAnisotropy);break;case "mapLightRepeat":case "mapLightOffset":case "mapLightWrap":case "mapLightAnisotropy":break;case "mapAO":m.aoMap=h(n,e.mapAORepeat,e.mapAOOffset,e.mapAOWrap, +e.mapAOAnisotropy);break;case "mapAORepeat":case "mapAOOffset":case "mapAOWrap":case "mapAOAnisotropy":break;case "mapBump":m.bumpMap=h(n,e.mapBumpRepeat,e.mapBumpOffset,e.mapBumpWrap,e.mapBumpAnisotropy);break;case "mapBumpScale":m.bumpScale=n;break;case "mapBumpRepeat":case "mapBumpOffset":case "mapBumpWrap":case "mapBumpAnisotropy":break;case "mapNormal":m.normalMap=h(n,e.mapNormalRepeat,e.mapNormalOffset,e.mapNormalWrap,e.mapNormalAnisotropy);break;case "mapNormalFactor":m.normalScale=n;break; +case "mapNormalRepeat":case "mapNormalOffset":case "mapNormalWrap":case "mapNormalAnisotropy":break;case "mapSpecular":m.specularMap=h(n,e.mapSpecularRepeat,e.mapSpecularOffset,e.mapSpecularWrap,e.mapSpecularAnisotropy);break;case "mapSpecularRepeat":case "mapSpecularOffset":case "mapSpecularWrap":case "mapSpecularAnisotropy":break;case "mapMetalness":m.metalnessMap=h(n,e.mapMetalnessRepeat,e.mapMetalnessOffset,e.mapMetalnessWrap,e.mapMetalnessAnisotropy);break;case "mapMetalnessRepeat":case "mapMetalnessOffset":case "mapMetalnessWrap":case "mapMetalnessAnisotropy":break; +case "mapRoughness":m.roughnessMap=h(n,e.mapRoughnessRepeat,e.mapRoughnessOffset,e.mapRoughnessWrap,e.mapRoughnessAnisotropy);break;case "mapRoughnessRepeat":case "mapRoughnessOffset":case "mapRoughnessWrap":case "mapRoughnessAnisotropy":break;case "mapAlpha":m.alphaMap=h(n,e.mapAlphaRepeat,e.mapAlphaOffset,e.mapAlphaWrap,e.mapAlphaAnisotropy);break;case "mapAlphaRepeat":case "mapAlphaOffset":case "mapAlphaWrap":case "mapAlphaAnisotropy":break;case "flipSided":m.side=1;break;case "doubleSided":m.side= +2;break;case "transparency":console.warn("THREE.Loader.createMaterial: transparency has been renamed to opacity");m.opacity=n;break;case "depthTest":case "depthWrite":case "colorWrite":case "opacity":case "reflectivity":case "transparent":case "visible":case "wireframe":m[l]=n;break;case "vertexColors":!0===n&&(m.vertexColors=2);"face"===n&&(m.vertexColors=1);break;default:console.error("THREE.Loader.createMaterial: Unsupported",l,n)}}"MeshBasicMaterial"===m.type&&delete m.emissive;"MeshPhongMaterial"!== +m.type&&delete m.specular;1>m.opacity&&(m.transparent=!0);d.setTextures(k);return d.parse(m)}}()});var Wd,ue={getContext:function(){void 0===Wd&&(Wd=new (window.AudioContext||window.webkitAudioContext));return Wd},setContext:function(a){Wd=a}};Object.assign(re.prototype,{load:function(a,b,c,d){var e=new Ja(this.manager);e.setResponseType("arraybuffer");e.setPath(this.path);e.load(a,function(a){a=a.slice(0);ue.getContext().decodeAudioData(a,function(a){b(a)})},c,d)},setPath:function(a){this.path=a; +return this}});Object.assign(zf.prototype,{update:function(){var a,b,c,d,e,f,g,h,k=new P,m=new P;return function(l){if(a!==this||b!==l.focus||c!==l.fov||d!==l.aspect*this.aspect||e!==l.near||f!==l.far||g!==l.zoom||h!==this.eyeSep){a=this;b=l.focus;c=l.fov;d=l.aspect*this.aspect;e=l.near;f=l.far;g=l.zoom;var n=l.projectionMatrix.clone();h=this.eyeSep/2;var q=h*e/b,x=e*Math.tan(F.DEG2RAD*c*.5)/g;m.elements[12]=-h;k.elements[12]=h;var r=-x*d+q;var u=x*d+q;n.elements[0]=2*e/(u-r);n.elements[8]=(u+r)/ +(u-r);this.cameraL.projectionMatrix.copy(n);r=-x*d-q;u=x*d-q;n.elements[0]=2*e/(u-r);n.elements[8]=(u+r)/(u-r);this.cameraR.projectionMatrix.copy(n)}this.cameraL.matrixWorld.copy(l.matrixWorld).multiply(m);this.cameraR.matrixWorld.copy(l.matrixWorld).multiply(k)}}()});kd.prototype=Object.create(E.prototype);kd.prototype.constructor=kd;Object.assign(se.prototype,{start:function(){this.oldTime=this.startTime=("undefined"===typeof performance?Date:performance).now();this.elapsedTime=0;this.running=!0}, stop:function(){this.getElapsedTime();this.autoStart=this.running=!1},getElapsedTime:function(){this.getDelta();return this.elapsedTime},getDelta:function(){var a=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var b=("undefined"===typeof performance?Date:performance).now();a=(b-this.oldTime)/1E3;this.oldTime=b;this.elapsedTime+=a}return a}});te.prototype=Object.assign(Object.create(E.prototype),{constructor:te,getInput:function(){return this.gain},removeFilter:function(){null!== this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null);return this},getFilter:function(){return this.filter},setFilter:function(a){null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination);this.filter=a;this.gain.connect(this.filter);this.filter.connect(this.context.destination);return this},getMasterVolume:function(){return this.gain.gain.value}, setMasterVolume:function(a){this.gain.gain.setTargetAtTime(a,this.context.currentTime,.01);return this},updateMatrixWorld:function(){var a=new n,b=new ka,c=new n,d=new n,e=new se;return function(f){E.prototype.updateMatrixWorld.call(this,f);f=this.context.listener;var g=this.up;this.timeDelta=e.getDelta();this.matrixWorld.decompose(a,b,c);d.set(0,0,-1).applyQuaternion(b);if(f.positionX){var h=this.context.currentTime+this.timeDelta;f.positionX.linearRampToValueAtTime(a.x,h);f.positionY.linearRampToValueAtTime(a.y, diff --git a/build/three.module.js b/build/three.module.js index 66dbf5ffb9e34ce66d7bcb2cfc290553b3d3e317..47bf5c165dc5f9f682606d479e5fec527c1eef29 100644 --- a/build/three.module.js +++ b/build/three.module.js @@ -6073,7 +6073,7 @@ var emissivemap_pars_fragment = "#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emi var encodings_fragment = "gl_FragColor = linearToOutputTexel( gl_FragColor );"; -var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}"; +var encodings_pars_fragment = "\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}"; var envmap_fragment = "#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif"; @@ -12020,6 +12020,33 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy toNonIndexed: function () { + function convertBufferAttribute( attribute, indices ) { + + var array = attribute.array; + var itemSize = attribute.itemSize; + + var array2 = new array.constructor( indices.length * itemSize ); + + var index = 0, index2 = 0; + + for ( var i = 0, l = indices.length; i < l; i ++ ) { + + index = indices[ i ] * itemSize; + + for ( var j = 0; j < itemSize; j ++ ) { + + array2[ index2 ++ ] = array[ index ++ ]; + + } + + } + + return new BufferAttribute( array2, itemSize ); + + } + + // + if ( this.index === null ) { console.warn( 'THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed.' ); @@ -12032,33 +12059,43 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy var indices = this.index.array; var attributes = this.attributes; + // attributes + for ( var name in attributes ) { var attribute = attributes[ name ]; - var array = attribute.array; - var itemSize = attribute.itemSize; + var newAttribute = convertBufferAttribute( attribute, indices ); - var array2 = new array.constructor( indices.length * itemSize ); + geometry2.addAttribute( name, newAttribute ); - var index = 0, index2 = 0; + } - for ( var i = 0, l = indices.length; i < l; i ++ ) { + // morph attributes - index = indices[ i ] * itemSize; + var morphAttributes = this.morphAttributes; - for ( var j = 0; j < itemSize; j ++ ) { + for ( name in morphAttributes ) { - array2[ index2 ++ ] = array[ index ++ ]; + var morphArray = []; + var morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes - } + for ( var i = 0, il = morphAttribute.length; i < il; i ++ ) { + + var attribute = morphAttribute[ i ]; + + var newAttribute = convertBufferAttribute( attribute, indices ); + + morphArray.push( newAttribute ); } - geometry2.addAttribute( name, new BufferAttribute( array2, itemSize ) ); + geometry2.morphAttributes[ name ] = morphArray; } + // groups + var groups = this.groups; for ( var i = 0, l = groups.length; i < l; i ++ ) { @@ -18681,12 +18718,10 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) { if ( lights.length === 0 ) return; - // TODO Clean up (needed in case of contextlost) - var _gl = _renderer.context; var _state = _renderer.state; // Set GL state for depth map. - _state.disable( 3042 ); + _state.setBlending( NoBlending ); _state.buffers.color.setClear( 1, 1, 1, 1 ); _state.buffers.depth.setTest( true ); _state.setScissorTest( false ); @@ -44654,7 +44689,7 @@ function RectAreaLightHelper( light, color ) { geometry2.addAttribute( 'position', new Float32BufferAttribute( positions2, 3 ) ); geometry2.computeBoundingSphere(); - this.add( new Mesh( geometry2, new MeshBasicMaterial( { side: THREE.BackSide, fog: false } ) ) ); + this.add( new Mesh( geometry2, new MeshBasicMaterial( { side: BackSide, fog: false } ) ) ); this.update(); @@ -45546,8 +45581,8 @@ function ArrowHelper( dir, origin, length, color, headLength, headWidth ) { Object3D.call( this ); - if ( dir === undefined ) dir = new THREE.Vector3( 0, 0, 1 ); - if ( origin === undefined ) origin = new THREE.Vector3( 0, 0, 0 ); + if ( dir === undefined ) dir = new Vector3( 0, 0, 1 ); + if ( origin === undefined ) origin = new Vector3( 0, 0, 0 ); if ( length === undefined ) length = 1; if ( color === undefined ) color = 0xffff00; if ( headLength === undefined ) headLength = 0.2 * length; diff --git a/dist/Three.d.ts b/dist/Three.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8bf447231b1265f1a1e4741165cbe9170874a59e --- /dev/null +++ b/dist/Three.d.ts @@ -0,0 +1,143 @@ +import './polyfills'; +export { WebGLRenderTargetCube } from './renderers/WebGLRenderTargetCube'; +export { WebGLRenderTarget } from './renderers/WebGLRenderTarget'; +export { WebGLRenderer } from './renderers/WebGLRenderer'; +export { ShaderLib } from './renderers/shaders/ShaderLib'; +export { UniformsLib } from './renderers/shaders/UniformsLib'; +export { UniformsUtils } from './renderers/shaders/UniformsUtils'; +export { ShaderChunk } from './renderers/shaders/ShaderChunk'; +export { FogExp2 } from './scenes/FogExp2'; +export { Fog } from './scenes/Fog'; +export { Scene } from './scenes/Scene'; +export { Sprite } from './objects/Sprite'; +export { LOD } from './objects/LOD'; +export { SkinnedMesh } from './objects/SkinnedMesh'; +export { Skeleton } from './objects/Skeleton'; +export { Bone } from './objects/Bone'; +export { Mesh } from './objects/Mesh'; +export { LineSegments } from './objects/LineSegments'; +export { Line } from './objects/Line'; +export { Points } from './objects/Points'; +export { Group } from './objects/Group'; +export { VideoTexture } from './textures/VideoTexture'; +export { DataTexture } from './textures/DataTexture'; +export { CompressedTexture } from './textures/CompressedTexture'; +export { CubeTexture } from './textures/CubeTexture'; +export { CanvasTexture } from './textures/CanvasTexture'; +export { DepthTexture } from './textures/DepthTexture'; +export { Texture } from './textures/Texture'; +export * from './geometries/Geometries'; +export * from './materials/Materials'; +export { CompressedTextureLoader } from './loaders/CompressedTextureLoader'; +export { DataTextureLoader } from './loaders/DataTextureLoader'; +export { CubeTextureLoader } from './loaders/CubeTextureLoader'; +export { TextureLoader } from './loaders/TextureLoader'; +export { ObjectLoader } from './loaders/ObjectLoader'; +export { MaterialLoader } from './loaders/MaterialLoader'; +export { BufferGeometryLoader } from './loaders/BufferGeometryLoader'; +export { LoadingManager, DefaultLoadingManager, } from './loaders/LoadingManager'; +export { ImageLoader } from './loaders/ImageLoader'; +export { FontLoader } from './loaders/FontLoader'; +export { FileLoader } from './loaders/FileLoader'; +export { Loader } from './loaders/Loader'; +export { LoaderUtils } from './loaders/LoaderUtils'; +export { Cache } from './loaders/Cache'; +export { AudioLoader } from './loaders/AudioLoader'; +export { SpotLightShadow } from './lights/SpotLightShadow'; +export { SpotLight } from './lights/SpotLight'; +export { PointLight } from './lights/PointLight'; +export { HemisphereLight } from './lights/HemisphereLight'; +export { DirectionalLightShadow } from './lights/DirectionalLightShadow'; +export { DirectionalLight } from './lights/DirectionalLight'; +export { AmbientLight } from './lights/AmbientLight'; +export { LightShadow } from './lights/LightShadow'; +export { Light } from './lights/Light'; +export { StereoCamera } from './cameras/StereoCamera'; +export { PerspectiveCamera } from './cameras/PerspectiveCamera'; +export { OrthographicCamera } from './cameras/OrthographicCamera'; +export { CubeCamera } from './cameras/CubeCamera'; +export { ArrayCamera } from './cameras/ArrayCamera'; +export { Camera } from './cameras/Camera'; +export { AudioListener } from './audio/AudioListener'; +export { PositionalAudio } from './audio/PositionalAudio'; +export { AudioContext } from './audio/AudioContext'; +export { AudioAnalyser } from './audio/AudioAnalyser'; +export { Audio } from './audio/Audio'; +export { VectorKeyframeTrack } from './animation/tracks/VectorKeyframeTrack'; +export { StringKeyframeTrack } from './animation/tracks/StringKeyframeTrack'; +export { QuaternionKeyframeTrack, } from './animation/tracks/QuaternionKeyframeTrack'; +export { NumberKeyframeTrack } from './animation/tracks/NumberKeyframeTrack'; +export { ColorKeyframeTrack } from './animation/tracks/ColorKeyframeTrack'; +export { BooleanKeyframeTrack } from './animation/tracks/BooleanKeyframeTrack'; +export { PropertyMixer } from './animation/PropertyMixer'; +export { PropertyBinding } from './animation/PropertyBinding'; +export { KeyframeTrack } from './animation/KeyframeTrack'; +export { AnimationUtils } from './animation/AnimationUtils'; +export { AnimationObjectGroup } from './animation/AnimationObjectGroup'; +export { AnimationMixer } from './animation/AnimationMixer'; +export { AnimationClip } from './animation/AnimationClip'; +export { Uniform } from './core/Uniform'; +export { InstancedBufferGeometry } from './core/InstancedBufferGeometry'; +export { BufferGeometry } from './core/BufferGeometry'; +export { Geometry } from './core/Geometry'; +export { InterleavedBufferAttribute } from './core/InterleavedBufferAttribute'; +export { InstancedInterleavedBuffer } from './core/InstancedInterleavedBuffer'; +export { InterleavedBuffer } from './core/InterleavedBuffer'; +export { InstancedBufferAttribute } from './core/InstancedBufferAttribute'; +export * from './core/BufferAttribute'; +export { Face3 } from './core/Face3'; +export { Object3D } from './core/Object3D'; +export { Raycaster } from './core/Raycaster'; +export { Layers } from './core/Layers'; +export { EventDispatcher } from './core/EventDispatcher'; +export { Clock } from './core/Clock'; +export { QuaternionLinearInterpolant, } from './math/interpolants/QuaternionLinearInterpolant'; +export { LinearInterpolant } from './math/interpolants/LinearInterpolant'; +export { DiscreteInterpolant } from './math/interpolants/DiscreteInterpolant'; +export { CubicInterpolant } from './math/interpolants/CubicInterpolant'; +export { Interpolant } from './math/Interpolant'; +export { Triangle } from './math/Triangle'; +export { _Math as Math } from './math/Math'; +export { Spherical } from './math/Spherical'; +export { Cylindrical } from './math/Cylindrical'; +export { Plane } from './math/Plane'; +export { Frustum } from './math/Frustum'; +export { Sphere } from './math/Sphere'; +export { Ray } from './math/Ray'; +export { Matrix4 } from './math/Matrix4'; +export { Matrix3 } from './math/Matrix3'; +export { Box3 } from './math/Box3'; +export { Box2 } from './math/Box2'; +export { Line3 } from './math/Line3'; +export { Euler } from './math/Euler'; +export { Vector4 } from './math/Vector4'; +export { Vector3 } from './math/Vector3'; +export { Vector2 } from './math/Vector2'; +export { Quaternion } from './math/Quaternion'; +export { Color } from './math/Color'; +export { ImmediateRenderObject } from './extras/objects/ImmediateRenderObject'; +export { VertexNormalsHelper } from './helpers/VertexNormalsHelper'; +export { SpotLightHelper } from './helpers/SpotLightHelper'; +export { SkeletonHelper } from './helpers/SkeletonHelper'; +export { PointLightHelper } from './helpers/PointLightHelper'; +export { HemisphereLightHelper } from './helpers/HemisphereLightHelper'; +export { GridHelper } from './helpers/GridHelper'; +export { FaceNormalsHelper } from './helpers/FaceNormalsHelper'; +export { DirectionalLightHelper } from './helpers/DirectionalLightHelper'; +export { CameraHelper } from './helpers/CameraHelper'; +export { BoxHelper } from './helpers/BoxHelper'; +export { PlaneHelper } from './helpers/PlaneHelper'; +export { ArrowHelper } from './helpers/ArrowHelper'; +export { AxesHelper } from './helpers/AxesHelper'; +export * from './extras/curves/Curves'; +export { Shape } from './extras/core/Shape'; +export { Path } from './extras/core/Path'; +export { ShapePath } from './extras/core/ShapePath'; +export { Font } from './extras/core/Font'; +export { CurvePath } from './extras/core/CurvePath'; +export { Curve } from './extras/core/Curve'; +export { ImageUtils } from './extras/ImageUtils'; +export { ShapeUtils } from './extras/ShapeUtils'; +export * from './constants'; +export * from './Three.Legacy'; +//# sourceMappingURL=Three.d.ts.map \ No newline at end of file diff --git a/docs/api/en/animation/AnimationClip.html b/docs/api/en/animation/AnimationClip.html index 08e6212cf47b402704798712fffac36e4328f5d4..258cde59c5a8cf1d2a9ed6e8d4871481ac8d0238 100644 --- a/docs/api/en/animation/AnimationClip.html +++ b/docs/api/en/animation/AnimationClip.html @@ -66,6 +66,11 @@

Methods

+

[method:AnimationClip clone]()

+

+ Returns a copy of this clip. +

+

[method:this optimize]()

Optimizes each track by removing equivalent sequential keys (which are common in morph target diff --git a/docs/api/en/animation/KeyframeTrack.html b/docs/api/en/animation/KeyframeTrack.html index fa648b3aa26351de9223916c35fc0c76dd11f3b2..704a87719d78f7b5403a66791b3aa4d8a16d1f3d 100644 --- a/docs/api/en/animation/KeyframeTrack.html +++ b/docs/api/en/animation/KeyframeTrack.html @@ -160,6 +160,11 @@

Methods

+

[method:KeyframeTrack clone]()

+

+ Returns a copy of this track. +

+

[method:null createInterpolant]()

Creates a [page:LinearInterpolant LinearInterpolant], [page:CubicInterpolant CubicInterpolant] diff --git a/docs/api/en/objects/SkinnedMesh.html b/docs/api/en/objects/SkinnedMesh.html index f6c676df413180c931d9d358e7e747a5ca5603eb..850c8777f05dba877676a0fcdbb7df4d36d86257 100644 --- a/docs/api/en/objects/SkinnedMesh.html +++ b/docs/api/en/objects/SkinnedMesh.html @@ -91,8 +91,8 @@

Constructor

[name]( [param:BufferGeometry geometry], [param:Material material] )

- [page:Geometry geometry] - an instance of [page:BufferGeometry].
- [page:Material material] - (optional) an instance of [page:Material]. Default is a new [page:MeshBasicMaterial]. + [page:Geometry geometry] - an instance of [page:BufferGeometry].
+ [page:Material material] - (optional) an instance of [page:Material]. Default is a new [page:MeshBasicMaterial].

diff --git a/docs/api/zh/animation/AnimationClip.html b/docs/api/zh/animation/AnimationClip.html index 70b8607847cbf692bbb60f3461b59e91f224b7ce..6b6f884dff808a180745795ec353c76da58a0850 100644 --- a/docs/api/zh/animation/AnimationClip.html +++ b/docs/api/zh/animation/AnimationClip.html @@ -62,6 +62,9 @@

方法

+

[method:AnimationClip clone]()

+

+

[method:this optimize]()

通过移除等效的顺序键(在变形目标序列中很常见)来优化每一个轨道 diff --git a/docs/api/zh/animation/AnimationUtils.html b/docs/api/zh/animation/AnimationUtils.html index 0c6880a4fb0a982964fcea356ad4b7dcd15c111a..488e558ed0f3b244a19c9ef5c4abf7472897bf52 100644 --- a/docs/api/zh/animation/AnimationUtils.html +++ b/docs/api/zh/animation/AnimationUtils.html @@ -38,12 +38,18 @@ 返回一个数组,时间和值可以根据此数组排序。

+

[method:Number insertKeyframe]( [param:KeyframeTrack track], [param:Number time] )

+

+

[method:Boolean isTypedArray]( object )

如果该对象是类型化数组,返回*true*

+

[method:AnimationClip mergeMorphTargetTracks]( [param:AnimationClip clip], [param:Object3D root] )

+

+

[method:Array sortedArray]( values, stride, order )

将[page:AnimationUtils.getKeyframeOrder getKeyframeOrder]方法返回的数组排序。 diff --git a/docs/api/zh/animation/KeyframeTrack.html b/docs/api/zh/animation/KeyframeTrack.html index 3586631ee63657944c90cebec39ae03fd946bec3..e0a4535c56f7b86ccc06f647439a30c83b97282a 100644 --- a/docs/api/zh/animation/KeyframeTrack.html +++ b/docs/api/zh/animation/KeyframeTrack.html @@ -137,6 +137,9 @@

方法

+

[method:KeyframeTrack clone]()

+

+

[method:null createInterpolant]()

根据传入构造器中的插值类型参数,创建线性插值([page:LinearInterpolant LinearInterpolant]),立方插值([page:CubicInterpolant CubicInterpolant])或离散插值 diff --git a/docs/examples/exporters/GLTFExporter.html b/docs/examples/exporters/GLTFExporter.html index 436311c72a0e73db481dbeb3a03a8428c94696fc..ddcd65c43d46ca6ba86fa2d7ca4c12493399ebeb 100644 --- a/docs/examples/exporters/GLTFExporter.html +++ b/docs/examples/exporters/GLTFExporter.html @@ -29,6 +29,7 @@

    +
  • KHR_lights_punctual
  • KHR_materials_unlit
  • KHR_texture_transform
diff --git a/examples/js/controls/FirstPersonControls.js b/examples/js/controls/FirstPersonControls.js index 4994e003073250ce1eb9c658f181671545dcaad3..7730ba354abae4948d881db161a3175c04909a97 100644 --- a/examples/js/controls/FirstPersonControls.js +++ b/examples/js/controls/FirstPersonControls.js @@ -7,7 +7,6 @@ THREE.FirstPersonControls = function ( object, domElement ) { this.object = object; - this.target = new THREE.Vector3( 0, 0, 0 ); this.domElement = ( domElement !== undefined ) ? domElement : document; @@ -37,8 +36,6 @@ THREE.FirstPersonControls = function ( object, domElement ) { this.lat = 0; this.lon = 0; - this.phi = 0; - this.theta = 0; this.moveForward = false; this.moveBackward = false; @@ -184,74 +181,77 @@ THREE.FirstPersonControls = function ( object, domElement ) { }; - this.update = function ( delta ) { + this.update = function () { - if ( this.enabled === false ) return; + var targetPosition = new THREE.Vector3(); - if ( this.heightSpeed ) { + return function update( delta ) { - var y = THREE.Math.clamp( this.object.position.y, this.heightMin, this.heightMax ); - var heightDelta = y - this.heightMin; + if ( this.enabled === false ) return; - this.autoSpeedFactor = delta * ( heightDelta * this.heightCoef ); + if ( this.heightSpeed ) { - } else { + var y = THREE.Math.clamp( this.object.position.y, this.heightMin, this.heightMax ); + var heightDelta = y - this.heightMin; - this.autoSpeedFactor = 0.0; + this.autoSpeedFactor = delta * ( heightDelta * this.heightCoef ); - } + } else { - var actualMoveSpeed = delta * this.movementSpeed; + this.autoSpeedFactor = 0.0; - if ( this.moveForward || ( this.autoForward && ! this.moveBackward ) ) this.object.translateZ( - ( actualMoveSpeed + this.autoSpeedFactor ) ); - if ( this.moveBackward ) this.object.translateZ( actualMoveSpeed ); + } - if ( this.moveLeft ) this.object.translateX( - actualMoveSpeed ); - if ( this.moveRight ) this.object.translateX( actualMoveSpeed ); + var actualMoveSpeed = delta * this.movementSpeed; - if ( this.moveUp ) this.object.translateY( actualMoveSpeed ); - if ( this.moveDown ) this.object.translateY( - actualMoveSpeed ); + if ( this.moveForward || ( this.autoForward && ! this.moveBackward ) ) this.object.translateZ( - ( actualMoveSpeed + this.autoSpeedFactor ) ); + if ( this.moveBackward ) this.object.translateZ( actualMoveSpeed ); - var actualLookSpeed = delta * this.lookSpeed; + if ( this.moveLeft ) this.object.translateX( - actualMoveSpeed ); + if ( this.moveRight ) this.object.translateX( actualMoveSpeed ); - if ( ! this.activeLook ) { + if ( this.moveUp ) this.object.translateY( actualMoveSpeed ); + if ( this.moveDown ) this.object.translateY( - actualMoveSpeed ); - actualLookSpeed = 0; + var actualLookSpeed = delta * this.lookSpeed; - } + if ( ! this.activeLook ) { - var verticalLookRatio = 1; + actualLookSpeed = 0; - if ( this.constrainVertical ) { + } - verticalLookRatio = Math.PI / ( this.verticalMax - this.verticalMin ); + var verticalLookRatio = 1; - } + if ( this.constrainVertical ) { + + verticalLookRatio = Math.PI / ( this.verticalMax - this.verticalMin ); - this.lon += this.mouseX * actualLookSpeed; - if ( this.lookVertical ) this.lat -= this.mouseY * actualLookSpeed * verticalLookRatio; + } - this.lat = Math.max( - 85, Math.min( 85, this.lat ) ); - this.phi = THREE.Math.degToRad( 90 - this.lat ); + this.lon -= this.mouseX * actualLookSpeed; + if ( this.lookVertical ) this.lat -= this.mouseY * actualLookSpeed * verticalLookRatio; - this.theta = THREE.Math.degToRad( this.lon ); + this.lat = Math.max( - 85, Math.min( 85, this.lat ) ); - if ( this.constrainVertical ) { + var phi = THREE.Math.degToRad( 90 - this.lat ); + var theta = THREE.Math.degToRad( this.lon ); - this.phi = THREE.Math.mapLinear( this.phi, 0, Math.PI, this.verticalMin, this.verticalMax ); + if ( this.constrainVertical ) { - } + phi = THREE.Math.mapLinear( phi, 0, Math.PI, this.verticalMin, this.verticalMax ); - var targetPosition = this.target, - position = this.object.position; + } - targetPosition.x = position.x + 100 * Math.sin( this.phi ) * Math.cos( this.theta ); - targetPosition.y = position.y + 100 * Math.cos( this.phi ); - targetPosition.z = position.z + 100 * Math.sin( this.phi ) * Math.sin( this.theta ); + var position = this.object.position; - this.object.lookAt( targetPosition ); + targetPosition.setFromSphericalCoords( 1, phi, theta ).add( position ); - }; + this.object.lookAt( targetPosition ); + + }; + + }(); function contextmenu( event ) { diff --git a/examples/js/exporters/GLTFExporter.js b/examples/js/exporters/GLTFExporter.js index 2db9860de9a14b4d314086639e32b6223963354e..4cd93bf004a41c087af1f0f996fc92fd83b71100 100644 --- a/examples/js/exporters/GLTFExporter.js +++ b/examples/js/exporters/GLTFExporter.js @@ -385,7 +385,7 @@ THREE.GLTFExporter.prototype = { if ( texture.repeat.x !== 1 || texture.repeat.y !== 1 ) { transformDef.scale = texture.repeat.toArray(); - didTransform = true; + didTransform = true; } @@ -981,7 +981,10 @@ THREE.GLTFExporter.prototype = { // occlusionTexture if ( material.aoMap ) { - var occlusionMapDef = { index: processTexture( material.aoMap ) }; + var occlusionMapDef = { + index: processTexture( material.aoMap ), + texCoord: 1 + }; if ( material.aoMapIntensity !== 1.0 ) { @@ -1227,9 +1230,9 @@ THREE.GLTFExporter.prototype = { var baseAttribute = geometry.attributes[ attributeName ]; - if ( cachedData.attributes.has( baseAttribute ) ) { + if ( cachedData.attributes.has( attribute ) ) { - target[ gltfAttributeName ] = cachedData.attributes.get( baseAttribute ); + target[ gltfAttributeName ] = cachedData.attributes.get( attribute ); continue; } @@ -1443,12 +1446,15 @@ THREE.GLTFExporter.prototype = { } + clip = THREE.GLTFExporter.Utils.mergeMorphTargetTracks( clip.clone(), root ); + + var tracks = clip.tracks; var channels = []; var samplers = []; - for ( var i = 0; i < clip.tracks.length; ++ i ) { + for ( var i = 0; i < tracks.length; ++ i ) { - var track = clip.tracks[ i ]; + var track = tracks[ i ]; var trackBinding = THREE.PropertyBinding.parseTrackName( track.name ); var trackNode = THREE.PropertyBinding.findNode( root, trackBinding.nodeName ); var trackProperty = PATH_PROPERTIES[ trackBinding.propertyName ]; @@ -1479,16 +1485,6 @@ THREE.GLTFExporter.prototype = { if ( trackProperty === PATH_PROPERTIES.morphTargetInfluences ) { - if ( trackNode.morphTargetInfluences.length !== 1 && - trackBinding.propertyIndex !== undefined ) { - - console.warn( 'THREE.GLTFExporter: Skipping animation track "%s". ' + - 'Morph target keyframe tracks must target all available morph targets ' + - 'for the given mesh.', track.name ); - continue; - - } - outputItemSize /= trackNode.morphTargetInfluences.length; } @@ -1591,6 +1587,59 @@ THREE.GLTFExporter.prototype = { } + function processLight( light ) { + + var lightDef = {}; + + if ( light.name ) lightDef.name = light.name; + + lightDef.color = light.color.toArray(); + + lightDef.intensity = light.intensity; + + if ( light.isDirectionalLight ) { + + lightDef.type = 'directional'; + + } else if ( light.isPointLight ) { + + lightDef.type = 'point'; + if ( light.distance > 0 ) lightDef.range = light.distance; + + } else if ( light.isSpotLight ) { + + lightDef.type = 'spot'; + if ( light.distance > 0 ) lightDef.range = light.distance; + lightDef.spot = {}; + lightDef.spot.innerConeAngle = ( light.penumbra - 1.0 ) * light.angle * -1.0; + lightDef.spot.outerConeAngle = light.angle; + + } + + if ( light.decay !== undefined && light.decay !== 2 ) { + + console.warn( 'THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, ' + + 'and expects light.decay=2.' ); + + } + + if ( light.target + && ( light.target.parent !== light + || light.target.position.x !== 0 + || light.target.position.y !== 0 + || light.target.position.z !== -1 ) ) { + + console.warn( 'THREE.GLTFExporter: Light direction may be lost. For best results, ' + + 'make light.target a child of the light with position 0,0,-1.' ); + + } + + var lights = outputJSON.extensions[ 'KHR_lights_punctual' ].lights; + lights.push( lightDef ); + return lights.length - 1; + + } + /** * Process Object3D node * @param {THREE.Object3D} node Object3D to processNode @@ -1598,13 +1647,6 @@ THREE.GLTFExporter.prototype = { */ function processNode( object ) { - if ( object.isLight ) { - - console.warn( 'GLTFExporter: Unsupported node type:', object.constructor.name ); - return null; - - } - if ( ! outputJSON.nodes ) { outputJSON.nodes = []; @@ -1675,6 +1717,24 @@ THREE.GLTFExporter.prototype = { gltfNode.camera = processCamera( object ); + } else if ( object.isDirectionalLight || object.isPointLight || object.isSpotLight ) { + + if ( ! extensionsUsed[ 'KHR_lights_punctual' ] ) { + + outputJSON.extensions = outputJSON.extensions || {}; + outputJSON.extensions[ 'KHR_lights_punctual' ] = { lights: [] }; + extensionsUsed[ 'KHR_lights_punctual' ] = true; + + } + + gltfNode.extensions = gltfNode.extensions || {}; + gltfNode.extensions[ 'KHR_lights_punctual' ] = { light: processLight( object ) }; + + } else if ( object.isLight ) { + + console.warn( 'THREE.GLTFExporter: Only directional, point, and spot lights are supported.' ); + return null; + } if ( object.isSkinnedMesh ) { @@ -1942,3 +2002,196 @@ THREE.GLTFExporter.prototype = { } }; + +THREE.GLTFExporter.Utils = { + + insertKeyframe: function ( track, time ) { + + var tolerance = 0.001; // 1ms + var valueSize = track.getValueSize(); + + var times = new track.TimeBufferType( track.times.length + 1 ); + var values = new track.ValueBufferType( track.values.length + valueSize ); + var interpolant = track.createInterpolant( new track.ValueBufferType( valueSize ) ); + + var index; + + if ( track.times.length === 0 ) { + + times[ 0 ] = time; + + for ( var i = 0; i < valueSize; i ++ ) { + + values[ i ] = 0; + + } + + index = 0; + + } else if ( time < track.times[ 0 ] ) { + + if ( Math.abs( track.times[ 0 ] - time ) < tolerance ) return 0; + + times[ 0 ] = time; + times.set( track.times, 1 ); + + values.set( interpolant.evaluate( time ), 0 ); + values.set( track.values, valueSize ); + + index = 0; + + } else if ( time > track.times[ track.times.length - 1 ] ) { + + if ( Math.abs( track.times[ track.times.length - 1 ] - time ) < tolerance ) { + + return track.times.length - 1; + + } + + times[ times.length - 1 ] = time; + times.set( track.times, 0 ); + + values.set( track.values, 0 ); + values.set( interpolant.evaluate( time ), track.values.length ); + + index = times.length - 1; + + } else { + + for ( var i = 0; i < track.times.length; i ++ ) { + + if ( Math.abs( track.times[ i ] - time ) < tolerance ) return i; + + if ( track.times[ i ] < time && track.times[ i + 1 ] > time ) { + + times.set( track.times.slice( 0, i + 1 ), 0 ); + times[ i + 1 ] = time; + times.set( track.times.slice( i + 1 ), i + 2 ); + + values.set( track.values.slice( 0, ( i + 1 ) * valueSize ), 0 ); + values.set( interpolant.evaluate( time ), ( i + 1 ) * valueSize ); + values.set( track.values.slice( ( i + 1 ) * valueSize ), ( i + 2 ) * valueSize ); + + index = i + 1; + + break; + + } + + } + + } + + track.times = times; + track.values = values; + + return index; + + }, + + mergeMorphTargetTracks: function ( clip, root ) { + + var tracks = []; + var mergedTracks = {}; + var sourceTracks = clip.tracks; + + for ( var i = 0; i < sourceTracks.length; ++ i ) { + + var sourceTrack = sourceTracks[ i ]; + var sourceTrackBinding = THREE.PropertyBinding.parseTrackName( sourceTrack.name ); + var sourceTrackNode = THREE.PropertyBinding.findNode( root, sourceTrackBinding.nodeName ); + + if ( sourceTrackBinding.propertyName !== 'morphTargetInfluences' || sourceTrackBinding.propertyIndex === undefined ) { + + // Tracks that don't affect morph targets, or that affect all morph targets together, can be left as-is. + tracks.push( sourceTrack ); + continue; + + } + + if ( sourceTrack.createInterpolant !== sourceTrack.InterpolantFactoryMethodDiscrete + && sourceTrack.createInterpolant !== sourceTrack.InterpolantFactoryMethodLinear ) { + + if ( sourceTrack.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline ) { + + // This should never happen, because glTF morph target animations + // affect all targets already. + throw new Error( 'THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.' ); + + } + + console.warn( 'THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.' ); + + sourceTrack = sourceTrack.clone(); + sourceTrack.setInterpolation( InterpolateLinear ); + + } + + var targetCount = sourceTrackNode.morphTargetInfluences.length; + var targetIndex = sourceTrackNode.morphTargetDictionary[ sourceTrackBinding.propertyIndex ]; + + if ( targetIndex === undefined ) { + + throw new Error( 'THREE.GLTFExporter: Morph target name not found: ' + sourceTrackBinding.propertyIndex ); + + } + + var mergedTrack; + + // If this is the first time we've seen this object, create a new + // track to store merged keyframe data for each morph target. + if ( mergedTracks[ sourceTrackNode.uuid ] === undefined ) { + + mergedTrack = sourceTrack.clone(); + + var values = new mergedTrack.ValueBufferType( targetCount * mergedTrack.times.length ); + + for ( var j = 0; j < mergedTrack.times.length; j ++ ) { + + values[ j * targetCount + targetIndex ] = mergedTrack.values[ j ]; + + } + + mergedTrack.name = '.morphTargetInfluences'; + mergedTrack.values = values; + + mergedTracks[ sourceTrackNode.uuid ] = mergedTrack; + tracks.push( mergedTrack ); + + continue; + + } + + var mergedKeyframeIndex = 0; + var sourceKeyframeIndex = 0; + var sourceInterpolant = sourceTrack.createInterpolant( new sourceTrack.ValueBufferType( 1 ) ); + + mergedTrack = mergedTracks[ sourceTrackNode.uuid ]; + + // For every existing keyframe of the merged track, write a (possibly + // interpolated) value from the source track. + for ( var j = 0; j < mergedTrack.times.length; j ++ ) { + + mergedTrack.values[ j * targetCount + targetIndex ] = sourceInterpolant.evaluate( mergedTrack.times[ j ] ); + + } + + // For every existing keyframe of the source track, write a (possibly + // new) keyframe to the merged track. Values from the previous loop may + // be written again, but keyframes are de-duplicated. + for ( var j = 0; j < sourceTrack.times.length; j ++ ) { + + var keyframeIndex = this.insertKeyframe( mergedTrack, sourceTrack.times[ j ] ); + mergedTrack.values[ keyframeIndex * targetCount + targetIndex ] = sourceTrack.values[ j ]; + + } + + } + + clip.tracks = tracks; + + return clip; + + } + +}; diff --git a/examples/js/loaders/GLTFLoader.js b/examples/js/loaders/GLTFLoader.js index d011eb7cd5252445719bbc61556934640f3c3b57..0c330270e96af763561bf4d03bcdf1541306ebb6 100644 --- a/examples/js/loaders/GLTFLoader.js +++ b/examples/js/loaders/GLTFLoader.js @@ -365,6 +365,10 @@ THREE.GLTFLoader = ( function () { } + // Some lights (e.g. spot) default to a position other than the origin. Reset the position + // here, because node-level parsing will only override position if explicitly specified. + lightNode.position.set( 0, 0, 0 ); + lightNode.decay = 2; if ( lightDef.intensity !== undefined ) lightNode.intensity = lightDef.intensity; diff --git a/examples/js/nodes/utils/ColorSpaceNode.js b/examples/js/nodes/utils/ColorSpaceNode.js index 44572735140baf8b0ccd4d84dc58fc1f1c46fd64..afede0b1e0dfddf70f864c86a88b973c5f0916f2 100644 --- a/examples/js/nodes/utils/ColorSpaceNode.js +++ b/examples/js/nodes/utils/ColorSpaceNode.js @@ -131,7 +131,7 @@ ColorSpaceNode.Nodes = ( function () { var LinearToLogLuv = new FunctionNode( [ "vec4 LinearToLogLuv( in vec4 value ) {", - " vec3 Xp_Y_XYZp = value.rgb * cLogLuvM;", + " vec3 Xp_Y_XYZp = cLogLuvM * value.rgb;", " Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));", " vec4 vResult;", " vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;", @@ -155,7 +155,7 @@ ColorSpaceNode.Nodes = ( function () { " Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);", " Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;", " Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;", - " vec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;", + " vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;", " return vec4( max(vRGB, 0.0), 1.0 );", "}" diff --git a/examples/js/postprocessing/SSAOPass.js b/examples/js/postprocessing/SSAOPass.js index 2421514f760df693f939802d361bfa450aa67c12..04c567ff08197fb11893c47ac96c28cd27068815 100644 --- a/examples/js/postprocessing/SSAOPass.js +++ b/examples/js/postprocessing/SSAOPass.js @@ -369,19 +369,26 @@ THREE.SSAOPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), var simplex = new SimplexNoise(); var size = width * height; - var data = new Float32Array( size ); + var data = new Float32Array( size * 4 ); for ( var i = 0; i < size; i ++ ) { + var stride = i * 4; + var x = ( Math.random() * 2 ) - 1; var y = ( Math.random() * 2 ) - 1; var z = 0; - data[ i ] = simplex.noise3d( x, y, z ); + var noise = simplex.noise3d( x, y, z ); + + data[ stride ] = noise; + data[ stride + 1 ] = noise; + data[ stride + 2 ] = noise; + data[ stride + 3 ] = 1; } - this.noiseTexture = new THREE.DataTexture( data, width, height, THREE.LuminanceFormat, THREE.FloatType ); + this.noiseTexture = new THREE.DataTexture( data, width, height, THREE.RGBA, THREE.FloatType ); this.noiseTexture.wrapS = THREE.RepeatWrapping; this.noiseTexture.wrapT = THREE.RepeatWrapping; this.noiseTexture.needsUpdate = true; diff --git a/examples/misc_exporter_gltf.html b/examples/misc_exporter_gltf.html index 3738e446039e4ccff82c787fde1db6931a3bfc7b..2e685b226f83f2b6432f4cb8101a4795d692c19e 100644 --- a/examples/misc_exporter_gltf.html +++ b/examples/misc_exporter_gltf.html @@ -182,7 +182,9 @@ // DirectLight // --------------------------------------------------------------------- light = new THREE.DirectionalLight( 0xffffff, 1 ); - light.position.set( 1, 1, 0 ); + light.target.position.set( 0, 0, -1 ); + light.add( light.target ); + light.lookAt( -1, -1, 0 ); light.name = 'DirectionalLight'; scene1.add( light ); diff --git a/examples/webgl_geometry_spline_editor.html b/examples/webgl_geometry_spline_editor.html index 25a7a51670bf6411d83c56b916cb4acc0aa12576..ad3b2b30fca3f429dd237e92cf0f2275e51e204c 100644 --- a/examples/webgl_geometry_spline_editor.html +++ b/examples/webgl_geometry_spline_editor.html @@ -151,7 +151,7 @@ controls.addEventListener( 'start', function () { - cancelHideTransorm(); + cancelHideTransform(); } ); @@ -173,13 +173,13 @@ // Hiding transform situation is a little in a mess :() transformControl.addEventListener( 'change', function () { - cancelHideTransorm(); + cancelHideTransform(); } ); transformControl.addEventListener( 'mouseDown', function () { - cancelHideTransorm(); + cancelHideTransform(); } ); @@ -200,7 +200,7 @@ dragcontrols.addEventListener( 'hoveron', function ( event ) { transformControl.attach( event.object ); - cancelHideTransorm(); + cancelHideTransform(); } ); @@ -214,7 +214,7 @@ function delayHideTransform() { - cancelHideTransorm(); + cancelHideTransform(); hideTransform(); } @@ -229,7 +229,7 @@ } - function cancelHideTransorm() { + function cancelHideTransform() { if ( hiding ) clearTimeout( hiding ); diff --git a/src/Three.Legacy.d.ts b/src/Three.Legacy.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5b3adde0e38f79a9f1b6c68dfbbe2e154fc893be --- /dev/null +++ b/src/Three.Legacy.d.ts @@ -0,0 +1,13 @@ +import { Geometry } from './core/Geometry'; +import { Material } from './materials/Material'; +import { Object3D } from './core/Object3D'; +import { Scene } from './scenes/Scene'; + +export namespace SceneUtils { + export function createMultiMaterialObject( + geometry: Geometry, + materials: Material[] + ): Object3D; + export function detach(child: Object3D, parent: Object3D, scene: Scene): void; + export function attach(child: Object3D, scene: Scene, parent: Object3D): void; +} diff --git a/src/Three.d.ts b/src/Three.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0901252240f9aca5c49984eea7fba1fef49d425a --- /dev/null +++ b/src/Three.d.ts @@ -0,0 +1,159 @@ +import './polyfills'; + +export { + WebGLMultisampleRenderTarget, +} from './renderers/WebGLMultisampleRenderTarget'; +export { WebGLRenderTargetCube } from './renderers/WebGLRenderTargetCube'; +export { WebGLRenderTarget } from './renderers/WebGLRenderTarget'; +export { WebGLRenderer } from './renderers/WebGLRenderer'; +export { ShaderLib } from './renderers/shaders/ShaderLib'; +export { UniformsLib } from './renderers/shaders/UniformsLib'; +export { UniformsUtils } from './renderers/shaders/UniformsUtils'; +export { ShaderChunk } from './renderers/shaders/ShaderChunk'; +export { FogExp2 } from './scenes/FogExp2'; +export { Fog } from './scenes/Fog'; +export { Scene } from './scenes/Scene'; +export { Sprite } from './objects/Sprite'; +export { LOD } from './objects/LOD'; +export { SkinnedMesh } from './objects/SkinnedMesh'; +export { Skeleton } from './objects/Skeleton'; +export { Bone } from './objects/Bone'; +export { Mesh } from './objects/Mesh'; +export { LineSegments } from './objects/LineSegments'; +export { LineLoop } from './objects/LineLoop'; +export { Line } from './objects/Line'; +export { Points } from './objects/Points'; +export { Group } from './objects/Group'; +export { VideoTexture } from './textures/VideoTexture'; +export { DataTexture } from './textures/DataTexture'; +export { DataTexture3D } from './textures/DataTexture3D'; +export { CompressedTexture } from './textures/CompressedTexture'; +export { CubeTexture } from './textures/CubeTexture'; +export { CanvasTexture } from './textures/CanvasTexture'; +export { DepthTexture } from './textures/DepthTexture'; +export { Texture } from './textures/Texture'; +export * from './geometries/Geometries'; +export * from './materials/Materials'; +//export { AnimationLoader } from './loaders/AnimationLoader'; +export { CompressedTextureLoader } from './loaders/CompressedTextureLoader'; +export { DataTextureLoader } from './loaders/DataTextureLoader'; +export { CubeTextureLoader } from './loaders/CubeTextureLoader'; +export { TextureLoader } from './loaders/TextureLoader'; +export { ObjectLoader } from './loaders/ObjectLoader'; +export { MaterialLoader } from './loaders/MaterialLoader'; +export { BufferGeometryLoader } from './loaders/BufferGeometryLoader'; +export { LoadingManager } from './loaders/LoadingManager'; +export { ImageLoader } from './loaders/ImageLoader'; +export { ImageBitmapLoader } from './loaders/ImageBitmapLoader'; +export { FontLoader } from './loaders/FontLoader'; +export { FileLoader } from './loaders/FileLoader'; +export { Loader } from './loaders/Loader'; +export { LoaderUtils } from './loaders/LoaderUtils'; +export { Cache } from './loaders/Cache'; +export { AudioLoader } from './loaders/AudioLoader'; +export { SpotLightShadow } from './lights/SpotLightShadow'; +export { SpotLight } from './lights/SpotLight'; +export { PointLight } from './lights/PointLight'; +export { RectAreaLight } from './lights/RectAreaLight'; +export { HemisphereLight } from './lights/HemisphereLight'; +export { DirectionalLightShadow } from './lights/DirectionalLightShadow'; +export { DirectionalLight } from './lights/DirectionalLight'; +export { AmbientLight } from './lights/AmbientLight'; +export { LightShadow } from './lights/LightShadow'; +export { Light } from './lights/Light'; +export { StereoCamera } from './cameras/StereoCamera'; +export { PerspectiveCamera } from './cameras/PerspectiveCamera'; +export { OrthographicCamera } from './cameras/OrthographicCamera'; +export { CubeCamera } from './cameras/CubeCamera'; +export { ArrayCamera } from './cameras/ArrayCamera'; +export { Camera } from './cameras/Camera'; +export { AudioListener } from './audio/AudioListener'; +export { PositionalAudio } from './audio/PositionalAudio'; +export { AudioContext } from './audio/AudioContext'; +export { AudioAnalyser } from './audio/AudioAnalyser'; +export { Audio } from './audio/Audio'; +export { VectorKeyframeTrack } from './animation/tracks/VectorKeyframeTrack'; +export { StringKeyframeTrack } from './animation/tracks/StringKeyframeTrack'; +export { + QuaternionKeyframeTrack, +} from './animation/tracks/QuaternionKeyframeTrack'; +export { NumberKeyframeTrack } from './animation/tracks/NumberKeyframeTrack'; +export { ColorKeyframeTrack } from './animation/tracks/ColorKeyframeTrack'; +export { BooleanKeyframeTrack } from './animation/tracks/BooleanKeyframeTrack'; +export { PropertyMixer } from './animation/PropertyMixer'; +export { PropertyBinding } from './animation/PropertyBinding'; +export { KeyframeTrack } from './animation/KeyframeTrack'; +export { AnimationUtils } from './animation/AnimationUtils'; +export { AnimationObjectGroup } from './animation/AnimationObjectGroup'; +export { AnimationMixer } from './animation/AnimationMixer'; +export { AnimationClip } from './animation/AnimationClip'; +export { Uniform } from './core/Uniform'; +export { InstancedBufferGeometry } from './core/InstancedBufferGeometry'; +export { BufferGeometry } from './core/BufferGeometry'; +export { Geometry } from './core/Geometry'; +export { InterleavedBufferAttribute } from './core/InterleavedBufferAttribute'; +export { InstancedInterleavedBuffer } from './core/InstancedInterleavedBuffer'; +export { InterleavedBuffer } from './core/InterleavedBuffer'; +export { InstancedBufferAttribute } from './core/InstancedBufferAttribute'; +export * from './core/BufferAttribute'; +export { Face3 } from './core/Face3'; +export { Object3D } from './core/Object3D'; +export { Raycaster } from './core/Raycaster'; +export { Layers } from './core/Layers'; +export { EventDispatcher } from './core/EventDispatcher'; +export { Clock } from './core/Clock'; +export { + QuaternionLinearInterpolant, +} from './math/interpolants/QuaternionLinearInterpolant'; +export { LinearInterpolant } from './math/interpolants/LinearInterpolant'; +export { DiscreteInterpolant } from './math/interpolants/DiscreteInterpolant'; +export { CubicInterpolant } from './math/interpolants/CubicInterpolant'; +export { Interpolant } from './math/Interpolant'; +export { Triangle } from './math/Triangle'; +export { _Math as Math } from './math/Math'; +export { Spherical } from './math/Spherical'; +export { Cylindrical } from './math/Cylindrical'; +export { Plane } from './math/Plane'; +export { Frustum } from './math/Frustum'; +export { Sphere } from './math/Sphere'; +export { Ray } from './math/Ray'; +export { Matrix4 } from './math/Matrix4'; +export { Matrix3 } from './math/Matrix3'; +export { Box3 } from './math/Box3'; +export { Box2 } from './math/Box2'; +export { Line3 } from './math/Line3'; +export { Euler } from './math/Euler'; +export { Vector4 } from './math/Vector4'; +export { Vector3 } from './math/Vector3'; +export { Vector2 } from './math/Vector2'; +export { Quaternion } from './math/Quaternion'; +export { Color } from './math/Color'; +export { ImmediateRenderObject } from './extras/objects/ImmediateRenderObject'; +export { VertexNormalsHelper } from './helpers/VertexNormalsHelper'; +export { SpotLightHelper } from './helpers/SpotLightHelper'; +export { SkeletonHelper } from './helpers/SkeletonHelper'; +export { PointLightHelper } from './helpers/PointLightHelper'; +export { RectAreaLightHelper } from './helpers/RectAreaLightHelper'; +export { HemisphereLightHelper } from './helpers/HemisphereLightHelper'; +export { GridHelper } from './helpers/GridHelper'; +export { PolarGridHelper } from './helpers/PolarGridHelper'; +export { FaceNormalsHelper } from './helpers/FaceNormalsHelper'; +export { DirectionalLightHelper } from './helpers/DirectionalLightHelper'; +export { CameraHelper } from './helpers/CameraHelper'; +export { BoxHelper } from './helpers/BoxHelper'; +export { Box3Helper } from './helpers/Box3Helper'; +export { PlaneHelper } from './helpers/PlaneHelper'; +export { ArrowHelper } from './helpers/ArrowHelper'; +export { AxesHelper } from './helpers/AxesHelper'; +export * from './extras/curves/Curves'; +export { Shape } from './extras/core/Shape'; +export { Path } from './extras/core/Path'; +export { ShapePath } from './extras/core/ShapePath'; +export { Font } from './extras/core/Font'; +export { CurvePath } from './extras/core/CurvePath'; +export { Curve } from './extras/core/Curve'; +export { ImageUtils } from './extras/ImageUtils'; +export { ShapeUtils } from './extras/ShapeUtils'; +//export { WebGLUtils } from './renderers/webgl/WebGLUtils'; +export * from './constants'; +export * from './Three.Legacy'; diff --git a/src/Three.ts b/src/Three.ts new file mode 100644 index 0000000000000000000000000000000000000000..92aa8d6a28672ab3390c2db23d08503bff0efa8d --- /dev/null +++ b/src/Three.ts @@ -0,0 +1,162 @@ +import './polyfills'; + +export { + WebGLMultisampleRenderTarget, +} from './renderers/WebGLMultisampleRenderTarget'; +export { WebGLRenderTargetCube } from './renderers/WebGLRenderTargetCube'; +export { WebGLRenderTarget } from './renderers/WebGLRenderTarget'; +export { WebGLRenderer } from './renderers/WebGLRenderer'; +export { ShaderLib } from './renderers/shaders/ShaderLib'; +export { UniformsLib } from './renderers/shaders/UniformsLib'; +export { UniformsUtils } from './renderers/shaders/UniformsUtils'; +export { ShaderChunk } from './renderers/shaders/ShaderChunk'; +export { FogExp2 } from './scenes/FogExp2'; +export { Fog } from './scenes/Fog'; +export { Scene } from './scenes/Scene'; +export { Sprite } from './objects/Sprite'; +export { LOD } from './objects/LOD'; +export { SkinnedMesh } from './objects/SkinnedMesh'; +export { Skeleton } from './objects/Skeleton'; +export { Bone } from './objects/Bone'; +export { Mesh } from './objects/Mesh'; +export { LineSegments } from './objects/LineSegments'; +export { LineLoop } from './objects/LineLoop'; +export { Line } from './objects/Line'; +export { Points } from './objects/Points'; +export { Group } from './objects/Group'; +export { VideoTexture } from './textures/VideoTexture'; +export { DataTexture } from './textures/DataTexture'; +export { DataTexture3D } from './textures/DataTexture3D'; +export { CompressedTexture } from './textures/CompressedTexture'; +export { CubeTexture } from './textures/CubeTexture'; +export { CanvasTexture } from './textures/CanvasTexture'; +export { DepthTexture } from './textures/DepthTexture'; +export { Texture } from './textures/Texture'; +export * from './geometries/Geometries'; +export * from './materials/Materials'; +export { AnimationLoader } from './loaders/AnimationLoader'; +export { CompressedTextureLoader } from './loaders/CompressedTextureLoader'; +export { DataTextureLoader } from './loaders/DataTextureLoader'; +export { CubeTextureLoader } from './loaders/CubeTextureLoader'; +export { TextureLoader } from './loaders/TextureLoader'; +export { ObjectLoader } from './loaders/ObjectLoader'; +export { MaterialLoader } from './loaders/MaterialLoader'; +export { BufferGeometryLoader } from './loaders/BufferGeometryLoader'; +export { + LoadingManager, + DefaultLoadingManager, +} from './loaders/LoadingManager'; +export { ImageLoader } from './loaders/ImageLoader'; +export { ImageBitmapLoader } from './loaders/ImageBitmapLoader'; +export { FontLoader } from './loaders/FontLoader'; +export { FileLoader } from './loaders/FileLoader'; +export { Loader } from './loaders/Loader'; +export { LoaderUtils } from './loaders/LoaderUtils'; +export { Cache } from './loaders/Cache'; +export { AudioLoader } from './loaders/AudioLoader'; +export { SpotLightShadow } from './lights/SpotLightShadow'; +export { SpotLight } from './lights/SpotLight'; +export { PointLight } from './lights/PointLight'; +export { RectAreaLight } from './lights/RectAreaLight'; +export { HemisphereLight } from './lights/HemisphereLight'; +export { DirectionalLightShadow } from './lights/DirectionalLightShadow'; +export { DirectionalLight } from './lights/DirectionalLight'; +export { AmbientLight } from './lights/AmbientLight'; +export { LightShadow } from './lights/LightShadow'; +export { Light } from './lights/Light'; +export { StereoCamera } from './cameras/StereoCamera'; +export { PerspectiveCamera } from './cameras/PerspectiveCamera'; +export { OrthographicCamera } from './cameras/OrthographicCamera'; +export { CubeCamera } from './cameras/CubeCamera'; +export { ArrayCamera } from './cameras/ArrayCamera'; +export { Camera } from './cameras/Camera'; +export { AudioListener } from './audio/AudioListener'; +export { PositionalAudio } from './audio/PositionalAudio'; +export { AudioContext } from './audio/AudioContext'; +export { AudioAnalyser } from './audio/AudioAnalyser'; +export { Audio } from './audio/Audio'; +export { VectorKeyframeTrack } from './animation/tracks/VectorKeyframeTrack'; +export { StringKeyframeTrack } from './animation/tracks/StringKeyframeTrack'; +export { + QuaternionKeyframeTrack, +} from './animation/tracks/QuaternionKeyframeTrack'; +export { NumberKeyframeTrack } from './animation/tracks/NumberKeyframeTrack'; +export { ColorKeyframeTrack } from './animation/tracks/ColorKeyframeTrack'; +export { BooleanKeyframeTrack } from './animation/tracks/BooleanKeyframeTrack'; +export { PropertyMixer } from './animation/PropertyMixer'; +export { PropertyBinding } from './animation/PropertyBinding'; +export { KeyframeTrack } from './animation/KeyframeTrack'; +export { AnimationUtils } from './animation/AnimationUtils'; +export { AnimationObjectGroup } from './animation/AnimationObjectGroup'; +export { AnimationMixer } from './animation/AnimationMixer'; +export { AnimationClip } from './animation/AnimationClip'; +export { Uniform } from './core/Uniform'; +export { InstancedBufferGeometry } from './core/InstancedBufferGeometry'; +export { BufferGeometry } from './core/BufferGeometry'; +export { Geometry } from './core/Geometry'; +export { InterleavedBufferAttribute } from './core/InterleavedBufferAttribute'; +export { InstancedInterleavedBuffer } from './core/InstancedInterleavedBuffer'; +export { InterleavedBuffer } from './core/InterleavedBuffer'; +export { InstancedBufferAttribute } from './core/InstancedBufferAttribute'; +export * from './core/BufferAttribute'; +export { Face3 } from './core/Face3'; +export { Object3D } from './core/Object3D'; +export { Raycaster } from './core/Raycaster'; +export { Layers } from './core/Layers'; +export { EventDispatcher } from './core/EventDispatcher'; +export { Clock } from './core/Clock'; +export { + QuaternionLinearInterpolant, +} from './math/interpolants/QuaternionLinearInterpolant'; +export { LinearInterpolant } from './math/interpolants/LinearInterpolant'; +export { DiscreteInterpolant } from './math/interpolants/DiscreteInterpolant'; +export { CubicInterpolant } from './math/interpolants/CubicInterpolant'; +export { Interpolant } from './math/Interpolant'; +export { Triangle } from './math/Triangle'; +export { _Math as Math } from './math/Math'; +export { Spherical } from './math/Spherical'; +export { Cylindrical } from './math/Cylindrical'; +export { Plane } from './math/Plane'; +export { Frustum } from './math/Frustum'; +export { Sphere } from './math/Sphere'; +export { Ray } from './math/Ray'; +export { Matrix4 } from './math/Matrix4'; +export { Matrix3 } from './math/Matrix3'; +export { Box3 } from './math/Box3'; +export { Box2 } from './math/Box2'; +export { Line3 } from './math/Line3'; +export { Euler } from './math/Euler'; +export { Vector4 } from './math/Vector4'; +export { Vector3 } from './math/Vector3'; +export { Vector2 } from './math/Vector2'; +export { Quaternion } from './math/Quaternion'; +export { Color } from './math/Color'; +export { ImmediateRenderObject } from './extras/objects/ImmediateRenderObject'; +export { VertexNormalsHelper } from './helpers/VertexNormalsHelper'; +export { SpotLightHelper } from './helpers/SpotLightHelper'; +export { SkeletonHelper } from './helpers/SkeletonHelper'; +export { PointLightHelper } from './helpers/PointLightHelper'; +export { RectAreaLightHelper } from './helpers/RectAreaLightHelper'; +export { HemisphereLightHelper } from './helpers/HemisphereLightHelper'; +export { GridHelper } from './helpers/GridHelper'; +export { PolarGridHelper } from './helpers/PolarGridHelper'; +export { FaceNormalsHelper } from './helpers/FaceNormalsHelper'; +export { DirectionalLightHelper } from './helpers/DirectionalLightHelper'; +export { CameraHelper } from './helpers/CameraHelper'; +export { BoxHelper } from './helpers/BoxHelper'; +export { Box3Helper } from './helpers/Box3Helper'; +export { PlaneHelper } from './helpers/PlaneHelper'; +export { ArrowHelper } from './helpers/ArrowHelper'; +export { AxesHelper } from './helpers/AxesHelper'; +export * from './extras/curves/Curves'; +export { Shape } from './extras/core/Shape'; +export { Path } from './extras/core/Path'; +export { ShapePath } from './extras/core/ShapePath'; +export { Font } from './extras/core/Font'; +export { CurvePath } from './extras/core/CurvePath'; +export { Curve } from './extras/core/Curve'; +export { ImageUtils } from './extras/ImageUtils'; +export { ShapeUtils } from './extras/ShapeUtils'; +//export { WebGLUtils } from './renderers/webgl/WebGLUtils'; +export * from './constants'; +export * from './Three.Legacy'; diff --git a/src/animation/AnimationAction.d.ts b/src/animation/AnimationAction.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b6f44bba796ffe9fb4ea7497732e890379f859e --- /dev/null +++ b/src/animation/AnimationAction.d.ts @@ -0,0 +1,56 @@ +import { AnimationMixer } from './AnimationMixer'; +import { AnimationClip } from './AnimationClip'; +import { AnimationActionLoopStyles } from '../constants'; +// Animation //////////////////////////////////////////////////////////////////////////////////////// + +export class AnimationAction { + loop: boolean; + time: number; + timeScale: number; + weight: number; + repetitions: number; + paused: boolean; + enabled: boolean; + clampWhenFinished: boolean; + zeroSlopeAtStart: boolean; + zeroSlopeAtEnd: boolean; + + play(): AnimationAction; + stop(): AnimationAction; + reset(): AnimationAction; + isRunning(): boolean; + startAt(time: number): AnimationAction; + setLoop( + mode: AnimationActionLoopStyles, + repetitions: number + ): AnimationAction; + setEffectiveWeight(weight: number): AnimationAction; + getEffectiveWeight(): number; + fadeIn(duration: number): AnimationAction; + fadeOut(duration: number): AnimationAction; + crossFadeFrom( + fadeOutAction: AnimationAction, + duration: number, + warp: boolean + ): AnimationAction; + crossFadeTo( + fadeInAction: AnimationAction, + duration: number, + warp: boolean + ): AnimationAction; + stopFading(): AnimationAction; + setEffectiveTimeScale(timeScale: number): AnimationAction; + getEffectiveTimeScale(): number; + setDuration(duration: number): AnimationAction; + syncWith(action: AnimationAction): AnimationAction; + halt(duration: number): AnimationAction; + warp( + statTimeScale: number, + endTimeScale: number, + duration: number + ): AnimationAction; + stopWarping(): AnimationAction; + getMixer(): AnimationMixer; + getClip(): AnimationClip; + getRoot(): any; +} diff --git a/src/animation/AnimationClip.d.ts b/src/animation/AnimationClip.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..34ff79dc51dc9d62cb2defaacdc4f8e58c5e6daf --- /dev/null +++ b/src/animation/AnimationClip.d.ts @@ -0,0 +1,37 @@ +import { KeyframeTrack } from './KeyframeTrack'; +import { Bone } from './../objects/Bone'; +import { MorphTarget } from '../core/Geometry'; + +export class AnimationClip { + constructor(name?: string, duration?: number, tracks?: KeyframeTrack[]); + + name: string; + tracks: KeyframeTrack[]; + duration: number; + uuid: string; + results: any[]; + + resetDuration(): void; + trim(): AnimationClip; + optimize(): AnimationClip; + + static CreateFromMorphTargetSequence( + name: string, + morphTargetSequence: MorphTarget[], + fps: number, + noLoop: boolean + ): AnimationClip; + static findByName(clipArray: AnimationClip[], name: string): AnimationClip; + static CreateClipsFromMorphTargetSequences( + morphTargets: MorphTarget[], + fps: number, + noLoop: boolean + ): AnimationClip[]; + static parse(json: any): AnimationClip; + static parseAnimation( + animation: any, + bones: Bone[], + nodeName: string + ): AnimationClip; + static toJSON(): any; +} diff --git a/src/animation/AnimationClip.js b/src/animation/AnimationClip.js index 810bc4b614e2a840312d080d0930f43b0c033504..c9374656b2732e5ba835e09f73a0973d51ba25c7 100644 --- a/src/animation/AnimationClip.js +++ b/src/animation/AnimationClip.js @@ -445,6 +445,21 @@ Object.assign( AnimationClip.prototype, { return this; + }, + + + clone: function () { + + var tracks = []; + + for ( var i = 0; i < this.tracks.length; i ++ ) { + + tracks.push( this.tracks[ i ].clone() ); + + } + + return new AnimationClip( this.name, this.duration, tracks ); + } } ); diff --git a/src/animation/AnimationMixer.d.ts b/src/animation/AnimationMixer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..418931ec86c88de7d4b7ba10dde01c1086739578 --- /dev/null +++ b/src/animation/AnimationMixer.d.ts @@ -0,0 +1,19 @@ +import { AnimationClip } from './AnimationClip'; +import { AnimationAction } from './AnimationAction'; +import { EventDispatcher } from './../core/EventDispatcher'; + +export class AnimationMixer extends EventDispatcher { + constructor(root: any); + + time: number; + timeScale: number; + + clipAction(clip: AnimationClip, root?: any): AnimationAction; + existingAction(clip: AnimationClip, root?: any): AnimationAction; + stopAllAction(): AnimationMixer; + update(deltaTime: number): AnimationMixer; + getRoot(): any; + uncacheClip(clip: AnimationClip): void; + uncacheRoot(root: any): void; + uncacheAction(clip: AnimationClip, root?: any): void; +} diff --git a/src/animation/AnimationObjectGroup.d.ts b/src/animation/AnimationObjectGroup.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d7c68ebe45ba472f681017b85aa5c67e324de30e --- /dev/null +++ b/src/animation/AnimationObjectGroup.d.ts @@ -0,0 +1,16 @@ +export class AnimationObjectGroup { + constructor(...args: any[]); + + uuid: string; + stats: { + bindingsPerObject: number; + objects: { + total: number; + inUse: number; + }; + }; + + add(...args: any[]): void; + remove(...args: any[]): void; + uncache(...args: any[]): void; +} diff --git a/src/animation/AnimationUtils.d.ts b/src/animation/AnimationUtils.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1aa12e7f9ad093889a5cc228c9bc5bcf6886a497 --- /dev/null +++ b/src/animation/AnimationUtils.d.ts @@ -0,0 +1,17 @@ +export namespace AnimationUtils { + export function arraySlice(array: any, from: number, to: number): any; + export function convertArray(array: any, type: any, forceClone: boolean): any; + export function isTypedArray(object: any): boolean; + export function getKeyFrameOrder(times: number): number[]; + export function sortedArray( + values: any[], + stride: number, + order: number[] + ): any[]; + export function flattenJSON( + jsonKeys: string[], + times: any[], + values: any[], + valuePropertyName: string + ): void; +} diff --git a/src/animation/KeyframeTrack.d.ts b/src/animation/KeyframeTrack.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..203beb4bb242d1d8a385915e154ad06a316cb7a3 --- /dev/null +++ b/src/animation/KeyframeTrack.d.ts @@ -0,0 +1,41 @@ +import { DiscreteInterpolant } from './../math/interpolants/DiscreteInterpolant'; +import { LinearInterpolant } from './../math/interpolants/LinearInterpolant'; +import { CubicInterpolant } from './../math/interpolants/CubicInterpolant'; +import { InterpolationModes } from '../constants'; + +export class KeyframeTrack { + constructor( + name: string, + times: any[], + values: any[], + interpolation?: InterpolationModes + ); + + name: string; + times: any[]; + values: any[]; + + ValueTypeName: string; + TimeBufferType: Float32Array; + ValueBufferType: Float32Array; + + DefaultInterpolation: InterpolationModes; + + InterpolantFactoryMethodDiscrete(result: any): DiscreteInterpolant; + InterpolantFactoryMethodLinear(result: any): LinearInterpolant; + InterpolantFactoryMethodSmooth(result: any): CubicInterpolant; + + setInterpolation(interpolation: InterpolationModes): void; + getInterpolation(): InterpolationModes; + + getValuesize(): number; + + shift(timeOffset: number): KeyframeTrack; + scale(timeScale: number): KeyframeTrack; + trim(startTime: number, endTime: number): KeyframeTrack; + validate(): boolean; + optimize(): KeyframeTrack; + + static parse(json: any): KeyframeTrack; + static toJSON(track: KeyframeTrack): any; +} diff --git a/src/animation/KeyframeTrack.js b/src/animation/KeyframeTrack.js index 06b4bde3c9fd3c40f75dace665831d8dc8bc9ea5..d4900673889def3ffe34e7f526a0bf99b26bfbd8 100644 --- a/src/animation/KeyframeTrack.js +++ b/src/animation/KeyframeTrack.js @@ -447,6 +447,21 @@ Object.assign( KeyframeTrack.prototype, { return this; + }, + + clone: function () { + + var times = AnimationUtils.arraySlice( this.times, 0 ); + var values = AnimationUtils.arraySlice( this.values, 0 ); + + var TypedKeyframeTrack = this.constructor; + var track = new TypedKeyframeTrack( this.name, times, values ); + + // Interpolant argument to constructor is not saved, so copy the factory method directly. + track.createInterpolant = this.createInterpolant; + + return track; + } } ); diff --git a/src/animation/PropertyBinding.d.ts b/src/animation/PropertyBinding.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a5f3c8003b41999d170179da0b7cba4cfbd05f65 --- /dev/null +++ b/src/animation/PropertyBinding.d.ts @@ -0,0 +1,38 @@ +export class PropertyBinding { + constructor(rootNode: any, path: string, parsedPath?: any); + + path: string; + parsedPath: any; + node: any; + rootNode: any; + + getValue(targetArray: any, offset: number): any; + setValue(sourceArray: any, offset: number): void; + bind(): void; + unbind(): void; + + BindingType: { [bindingType: string]: number }; + Versioning: { [versioning: string]: number }; + + GetterByBindingType: Function[]; + SetterByBindingTypeAndVersioning: Array; + + static create( + root: any, + path: any, + parsedPath?: any + ): PropertyBinding | PropertyBinding.Composite; + static parseTrackName(trackName: string): any; + static findNode(root: any, nodeName: string): any; +} + +export namespace PropertyBinding { + export class Composite { + constructor(targetGroup: any, path: any, parsedPath?: any); + + getValue(array: any, offset: number): any; + setValue(array: any, offset: number): void; + bind(): void; + unbind(): void; + } +} diff --git a/src/animation/PropertyMixer.d.ts b/src/animation/PropertyMixer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac71cb56529538fe4641539993b2a8f5e151422f --- /dev/null +++ b/src/animation/PropertyMixer.d.ts @@ -0,0 +1,15 @@ +export class PropertyMixer { + constructor(binding: any, typeName: string, valueSize: number); + + binding: any; + valueSize: number; + buffer: any; + cumulativeWeight: number; + useCount: number; + referenceCount: number; + + accumulate(accuIndex: number, weight: number): void; + apply(accuIndex: number): void; + saveOriginalState(): void; + restoreOriginalState(): void; +} diff --git a/src/animation/tracks/BooleanKeyframeTrack.d.ts b/src/animation/tracks/BooleanKeyframeTrack.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..709f10e22951a6981ee1480f5693c733ea708dda --- /dev/null +++ b/src/animation/tracks/BooleanKeyframeTrack.d.ts @@ -0,0 +1,5 @@ +import { KeyframeTrack } from './../KeyframeTrack'; + +export class BooleanKeyframeTrack extends KeyframeTrack { + constructor(name: string, times: any[], values: any[]); +} diff --git a/src/animation/tracks/ColorKeyframeTrack.d.ts b/src/animation/tracks/ColorKeyframeTrack.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..44037ee2de72bdb9d67ca859518df1fc42cdee78 --- /dev/null +++ b/src/animation/tracks/ColorKeyframeTrack.d.ts @@ -0,0 +1,11 @@ +import { KeyframeTrack } from './../KeyframeTrack'; +import { InterpolationModes } from '../../constants'; + +export class ColorKeyframeTrack extends KeyframeTrack { + constructor( + name: string, + times: any[], + values: any[], + interpolation?: InterpolationModes + ); +} diff --git a/src/animation/tracks/NumberKeyframeTrack.d.ts b/src/animation/tracks/NumberKeyframeTrack.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8bb54fdd9bb210544bf7910b10d46e7c3a43ff68 --- /dev/null +++ b/src/animation/tracks/NumberKeyframeTrack.d.ts @@ -0,0 +1,11 @@ +import { KeyframeTrack } from './../KeyframeTrack'; +import { InterpolationModes } from '../../constants'; + +export class NumberKeyframeTrack extends KeyframeTrack { + constructor( + name: string, + times: any[], + values: any[], + interpolation?: InterpolationModes + ); +} diff --git a/src/animation/tracks/QuaternionKeyframeTrack.d.ts b/src/animation/tracks/QuaternionKeyframeTrack.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c93686f79f7e12347294cafce1a6eab58e7e30a5 --- /dev/null +++ b/src/animation/tracks/QuaternionKeyframeTrack.d.ts @@ -0,0 +1,11 @@ +import { KeyframeTrack } from './../KeyframeTrack'; +import { InterpolationModes } from '../../constants'; + +export class QuaternionKeyframeTrack extends KeyframeTrack { + constructor( + name: string, + times: any[], + values: any[], + interpolation?: InterpolationModes + ); +} diff --git a/src/animation/tracks/StringKeyframeTrack.d.ts b/src/animation/tracks/StringKeyframeTrack.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..03e2f9d170127b260db1978680ec088e82c28551 --- /dev/null +++ b/src/animation/tracks/StringKeyframeTrack.d.ts @@ -0,0 +1,11 @@ +import { KeyframeTrack } from './../KeyframeTrack'; +import { InterpolationModes } from '../../constants'; + +export class StringKeyframeTrack extends KeyframeTrack { + constructor( + name: string, + times: any[], + values: any[], + interpolation?: InterpolationModes + ); +} diff --git a/src/animation/tracks/VectorKeyframeTrack.d.ts b/src/animation/tracks/VectorKeyframeTrack.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2e3ed7c5e387ff5d0b5de71e4ebf2c2dd8982ff6 --- /dev/null +++ b/src/animation/tracks/VectorKeyframeTrack.d.ts @@ -0,0 +1,11 @@ +import { KeyframeTrack } from './../KeyframeTrack'; +import { InterpolationModes } from '../../constants'; + +export class VectorKeyframeTrack extends KeyframeTrack { + constructor( + name: string, + times: any[], + values: any[], + interpolation?: InterpolationModes + ); +} diff --git a/src/audio/Audio.d.ts b/src/audio/Audio.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ce13e1ea6a5050710a79de12f91d9745bcc59b8c --- /dev/null +++ b/src/audio/Audio.d.ts @@ -0,0 +1,49 @@ +import { Object3D } from './../core/Object3D'; +import { AudioListener } from './AudioListener'; +import { AudioContext } from './AudioContext'; + +// Extras / Audio ///////////////////////////////////////////////////////////////////// + +export class Audio extends Object3D { + constructor(listener: AudioListener); + type: 'Audio'; + + context: AudioContext; + gain: GainNode; + autoplay: boolean; + buffer: null | Audio; + loop: boolean; + startTime: number; + offset: number; + playbackRate: number; + isPlaying: boolean; + hasPlaybackControl: boolean; + sourceType: string; + source: AudioBufferSourceNode; + filters: any[]; + + getOutput(): GainNode; + setNodeSource(audioNode: AudioBufferSourceNode): this; + setMediaElementSource(mediaElement: MediaElementAudioSourceNode): this; + setBuffer(audioBuffer: AudioBuffer): this; + play(): this; + onEnded(): void; + pause(): this; + stop(): this; + connect(): this; + disconnect(): this; + getFilters(): any[]; + setFilter(value: any[]): this; + getFilter(): any; + setFilter(filter: any): this; + setPlaybackRate(value: number): this; + getPlaybackRate(): number; + getLoop(): boolean; + setLoop(value: boolean): void; + getVolume(): number; + setVolume(value: number): this; + /** + * @deprecated Use {@link AudioLoader} instead. + */ + load(file: string): Audio; +} diff --git a/src/audio/Audio.js b/src/audio/Audio.js index ff3b748d27656d018ee65e30450dc4bfdb79e867..c7562d9bdd5866008e6d91fca244af47c55bfe61 100644 --- a/src/audio/Audio.js +++ b/src/audio/Audio.js @@ -95,7 +95,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { var source = this.context.createBufferSource(); source.buffer = this.buffer; - source.detune.value = this.detune; + this.setDetune( this.detune ); source.loop = this.loop; source.onended = this.onEnded.bind( this ); source.playbackRate.setValueAtTime( this.playbackRate, this.startTime ); @@ -228,6 +228,13 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { this.detune = value; + if ( this.source.detune === undefined ) { + + console.warn( 'THREE.Audio: AudioBufferSourceNode.detune not supported by the browser.' ); + return; + + } + if ( this.isPlaying === true ) { this.source.detune.setTargetAtTime( this.detune, this.context.currentTime, 0.01 ); diff --git a/src/audio/AudioAnalyser.d.ts b/src/audio/AudioAnalyser.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4351b07e73bba0af88fe8fb4253725d1653a2b90 --- /dev/null +++ b/src/audio/AudioAnalyser.d.ts @@ -0,0 +1,14 @@ +export class AudioAnalyser { + constructor(audio: any, fftSize: number); + + analyser: any; + data: Uint8Array; + + getFrequencyData(): Uint8Array; + getAverageFrequency(): number; + + /** + * @deprecated Use {@link AudioAnalyser#getFrequencyData .getFrequencyData()} instead. + */ + getData(file: any): any; +} diff --git a/src/audio/AudioContext.d.ts b/src/audio/AudioContext.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5fb703a41b6d3886b276d222d1d3c7312a600747 --- /dev/null +++ b/src/audio/AudioContext.d.ts @@ -0,0 +1 @@ +export const AudioContext: AudioContext; diff --git a/src/audio/AudioListener.d.ts b/src/audio/AudioListener.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac79ff306611b6f82a96ad6cf3b2aa332d12badc --- /dev/null +++ b/src/audio/AudioListener.d.ts @@ -0,0 +1,19 @@ +import { Object3D } from './../core/Object3D'; +import { AudioContext } from './AudioContext'; + +export class AudioListener extends Object3D { + constructor(); + + type: 'AudioListener'; + context: AudioContext; + gain: GainNode; + filter: null | any; + + getInput(): GainNode; + removeFilter(): void; + setFilter(value: any): void; + getFilter(): any; + setMasterVolume(value: number): void; + getMasterVolume(): number; + updateMatrixWorld(force?: boolean): void; +} diff --git a/src/audio/PositionalAudio.d.ts b/src/audio/PositionalAudio.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..607a59583808b71e6591e99a592a2db1ee9e2ea5 --- /dev/null +++ b/src/audio/PositionalAudio.d.ts @@ -0,0 +1,28 @@ +import { AudioListener } from './AudioListener'; +import { Audio } from './Audio'; + +export class AudioBuffer { + constructor(context: any); + + context: any; + ready: boolean; + readyCallbacks: Function[]; + + load(file: string): AudioBuffer; + onReady(callback: Function): void; +} + +export class PositionalAudio extends Audio { + constructor(listener: AudioListener); + + panner: PannerNode; + + setRefDistance(value: number): void; + getRefDistance(): number; + setRolloffFactor(value: number): void; + getRolloffFactor(): number; + setDistanceModel(value: number): void; + getDistanceModel(): number; + setMaxDistance(value: number): void; + getMaxDistance(): number; +} diff --git a/src/cameras/ArrayCamera.d.ts b/src/cameras/ArrayCamera.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ead49b9fb174c439dacc460439adaec185c9115b --- /dev/null +++ b/src/cameras/ArrayCamera.d.ts @@ -0,0 +1,8 @@ +import { PerspectiveCamera } from './PerspectiveCamera'; + +export class ArrayCamera extends PerspectiveCamera { + constructor(cameras?: PerspectiveCamera[]); + + cameras: PerspectiveCamera[]; + isArrayCamera: true; +} diff --git a/src/cameras/Camera.d.ts b/src/cameras/Camera.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ff3a586ad13e6532af662b5afc296456f38132bf --- /dev/null +++ b/src/cameras/Camera.d.ts @@ -0,0 +1,33 @@ +import { Matrix4 } from './../math/Matrix4'; +import { Vector3 } from './../math/Vector3'; +import { Object3D } from './../core/Object3D'; + +// Cameras //////////////////////////////////////////////////////////////////////////////////////// + +/** + * Abstract base class for cameras. This class should always be inherited when you build a new camera. + */ +export class Camera extends Object3D { + /** + * This constructor sets following properties to the correct type: matrixWorldInverse, projectionMatrix and projectionMatrixInverse. + */ + constructor(); + + /** + * This is the inverse of matrixWorld. MatrixWorld contains the Matrix which has the world transform of the Camera. + */ + matrixWorldInverse: Matrix4; + + /** + * This is the matrix which contains the projection. + */ + projectionMatrix: Matrix4; + + isCamera: true; + + copy(source: Camera, recursive?: boolean): this; + + getWorldDirection(target: Vector3): Vector3; + + updateMatrixWorld(force: boolean): void; +} diff --git a/src/cameras/CubeCamera.d.ts b/src/cameras/CubeCamera.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f2dea8b7b743e900a7d33eb700330af89770289b --- /dev/null +++ b/src/cameras/CubeCamera.d.ts @@ -0,0 +1,19 @@ +import { WebGLRenderTargetCube } from './../renderers/WebGLRenderTargetCube'; +import { Scene } from './../scenes/Scene'; +import { WebGLRenderer } from './../renderers/WebGLRenderer'; +import { Object3D } from './../core/Object3D'; + +export class CubeCamera extends Object3D { + constructor(near?: number, far?: number, cubeResolution?: number); + + type: 'CubeCamera'; + + renderTarget: WebGLRenderTargetCube; + + /** + * @deprecated Use {@link CubeCamera#update .update()} instead + */ + //updateCubeMap(renderer: Renderer, scene: Scene): void; + + update(renderer: WebGLRenderer, scene: Scene): void; +} diff --git a/src/cameras/OrthographicCamera.d.ts b/src/cameras/OrthographicCamera.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..748abf23bf9bd313e2a6e8c6da024bb101fd395b --- /dev/null +++ b/src/cameras/OrthographicCamera.d.ts @@ -0,0 +1,89 @@ +import { Camera } from './Camera'; + +/** + * Camera with orthographic projection + * + * @example + * var camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 ); + * scene.add( camera ); + * + * @see src/cameras/OrthographicCamera.js + */ +export class OrthographicCamera extends Camera { + /** + * @param left Camera frustum left plane. + * @param right Camera frustum right plane. + * @param top Camera frustum top plane. + * @param bottom Camera frustum bottom plane. + * @param near Camera frustum near plane. + * @param far Camera frustum far plane. + */ + constructor( + left: number, + right: number, + top: number, + bottom: number, + near?: number, + far?: number + ); + + type: 'OrthographicCamera'; + + isOrthographicCamera: true; + + zoom: number; + view: null | { + enabled: boolean; + fullWidth: number; + fullHeight: number; + offsetX: number; + offsetY: number; + width: number; + height: number; + }; + + /** + * Camera frustum left plane. + */ + left: number; + + /** + * Camera frustum right plane. + */ + right: number; + + /** + * Camera frustum top plane. + */ + top: number; + + /** + * Camera frustum bottom plane. + */ + bottom: number; + + /** + * Camera frustum near plane. + */ + near: number; + + /** + * Camera frustum far plane. + */ + far: number; + + /** + * Updates the camera projection matrix. Must be called after change of parameters. + */ + updateProjectionMatrix(): void; + setViewOffset( + fullWidth: number, + fullHeight: number, + offsetX: number, + offsetY: number, + width: number, + height: number + ): void; + clearViewOffset(): void; + toJSON(meta?: any): any; +} diff --git a/src/cameras/PerspectiveCamera.d.ts b/src/cameras/PerspectiveCamera.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a90a4c22f10ac24f526cb87751f19ca5088f551a --- /dev/null +++ b/src/cameras/PerspectiveCamera.d.ts @@ -0,0 +1,123 @@ +import { Camera } from './Camera'; + +/** + * Camera with perspective projection. + * + * # example + * var camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 ); + * scene.add( camera ); + * + * @source https://github.com/mrdoob/three.js/blob/master/src/cameras/PerspectiveCamera.js + */ +export class PerspectiveCamera extends Camera { + /** + * @param fov Camera frustum vertical field of view. Default value is 50. + * @param aspect Camera frustum aspect ratio. Default value is 1. + * @param near Camera frustum near plane. Default value is 0.1. + * @param far Camera frustum far plane. Default value is 2000. + */ + constructor(fov?: number, aspect?: number, near?: number, far?: number); + + type: 'PerspectiveCamera'; + + isPerspectiveCamera: true; + + zoom: number; + + /** + * Camera frustum vertical field of view, from bottom to top of view, in degrees. + */ + fov: number; + + /** + * Camera frustum aspect ratio, window width divided by window height. + */ + aspect: number; + + /** + * Camera frustum near plane. + */ + near: number; + + /** + * Camera frustum far plane. + */ + far: number; + + focus: number; + view: null | { + enabled: boolean; + fullWidth: number; + fullHeight: number; + offsetX: number; + offsetY: number; + width: number; + height: number; + }; + filmGauge: number; + filmOffset: number; + + setFocalLength(focalLength: number): void; + getFocalLength(): number; + getEffectiveFOV(): number; + getFilmWidth(): number; + getFilmHeight(): number; + + /** + * Sets an offset in a larger frustum. This is useful for multi-window or multi-monitor/multi-machine setups. + * For example, if you have 3x2 monitors and each monitor is 1920x1080 and the monitors are in grid like this: + * + * +---+---+---+ + * | A | B | C | + * +---+---+---+ + * | D | E | F | + * +---+---+---+ + * + * then for each monitor you would call it like this: + * + * var w = 1920; + * var h = 1080; + * var fullWidth = w * 3; + * var fullHeight = h * 2; + * + * // A + * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h ); + * // B + * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h ); + * // C + * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h ); + * // D + * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h ); + * // E + * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h ); + * // F + * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h ); Note there is no reason monitors have to be the same size or in a grid. + * + * @param fullWidth full width of multiview setup + * @param fullHeight full height of multiview setup + * @param x horizontal offset of subcamera + * @param y vertical offset of subcamera + * @param width width of subcamera + * @param height height of subcamera + */ + setViewOffset( + fullWidth: number, + fullHeight: number, + x: number, + y: number, + width: number, + height: number + ): void; + clearViewOffset(): void; + + /** + * Updates the camera projection matrix. Must be called after change of parameters. + */ + updateProjectionMatrix(): void; + toJSON(meta?: any): any; + + /** + * @deprecated Use {@link PerspectiveCamera#setFocalLength .setFocalLength()} and {@link PerspectiveCamera#filmGauge .filmGauge} instead. + */ + setLens(focalLength: number, frameHeight?: number): void; +} diff --git a/src/cameras/StereoCamera.d.ts b/src/cameras/StereoCamera.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cf27ebddd26891cd83d49378e3d38b6d8f68a60f --- /dev/null +++ b/src/cameras/StereoCamera.d.ts @@ -0,0 +1,15 @@ +import { PerspectiveCamera } from './PerspectiveCamera'; +import { Camera } from './Camera'; + +export class StereoCamera extends Camera { + constructor(); + + type: 'StereoCamera'; + + aspect: number; + eyeSep: number; + cameraL: PerspectiveCamera; + cameraR: PerspectiveCamera; + + update(camera: PerspectiveCamera): void; +} diff --git a/src/constants.d.ts b/src/constants.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..736669f945def6c65353ce98085662cb54dea6ef --- /dev/null +++ b/src/constants.d.ts @@ -0,0 +1,235 @@ +export const REVISION: string; + +// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent.button +export enum MOUSE { + LEFT, + MIDDLE, + RIGHT, +} + +// GL STATE CONSTANTS +export enum CullFace {} +export const CullFaceNone: CullFace; +export const CullFaceBack: CullFace; +export const CullFaceFront: CullFace; +export const CullFaceFrontBack: CullFace; + +export enum FrontFaceDirection {} +export const FrontFaceDirectionCW: FrontFaceDirection; +export const FrontFaceDirectionCCW: FrontFaceDirection; + +// Shadowing Type +export enum ShadowMapType {} +export const BasicShadowMap: ShadowMapType; +export const PCFShadowMap: ShadowMapType; +export const PCFSoftShadowMap: ShadowMapType; + +// MATERIAL CONSTANTS + +// side +export enum Side {} +export const FrontSide: Side; +export const BackSide: Side; +export const DoubleSide: Side; + +// shading +export enum Shading {} +export const FlatShading: Shading; +export const SmoothShading: Shading; + +// colors +export enum Colors {} +export const NoColors: Colors; +export const FaceColors: Colors; +export const VertexColors: Colors; + +// blending modes +export enum Blending {} +export const NoBlending: Blending; +export const NormalBlending: Blending; +export const AdditiveBlending: Blending; +export const SubtractiveBlending: Blending; +export const MultiplyBlending: Blending; +export const CustomBlending: Blending; + +// custom blending equations +// (numbers start from 100 not to clash with other +// mappings to OpenGL constants defined in Texture.js) +export enum BlendingEquation {} +export const AddEquation: BlendingEquation; +export const SubtractEquation: BlendingEquation; +export const ReverseSubtractEquation: BlendingEquation; +export const MinEquation: BlendingEquation; +export const MaxEquation: BlendingEquation; + +// custom blending destination factors +export enum BlendingDstFactor {} +export const ZeroFactor: BlendingDstFactor; +export const OneFactor: BlendingDstFactor; +export const SrcColorFactor: BlendingDstFactor; +export const OneMinusSrcColorFactor: BlendingDstFactor; +export const SrcAlphaFactor: BlendingDstFactor; +export const OneMinusSrcAlphaFactor: BlendingDstFactor; +export const DstAlphaFactor: BlendingDstFactor; +export const OneMinusDstAlphaFactor: BlendingDstFactor; +export const DstColorFactor: BlendingDstFactor; +export const OneMinusDstColorFactor: BlendingDstFactor; + +// custom blending src factors +export enum BlendingSrcFactor {} +export const SrcAlphaSaturateFactor: BlendingSrcFactor; + +// depth modes +export enum DepthModes {} +export const NeverDepth: DepthModes; +export const AlwaysDepth: DepthModes; +export const LessDepth: DepthModes; +export const LessEqualDepth: DepthModes; +export const EqualDepth: DepthModes; +export const GreaterEqualDepth: DepthModes; +export const GreaterDepth: DepthModes; +export const NotEqualDepth: DepthModes; + +// TEXTURE CONSTANTS +// Operations +export enum Combine {} +export const MultiplyOperation: Combine; +export const MixOperation: Combine; +export const AddOperation: Combine; + +// Tone Mapping modes +export enum ToneMapping {} +export const NoToneMapping: ToneMapping; +export const LinearToneMapping: ToneMapping; +export const ReinhardToneMapping: ToneMapping; +export const Uncharted2ToneMapping: ToneMapping; +export const CineonToneMapping: ToneMapping; + +// Mapping modes +export enum Mapping {} +export const UVMapping: Mapping; +export const CubeReflectionMapping: Mapping; +export const CubeRefractionMapping: Mapping; +export const EquirectangularReflectionMapping: Mapping; +export const EquirectangularRefractionMapping: Mapping; +export const SphericalReflectionMapping: Mapping; +export const CubeUVReflectionMapping: Mapping; +export const CubeUVRefractionMapping: Mapping; + +// Wrapping modes +export enum Wrapping {} +export const RepeatWrapping: Wrapping; +export const ClampToEdgeWrapping: Wrapping; +export const MirroredRepeatWrapping: Wrapping; + +// Filters +export enum TextureFilter {} +export const NearestFilter: TextureFilter; +export const NearestMipMapNearestFilter: TextureFilter; +export const NearestMipMapLinearFilter: TextureFilter; +export const LinearFilter: TextureFilter; +export const LinearMipMapNearestFilter: TextureFilter; +export const LinearMipMapLinearFilter: TextureFilter; + +// Data types +export enum TextureDataType {} +export const UnsignedByteType: TextureDataType; +export const ByteType: TextureDataType; +export const ShortType: TextureDataType; +export const UnsignedShortType: TextureDataType; +export const IntType: TextureDataType; +export const UnsignedIntType: TextureDataType; +export const FloatType: TextureDataType; +export const HalfFloatType: TextureDataType; + +// Pixel types +export enum PixelType {} +export const UnsignedShort4444Type: PixelType; +export const UnsignedShort5551Type: PixelType; +export const UnsignedShort565Type: PixelType; +export const UnsignedInt248Type: PixelType; + +// Pixel formats +export enum PixelFormat {} +export const AlphaFormat: PixelFormat; +export const RGBFormat: PixelFormat; +export const RGBAFormat: PixelFormat; +export const LuminanceFormat: PixelFormat; +export const LuminanceAlphaFormat: PixelFormat; +export const RGBEFormat: PixelFormat; +export const DepthFormat: PixelFormat; +export const DepthStencilFormat: PixelFormat; +export const RedFormat: PixelFormat; + +// Compressed texture formats +// DDS / ST3C Compressed texture formats +export enum CompressedPixelFormat {} +export const RGB_S3TC_DXT1_Format: CompressedPixelFormat; +export const RGBA_S3TC_DXT1_Format: CompressedPixelFormat; +export const RGBA_S3TC_DXT3_Format: CompressedPixelFormat; +export const RGBA_S3TC_DXT5_Format: CompressedPixelFormat; + +// PVRTC compressed './texture formats +export const RGB_PVRTC_4BPPV1_Format: CompressedPixelFormat; +export const RGB_PVRTC_2BPPV1_Format: CompressedPixelFormat; +export const RGBA_PVRTC_4BPPV1_Format: CompressedPixelFormat; +export const RGBA_PVRTC_2BPPV1_Format: CompressedPixelFormat; + +// ETC compressed texture formats +export const RGB_ETC1_Format: CompressedPixelFormat; + +// ASTC compressed texture formats +export const RGBA_ASTC_4x4_Format: CompressedPixelFormat; +export const RGBA_ASTC_5x4_Format: CompressedPixelFormat; +export const RGBA_ASTC_5x5_Format: CompressedPixelFormat; +export const RGBA_ASTC_6x5_Format: CompressedPixelFormat; +export const RGBA_ASTC_6x6_Format: CompressedPixelFormat; +export const RGBA_ASTC_8x5_Format: CompressedPixelFormat; +export const RGBA_ASTC_8x6_Format: CompressedPixelFormat; +export const RGBA_ASTC_8x8_Format: CompressedPixelFormat; +export const RGBA_ASTC_10x5_Format: CompressedPixelFormat; +export const RGBA_ASTC_10x6_Format: CompressedPixelFormat; +export const RGBA_ASTC_10x8_Format: CompressedPixelFormat; +export const RGBA_ASTC_10x10_Format: CompressedPixelFormat; +export const RGBA_ASTC_12x10_Format: CompressedPixelFormat; +export const RGBA_ASTC_12x12_Format: CompressedPixelFormat; + +// Loop styles for AnimationAction +export enum AnimationActionLoopStyles {} +export const LoopOnce: AnimationActionLoopStyles; +export const LoopRepeat: AnimationActionLoopStyles; +export const LoopPingPong: AnimationActionLoopStyles; + +// Interpolation +export enum InterpolationModes {} +export const InterpolateDiscrete: InterpolationModes; +export const InterpolateLinear: InterpolationModes; +export const InterpolateSmooth: InterpolationModes; + +// Interpolant ending modes +export enum InterpolationEndingModes {} +export const ZeroCurvatureEnding: InterpolationEndingModes; +export const ZeroSlopeEnding: InterpolationEndingModes; +export const WrapAroundEnding: InterpolationEndingModes; + +// Triangle Draw modes +export enum TrianglesDrawModes {} +export const TrianglesDrawMode: TrianglesDrawModes; +export const TriangleStripDrawMode: TrianglesDrawModes; +export const TriangleFanDrawMode: TrianglesDrawModes; + +// Texture Encodings +export enum TextureEncoding {} +export const LinearEncoding: TextureEncoding; +export const sRGBEncoding: TextureEncoding; +export const GammaEncoding: TextureEncoding; +export const RGBEEncoding: TextureEncoding; +export const LogLuvEncoding: TextureEncoding; +export const RGBM7Encoding: TextureEncoding; +export const RGBM16Encoding: TextureEncoding; +export const RGBDEncoding: TextureEncoding; + +// Depth packing strategies +export enum DepthPackingStrategies {} +export const BasicDepthPacking: DepthPackingStrategies; +export const RGBADepthPacking: DepthPackingStrategies; diff --git a/src/core/BufferAttribute.d.ts b/src/core/BufferAttribute.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..700633be5e162a4c1549d637b745a3aa6b9d59c7 --- /dev/null +++ b/src/core/BufferAttribute.d.ts @@ -0,0 +1,198 @@ +/** + * @see src/core/BufferAttribute.js + */ +export class BufferAttribute { + constructor(array: ArrayLike, itemSize: number, normalized?: boolean); // array parameter should be TypedArray. + + uuid: string; + array: ArrayLike; + itemSize: number; + dynamic: boolean; + updateRange: { offset: number; count: number }; + version: number; + normalized: boolean; + needsUpdate: boolean; + count: number; + onUpload: Function; + + setArray(array?: ArrayBufferView): void; + setDynamic(dynamic: boolean): BufferAttribute; + clone(): this; + copy(source: BufferAttribute): this; + copyAt( + index1: number, + attribute: BufferAttribute, + index2: number + ): BufferAttribute; + copyArray(array: ArrayLike): BufferAttribute; + copyColorsArray( + colors: { r: number; g: number; b: number }[] + ): BufferAttribute; + copyVector2sArray(vectors: { x: number; y: number }[]): BufferAttribute; + copyVector3sArray( + vectors: { x: number; y: number; z: number }[] + ): BufferAttribute; + copyVector4sArray( + vectors: { x: number; y: number; z: number; w: number }[] + ): BufferAttribute; + set( + value: ArrayLike | ArrayBufferView, + offset?: number + ): BufferAttribute; + getX(index: number): number; + setX(index: number, x: number): BufferAttribute; + getY(index: number): number; + setY(index: number, y: number): BufferAttribute; + getZ(index: number): number; + setZ(index: number, z: number): BufferAttribute; + getW(index: number): number; + setW(index: number, z: number): BufferAttribute; + setXY(index: number, x: number, y: number): BufferAttribute; + setXYZ(index: number, x: number, y: number, z: number): BufferAttribute; + setXYZW( + index: number, + x: number, + y: number, + z: number, + w: number + ): BufferAttribute; + /** + * @deprecated Use {@link BufferAttribute#count .count} instead. + */ + length: number; +} + +/** + * @deprecated THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead. + */ +export class Int8Attribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +/** + * @deprecated THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead. + */ +export class Uint8Attribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +/** + * @deprecated THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead. + */ +export class Uint8ClampedAttribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +/** + * @deprecated THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead. + */ +export class Int16Attribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +/** + * @deprecated THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead. + */ +export class Uint16Attribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +/** + * @deprecated THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead. + */ +export class Int32Attribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +/** + * @deprecated THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead. + */ +export class Uint32Attribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +/** + * @deprecated THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead. + */ +export class Float32Attribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +/** + * @deprecated THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead. + */ +export class Float64Attribute extends BufferAttribute { + constructor(array: any, itemSize: number); +} + +export class Int8BufferAttribute extends BufferAttribute { + constructor( + array: Iterable | ArrayLike | ArrayBuffer, + itemSize: number, + normalized?: boolean + ); +} + +export class Uint8BufferAttribute extends BufferAttribute { + constructor( + array: Iterable | ArrayLike | ArrayBuffer, + itemSize: number, + normalized?: boolean + ); +} + +export class Uint8ClampedBufferAttribute extends BufferAttribute { + constructor( + array: Iterable | ArrayLike | ArrayBuffer, + itemSize: number, + normalized?: boolean + ); +} + +export class Int16BufferAttribute extends BufferAttribute { + constructor( + array: Iterable | ArrayLike | ArrayBuffer, + itemSize: number, + normalized?: boolean + ); +} + +export class Uint16BufferAttribute extends BufferAttribute { + constructor( + array: Iterable | ArrayLike | ArrayBuffer, + itemSize: number, + normalized?: boolean + ); +} + +export class Int32BufferAttribute extends BufferAttribute { + constructor( + array: Iterable | ArrayLike | ArrayBuffer, + itemSize: number, + normalized?: boolean + ); +} + +export class Uint32BufferAttribute extends BufferAttribute { + constructor( + array: Iterable | ArrayLike | ArrayBuffer, + itemSize: number, + normalized?: boolean + ); +} + +export class Float32BufferAttribute extends BufferAttribute { + constructor( + array: Iterable | ArrayLike | ArrayBuffer, + itemSize: number, + normalized?: boolean + ); +} + +export class Float64BufferAttribute extends BufferAttribute { + constructor( + array: Iterable | ArrayLike | ArrayBuffer, + itemSize: number, + normalized?: boolean + ); +} diff --git a/src/core/BufferGeometry.d.ts b/src/core/BufferGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ef35b725cdab292203fcc0a5e298d5d82b3c3f80 --- /dev/null +++ b/src/core/BufferGeometry.d.ts @@ -0,0 +1,144 @@ +import { BufferAttribute } from './BufferAttribute'; +import { Box3 } from './../math/Box3'; +import { Sphere } from './../math/Sphere'; +import { Matrix4 } from './../math/Matrix4'; +import { Vector2 } from './../math/Vector2'; +import { Vector3 } from './../math/Vector3'; +import { Object3D } from './Object3D'; +import { Geometry } from './Geometry'; +import { DirectGeometry } from './DirectGeometry'; +import { EventDispatcher } from './EventDispatcher'; +import { InterleavedBufferAttribute } from './InterleavedBufferAttribute'; +/** + * @deprecated Use {@link BufferAttribute#setDynamic THREE.BufferAttribute().setDynamic( true )} instead. + */ + +/** + * This is a superefficent class for geometries because it saves all data in buffers. + * It reduces memory costs and cpu cycles. But it is not as easy to work with because of all the nessecary buffer calculations. + * It is mainly interesting when working with static objects. + * + * @see src/core/BufferGeometry.js + */ +export class BufferGeometry extends EventDispatcher { + /** + * This creates a new BufferGeometry. It also sets several properties to an default value. + */ + constructor(); + + static MaxIndex: number; + + /** + * Unique number of this buffergeometry instance + */ + id: number; + uuid: string; + name: string; + type: string; + index: BufferAttribute; + attributes: { + [name: string]: BufferAttribute | InterleavedBufferAttribute; + }; + morphAttributes: any; + groups: { start: number; count: number; materialIndex?: number }[]; + boundingBox: Box3; + boundingSphere: Sphere; + drawRange: { start: number; count: number }; + + getIndex(): BufferAttribute; + setIndex(index: BufferAttribute | number[]): void; + + addAttribute( + name: string, + attribute: BufferAttribute | InterleavedBufferAttribute + ): BufferGeometry; + + getAttribute(name: string): BufferAttribute | InterleavedBufferAttribute; + removeAttribute(name: string): BufferGeometry; + + addGroup(start: number, count: number, materialIndex?: number): void; + clearGroups(): void; + + setDrawRange(start: number, count: number): void; + + /** + * Bakes matrix transform directly into vertex coordinates. + */ + applyMatrix(matrix: Matrix4): BufferGeometry; + + rotateX(angle: number): BufferGeometry; + rotateY(angle: number): BufferGeometry; + rotateZ(angle: number): BufferGeometry; + translate(x: number, y: number, z: number): BufferGeometry; + scale(x: number, y: number, z: number): BufferGeometry; + lookAt(v: Vector3): void; + + center(): BufferGeometry; + + setFromObject(object: Object3D): BufferGeometry; + setFromPoints(points: Vector3[] | Vector2[]): BufferGeometry; + updateFromObject(object: Object3D): void; + + fromGeometry(geometry: Geometry, settings?: any): BufferGeometry; + + fromDirectGeometry(geometry: DirectGeometry): BufferGeometry; + + /** + * Computes bounding box of the geometry, updating Geometry.boundingBox attribute. + * Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are null. + */ + computeBoundingBox(): void; + + /** + * Computes bounding sphere of the geometry, updating Geometry.boundingSphere attribute. + * Bounding spheres aren't' computed by default. They need to be explicitly computed, otherwise they are null. + */ + computeBoundingSphere(): void; + + /** + * Computes vertex normals by averaging face normals. + */ + computeVertexNormals(): void; + + merge(geometry: BufferGeometry, offset: number): BufferGeometry; + normalizeNormals(): void; + + toNonIndexed(): BufferGeometry; + + toJSON(): any; + clone(): this; + copy(source: BufferGeometry): this; + + /** + * Disposes the object from memory. + * You need to call this when you want the bufferGeometry removed while the application is running. + */ + dispose(): void; + + /** + * @deprecated Use {@link BufferGeometry#groups .groups} instead. + */ + drawcalls: any; + + /** + * @deprecated Use {@link BufferGeometry#groups .groups} instead. + */ + offsets: any; + + /** + * @deprecated Use {@link BufferGeometry#setIndex .setIndex()} instead. + */ + addIndex(index: any): void; + + /** + * @deprecated Use {@link BufferGeometry#addGroup .addGroup()} instead. + */ + addDrawCall(start: any, count: any, indexOffset?: any): void; + + /** + * @deprecated Use {@link BufferGeometry#clearGroups .clearGroups()} instead. + */ + clearDrawCalls(): void; + + addAttribute(name: any, array: any, itemSize: any): any; +} diff --git a/src/core/Clock.d.ts b/src/core/Clock.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..82a24d4dc0d7faf0084295204a80e75415c16b2e --- /dev/null +++ b/src/core/Clock.d.ts @@ -0,0 +1,59 @@ +/** + * Object for keeping track of time. + * + * @see src/core/Clock.js + */ +export class Clock { + /** + * @param autoStart Automatically start the clock. + */ + constructor(autoStart?: boolean); + + /** + * If set, starts the clock automatically when the first update is called. + */ + autoStart: boolean; + + /** + * When the clock is running, It holds the starttime of the clock. + * This counted from the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. + */ + startTime: number; + + /** + * When the clock is running, It holds the previous time from a update. + * This counted from the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. + */ + oldTime: number; + + /** + * When the clock is running, It holds the time elapsed between the start of the clock to the previous update. + * This parameter is in seconds of three decimal places. + */ + elapsedTime: number; + + /** + * This property keeps track whether the clock is running or not. + */ + running: boolean; + + /** + * Starts clock. + */ + start(): void; + + /** + * Stops clock. + */ + stop(): void; + + /** + * Get the seconds passed since the clock started. + */ + getElapsedTime(): number; + + /** + * Get the seconds passed since the last call to this method. + */ + getDelta(): number; +} diff --git a/src/core/DirectGeometry.d.ts b/src/core/DirectGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f1651790695f4a64cec9c3b62e1485715f6fd0f5 --- /dev/null +++ b/src/core/DirectGeometry.d.ts @@ -0,0 +1,50 @@ +import { Vector3 } from './../math/Vector3'; +import { Color } from './../math/Color'; +import { Vector2 } from './../math/Vector2'; +import { Vector4 } from './../math/Vector4'; +import { Box3 } from './../math/Box3'; +import { Sphere } from './../math/Sphere'; +import { Geometry } from './Geometry'; +import { Event } from './Face3'; +import { EventDispatcher } from './EventDispatcher'; +import { MorphTarget } from './Geometry'; +/** + * @see src/core/DirectGeometry.js + */ +export class DirectGeometry extends EventDispatcher { + constructor(); + + id: number; + uuid: string; + name: string; + type: string; + indices: number[]; + vertices: Vector3[]; + normals: Vector3[]; + colors: Color[]; + uvs: Vector2[]; + uvs2: Vector2[]; + groups: { start: number; materialIndex: number }[]; + morphTargets: MorphTarget[]; + skinWeights: Vector4[]; + skinIndices: Vector4[]; + boundingBox: Box3; + boundingSphere: Sphere; + verticesNeedUpdate: boolean; + normalsNeedUpdate: boolean; + colorsNeedUpdate: boolean; + uvsNeedUpdate: boolean; + groupsNeedUpdate: boolean; + + computeBoundingBox(): void; + computeBoundingSphere(): void; + computeGroups(geometry: Geometry): void; + fromGeometry(geometry: Geometry): DirectGeometry; + dispose(): void; + + // EventDispatcher mixins + addEventListener(type: string, listener: (event: Event) => void): void; + hasEventListener(type: string, listener: (event: Event) => void): boolean; + removeEventListener(type: string, listener: (event: Event) => void): void; + dispatchEvent(event: { type: string; [attachment: string]: any }): void; +} diff --git a/src/core/EventDispatcher.d.ts b/src/core/EventDispatcher.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..29fa97e806315beed02662784db6bfa81dffd37f --- /dev/null +++ b/src/core/EventDispatcher.d.ts @@ -0,0 +1,60 @@ +import { Event } from './Face3'; + +/** + * JavaScript events for custom objects + * + * # Example + * var Car = function () { + * + * EventDispatcher.call( this ); + * this.start = function () { + * + * this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } ); + * + * }; + * + * }; + * + * var car = new Car(); + * car.addEventListener( 'start', function ( event ) { + * + * alert( event.message ); + * + * } ); + * car.start(); + * + * @source src/core/EventDispatcher.js + */ +export class EventDispatcher { + /** + * Creates eventDispatcher object. It needs to be call with '.call' to add the functionality to an object. + */ + constructor(); + + /** + * Adds a listener to an event type. + * @param type The type of event to listen to. + * @param listener The function that gets called when the event is fired. + */ + addEventListener(type: string, listener: (event: Event) => void): void; + + /** + * Checks if listener is added to an event type. + * @param type The type of event to listen to. + * @param listener The function that gets called when the event is fired. + */ + hasEventListener(type: string, listener: (event: Event) => void): boolean; + + /** + * Removes a listener from an event type. + * @param type The type of the listener that gets removed. + * @param listener The listener function that gets removed. + */ + removeEventListener(type: string, listener: (event: Event) => void): void; + + /** + * Fire an event type. + * @param type The type of event that gets fired. + */ + dispatchEvent(event: { type: string; [attachment: string]: any }): void; +} diff --git a/src/core/Face3.d.ts b/src/core/Face3.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6e7a03850996e293265fec88a940f5513e78d60 --- /dev/null +++ b/src/core/Face3.d.ts @@ -0,0 +1,104 @@ +import { Vector3 } from './../math/Vector3'; +import { Color } from './../math/Color'; + +export interface Event { + type: string; + target?: any; + [attachment: string]: any; +} + +/** + * Triangle face. + * + * # Example + * var normal = new THREE.Vector3( 0, 1, 0 ); + * var color = new THREE.Color( 0xffaa00 ); + * var face = new THREE.Face3( 0, 1, 2, normal, color, 0 ); + * + * @source https://github.com/mrdoob/three.js/blob/master/src/core/Face3.js + */ +export class Face3 { + /** + * @param a Vertex A index. + * @param b Vertex B index. + * @param c Vertex C index. + * @param normal Face normal or array of vertex normals. + * @param color Face color or array of vertex colors. + * @param materialIndex Material index. + */ + constructor( + a: number, + b: number, + c: number, + normal?: Vector3, + color?: Color, + materialIndex?: number + ); + constructor( + a: number, + b: number, + c: number, + normal?: Vector3, + vertexColors?: Color[], + materialIndex?: number + ); + constructor( + a: number, + b: number, + c: number, + vertexNormals?: Vector3[], + color?: Color, + materialIndex?: number + ); + constructor( + a: number, + b: number, + c: number, + vertexNormals?: Vector3[], + vertexColors?: Color[], + materialIndex?: number + ); + + /** + * Vertex A index. + */ + a: number; + + /** + * Vertex B index. + */ + b: number; + + /** + * Vertex C index. + */ + c: number; + + /** + * Face normal. + */ + normal: Vector3; + + /** + * Array of 4 vertex normals. + */ + vertexNormals: Vector3[]; + + /** + * Face color. + */ + color: Color; + + /** + * Array of 4 vertex normals. + */ + vertexColors: Color[]; + + /** + * Material index (points to {@link Geometry.materials}). + */ + materialIndex: number; + + clone(): this; + copy(source: Face3): this; +} diff --git a/src/core/Geometry.d.ts b/src/core/Geometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e82a4dd10c1a725e7b2fda15f30c64580d7f7170 --- /dev/null +++ b/src/core/Geometry.d.ts @@ -0,0 +1,265 @@ +import { Vector3 } from './../math/Vector3'; +import { Color } from './../math/Color'; +import { Face3, Event } from './Face3'; +import { Vector2 } from './../math/Vector2'; +import { Vector4 } from './../math/Vector4'; +import { Box3 } from './../math/Box3'; +import { Sphere } from './../math/Sphere'; +import { Matrix4 } from './../math/Matrix4'; +import { BufferGeometry } from './BufferGeometry'; +import { Matrix } from './../math/Matrix3'; +import { Mesh } from './../objects/Mesh'; +import { Bone } from './../objects/Bone'; +import { AnimationClip } from './../animation/AnimationClip'; +import { EventDispatcher } from './EventDispatcher'; + +/** + * @deprecated Use {@link Face3} instead. + */ + +export interface MorphTarget { + name: string; + vertices: Vector3[]; +} + +export interface MorphColor { + name: string; + colors: Color[]; +} + +export interface MorphNormals { + name: string; + normals: Vector3[]; +} + +export let GeometryIdCount: number; + +/** + * Base class for geometries + * + * # Example + * var geometry = new THREE.Geometry(); + * geometry.vertices.push( new THREE.Vector3( -10, 10, 0 ) ); + * geometry.vertices.push( new THREE.Vector3( -10, -10, 0 ) ); + * geometry.vertices.push( new THREE.Vector3( 10, -10, 0 ) ); + * geometry.faces.push( new THREE.Face3( 0, 1, 2 ) ); + * geometry.computeBoundingSphere(); + * + * @see https://github.com/mrdoob/three.js/blob/master/src/core/Geometry.js + */ +export class Geometry extends EventDispatcher { + constructor(); + + /** + * Unique number of this geometry instance + */ + id: number; + + uuid: string; + + /** + * Name for this geometry. Default is an empty string. + */ + name: string; + + type: string; + + /** + * The array of vertices hold every position of points of the model. + * To signal an update in this array, Geometry.verticesNeedUpdate needs to be set to true. + */ + vertices: Vector3[]; + + /** + * Array of vertex colors, matching number and order of vertices. + * Used in ParticleSystem, Line and Ribbon. + * Meshes use per-face-use-of-vertex colors embedded directly in faces. + * To signal an update in this array, Geometry.colorsNeedUpdate needs to be set to true. + */ + colors: Color[]; + + /** + * Array of triangles or/and quads. + * The array of faces describe how each vertex in the model is connected with each other. + * To signal an update in this array, Geometry.elementsNeedUpdate needs to be set to true. + */ + faces: Face3[]; + + /** + * Array of face UV layers. + * Each UV layer is an array of UV matching order and number of vertices in faces. + * To signal an update in this array, Geometry.uvsNeedUpdate needs to be set to true. + */ + faceVertexUvs: Vector2[][][]; + + /** + * Array of morph targets. Each morph target is a Javascript object: + * + * { name: "targetName", vertices: [ new THREE.Vector3(), ... ] } + * + * Morph vertices match number and order of primary vertices. + */ + morphTargets: MorphTarget[]; + + /** + * Array of morph normals. Morph normals have similar structure as morph targets, each normal set is a Javascript object: + * + * morphNormal = { name: "NormalName", normals: [ new THREE.Vector3(), ... ] } + */ + morphNormals: MorphNormals[]; + + /** + * Array of skinning weights, matching number and order of vertices. + */ + skinWeights: Vector4[]; + + /** + * Array of skinning indices, matching number and order of vertices. + */ + skinIndices: Vector4[]; + + /** + * + */ + lineDistances: number[]; + + /** + * Bounding box. + */ + boundingBox: Box3; + + /** + * Bounding sphere. + */ + boundingSphere: Sphere; + + /** + * Set to true if the vertices array has been updated. + */ + verticesNeedUpdate: boolean; + + /** + * Set to true if the faces array has been updated. + */ + elementsNeedUpdate: boolean; + + /** + * Set to true if the uvs array has been updated. + */ + uvsNeedUpdate: boolean; + + /** + * Set to true if the normals array has been updated. + */ + normalsNeedUpdate: boolean; + + /** + * Set to true if the colors array has been updated. + */ + colorsNeedUpdate: boolean; + + /** + * Set to true if the linedistances array has been updated. + */ + lineDistancesNeedUpdate: boolean; + + /** + * + */ + groupsNeedUpdate: boolean; + + /** + * Bakes matrix transform directly into vertex coordinates. + */ + applyMatrix(matrix: Matrix4): Geometry; + + rotateX(angle: number): Geometry; + rotateY(angle: number): Geometry; + rotateZ(angle: number): Geometry; + + translate(x: number, y: number, z: number): Geometry; + scale(x: number, y: number, z: number): Geometry; + lookAt(vector: Vector3): void; + + fromBufferGeometry(geometry: BufferGeometry): Geometry; + + center(): Geometry; + + normalize(): Geometry; + + /** + * Computes face normals. + */ + computeFaceNormals(): void; + + /** + * Computes vertex normals by averaging face normals. + * Face normals must be existing / computed beforehand. + */ + computeVertexNormals(areaWeighted?: boolean): void; + + /** + * Compute vertex normals, but duplicating face normals. + */ + computeFlatVertexNormals(): void; + + /** + * Computes morph normals. + */ + computeMorphNormals(): void; + + /** + * Computes bounding box of the geometry, updating {@link Geometry.boundingBox} attribute. + */ + computeBoundingBox(): void; + + /** + * Computes bounding sphere of the geometry, updating Geometry.boundingSphere attribute. + * Neither bounding boxes or bounding spheres are computed by default. They need to be explicitly computed, otherwise they are null. + */ + computeBoundingSphere(): void; + + merge( + geometry: Geometry, + matrix?: Matrix, + materialIndexOffset?: number + ): void; + + mergeMesh(mesh: Mesh): void; + + /** + * Checks for duplicate vertices using hashmap. + * Duplicated vertices are removed and faces' vertices are updated. + */ + mergeVertices(): number; + + setFromPoints(points: Array | Array): this; + + sortFacesByMaterialIndex(): void; + + toJSON(): any; + + /** + * Creates a new clone of the Geometry. + */ + clone(): this; + + copy(source: Geometry): this; + + /** + * Removes The object from memory. + * Don't forget to call this method when you remove an geometry because it can cuase meomory leaks. + */ + dispose(): void; + + // These properties do not exist in a normal Geometry class, but if you use the instance that was passed by JSONLoader, it will be added. + bones: Bone[]; + animation: AnimationClip; + animations: AnimationClip[]; + + // EventDispatcher mixins + addEventListener(type: string, listener: (event: Event) => void): void; + hasEventListener(type: string, listener: (event: Event) => void): boolean; + removeEventListener(type: string, listener: (event: Event) => void): void; + dispatchEvent(event: { type: string; [attachment: string]: any }): void; +} diff --git a/src/core/InstancedBufferAttribute.d.ts b/src/core/InstancedBufferAttribute.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..01d214344355530d587436f442aa37d6afb0f9a3 --- /dev/null +++ b/src/core/InstancedBufferAttribute.d.ts @@ -0,0 +1,46 @@ +import { BufferGeometry } from './BufferGeometry'; +import { BufferAttribute } from './BufferAttribute'; + +/** + * @see examples/js/BufferGeometryUtils.js + */ +export namespace BufferGeometryUtils { + export function mergeBufferGeometries( + geometries: BufferGeometry[] + ): BufferGeometry; + export function computeTangents(geometry: BufferGeometry): null; + export function mergeBufferAttributes( + attributes: BufferAttribute[] + ): BufferAttribute; +} + +/** + * @deprecated + */ +export namespace GeometryUtils { + /** + * @deprecated Use {@link Geometry#merge geometry.merge( geometry2, matrix, materialIndexOffset )} instead. + */ + export function merge( + geometry1: any, + geometry2: any, + materialIndexOffset?: any + ): any; + /** + * @deprecated Use {@link Geometry#center geometry.center()} instead. + */ + export function center(geometry: any): any; +} + +/** + * @see src/core/InstancedBufferAttribute.js + */ +export class InstancedBufferAttribute extends BufferAttribute { + constructor( + data: ArrayLike, + itemSize: number, + meshPerAttribute?: number + ); + + meshPerAttribute: number; +} diff --git a/src/core/InstancedBufferGeometry.d.ts b/src/core/InstancedBufferGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..da8bab0072c1fccfcd4ab13c15cfbee2f1341183 --- /dev/null +++ b/src/core/InstancedBufferGeometry.d.ts @@ -0,0 +1,13 @@ +import { BufferGeometry } from './BufferGeometry'; + +/** + * @see src/core/InstancedBufferGeometry.js + */ +export class InstancedBufferGeometry extends BufferGeometry { + constructor(); + + groups: { start: number; count: number; instances: number }[]; + maxInstancedCount: number; + + addGroup(start: number, count: number, instances: number): void; +} diff --git a/src/core/InstancedInterleavedBuffer.d.ts b/src/core/InstancedInterleavedBuffer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4205764ca45d325830e9322183ed4f052c112092 --- /dev/null +++ b/src/core/InstancedInterleavedBuffer.d.ts @@ -0,0 +1,14 @@ +import { InterleavedBuffer } from './InterleavedBuffer'; + +/** + * @see src/core/InstancedInterleavedBuffer.js + */ +export class InstancedInterleavedBuffer extends InterleavedBuffer { + constructor( + array: ArrayLike, + stride: number, + meshPerAttribute?: number + ); + + meshPerAttribute: number; +} diff --git a/src/core/InterleavedBuffer.d.ts b/src/core/InterleavedBuffer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8b97ca15d7048ef69455eb0a595f75a58db51160 --- /dev/null +++ b/src/core/InterleavedBuffer.d.ts @@ -0,0 +1,28 @@ +import { InterleavedBufferAttribute } from './InterleavedBufferAttribute'; + +/** + * @see src/core/InterleavedBuffer.js + */ +export class InterleavedBuffer { + constructor(array: ArrayLike, stride: number); + + array: ArrayLike; + stride: number; + dynamic: boolean; + updateRange: { offset: number; count: number }; + version: number; + length: number; + count: number; + needsUpdate: boolean; + + setArray(array?: ArrayBufferView): void; + setDynamic(dynamic: boolean): InterleavedBuffer; + clone(): this; + copy(source: InterleavedBuffer): this; + copyAt( + index1: number, + attribute: InterleavedBufferAttribute, + index2: number + ): InterleavedBuffer; + set(value: ArrayLike, index: number): InterleavedBuffer; +} diff --git a/src/core/InterleavedBufferAttribute.d.ts b/src/core/InterleavedBufferAttribute.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..43bf28b3b205d6c8552ea0823f15f2c47b7f2b14 --- /dev/null +++ b/src/core/InterleavedBufferAttribute.d.ts @@ -0,0 +1,47 @@ +import { InterleavedBuffer } from './InterleavedBuffer'; +/** + * @see src/core/InterleavedBufferAttribute.js + */ +export class InterleavedBufferAttribute { + constructor( + interleavedBuffer: InterleavedBuffer, + itemSize: number, + offset: number, + normalized?: boolean + ); + + uuid: string; + data: InterleavedBuffer; + itemSize: number; + offset: number; + count: number; + normalized: boolean; + array: any[]; + + getX(index: number): number; + setX(index: number, x: number): InterleavedBufferAttribute; + getY(index: number): number; + setY(index: number, y: number): InterleavedBufferAttribute; + getZ(index: number): number; + setZ(index: number, z: number): InterleavedBufferAttribute; + getW(index: number): number; + setW(index: number, z: number): InterleavedBufferAttribute; + setXY(index: number, x: number, y: number): InterleavedBufferAttribute; + setXYZ( + index: number, + x: number, + y: number, + z: number + ): InterleavedBufferAttribute; + setXYZW( + index: number, + x: number, + y: number, + z: number, + w: number + ): InterleavedBufferAttribute; + /** + * @deprecated Use {@link InterleavedBufferAttribute#count .count} instead. + */ + length: number; +} diff --git a/src/core/Layers.d.ts b/src/core/Layers.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9bed9954e50ab9313695981da7c69d3b6bdeb9bd --- /dev/null +++ b/src/core/Layers.d.ts @@ -0,0 +1,11 @@ +export class Layers { + constructor(); + + mask: number; + + set(channel: number): void; + enable(channel: number): void; + toggle(channel: number): void; + disable(channel: number): void; + test(layers: Layers): boolean; +} diff --git a/src/core/Object3D.d.ts b/src/core/Object3D.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..820c6786abc6ae63e91bfcc905e15d4d805502c2 --- /dev/null +++ b/src/core/Object3D.d.ts @@ -0,0 +1,326 @@ +import { Vector3 } from './../math/Vector3'; +import { Euler } from './../math/Euler'; +import { Quaternion } from './../math/Quaternion'; +import { Matrix4 } from './../math/Matrix4'; +import { Matrix3 } from './../math/Matrix3'; +import { Layers } from './Layers'; +import { WebGLRenderer } from './../renderers/WebGLRenderer'; +import { Scene } from './../scenes/Scene'; +import { Camera } from './../cameras/Camera'; +import { Geometry } from './Geometry'; +import { Material } from './../materials/Material'; +import { Group } from './../objects/Group'; +import { Raycaster } from './Raycaster'; +import { EventDispatcher } from './EventDispatcher'; +import { BufferGeometry } from './BufferGeometry'; +import { Intersection } from './Raycaster'; + +export let Object3DIdCount: number; + +/** + * Base class for scene graph objects + */ +export class Object3D extends EventDispatcher { + constructor(); + + /** + * Unique number of this object instance. + */ + id: number; + + /** + * + */ + uuid: string; + + /** + * Optional name of the object (doesn't need to be unique). + */ + name: string; + + type: string; + + /** + * Object's parent in the scene graph. + */ + parent: Object3D | null; + + /** + * Array with object's children. + */ + children: Object3D[]; + + /** + * Up direction. + */ + up: Vector3; + + /** + * Object's local position. + */ + position: Vector3; + + /** + * Object's local rotation (Euler angles), in radians. + */ + rotation: Euler; + + /** + * Global rotation. + */ + quaternion: Quaternion; + + /** + * Object's local scale. + */ + scale: Vector3; + + modelViewMatrix: Matrix4; + + normalMatrix: Matrix3; + + /** + * Local transform. + */ + matrix: Matrix4; + + /** + * The global transform of the object. If the Object3d has no parent, then it's identical to the local transform. + */ + matrixWorld: Matrix4; + + /** + * When this is set, it calculates the matrix of position, (rotation or quaternion) and scale every frame and also recalculates the matrixWorld property. + */ + matrixAutoUpdate: boolean; + + /** + * When this is set, it calculates the matrixWorld in that frame and resets this property to false. + */ + matrixWorldNeedsUpdate: boolean; + + layers: Layers; + /** + * Object gets rendered if true. + */ + visible: boolean; + + /** + * Gets rendered into shadow map. + */ + castShadow: boolean; + + /** + * Material gets baked in shadow receiving. + */ + receiveShadow: boolean; + + /** + * When this is set, it checks every frame if the object is in the frustum of the camera. Otherwise the object gets drawn every frame even if it isn't visible. + */ + frustumCulled: boolean; + + renderOrder: number; + + /** + * An object that can be used to store custom data about the Object3d. It should not hold references to functions as these will not be cloned. + */ + userData: { [key: string]: any }; + + /** + * Used to check whether this or derived classes are Object3Ds. Default is true. + * You should not change this, as it is used internally for optimisation. + */ + isObject3D: true; + + /** + * Calls before rendering object + */ + onBeforeRender: ( + renderer: WebGLRenderer, + scene: Scene, + camera: Camera, + geometry: Geometry | BufferGeometry, + material: Material, + group: Group + ) => void; + + /** + * Calls after rendering object + */ + onAfterRender: ( + renderer: WebGLRenderer, + scene: Scene, + camera: Camera, + geometry: Geometry | BufferGeometry, + material: Material, + group: Group + ) => void; + + static DefaultUp: Vector3; + static DefaultMatrixAutoUpdate: boolean; + + /** + * This updates the position, rotation and scale with the matrix. + */ + applyMatrix(matrix: Matrix4): void; + + applyQuaternion(quaternion: Quaternion): this; + + /** + * + */ + setRotationFromAxisAngle(axis: Vector3, angle: number): void; + + /** + * + */ + setRotationFromEuler(euler: Euler): void; + + /** + * + */ + setRotationFromMatrix(m: Matrix4): void; + + /** + * + */ + setRotationFromQuaternion(q: Quaternion): void; + + /** + * Rotate an object along an axis in object space. The axis is assumed to be normalized. + * @param axis A normalized vector in object space. + * @param angle The angle in radians. + */ + rotateOnAxis(axis: Vector3, angle: number): this; + + /** + * Rotate an object along an axis in world space. The axis is assumed to be normalized. Method Assumes no rotated parent. + * @param axis A normalized vector in object space. + * @param angle The angle in radians. + */ + rotateOnWorldAxis(axis: Vector3, angle: number): this; + + /** + * + * @param angle + */ + rotateX(angle: number): this; + + /** + * + * @param angle + */ + rotateY(angle: number): this; + + /** + * + * @param angle + */ + rotateZ(angle: number): this; + + /** + * @param axis A normalized vector in object space. + * @param distance The distance to translate. + */ + translateOnAxis(axis: Vector3, distance: number): this; + + /** + * Translates object along x axis by distance. + * @param distance Distance. + */ + translateX(distance: number): this; + + /** + * Translates object along y axis by distance. + * @param distance Distance. + */ + translateY(distance: number): this; + + /** + * Translates object along z axis by distance. + * @param distance Distance. + */ + translateZ(distance: number): this; + + /** + * Updates the vector from local space to world space. + * @param vector A local vector. + */ + localToWorld(vector: Vector3): Vector3; + + /** + * Updates the vector from world space to local space. + * @param vector A world vector. + */ + worldToLocal(vector: Vector3): Vector3; + + /** + * Rotates object to face point in space. + * @param vector A world vector to look at. + */ + lookAt(vector: Vector3 | number, y?: number, z?: number): void; + + /** + * Adds object as child of this object. + */ + add(...object: Object3D[]): this; + + /** + * Removes object as child of this object. + */ + remove(...object: Object3D[]): this; + + /** + * Searches through the object's children and returns the first with a matching id. + * @param id Unique number of the object instance + */ + getObjectById(id: number): Object3D | undefined; + + /** + * Searches through the object's children and returns the first with a matching name. + * @param name String to match to the children's Object3d.name property. + */ + getObjectByName(name: string): Object3D | undefined; + + getObjectByProperty(name: string, value: string): Object3D | undefined; + + getWorldPosition(target: Vector3): Vector3; + getWorldQuaternion(target: Quaternion): Quaternion; + getWorldScale(target: Vector3): Vector3; + getWorldDirection(target: Vector3): Vector3; + + raycast(raycaster: Raycaster, intersects: Intersection[]): void; + + traverse(callback: (object: Object3D) => any): void; + + traverseVisible(callback: (object: Object3D) => any): void; + + traverseAncestors(callback: (object: Object3D) => any): void; + + /** + * Updates local transform. + */ + updateMatrix(): void; + + /** + * Updates global transform of the object and its children. + */ + updateMatrixWorld(force: boolean): void; + + toJSON(meta?: { + geometries: any; + materials: any; + textures: any; + images: any; + }): any; + + clone(recursive?: boolean): this; + + /** + * + * @param object + * @param recursive + */ + copy(source: Object3D, recursive?: boolean): this; +} diff --git a/src/core/Raycaster.d.ts b/src/core/Raycaster.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..07aa77ab9fcb2f63ff7c0f9f6eb2a0847c5031cf --- /dev/null +++ b/src/core/Raycaster.d.ts @@ -0,0 +1,101 @@ +import { Vector3 } from './../math/Vector3'; +import { Face3 } from './Face3'; +import { Object3D } from './Object3D'; +import { Vector2 } from './../math/Vector2'; +import { Ray } from './../math/Ray'; +import { Camera } from './../cameras/Camera'; + +export interface Intersection { + distance: number; + distanceToRay?: number; + point: Vector3; + index?: number; + face?: Face3 | null; + faceIndex?: number; + object: Object3D; + uv?: Vector2; +} + +export interface RaycasterParameters { + Mesh?: any; + Line?: any; + LOD?: any; + Points?: { threshold: number }; + Sprite?: any; +} + +export class Raycaster { + /** + * This creates a new raycaster object. + * @param origin The origin vector where the ray casts from. + * @param direction The direction vector that gives direction to the ray. Should be normalized. + * @param near All results returned are further away than near. Near can't be negative. Default value is 0. + * @param far All results returned are closer then far. Far can't be lower then near . Default value is Infinity. + */ + constructor( + origin?: Vector3, + direction?: Vector3, + near?: number, + far?: number + ); + + /** The Ray used for the raycasting. */ + ray: Ray; + + /** + * The near factor of the raycaster. This value indicates which objects can be discarded based on the + * distance. This value shouldn't be negative and should be smaller than the far property. + */ + near: number; + + /** + * The far factor of the raycaster. This value indicates which objects can be discarded based on the + * distance. This value shouldn't be negative and should be larger than the near property. + */ + far: number; + + params: RaycasterParameters; + + /** + * The precision factor of the raycaster when intersecting Line objects. + */ + linePrecision: number; + + /** + * Updates the ray with a new origin and direction. + * @param origin The origin vector where the ray casts from. + * @param direction The normalized direction vector that gives direction to the ray. + */ + set(origin: Vector3, direction: Vector3): void; + + /** + * Updates the ray with a new origin and direction. + * @param coords 2D coordinates of the mouse, in normalized device coordinates (NDC)---X and Y components should be between -1 and 1. + * @param camera camera from which the ray should originate + */ + setFromCamera(coords: { x: number; y: number }, camera: Camera): void; + + /** + * Checks all intersection between the ray and the object with or without the descendants. Intersections are returned sorted by distance, closest first. + * @param object The object to check for intersection with the ray. + * @param recursive If true, it also checks all descendants. Otherwise it only checks intersecton with the object. Default is false. + * @param optionalTarget (optional) target to set the result. Otherwise a new Array is instantiated. If set, you must clear this array prior to each call (i.e., array.length = 0;). + */ + intersectObject( + object: Object3D, + recursive?: boolean, + optionalTarget?: Intersection[] + ): Intersection[]; + + /** + * Checks all intersection between the ray and the objects with or without the descendants. Intersections are returned sorted by distance, closest first. Intersections are of the same form as those returned by .intersectObject. + * @param objects The objects to check for intersection with the ray. + * @param recursive If true, it also checks all descendants of the objects. Otherwise it only checks intersecton with the objects. Default is false. + * @param optionalTarget (optional) target to set the result. Otherwise a new Array is instantiated. If set, you must clear this array prior to each call (i.e., array.length = 0;). + */ + intersectObjects( + objects: Object3D[], + recursive?: boolean, + optionalTarget?: Intersection[] + ): Intersection[]; +} diff --git a/src/core/Uniform.d.ts b/src/core/Uniform.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..823ecc517a8625972e483cc7715a950334979f9e --- /dev/null +++ b/src/core/Uniform.d.ts @@ -0,0 +1,22 @@ +export class Uniform { + constructor(value: any); + /** + * @deprecated + */ + constructor(type: string, value: any); + /** + * @deprecated + */ + type: string; + value: any; + /** + * @deprecated Use {@link Object3D#onBeforeRender object.onBeforeRender()} instead. + */ + dynamic: boolean; + onUpdateCallback: Function; + + /** + * @deprecated Use {@link Object3D#onBeforeRender object.onBeforeRender()} instead. + */ + onUpdate(callback: Function): Uniform; +} diff --git a/src/extras/ImageUtils.d.ts b/src/extras/ImageUtils.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..61bc09b45b49d9fb840802f463b3b9be35697eea --- /dev/null +++ b/src/extras/ImageUtils.d.ts @@ -0,0 +1,34 @@ +import { Mapping } from '../constants'; +import { Texture } from '../textures/Texture'; + +// Extras ///////////////////////////////////////////////////////////////////// + +/** + * @deprecated Use {@link TextureLoader} instead. + */ +export namespace ImageUtils { + /** + * @deprecated + */ + export let crossOrigin: string; + + /** + * @deprecated Use {@link TextureLoader THREE.TextureLoader()} instead. + */ + export function loadTexture( + url: string, + mapping?: Mapping, + onLoad?: (texture: Texture) => void, + onError?: (message: string) => void + ): Texture; + + /** + * @deprecated Use {@link CubeTextureLoader THREE.CubeTextureLoader()} instead. + */ + export function loadTextureCube( + array: string[], + mapping?: Mapping, + onLoad?: (texture: Texture) => void, + onError?: (message: string) => void + ): Texture; +} diff --git a/src/extras/ShapeUtils.d.ts b/src/extras/ShapeUtils.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ded77c619d2248b2c7e3a9650a2e9882c188e63e --- /dev/null +++ b/src/extras/ShapeUtils.d.ts @@ -0,0 +1,11 @@ +interface Vec2 { + x: number; + y: number; +} + +export namespace ShapeUtils { + export function area(contour: Vec2[]): number; + export function triangulate(contour: Vec2[], indices: boolean): number[]; + export function triangulateShape(contour: Vec2[], holes: Vec2[]): number[][]; + export function isClockWise(pts: Vec2[]): boolean; +} diff --git a/src/extras/core/Curve.d.ts b/src/extras/core/Curve.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cd46920c0542185cfb1b801379a9ce23b622b438 --- /dev/null +++ b/src/extras/core/Curve.d.ts @@ -0,0 +1,77 @@ +import { Vector } from './../../math/Vector2'; + +// Extras / Core ///////////////////////////////////////////////////////////////////// + +/** + * An extensible curve object which contains methods for interpolation + * class Curve<T extends Vector> + */ +export class Curve { + /** + * This value determines the amount of divisions when calculating the cumulative segment lengths of a curve via .getLengths. + * To ensure precision when using methods like .getSpacedPoints, it is recommended to increase .arcLengthDivisions if the curve is very large. + * Default is 200. + */ + arcLengthDivisions: number; + + /** + * Returns a vector for point t of the curve where t is between 0 and 1 + * getPoint(t: number): T; + */ + getPoint(t: number, optionalTarget?: T): T; + + /** + * Returns a vector for point at relative position in curve according to arc length + * getPointAt(u: number): T; + */ + getPointAt(u: number, optionalTarget?: T): T; + + /** + * Get sequence of points using getPoint( t ) + * getPoints(divisions?: number): T[]; + */ + getPoints(divisions?: number): T[]; + + /** + * Get sequence of equi-spaced points using getPointAt( u ) + * getSpacedPoints(divisions?: number): T[]; + */ + getSpacedPoints(divisions?: number): T[]; + + /** + * Get total curve arc length + */ + getLength(): number; + + /** + * Get list of cumulative segment lengths + */ + getLengths(divisions?: number): number[]; + + /** + * Update the cumlative segment distance cache + */ + updateArcLengths(): void; + + /** + * Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equi distance + */ + getUtoTmapping(u: number, distance: number): number; + + /** + * Returns a unit vector tangent at t. If the subclassed curve do not implement its tangent derivation, 2 points a small delta apart will be used to find its gradient which seems to give a reasonable approximation + * getTangent(t: number): T; + */ + getTangent(t: number): T; + + /** + * Returns tangent at equidistance point u on the curve + * getTangentAt(u: number): T; + */ + getTangentAt(u: number): T; + + /** + * @deprecated since r84. + */ + static create(constructorFunc: Function, getPointFunc: Function): Function; +} diff --git a/src/extras/core/CurvePath.d.ts b/src/extras/core/CurvePath.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8a3ce4165c46d128c36e3c565523a17eab70d1bd --- /dev/null +++ b/src/extras/core/CurvePath.d.ts @@ -0,0 +1,33 @@ +import { Curve } from './Curve'; +import { Geometry } from './../../core/Geometry'; +import { Vector } from './../../math/Vector2'; + +export class CurvePath extends Curve { + constructor(); + + curves: Curve[]; + autoClose: boolean; + + add(curve: Curve): void; + checkConnection(): boolean; + closePath(): void; + getPoint(t: number): T; + getLength(): number; + updateArcLengths(): void; + getCurveLengths(): number[]; + getSpacedPoints(divisions?: number): T[]; + getPoints(divisions?: number): T[]; + + /** + * @deprecated Use {@link Geometry#setFromPoints new THREE.Geometry().setFromPoints( points )} instead. + */ + createPointsGeometry(divisions: number): Geometry; + /** + * @deprecated Use {@link Geometry#setFromPoints new THREE.Geometry().setFromPoints( points )} instead. + */ + createSpacedPointsGeometry(divisions: number): Geometry; + /** + * @deprecated Use {@link Geometry#setFromPoints new THREE.Geometry().setFromPoints( points )} instead. + */ + createGeometry(points: T[]): Geometry; +} diff --git a/src/extras/core/Font.d.ts b/src/extras/core/Font.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e0f45adefef219f39479523c5d29c79b4f83f4b5 --- /dev/null +++ b/src/extras/core/Font.d.ts @@ -0,0 +1,7 @@ +export class Font { + constructor(jsondata: any); + + data: string; + + generateShapes(text: string, size: number, divisions: number): any[]; +} diff --git a/src/extras/core/Path.d.ts b/src/extras/core/Path.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..012b1f9b6eb05ae887491d59e6b768ff3e07cc7a --- /dev/null +++ b/src/extras/core/Path.d.ts @@ -0,0 +1,80 @@ +import { Vector2 } from './../../math/Vector2'; +import { CurvePath } from './CurvePath'; + +export enum PathActions { + MOVE_TO, + LINE_TO, + QUADRATIC_CURVE_TO, // Bezier quadratic curve + BEZIER_CURVE_TO, // Bezier cubic curve + CSPLINE_THRU, // Catmull-rom spline + ARC, // Circle + ELLIPSE, +} + +export interface PathAction { + action: PathActions; + args: any; +} + +/** + * a 2d path representation, comprising of points, lines, and cubes, similar to the html5 2d canvas api. It extends CurvePath. + */ +export class Path extends CurvePath { + constructor(points?: Vector2[]); + + currentPoint: Vector2; + + /** + * @deprecated Use {@link Path#setFromPoints .setFromPoints()} instead. + */ + fromPoints(vectors: Vector2[]): void; + setFromPoints(vectors: Vector2[]): void; + moveTo(x: number, y: number): void; + lineTo(x: number, y: number): void; + quadraticCurveTo(aCPx: number, aCPy: number, aX: number, aY: number): void; + bezierCurveTo( + aCP1x: number, + aCP1y: number, + aCP2x: number, + aCP2y: number, + aX: number, + aY: number + ): void; + splineThru(pts: Vector2[]): void; + arc( + aX: number, + aY: number, + aRadius: number, + aStartAngle: number, + aEndAngle: number, + aClockwise: boolean + ): void; + absarc( + aX: number, + aY: number, + aRadius: number, + aStartAngle: number, + aEndAngle: number, + aClockwise: boolean + ): void; + ellipse( + aX: number, + aY: number, + xRadius: number, + yRadius: number, + aStartAngle: number, + aEndAngle: number, + aClockwise: boolean, + aRotation: number + ): void; + absellipse( + aX: number, + aY: number, + xRadius: number, + yRadius: number, + aStartAngle: number, + aEndAngle: number, + aClockwise: boolean, + aRotation: number + ): void; +} diff --git a/src/extras/core/Shape.d.ts b/src/extras/core/Shape.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..aa08894e41a205e8e7c4c3dc5609d86395b6849b --- /dev/null +++ b/src/extras/core/Shape.d.ts @@ -0,0 +1,35 @@ +import { Vector2 } from './../../math/Vector2'; +import { Path } from './Path'; +import { ExtrudeGeometry } from './../../geometries/ExtrudeGeometry'; +import { ShapeGeometry } from './../../geometries/ShapeGeometry'; + +/** + * Defines a 2d shape plane using paths. + */ +export class Shape extends Path { + constructor(points?: Vector2[]); + + holes: Path[]; + + /** + * @deprecated Use {@link ExtrudeGeometry ExtrudeGeometry()} instead. + */ + extrude(options?: any): ExtrudeGeometry; + + /** + * @deprecated Use {@link ShapeGeometry ShapeGeometry()} instead. + */ + makeGeometry(options?: any): ShapeGeometry; + getPointsHoles(divisions: number): Vector2[][]; + + /** + * @deprecated Use {@link Shape#extractPoints .extractPoints()} instead. + */ + extractAllPoints( + divisions: number + ): { + shape: Vector2[]; + holes: Vector2[][]; + }; + extractPoints(divisions: number): Vector2[]; +} diff --git a/src/extras/core/ShapePath.d.ts b/src/extras/core/ShapePath.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b93e90e1f0014324be6e57a1352a25b850d30c6d --- /dev/null +++ b/src/extras/core/ShapePath.d.ts @@ -0,0 +1,23 @@ +import { Vector2 } from './../../math/Vector2'; +import { Shape } from './Shape'; + +export class ShapePath { + constructor(); + + subPaths: any[]; + currentPath: any; + + moveTo(x: number, y: number): void; + lineTo(x: number, y: number): void; + quadraticCurveTo(aCPx: number, aCPy: number, aX: number, aY: number): void; + bezierCurveTo( + aCP1x: number, + aCP1y: number, + aCP2x: number, + aCP2y: number, + aX: number, + aY: number + ): void; + splineThru(pts: Vector2[]): void; + toShapes(isCCW: boolean, noHoles: any): Shape[]; +} diff --git a/src/extras/curves/ArcCurve.d.ts b/src/extras/curves/ArcCurve.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..985917215ff44c33488f4ff33d28db2534eda1ca --- /dev/null +++ b/src/extras/curves/ArcCurve.d.ts @@ -0,0 +1,11 @@ +import { EllipseCurve } from './EllipseCurve'; +export class ArcCurve extends EllipseCurve { + constructor( + aX: number, + aY: number, + aRadius: number, + aStartAngle: number, + aEndAngle: number, + aClockwise: boolean + ); +} diff --git a/src/extras/curves/CatmullRomCurve3.d.ts b/src/extras/curves/CatmullRomCurve3.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..686077d71e3b2162738c867b0001d89286bfbd49 --- /dev/null +++ b/src/extras/curves/CatmullRomCurve3.d.ts @@ -0,0 +1,46 @@ +import { Vector3 } from './../../math/Vector3'; +import { Curve } from './../core/Curve'; + +// Extras / Curves ///////////////////////////////////////////////////////////////////// +export namespace CurveUtils { + export function tangentQuadraticBezier( + t: number, + p0: number, + p1: number, + p2: number + ): number; + export function tangentCubicBezier( + t: number, + p0: number, + p1: number, + p2: number, + p3: number + ): number; + export function tangentSpline( + t: number, + p0: number, + p1: number, + p2: number, + p3: number + ): number; + export function interpolate( + p0: number, + p1: number, + p2: number, + p3: number, + t: number + ): number; +} + +export class CatmullRomCurve3 extends Curve { + constructor( + points?: Vector3[], + closed?: boolean, + curveType?: string, + tension?: number + ); + + points: Vector3[]; + + getPoint(t: number): Vector3; +} diff --git a/src/extras/curves/CubicBezierCurve.d.ts b/src/extras/curves/CubicBezierCurve.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c9b4b6d1d874942d99f0cc05155f3beed0f27268 --- /dev/null +++ b/src/extras/curves/CubicBezierCurve.d.ts @@ -0,0 +1,11 @@ +import { Vector2 } from './../../math/Vector2'; +import { Curve } from './../core/Curve'; + +export class CubicBezierCurve extends Curve { + constructor(v0: Vector2, v1: Vector2, v2: Vector2, v3: Vector2); + + v0: Vector2; + v1: Vector2; + v2: Vector2; + v3: Vector2; +} diff --git a/src/extras/curves/CubicBezierCurve3.d.ts b/src/extras/curves/CubicBezierCurve3.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..efce56ae21305deec0dddc80853ca86aae414237 --- /dev/null +++ b/src/extras/curves/CubicBezierCurve3.d.ts @@ -0,0 +1,13 @@ +import { Vector3 } from './../../math/Vector3'; +import { Curve } from './../core/Curve'; + +export class CubicBezierCurve3 extends Curve { + constructor(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3); + + v0: Vector3; + v1: Vector3; + v2: Vector3; + v3: Vector3; + + getPoint(t: number): Vector3; +} diff --git a/src/extras/curves/Curves.d.ts b/src/extras/curves/Curves.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c448984bb7b8125ddd1236e77eb440e0ccc2fc2f --- /dev/null +++ b/src/extras/curves/Curves.d.ts @@ -0,0 +1,10 @@ +export { ArcCurve } from './ArcCurve'; +export { CatmullRomCurve3 } from './CatmullRomCurve3'; +export { CubicBezierCurve } from './CubicBezierCurve'; +export { CubicBezierCurve3 } from './CubicBezierCurve3'; +export { EllipseCurve } from './EllipseCurve'; +export { LineCurve } from './LineCurve'; +export { LineCurve3 } from './LineCurve3'; +export { QuadraticBezierCurve } from './QuadraticBezierCurve'; +export { QuadraticBezierCurve3 } from './QuadraticBezierCurve3'; +export { SplineCurve } from './SplineCurve'; diff --git a/src/extras/curves/EllipseCurve.d.ts b/src/extras/curves/EllipseCurve.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fc02a18c2b969e7f805f5d42323243e3a171b24a --- /dev/null +++ b/src/extras/curves/EllipseCurve.d.ts @@ -0,0 +1,24 @@ +import { Curve } from './../core/Curve'; +import { Vector2 } from '../../math/Vector2'; + +export class EllipseCurve extends Curve { + constructor( + aX: number, + aY: number, + xRadius: number, + yRadius: number, + aStartAngle: number, + aEndAngle: number, + aClockwise: boolean, + aRotation: number + ); + + aX: number; + aY: number; + xRadius: number; + yRadius: number; + aStartAngle: number; + aEndAngle: number; + aClockwise: boolean; + aRotation: number; +} diff --git a/src/extras/curves/LineCurve.d.ts b/src/extras/curves/LineCurve.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5b2b45d3792f05060f62ecf45b061b8ba94b7d9e --- /dev/null +++ b/src/extras/curves/LineCurve.d.ts @@ -0,0 +1,9 @@ +import { Vector2 } from './../../math/Vector2'; +import { Curve } from './../core/Curve'; + +export class LineCurve extends Curve { + constructor(v1: Vector2, v2: Vector2); + + v1: Vector2; + v2: Vector2; +} diff --git a/src/extras/curves/LineCurve3.d.ts b/src/extras/curves/LineCurve3.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a3d975f5ab2b7008447702e0f1b6f4c5a1f79c74 --- /dev/null +++ b/src/extras/curves/LineCurve3.d.ts @@ -0,0 +1,11 @@ +import { Vector3 } from './../../math/Vector3'; +import { Curve } from './../core/Curve'; + +export class LineCurve3 extends Curve { + constructor(v1: Vector3, v2: Vector3); + + v1: Vector3; + v2: Vector3; + + getPoint(t: number): Vector3; +} diff --git a/src/extras/curves/QuadraticBezierCurve.d.ts b/src/extras/curves/QuadraticBezierCurve.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8face24fa9a42526d1033a4b649b86345606aa7b --- /dev/null +++ b/src/extras/curves/QuadraticBezierCurve.d.ts @@ -0,0 +1,10 @@ +import { Vector2 } from './../../math/Vector2'; +import { Curve } from './../core/Curve'; + +export class QuadraticBezierCurve extends Curve { + constructor(v0: Vector2, v1: Vector2, v2: Vector2); + + v0: Vector2; + v1: Vector2; + v2: Vector2; +} diff --git a/src/extras/curves/QuadraticBezierCurve3.d.ts b/src/extras/curves/QuadraticBezierCurve3.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6598c18e02fab639c17fcf97b06891c16af968b --- /dev/null +++ b/src/extras/curves/QuadraticBezierCurve3.d.ts @@ -0,0 +1,12 @@ +import { Vector3 } from './../../math/Vector3'; +import { Curve } from './../core/Curve'; + +export class QuadraticBezierCurve3 extends Curve { + constructor(v0: Vector3, v1: Vector3, v2: Vector3); + + v0: Vector3; + v1: Vector3; + v2: Vector3; + + getPoint(t: number): Vector3; +} diff --git a/src/extras/curves/SplineCurve.d.ts b/src/extras/curves/SplineCurve.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..de194d35ccd96499bf465839782e74f8ebf94559 --- /dev/null +++ b/src/extras/curves/SplineCurve.d.ts @@ -0,0 +1,8 @@ +import { Vector2 } from './../../math/Vector2'; +import { Curve } from './../core/Curve'; + +export class SplineCurve extends Curve { + constructor(points?: Vector2[]); + + points: Vector2[]; +} diff --git a/src/extras/objects/ImmediateRenderObject.d.ts b/src/extras/objects/ImmediateRenderObject.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f1c6cd8c1c77d0d976c443cbce84d13c66adae39 --- /dev/null +++ b/src/extras/objects/ImmediateRenderObject.d.ts @@ -0,0 +1,18 @@ +import { Object3D } from './../../core/Object3D'; +import { Material } from './../../materials/Material'; + +/** + * @deprecated Use {@link WireframeGeometry THREE.WireframeGeometry} instead. + */ +// export class WireframeHelper extends LineSegments { +// constructor(object: Object3D, hex?: number); +// } + +// Extras / Objects ///////////////////////////////////////////////////////////////////// + +export class ImmediateRenderObject extends Object3D { + constructor(material: Material); + + material: Material; + render(renderCallback: Function): void; +} diff --git a/src/geometries/BoxGeometry.d.ts b/src/geometries/BoxGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..acc79547cbbc16f53c6af27acbc18b40a5b397fa --- /dev/null +++ b/src/geometries/BoxGeometry.d.ts @@ -0,0 +1,56 @@ +import { Geometry } from '../core/Geometry'; +import { BufferGeometry } from '../core/BufferGeometry'; +import { Float32BufferAttribute } from '../core/BufferAttribute'; +import { Vector3 } from '../math/Vector3'; + +// Extras / Geometries ///////////////////////////////////////////////////////////////////// +export class BoxBufferGeometry extends BufferGeometry { + constructor( + width?: number, + height?: number, + depth?: number, + widthSegments?: number, + heightSegments?: number, + depthSegments?: number + ); + + parameters: { + width: number; + height: number; + depth: number; + widthSegments: number; + heightSegments: number; + depthSegments: number; + }; +} + +/** + * BoxGeometry is the quadrilateral primitive geometry class. It is typically used for creating a cube or irregular quadrilateral of the dimensions provided within the (optional) 'width', 'height', & 'depth' constructor arguments. + */ +export class BoxGeometry extends Geometry { + /** + * @param width — Width of the sides on the X axis. + * @param height — Height of the sides on the Y axis. + * @param depth — Depth of the sides on the Z axis. + * @param widthSegments — Number of segmented faces along the width of the sides. + * @param heightSegments — Number of segmented faces along the height of the sides. + * @param depthSegments — Number of segmented faces along the depth of the sides. + */ + constructor( + width?: number, + height?: number, + depth?: number, + widthSegments?: number, + heightSegments?: number, + depthSegments?: number + ); + + parameters: { + width: number; + height: number; + depth: number; + widthSegments: number; + heightSegments: number; + depthSegments: number; + }; +} diff --git a/src/geometries/CircleGeometry.d.ts b/src/geometries/CircleGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7c74b3fc350339fac8e98bcd008092406592ef04 --- /dev/null +++ b/src/geometries/CircleGeometry.d.ts @@ -0,0 +1,37 @@ +import { Geometry } from './../core/Geometry'; +import { BufferGeometry } from '../core/BufferGeometry'; + +/** + * @deprecated Use {@link BoxGeometry} instead. + */ +export class CircleBufferGeometry extends BufferGeometry { + constructor( + radius?: number, + segments?: number, + thetaStart?: number, + thetaLength?: number + ); + + parameters: { + radius: number; + segments: number; + thetaStart: number; + thetaLength: number; + }; +} + +export class CircleGeometry extends Geometry { + constructor( + radius?: number, + segments?: number, + thetaStart?: number, + thetaLength?: number + ); + + parameters: { + radius: number; + segments: number; + thetaStart: number; + thetaLength: number; + }; +} diff --git a/src/geometries/ConeGeometry.d.ts b/src/geometries/ConeGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..64dd57bc40b5b999cbc4f53ef1b3d0df45d66542 --- /dev/null +++ b/src/geometries/ConeGeometry.d.ts @@ -0,0 +1,27 @@ +import { CylinderGeometry } from './CylinderGeometry'; +import { CylinderBufferGeometry } from './CylinderGeometry'; +import { BufferGeometry } from '../core/BufferGeometry'; + +export class ConeBufferGeometry extends BufferGeometry { + constructor( + radius?: number, + height?: number, + radialSegment?: number, + heightSegment?: number, + openEnded?: boolean, + thetaStart?: number, + thetaLength?: number + ); +} + +export class ConeGeometry extends CylinderGeometry { + constructor( + radius?: number, + height?: number, + radialSegment?: number, + heightSegment?: number, + openEnded?: boolean, + thetaStart?: number, + thetaLength?: number + ); +} diff --git a/src/geometries/CylinderGeometry.d.ts b/src/geometries/CylinderGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4e777b0f9103309ad19be9ac1e797596963263da --- /dev/null +++ b/src/geometries/CylinderGeometry.d.ts @@ -0,0 +1,58 @@ +import { Geometry } from './../core/Geometry'; +import { BufferGeometry } from '../core/BufferGeometry'; + +export class CylinderBufferGeometry extends BufferGeometry { + constructor( + radiusTop?: number, + radiusBottom?: number, + height?: number, + radialSegments?: number, + heightSegments?: number, + openEnded?: boolean, + thetaStart?: number, + thetaLength?: number + ); + + parameters: { + radiusTop: number; + radiusBottom: number; + height: number; + radialSegments: number; + heightSegments: number; + openEnded: boolean; + thetaStart: number; + thetaLength: number; + }; +} + +export class CylinderGeometry extends Geometry { + /** + * @param radiusTop — Radius of the cylinder at the top. + * @param radiusBottom — Radius of the cylinder at the bottom. + * @param height — Height of the cylinder. + * @param radiusSegments — Number of segmented faces around the circumference of the cylinder. + * @param heightSegments — Number of rows of faces along the height of the cylinder. + * @param openEnded - A Boolean indicating whether or not to cap the ends of the cylinder. + */ + constructor( + radiusTop?: number, + radiusBottom?: number, + height?: number, + radiusSegments?: number, + heightSegments?: number, + openEnded?: boolean, + thetaStart?: number, + thetaLength?: number + ); + + parameters: { + radiusTop: number; + radiusBottom: number; + height: number; + radialSegments: number; + heightSegments: number; + openEnded: boolean; + thetaStart: number; + thetaLength: number; + }; +} diff --git a/src/geometries/DodecahedronGeometry.d.ts b/src/geometries/DodecahedronGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..587490ad1bfac1b8fb4fd685d4fcb82e59faa2d3 --- /dev/null +++ b/src/geometries/DodecahedronGeometry.d.ts @@ -0,0 +1,15 @@ +import { Geometry } from './../core/Geometry'; +import { PolyhedronBufferGeometry } from './PolyhedronGeometry'; + +export class DodecahedronBufferGeometry extends PolyhedronBufferGeometry { + constructor(radius?: number, detail?: number); +} + +export class DodecahedronGeometry extends Geometry { + constructor(radius?: number, detail?: number); + + parameters: { + radius: number; + detail: number; + }; +} diff --git a/src/geometries/EdgesGeometry.d.ts b/src/geometries/EdgesGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3f8d203ab86b5a5208a897c2f37b540d32e2839b --- /dev/null +++ b/src/geometries/EdgesGeometry.d.ts @@ -0,0 +1,6 @@ +import { BufferGeometry } from '../core/BufferGeometry'; +import { Geometry } from '../core/Geometry'; + +export class EdgesGeometry extends BufferGeometry { + constructor(geometry: BufferGeometry | Geometry, thresholdAngle?: number); +} diff --git a/src/geometries/ExtrudeGeometry.d.ts b/src/geometries/ExtrudeGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..475d201f12c82e60348be77f3ab34f1b1b6c9cdc --- /dev/null +++ b/src/geometries/ExtrudeGeometry.d.ts @@ -0,0 +1,55 @@ +import { CurvePath } from './../extras/core/CurvePath'; +import { UVGenerator } from './ExtrudeGeometry'; +import { Vector2 } from './../math/Vector2'; +import { Vector3 } from './../math/Vector3'; +import { Shape } from './../extras/core/Shape'; +import { Geometry } from './../core/Geometry'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export interface ExtrudeGeometryOptions { + curveSegments?: number; + steps?: number; + depth?: number; + bevelEnabled?: boolean; + bevelThickness?: number; + bevelSize?: number; + bevelSegments?: number; + extrudePath?: CurvePath; + UVGenerator?: UVGenerator; +} + +export interface UVGenerator { + generateTopUV( + geometry: ExtrudeBufferGeometry, + vertices: number[], + indexA: number, + indexB: number, + indexC: number + ): Vector2[]; + generateSideWallUV( + geometry: ExtrudeBufferGeometry, + vertices: number[], + indexA: number, + indexB: number, + indexC: number, + indexD: number + ): Vector2[]; +} + +export class ExtrudeBufferGeometry extends BufferGeometry { + constructor(shapes: Shape | Shape[], options?: ExtrudeGeometryOptions); + + static WorldUVGenerator: UVGenerator; + + addShapeList(shapes: Shape[], options?: any): void; + addShape(shape: Shape, options?: any): void; +} + +export class ExtrudeGeometry extends Geometry { + constructor(shapes: Shape | Shape[], options?: ExtrudeGeometryOptions); + + static WorldUVGenerator: UVGenerator; + + addShapeList(shapes: Shape[], options?: any): void; + addShape(shape: Shape, options?: any): void; +} diff --git a/src/geometries/Geometries.d.ts b/src/geometries/Geometries.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1cfc9b209eee24f96c5710ef353d92c599dac266 --- /dev/null +++ b/src/geometries/Geometries.d.ts @@ -0,0 +1,43 @@ +export { WireframeGeometry } from './WireframeGeometry'; +export { + ParametricGeometry, + ParametricBufferGeometry, +} from './ParametricGeometry'; +export { + TetrahedronGeometry, + TetrahedronBufferGeometry, +} from './TetrahedronGeometry'; +export { + OctahedronGeometry, + OctahedronBufferGeometry, +} from './OctahedronGeometry'; +export { + IcosahedronGeometry, + IcosahedronBufferGeometry, +} from './IcosahedronGeometry'; +export { + DodecahedronGeometry, + DodecahedronBufferGeometry, +} from './DodecahedronGeometry'; +export { + PolyhedronGeometry, + PolyhedronBufferGeometry, +} from './PolyhedronGeometry'; +export { TubeGeometry, TubeBufferGeometry } from './TubeGeometry'; +export { + TorusKnotGeometry, + TorusKnotBufferGeometry, +} from './TorusKnotGeometry'; +export { TorusGeometry, TorusBufferGeometry } from './TorusGeometry'; +export { TextGeometry, TextBufferGeometry } from './TextGeometry'; +export { SphereGeometry, SphereBufferGeometry } from './SphereGeometry'; +export { RingGeometry, RingBufferGeometry } from './RingGeometry'; +export { PlaneGeometry, PlaneBufferGeometry } from './PlaneGeometry'; +export { LatheGeometry, LatheBufferGeometry } from './LatheGeometry'; +export { ShapeGeometry, ShapeBufferGeometry } from './ShapeGeometry'; +export { ExtrudeGeometry, ExtrudeBufferGeometry } from './ExtrudeGeometry'; +export { EdgesGeometry } from './EdgesGeometry'; +export { ConeGeometry, ConeBufferGeometry } from './ConeGeometry'; +export { CylinderGeometry, CylinderBufferGeometry } from './CylinderGeometry'; +export { CircleGeometry, CircleBufferGeometry } from './CircleGeometry'; +export { BoxGeometry, BoxBufferGeometry } from './BoxGeometry'; diff --git a/src/geometries/IcosahedronGeometry.d.ts b/src/geometries/IcosahedronGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f21a04f01ca12328739fec1e0dbcde4cfe2bd309 --- /dev/null +++ b/src/geometries/IcosahedronGeometry.d.ts @@ -0,0 +1,14 @@ +import { Shape } from './../extras/core/Shape'; +import { UVGenerator } from './ExtrudeGeometry'; +import { + PolyhedronGeometry, + PolyhedronBufferGeometry, +} from './PolyhedronGeometry'; + +export class IcosahedronBufferGeometry extends PolyhedronBufferGeometry { + constructor(radius?: number, detail?: number); +} + +export class IcosahedronGeometry extends PolyhedronGeometry { + constructor(radius?: number, detail?: number); +} diff --git a/src/geometries/LatheGeometry.d.ts b/src/geometries/LatheGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f23e7687dae4e2c4de3a1f4b515f1e1d2a2fc2dd --- /dev/null +++ b/src/geometries/LatheGeometry.d.ts @@ -0,0 +1,35 @@ +import { Vector2 } from './../math/Vector2'; +import { Geometry } from './../core/Geometry'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export class LatheBufferGeometry extends BufferGeometry { + constructor( + points: Vector2[], + segments?: number, + phiStart?: number, + phiLength?: number + ); + + parameters: { + points: Vector2[]; + segments: number; + phiStart: number; + phiLength: number; + }; +} + +export class LatheGeometry extends Geometry { + constructor( + points: Vector2[], + segments?: number, + phiStart?: number, + phiLength?: number + ); + + parameters: { + points: Vector2[]; + segments: number; + phiStart: number; + phiLength: number; + }; +} diff --git a/src/geometries/OctahedronGeometry.d.ts b/src/geometries/OctahedronGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d7f0f4092a477c7b2317a8ef374933642b8b1f64 --- /dev/null +++ b/src/geometries/OctahedronGeometry.d.ts @@ -0,0 +1,12 @@ +import { + PolyhedronGeometry, + PolyhedronBufferGeometry, +} from './PolyhedronGeometry'; + +export class OctahedronBufferGeometry extends PolyhedronBufferGeometry { + constructor(radius?: number, detail?: number); +} + +export class OctahedronGeometry extends PolyhedronGeometry { + constructor(radius?: number, detail?: number); +} diff --git a/src/geometries/ParametricGeometry.d.ts b/src/geometries/ParametricGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f988197a92ab5a60484283b569c621ca5a3762a7 --- /dev/null +++ b/src/geometries/ParametricGeometry.d.ts @@ -0,0 +1,31 @@ +import { Vector3 } from './../math/Vector3'; +import { Geometry } from './../core/Geometry'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export class ParametricBufferGeometry extends BufferGeometry { + constructor( + func: (u: number, v: number, dest: Vector3) => void, + slices: number, + stacks: number + ); + + parameters: { + func: (u: number, v: number, dest: Vector3) => void; + slices: number; + stacks: number; + }; +} + +export class ParametricGeometry extends Geometry { + constructor( + func: (u: number, v: number, dest: Vector3) => void, + slices: number, + stacks: number + ); + + parameters: { + func: (u: number, v: number, dest: Vector3) => void; + slices: number; + stacks: number; + }; +} diff --git a/src/geometries/PlaneGeometry.d.ts b/src/geometries/PlaneGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f6dd7e02c4b88f394e7b5e183b3b945797ca071c --- /dev/null +++ b/src/geometries/PlaneGeometry.d.ts @@ -0,0 +1,34 @@ +import { Geometry } from './../core/Geometry'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export class PlaneBufferGeometry extends BufferGeometry { + constructor( + width?: number, + height?: number, + widthSegments?: number, + heightSegments?: number + ); + + parameters: { + width: number; + height: number; + widthSegments: number; + heightSegments: number; + }; +} + +export class PlaneGeometry extends Geometry { + constructor( + width?: number, + height?: number, + widthSegments?: number, + heightSegments?: number + ); + + parameters: { + width: number; + height: number; + widthSegments: number; + heightSegments: number; + }; +} diff --git a/src/geometries/PolyhedronGeometry.d.ts b/src/geometries/PolyhedronGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ea4f59b946a385f22d30796de09f3091e677b36b --- /dev/null +++ b/src/geometries/PolyhedronGeometry.d.ts @@ -0,0 +1,36 @@ +import { Sphere } from './../math/Sphere'; +import { Geometry } from './../core/Geometry'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export class PolyhedronBufferGeometry extends BufferGeometry { + constructor( + vertices: number[], + indices: number[], + radius?: number, + detail?: number + ); + + parameters: { + vertices: number[]; + indices: number[]; + radius: number; + detail: number; + }; +} + +export class PolyhedronGeometry extends Geometry { + constructor( + vertices: number[], + indices: number[], + radius?: number, + detail?: number + ); + + parameters: { + vertices: number[]; + indices: number[]; + radius: number; + detail: number; + }; + boundingSphere: Sphere; +} diff --git a/src/geometries/RingGeometry.d.ts b/src/geometries/RingGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fe902dab64eea5fab43f6355ae735a7453f7710e --- /dev/null +++ b/src/geometries/RingGeometry.d.ts @@ -0,0 +1,42 @@ +import { Geometry } from './../core/Geometry'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export class RingBufferGeometry extends BufferGeometry { + constructor( + innerRadius?: number, + outerRadius?: number, + thetaSegments?: number, + phiSegments?: number, + thetaStart?: number, + thetaLength?: number + ); + + parameters: { + innerRadius: number; + outerRadius: number; + thetaSegments: number; + phiSegments: number; + thetaStart: number; + thetaLength: number; + }; +} + +export class RingGeometry extends Geometry { + constructor( + innerRadius?: number, + outerRadius?: number, + thetaSegments?: number, + phiSegments?: number, + thetaStart?: number, + thetaLength?: number + ); + + parameters: { + innerRadius: number; + outerRadius: number; + thetaSegments: number; + phiSegments: number; + thetaStart: number; + thetaLength: number; + }; +} diff --git a/src/geometries/ShapeGeometry.d.ts b/src/geometries/ShapeGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..12c26af7412769f2c96cc51a49a3ffc066f492cd --- /dev/null +++ b/src/geometries/ShapeGeometry.d.ts @@ -0,0 +1,14 @@ +import { Shape } from './../extras/core/Shape'; +import { Geometry } from './../core/Geometry'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export class ShapeBufferGeometry extends BufferGeometry { + constructor(shapes: Shape | Shape[], curveSegments?: number); +} + +export class ShapeGeometry extends Geometry { + constructor(shapes: Shape | Shape[], curveSegments?: number); + + addShapeList(shapes: Shape[], options: any): ShapeGeometry; + addShape(shape: Shape, options?: any): void; +} diff --git a/src/geometries/SphereGeometry.d.ts b/src/geometries/SphereGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e21bd61a82a36d05f25d831bc55c50875f4b3c3c --- /dev/null +++ b/src/geometries/SphereGeometry.d.ts @@ -0,0 +1,61 @@ +import { Shape } from './../extras/core/Shape'; +import { Geometry } from './../core/Geometry'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export class SphereBufferGeometry extends BufferGeometry { + constructor( + radius?: number, + widthSegments?: number, + heightSegments?: number, + phiStart?: number, + phiLength?: number, + thetaStart?: number, + thetaLength?: number + ); + + parameters: { + radius: number; + widthSegments: number; + heightSegments: number; + phiStart: number; + phiLength: number; + thetaStart: number; + thetaLength: number; + }; +} + +/** + * A class for generating sphere geometries + */ +export class SphereGeometry extends Geometry { + /** + * The geometry is created by sweeping and calculating vertexes around the Y axis (horizontal sweep) and the Z axis (vertical sweep). Thus, incomplete spheres (akin to 'sphere slices') can be created through the use of different values of phiStart, phiLength, thetaStart and thetaLength, in order to define the points in which we start (or end) calculating those vertices. + * + * @param radius — sphere radius. Default is 50. + * @param widthSegments — number of horizontal segments. Minimum value is 3, and the default is 8. + * @param heightSegments — number of vertical segments. Minimum value is 2, and the default is 6. + * @param phiStart — specify horizontal starting angle. Default is 0. + * @param phiLength — specify horizontal sweep angle size. Default is Math.PI * 2. + * @param thetaStart — specify vertical starting angle. Default is 0. + * @param thetaLength — specify vertical sweep angle size. Default is Math.PI. + */ + constructor( + radius?: number, + widthSegments?: number, + heightSegments?: number, + phiStart?: number, + phiLength?: number, + thetaStart?: number, + thetaLength?: number + ); + + parameters: { + radius: number; + widthSegments: number; + heightSegments: number; + phiStart: number; + phiLength: number; + thetaStart: number; + thetaLength: number; + }; +} diff --git a/src/geometries/TetrahedronGeometry.d.ts b/src/geometries/TetrahedronGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..de0f3f1e5439c735b14e77faaa47419cf02a1416 --- /dev/null +++ b/src/geometries/TetrahedronGeometry.d.ts @@ -0,0 +1,11 @@ +import { PolyhedronGeometry } from './PolyhedronGeometry'; +import { BufferGeometry } from './../core/BufferGeometry'; +import { PolyhedronBufferGeometry } from './PolyhedronGeometry'; + +export class TetrahedronBufferGeometry extends PolyhedronBufferGeometry { + constructor(radius?: number, detail?: number); +} + +export class TetrahedronGeometry extends PolyhedronGeometry { + constructor(radius?: number, detail?: number); +} diff --git a/src/geometries/TextGeometry.d.ts b/src/geometries/TextGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c5bc606df116fadf36f5dd427a695734d626351 --- /dev/null +++ b/src/geometries/TextGeometry.d.ts @@ -0,0 +1,44 @@ +import { Font } from './../extras/core/Font'; +import { ExtrudeGeometry, ExtrudeBufferGeometry } from './ExtrudeGeometry'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export interface TextGeometryParameters { + font?: Font; + size?: number; + height?: number; + curveSegments?: number; + bevelEnabled?: boolean; + bevelThickness?: number; + bevelSize?: number; + bevelSegments?: number; +} + +export class TextBufferGeometry extends ExtrudeBufferGeometry { + constructor(text: string, parameters?: TextGeometryParameters); + + parameters: { + font: Font; + size: number; + height: number; + curveSegments: number; + bevelEnabled: boolean; + bevelThickness: number; + bevelSize: number; + bevelSegments: number; + }; +} + +export class TextGeometry extends ExtrudeGeometry { + constructor(text: string, parameters?: TextGeometryParameters); + + parameters: { + font: Font; + size: number; + height: number; + curveSegments: number; + bevelEnabled: boolean; + bevelThickness: number; + bevelSize: number; + bevelSegments: number; + }; +} diff --git a/src/geometries/TorusGeometry.d.ts b/src/geometries/TorusGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..059a0f4d031e6eafbd8e5219c16068e8c56c111a --- /dev/null +++ b/src/geometries/TorusGeometry.d.ts @@ -0,0 +1,40 @@ +import { TextGeometryParameters } from './TextGeometry'; +import { Font } from './../extras/core/Font'; +import { Geometry } from './../core/Geometry'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export class TorusBufferGeometry extends BufferGeometry { + constructor( + radius?: number, + tube?: number, + radialSegments?: number, + tubularSegments?: number, + arc?: number + ); + + parameters: { + radius: number; + tube: number; + radialSegments: number; + tubularSegments: number; + arc: number; + }; +} + +export class TorusGeometry extends Geometry { + constructor( + radius?: number, + tube?: number, + radialSegments?: number, + tubularSegments?: number, + arc?: number + ); + + parameters: { + radius: number; + tube: number; + radialSegments: number; + tubularSegments: number; + arc: number; + }; +} diff --git a/src/geometries/TorusKnotGeometry.d.ts b/src/geometries/TorusKnotGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..56307a1052039ef277d092018cbdba6231b74602 --- /dev/null +++ b/src/geometries/TorusKnotGeometry.d.ts @@ -0,0 +1,44 @@ +import { Geometry } from './../core/Geometry'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export class TorusKnotBufferGeometry extends BufferGeometry { + constructor( + radius?: number, + tube?: number, + tubularSegments?: number, + radialSegments?: number, + p?: number, + q?: number + ); + + parameters: { + radius: number; + tube: number; + tubularSegments: number; + radialSegments: number; + p: number; + q: number; + heightScale: number; + }; +} + +export class TorusKnotGeometry extends Geometry { + constructor( + radius?: number, + tube?: number, + tubularSegments?: number, + radialSegments?: number, + p?: number, + q?: number + ); + + parameters: { + radius: number; + tube: number; + tubularSegments: number; + radialSegments: number; + p: number; + q: number; + heightScale: number; + }; +} diff --git a/src/geometries/TubeGeometry.d.ts b/src/geometries/TubeGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1da3bd37f893d38b21d863526e00e2f0ca2d3678 --- /dev/null +++ b/src/geometries/TubeGeometry.d.ts @@ -0,0 +1,46 @@ +import { Curve } from './../extras/core/Curve'; +import { Vector3 } from './../math/Vector3'; +import { Geometry } from './../core/Geometry'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export class TubeBufferGeometry extends BufferGeometry { + constructor( + path: Curve, + tubularSegments?: number, + radius?: number, + radiusSegments?: number, + closed?: boolean + ); + + parameters: { + path: Curve; + tubularSegments: number; + radius: number; + radialSegments: number; + closed: boolean; + }; + tangents: Vector3[]; + normals: Vector3[]; + binormals: Vector3[]; +} + +export class TubeGeometry extends Geometry { + constructor( + path: Curve, + tubularSegments?: number, + radius?: number, + radiusSegments?: number, + closed?: boolean + ); + + parameters: { + path: Curve; + tubularSegments: number; + radius: number; + radialSegments: number; + closed: boolean; + }; + tangents: Vector3[]; + normals: Vector3[]; + binormals: Vector3[]; +} diff --git a/src/geometries/WireframeGeometry.d.ts b/src/geometries/WireframeGeometry.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a60dbdd22cfb0b6b820bf0f1e3a3e103da099ce --- /dev/null +++ b/src/geometries/WireframeGeometry.d.ts @@ -0,0 +1,8 @@ +import { Curve } from './../extras/core/Curve'; +import { Vector3 } from './../math/Vector3'; +import { Geometry } from './../core/Geometry'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export class WireframeGeometry extends BufferGeometry { + constructor(geometry: Geometry | BufferGeometry); +} diff --git a/src/helpers/ArrowHelper.d.ts b/src/helpers/ArrowHelper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..57c1d30689fb97a4c62bce6df1955fbeb4a4a9d7 --- /dev/null +++ b/src/helpers/ArrowHelper.d.ts @@ -0,0 +1,25 @@ +import { Vector3 } from './../math/Vector3'; +import { Line } from './../objects/Line'; +import { Mesh } from './../objects/Mesh'; +import { Color } from './../math/Color'; +import { Object3D } from './../core/Object3D'; + +// Extras / Helpers ///////////////////////////////////////////////////////////////////// + +export class ArrowHelper extends Object3D { + constructor( + dir: Vector3, + origin?: Vector3, + length?: number, + hex?: number, + headLength?: number, + headWidth?: number + ); + + line: Line; + cone: Mesh; + + setDirection(dir: Vector3): void; + setLength(length: number, headLength?: number, headWidth?: number): void; + setColor(color: Color): void; +} diff --git a/src/helpers/AxesHelper.d.ts b/src/helpers/AxesHelper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..020997a3882a23daec7ff7403f0d22c289250024 --- /dev/null +++ b/src/helpers/AxesHelper.d.ts @@ -0,0 +1,5 @@ +import { LineSegments } from './../objects/LineSegments'; + +export class AxesHelper extends LineSegments { + constructor(size?: number); +} diff --git a/src/helpers/Box3Helper.d.ts b/src/helpers/Box3Helper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0033bc1259b0a8a09ef1dbe2014a24b91ad50683 --- /dev/null +++ b/src/helpers/Box3Helper.d.ts @@ -0,0 +1,11 @@ +import { Object3D } from './../core/Object3D'; +import { Box3 } from './../math/Box3'; +import { Color } from './../math/Color'; +import { LineSegments } from './../objects/LineSegments'; + +export class Box3Helper { + constructor(object?: Object3D, color?: Color); + + type: string; + box: Box3; +} diff --git a/src/helpers/BoxHelper.d.ts b/src/helpers/BoxHelper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8e3e35debe1487e4042399770527fa6d4518e1fb --- /dev/null +++ b/src/helpers/BoxHelper.d.ts @@ -0,0 +1,22 @@ +import { Object3D } from './../core/Object3D'; +import { Box3 } from './../math/Box3'; +import { Color } from './../math/Color'; +import { LineSegments } from './../objects/LineSegments'; + +/** + * @deprecated Use {@link BoxHelper THREE.BoxHelper} instead. + */ +// export class BoundingBoxHelper extends Mesh { +// constructor(object?: Object3D, hex?: number); + +// object: Object3D; +// box: Box3; + +// update(): void; +// } + +export class BoxHelper extends LineSegments { + constructor(object?: Object3D, color?: Color); + + update(object?: Object3D): void; +} diff --git a/src/helpers/CameraHelper.d.ts b/src/helpers/CameraHelper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..52d44f1375191acf0f6f51597104af3d2e58cdac --- /dev/null +++ b/src/helpers/CameraHelper.d.ts @@ -0,0 +1,11 @@ +import { Camera } from './../cameras/Camera'; +import { LineSegments } from './../objects/LineSegments'; + +export class CameraHelper extends LineSegments { + constructor(camera: Camera); + + camera: Camera; + pointMap: { [id: string]: number[] }; + + update(): void; +} diff --git a/src/helpers/DirectionalLightHelper.d.ts b/src/helpers/DirectionalLightHelper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7fdd976b05c94d13d39164e5022c366d19098a68 --- /dev/null +++ b/src/helpers/DirectionalLightHelper.d.ts @@ -0,0 +1,23 @@ +import { DirectionalLight } from './../lights/DirectionalLight'; +import { Color } from './../math/Color'; +import { Line } from './../objects/Line'; +import { Matrix4 } from './../math/Matrix4'; +import { Object3D } from './../core/Object3D'; + +export class DirectionalLightHelper extends Object3D { + constructor( + light: DirectionalLight, + size?: number, + color?: Color | string | number + ); + + light: DirectionalLight; + lightPlane: Line; + targetPlane: Line; + color: Color | string | number | undefined; + matrix: Matrix4; + matrixAutoUpdate: boolean; + + dispose(): void; + update(): void; +} diff --git a/src/helpers/FaceNormalsHelper.d.ts b/src/helpers/FaceNormalsHelper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4f1564f62a4e935193661a962e257d859a3ab88d --- /dev/null +++ b/src/helpers/FaceNormalsHelper.d.ts @@ -0,0 +1,23 @@ +import { Object3D } from './../core/Object3D'; +import { LineSegments } from './../objects/LineSegments'; + +/** + * @deprecated Use {@link EdgesGeometry THREE.EdgesGeometry} + */ +// export class EdgesHelper extends LineSegments { +// constructor(object: Object3D, hex?: number, thresholdAngle?: number); +// } + +export class FaceNormalsHelper extends LineSegments { + constructor( + object: Object3D, + size?: number, + hex?: number, + linewidth?: number + ); + + object: Object3D; + size: number; + + update(object?: Object3D): void; +} diff --git a/src/helpers/GridHelper.d.ts b/src/helpers/GridHelper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..71d163e50b64dafc8107848a755c74067cd1c913 --- /dev/null +++ b/src/helpers/GridHelper.d.ts @@ -0,0 +1,15 @@ +import { Color } from './../math/Color'; +import { LineSegments } from './../objects/LineSegments'; + +export class GridHelper extends LineSegments { + constructor( + size: number, + divisions: number, + color1?: Color | number, + color2?: Color | number + ); + /** + * @deprecated Colors should be specified in the constructor. + */ + setColors(color1?: Color | number, color2?: Color | number): void; +} diff --git a/src/helpers/HemisphereLightHelper.d.ts b/src/helpers/HemisphereLightHelper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..74cc4c8a4662afb63d6cb32d01da63648d21f9d6 --- /dev/null +++ b/src/helpers/HemisphereLightHelper.d.ts @@ -0,0 +1,23 @@ +import { HemisphereLight } from './../lights/HemisphereLight'; +import { Color } from './../math/Color'; +import { Matrix4 } from './../math/Matrix4'; +import { MeshBasicMaterial } from './../materials/MeshBasicMaterial'; +import { Object3D } from './../core/Object3D'; + +export class HemisphereLightHelper extends Object3D { + constructor( + light: HemisphereLight, + size: number, + color?: Color | number | string + ); + + light: HemisphereLight; + matrix: Matrix4; + matrixAutoUpdate: boolean; + material: MeshBasicMaterial; + + color: Color | string | number | undefined; + + dispose(): void; + update(): void; +} diff --git a/src/helpers/PlaneHelper.d.ts b/src/helpers/PlaneHelper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4d1e7061c2d50418c9521b0eca6f4b26d0aab37b --- /dev/null +++ b/src/helpers/PlaneHelper.d.ts @@ -0,0 +1,11 @@ +import { Plane } from './../math/Plane'; +import { LineSegments } from './../objects/LineSegments'; + +export class PlaneHelper extends LineSegments { + constructor(plane: Plane, size?: number, hex?: number); + + plane: Plane; + size: number; + + updateMatrixWorld(force: boolean): void; +} diff --git a/src/helpers/PointLightHelper.d.ts b/src/helpers/PointLightHelper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..31685ca2eac43c39edccac5c047697baced02fc0 --- /dev/null +++ b/src/helpers/PointLightHelper.d.ts @@ -0,0 +1,20 @@ +import { PointLight } from './../lights/PointLight'; +import { Color } from './../math/Color'; +import { Matrix4 } from './../math/Matrix4'; +import { Object3D } from './../core/Object3D'; + +export class PointLightHelper extends Object3D { + constructor( + light: PointLight, + sphereSize?: number, + color?: Color | string | number + ); + + light: PointLight; + color: Color | string | number | undefined; + matrix: Matrix4; + matrixAutoUpdate: boolean; + + dispose(): void; + update(): void; +} diff --git a/src/helpers/PolarGridHelper.d.ts b/src/helpers/PolarGridHelper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..977c1ca2e9e3691728f4a64239e72a4ed30b3250 --- /dev/null +++ b/src/helpers/PolarGridHelper.d.ts @@ -0,0 +1,17 @@ +import { LineSegments } from '../objects/LineSegments'; +import { VertexColors } from '../constants.js'; +import { LineBasicMaterial } from '../materials/LineBasicMaterial'; +import { Float32BufferAttribute } from '../core/BufferAttribute'; +import { BufferGeometry } from '../core/BufferGeometry'; +import { Color } from '../math/Color'; + +export class PolarGridHelper { + constructor( + radius: number, + radials: number, + circles: number, + divisions: number, + color1: Color | string | number | undefined, + color2: Color | string | number | undefined + ); +} diff --git a/src/helpers/RectAreaLightHelper.d.ts b/src/helpers/RectAreaLightHelper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..248fbb9b539cd89cd7cd8b3fbf91b1c444daa96c --- /dev/null +++ b/src/helpers/RectAreaLightHelper.d.ts @@ -0,0 +1,11 @@ +import { RectAreaLight } from './../lights/RectAreaLight'; +import { Color } from './../math/Color'; +//import { Matrix4 } from './../math/Matrix4'; +//import { Object3D } from './../core/Object3D'; + +export class RectAreaLightHelper { + constructor(light: RectAreaLight, color?: Color | string | number); + + light: RectAreaLight; + color: Color | string | number | undefined; +} diff --git a/src/helpers/SkeletonHelper.d.ts b/src/helpers/SkeletonHelper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..98c7cb683875fff01c47f4d14068bdd3baf0e44a --- /dev/null +++ b/src/helpers/SkeletonHelper.d.ts @@ -0,0 +1,13 @@ +import { Object3D } from './../core/Object3D'; +import { Bone } from './../objects/Bone'; +import { LineSegments } from './../objects/LineSegments'; + +export class SkeletonHelper extends LineSegments { + constructor(bone: Object3D); + + bones: Bone[]; + root: Object3D; + + getBoneList(object: Object3D): Bone[]; + update(): void; +} diff --git a/src/helpers/SpotLightHelper.d.ts b/src/helpers/SpotLightHelper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6b2d04234b2acd8dbcf3c3db7fff5a3793abd50f --- /dev/null +++ b/src/helpers/SpotLightHelper.d.ts @@ -0,0 +1,16 @@ +import { Light } from './../lights/Light'; +import { Color } from './../math/Color'; +import { Matrix4 } from './../math/Matrix4'; +import { Object3D } from './../core/Object3D'; + +export class SpotLightHelper extends Object3D { + constructor(light: Light, color?: Color | string | number); + + light: Light; + matrix: Matrix4; + matrixAutoUpdate: boolean; + color: Color | string | number | undefined; + + dispose(): void; + update(): void; +} diff --git a/src/helpers/VertexNormalsHelper.d.ts b/src/helpers/VertexNormalsHelper.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6757419a6fc741401c98e02c1b6a4ecc6a6a25be --- /dev/null +++ b/src/helpers/VertexNormalsHelper.d.ts @@ -0,0 +1,16 @@ +import { Object3D } from './../core/Object3D'; +import { LineSegments } from './../objects/LineSegments'; + +export class VertexNormalsHelper extends LineSegments { + constructor( + object: Object3D, + size?: number, + hex?: number, + linewidth?: number + ); + + object: Object3D; + size: number; + + update(object?: Object3D): void; +} diff --git a/src/lights/AmbientLight.d.ts b/src/lights/AmbientLight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bc355048c2f0ed394bdc8d6f0a6696e40f92526a --- /dev/null +++ b/src/lights/AmbientLight.d.ts @@ -0,0 +1,21 @@ +import { Color } from './../math/Color'; +import { Light } from './Light'; + +/** + * This light's color gets applied to all the objects in the scene globally. + * + * # example + * var light = new THREE.AmbientLight( 0x404040 ); // soft white light + * scene.add( light ); + * + * @source https://github.com/mrdoob/three.js/blob/master/src/lights/AmbientLight.js + */ +export class AmbientLight extends Light { + /** + * This creates a Ambientlight with a color. + * @param color Numeric value of the RGB component of the color or a Color instance. + */ + constructor(color?: Color | string | number, intensity?: number); + + castShadow: boolean; +} diff --git a/src/lights/DirectionalLight.d.ts b/src/lights/DirectionalLight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e46637eafdfcf417307dee38f18f421c7f910cef --- /dev/null +++ b/src/lights/DirectionalLight.d.ts @@ -0,0 +1,32 @@ +import { Color } from './../math/Color'; +import { Object3D } from './../core/Object3D'; +import { DirectionalLightShadow } from './DirectionalLightShadow'; +import { Light } from './Light'; + +/** + * Affects objects using MeshLambertMaterial or MeshPhongMaterial. + * + * @example + * // White directional light at half intensity shining from the top. + * var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 ); + * directionalLight.position.set( 0, 1, 0 ); + * scene.add( directionalLight ); + * + * @see src/lights/DirectionalLight.js + */ +export class DirectionalLight extends Light { + constructor(color?: Color | string | number, intensity?: number); + + /** + * Target used for shadow camera orientation. + */ + target: Object3D; + + /** + * Light's intensity. + * Default — 1.0. + */ + intensity: number; + + shadow: DirectionalLightShadow; +} diff --git a/src/lights/DirectionalLightShadow.d.ts b/src/lights/DirectionalLightShadow.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..190c092272e0195fcb2575dcc9d852a53765b487 --- /dev/null +++ b/src/lights/DirectionalLightShadow.d.ts @@ -0,0 +1,6 @@ +import { OrthographicCamera } from './../cameras/OrthographicCamera'; +import { LightShadow } from './LightShadow'; + +export class DirectionalLightShadow extends LightShadow { + camera: OrthographicCamera; +} diff --git a/src/lights/HemisphereLight.d.ts b/src/lights/HemisphereLight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4df2e73ac00723ea0b3e8c8d2be9309436923d9b --- /dev/null +++ b/src/lights/HemisphereLight.d.ts @@ -0,0 +1,14 @@ +import { Color } from './../math/Color'; +import { Light } from './Light'; + +export class HemisphereLight extends Light { + constructor( + skyColor?: Color | string | number, + groundColor?: Color | string | number, + intensity?: number + ); + + skyColor: Color; + groundColor: Color; + intensity: number; +} diff --git a/src/lights/Light.d.ts b/src/lights/Light.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f893bf4cde1dfc4892f3250b74c4e128b2eeccfc --- /dev/null +++ b/src/lights/Light.d.ts @@ -0,0 +1,57 @@ +import { Color } from './../math/Color'; +import { LightShadow } from './LightShadow'; +import { Object3D } from './../core/Object3D'; + +// Lights ////////////////////////////////////////////////////////////////////////////////// + +/** + * Abstract base class for lights. + */ +export class Light extends Object3D { + constructor(hex?: number | string, intensity?: number); + + color: Color; + intensity: number; + receiveShadow: boolean; + shadow: LightShadow; + /** + * @deprecated Use shadow.camera.fov instead. + */ + shadowCameraFov: any; + /** + * @deprecated Use shadow.camera.left instead. + */ + shadowCameraLeft: any; + /** + * @deprecated Use shadow.camera.right instead. + */ + shadowCameraRight: any; + /** + * @deprecated Use shadow.camera.top instead. + */ + shadowCameraTop: any; + /** + * @deprecated Use shadow.camera.bottom instead. + */ + shadowCameraBottom: any; + /** + * @deprecated Use shadow.camera.near instead. + */ + shadowCameraNear: any; + /** + * @deprecated Use shadow.camera.far instead. + */ + shadowCameraFar: any; + /** + * @deprecated Use shadow.bias instead. + */ + shadowBias: any; + /** + * @deprecated Use shadow.mapSize.width instead. + */ + shadowMapWidth: any; + /** + * @deprecated Use shadow.mapSize.height instead. + */ + shadowMapHeight: any; +} diff --git a/src/lights/LightShadow.d.ts b/src/lights/LightShadow.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d588b0b7873c6529f9d763ac58059fbbcb348281 --- /dev/null +++ b/src/lights/LightShadow.d.ts @@ -0,0 +1,19 @@ +import { Camera } from './../cameras/Camera'; +import { Vector2 } from './../math/Vector2'; +import { Matrix4 } from './../math/Matrix4'; +import { RenderTarget } from '../renderers/webgl/WebGLRenderLists'; + +export class LightShadow { + constructor(camera: Camera); + + camera: Camera; + bias: number; + radius: number; + mapSize: Vector2; + map: RenderTarget; + matrix: Matrix4; + + copy(source: LightShadow): this; + clone(recursive?: boolean): this; + toJSON(): any; +} diff --git a/src/lights/PointLight.d.ts b/src/lights/PointLight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..97247a39f5ce37e56f3353e92883e63f29f03ca7 --- /dev/null +++ b/src/lights/PointLight.d.ts @@ -0,0 +1,41 @@ +import { Color } from './../math/Color'; +import { Light } from './Light'; +import { PerspectiveCamera } from './../cameras/PerspectiveCamera'; +import { LightShadow } from './LightShadow'; + +export class PointLightShadow extends LightShadow { + camera: PerspectiveCamera; +} + +/** + * Affects objects using {@link MeshLambertMaterial} or {@link MeshPhongMaterial}. + * + * @example + * var light = new THREE.PointLight( 0xff0000, 1, 100 ); + * light.position.set( 50, 50, 50 ); + * scene.add( light ); + */ +export class PointLight extends Light { + constructor( + color?: Color | string | number, + intensity?: number, + distance?: number, + decay?: number + ); + + /* + * Light's intensity. + * Default - 1.0. + */ + intensity: number; + + /** + * If non-zero, light will attenuate linearly from maximum intensity at light position down to zero at distance. + * Default — 0.0. + */ + distance: number; + + decay: number; + shadow: PointLightShadow; + power: number; +} diff --git a/src/lights/RectAreaLight.d.ts b/src/lights/RectAreaLight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fa4dd47b66b658c95c03325b1ccfe0ec8c571a4d --- /dev/null +++ b/src/lights/RectAreaLight.d.ts @@ -0,0 +1,16 @@ +import { Light } from './Light'; +import { Color } from './../math/Color'; + +export class RectAreaLight extends Light { + constructor( + color?: Color | string | number, + intensity?: number, + width?: number, + height?: number + ); + + type: string; + width: number; + height: number; + intensity: number; +} diff --git a/src/lights/SpotLight.d.ts b/src/lights/SpotLight.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a28f73503bf9e655ca05e63af8290f0aabf033b3 --- /dev/null +++ b/src/lights/SpotLight.d.ts @@ -0,0 +1,53 @@ +import { Color } from './../math/Color'; +import { Object3D } from './../core/Object3D'; +import { SpotLightShadow } from './SpotLightShadow'; +import { Light } from './Light'; + +/** + * A point light that can cast shadow in one direction. + */ +export class SpotLight extends Light { + constructor( + color?: Color | string | number, + intensity?: number, + distance?: number, + angle?: number, + exponent?: number, + decay?: number + ); + + /** + * Spotlight focus points at target.position. + * Default position — (0,0,0). + */ + target: Object3D; + + /** + * Light's intensity. + * Default — 1.0. + */ + intensity: number; + + /** + * If non-zero, light will attenuate linearly from maximum intensity at light position down to zero at distance. + * Default — 0.0. + */ + distance: number; + + /* + * Maximum extent of the spotlight, in radians, from its direction. + * Default — Math.PI/2. + */ + angle: number; + + /** + * Rapidity of the falloff of light from its target direction. + * Default — 10.0. + */ + exponent: number; + + decay: number; + shadow: SpotLightShadow; + power: number; + penumbra: number; +} diff --git a/src/lights/SpotLightShadow.d.ts b/src/lights/SpotLightShadow.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fa59dac66a47740663652ed642f791a38cc6af9c --- /dev/null +++ b/src/lights/SpotLightShadow.d.ts @@ -0,0 +1,8 @@ +import { PerspectiveCamera } from './../cameras/PerspectiveCamera'; +import { Light } from './Light'; +import { LightShadow } from './LightShadow'; + +export class SpotLightShadow extends LightShadow { + camera: PerspectiveCamera; + update(light: Light): void; +} diff --git a/src/loaders/AnimationLoader.d.ts b/src/loaders/AnimationLoader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b44f46493a5c65afaadbf3a4f26c9382fb2be462 --- /dev/null +++ b/src/loaders/AnimationLoader.d.ts @@ -0,0 +1,16 @@ +import { LoadingManager } from './LoadingManager'; + +export class AnimationLoader { + constructor(manager?: LoadingManager); + + manager: LoadingManager; + + load( + url: string, + onLoad?: (response: string | ArrayBuffer) => void, + onProgress?: (request: ProgressEvent) => void, + onError?: (event: ErrorEvent) => void + ): any; + parse(json: any, onLoad: (response: string | ArrayBuffer) => void): void; + setPath(path: string): AnimationLoader; +} diff --git a/src/loaders/AudioLoader.d.ts b/src/loaders/AudioLoader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8e4f3396934e5178201a84da7956b81bf1bacaf8 --- /dev/null +++ b/src/loaders/AudioLoader.d.ts @@ -0,0 +1,12 @@ +import { LoadingManager } from './LoadingManager'; + +export class AudioLoader { + constructor(manager?: LoadingManager); + + load( + url: string, + onLoad: Function, + onPrgress: Function, + onError: Function + ): void; +} diff --git a/src/loaders/BufferGeometryLoader.d.ts b/src/loaders/BufferGeometryLoader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fe3148f4ddf88a2cede3a12db5a9454a465ef865 --- /dev/null +++ b/src/loaders/BufferGeometryLoader.d.ts @@ -0,0 +1,16 @@ +import { LoadingManager } from './LoadingManager'; +import { BufferGeometry } from './../core/BufferGeometry'; + +export class BufferGeometryLoader { + constructor(manager?: LoadingManager); + + manager: LoadingManager; + + load( + url: string, + onLoad: (bufferGeometry: BufferGeometry) => void, + onProgress?: (event: any) => void, + onError?: (event: any) => void + ): void; + parse(json: any): BufferGeometry; +} diff --git a/src/loaders/Cache.d.ts b/src/loaders/Cache.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..36b470c410b510d2e772e67ca4234e46fce5dab3 --- /dev/null +++ b/src/loaders/Cache.d.ts @@ -0,0 +1,9 @@ +export namespace Cache { + export let enabled: boolean; + export let files: any; + + export function add(key: string, file: any): void; + export function get(key: string): any; + export function remove(key: string): void; + export function clear(): void; +} diff --git a/src/loaders/CompressedTextureLoader.d.ts b/src/loaders/CompressedTextureLoader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..028f8e16401ed83545bd91d611cbbb09ccc2a4c9 --- /dev/null +++ b/src/loaders/CompressedTextureLoader.d.ts @@ -0,0 +1,21 @@ +import { LoadingManager } from './LoadingManager'; +import { CompressedTexture } from './../textures/CompressedTexture'; + +/** + * @deprecated since 0.84.0. Use {@link DataTextureLoader} (renamed) + */ + +export class CompressedTextureLoader { + constructor(manager?: LoadingManager); + + manager: LoadingManager; + path: string; + + load( + url: string, + onLoad: (texture: CompressedTexture) => void, + onProgress?: (event: ProgressEvent) => void, + onError?: (event: ErrorEvent) => void + ): void; + setPath(path: string): CompressedTextureLoader; +} diff --git a/src/loaders/CubeTextureLoader.d.ts b/src/loaders/CubeTextureLoader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c8eb68aef38d6174b68a8f79fc47798423574b84 --- /dev/null +++ b/src/loaders/CubeTextureLoader.d.ts @@ -0,0 +1,19 @@ +import { LoadingManager } from './LoadingManager'; +import { CubeTexture } from './../textures/CubeTexture'; + +export class CubeTextureLoader { + constructor(manager?: LoadingManager); + + manager: LoadingManager; + crossOrigin: string; + path?: string; + + load( + urls: Array, + onLoad?: (texture: CubeTexture) => void, + onProgress?: (event: ProgressEvent) => void, + onError?: (event: ErrorEvent) => void + ): CubeTexture; + setCrossOrigin(crossOrigin: string): this; + setPath(path: string): this; +} diff --git a/src/loaders/DataTextureLoader.d.ts b/src/loaders/DataTextureLoader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8e4f6ba4baf44e1da0b2bea28d58a77ceeeb7d8e --- /dev/null +++ b/src/loaders/DataTextureLoader.d.ts @@ -0,0 +1,15 @@ +import { LoadingManager } from './LoadingManager'; +import { DataTexture } from './../textures/DataTexture'; + +export class DataTextureLoader { + constructor(manager?: LoadingManager); + + manager: LoadingManager; + + load( + url: string, + onLoad: (dataTexture: DataTexture) => void, + onProgress?: (event: ProgressEvent) => void, + onError?: (event: ErrorEvent) => void + ): void; +} diff --git a/src/loaders/FileLoader.d.ts b/src/loaders/FileLoader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b66b56d48f227db51966f715b3eaf6534c89f218 --- /dev/null +++ b/src/loaders/FileLoader.d.ts @@ -0,0 +1,44 @@ +import { LoadingManager } from './LoadingManager'; +import { Loader } from './Loader'; + +/** + * Interface for all loaders + * CompressedTextureLoader don't extends Loader class, but have load method + */ +export interface AnyLoader { + load( + url: string, + onLoad?: (result: any) => void, + onProgress?: (event: ProgressEvent) => void, + onError?: (event: ErrorEvent) => void + ): any; +} + +export interface LoaderHandler { + handlers: (RegExp | AnyLoader)[]; + + add(regex: RegExp, loader: AnyLoader): void; + get(file: string): AnyLoader | null; +} + +export class FileLoader { + constructor(manager?: LoadingManager); + + manager: LoadingManager; + mimeType: MimeType; + path: string; + responseType: string; + withCredentials: string; + + load( + url: string, + onLoad?: (response: string | ArrayBuffer) => void, + onProgress?: (request: ProgressEvent) => void, + onError?: (event: ErrorEvent) => void + ): any; + setMimeType(mimeType: MimeType): FileLoader; + setPath(path: string): FileLoader; + setResponseType(responseType: string): FileLoader; + setWithCredentials(value: string): FileLoader; + setRequestHeader(value: { [header: string]: string }): FileLoader; +} diff --git a/src/loaders/FontLoader.d.ts b/src/loaders/FontLoader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a911e7fcc6db93692bbb8bae157d45525bc8e701 --- /dev/null +++ b/src/loaders/FontLoader.d.ts @@ -0,0 +1,16 @@ +import { LoadingManager } from './LoadingManager'; +import { Font } from './../extras/core/Font'; + +export class FontLoader { + constructor(manager?: LoadingManager); + + manager: LoadingManager; + + load( + url: string, + onLoad?: (responseFont: Font) => void, + onProgress?: (event: ProgressEvent) => void, + onError?: (event: ErrorEvent) => void + ): void; + parse(json: any): Font; +} diff --git a/src/loaders/ImageBitmapLoader.d.ts b/src/loaders/ImageBitmapLoader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b26e2fd2af4d1c1717ddf929cd2b203b112c16f1 --- /dev/null +++ b/src/loaders/ImageBitmapLoader.d.ts @@ -0,0 +1,17 @@ +import { LoadingManager } from './LoadingManager.js'; + +export class ImageBitmapLoader { + constructor(manager?: LoadingManager); + + manager: LoadingManager; + + setOptions(options: any): ImageBitmapLoader; + load( + url: string, + onLoad?: (response: string | ArrayBuffer) => void, + onProgress?: (request: ProgressEvent) => void, + onError?: (event: ErrorEvent) => void + ): any; + setCrossOrigin(): ImageBitmapLoader; + setPath(path: string): ImageBitmapLoader; +} diff --git a/src/loaders/ImageLoader.d.ts b/src/loaders/ImageLoader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5bdd8e9c10f9745dbb5ea584302099fdf59dd228 --- /dev/null +++ b/src/loaders/ImageLoader.d.ts @@ -0,0 +1,28 @@ +import { LoadingManager } from './LoadingManager'; + +/** + * A loader for loading an image. + * Unlike other loaders, this one emits events instead of using predefined callbacks. So if you're interested in getting notified when things happen, you need to add listeners to the object. + */ +export class ImageLoader { + constructor(manager?: LoadingManager); + + manager: LoadingManager; + crossOrigin: string; + withCredentials: string; + path: string; + + /** + * Begin loading from url + * @param url + */ + load( + url: string, + onLoad?: (image: HTMLImageElement) => void, + onProgress?: (event: ProgressEvent) => void, + onError?: (event: ErrorEvent) => void + ): HTMLImageElement; + setCrossOrigin(crossOrigin: string): ImageLoader; + setWithCredentials(value: string): ImageLoader; + setPath(value: string): ImageLoader; +} diff --git a/src/loaders/Loader.d.ts b/src/loaders/Loader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a0f5fdda5aed737c09504ad5957d3b96fa99bba5 --- /dev/null +++ b/src/loaders/Loader.d.ts @@ -0,0 +1,58 @@ +import { Material } from './../materials/Material'; +import { LoaderHandler } from './FileLoader'; + +// Loaders ////////////////////////////////////////////////////////////////////////////////// + +/** + * Base class for implementing loaders. + * + * Events: + * load + * Dispatched when the image has completed loading + * content — loaded image + * + * error + * + * Dispatched when the image can't be loaded + * message — error message + */ +export class Loader { + constructor(); + + /** + * Will be called when load starts. + * The default is a function with empty body. + */ + onLoadStart: () => void; + + /** + * Will be called while load progresses. + * The default is a function with empty body. + */ + onLoadProgress: () => void; + + /** + * Will be called when load completes. + * The default is a function with empty body. + */ + onLoadComplete: () => void; + + /** + * default — null. + * If set, assigns the crossOrigin attribute of the image to the value of crossOrigin, prior to starting the load. + */ + crossOrigin: string; + + /** + * @deprecated Use THREE.LoaderUtils.extractUrlBase() instead. + */ + extractUrlBase(url: string): string; + initMaterials(materials: Material[], texturePath: string): Material[]; + createMaterial( + m: Material, + texturePath: string, + crossOrigin?: string + ): boolean; + + static Handlers: LoaderHandler; +} diff --git a/src/loaders/LoaderUtils.d.ts b/src/loaders/LoaderUtils.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f9940d8efe35b4d53a1539b8f6d67852ba628c24 --- /dev/null +++ b/src/loaders/LoaderUtils.d.ts @@ -0,0 +1,6 @@ +import { TypedArray } from '../polyfills'; + +export class LoaderUtils { + static decodeText(array: TypedArray): string; + static extractUrlBase(url: string): string; +} diff --git a/src/loaders/LoadingManager.d.ts b/src/loaders/LoadingManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9cf69f9bcff7ca960d3eef52104d9d8008e2f0b0 --- /dev/null +++ b/src/loaders/LoadingManager.d.ts @@ -0,0 +1,76 @@ +import { Geometry } from './../core/Geometry'; +import { Material } from './../materials/Material'; +import { Loader } from './Loader'; +/** + * A loader for loading objects in JSON format. + */ +export class JSONLoader extends Loader { + constructor(manager?: LoadingManager); + + manager: LoadingManager; + withCredentials: boolean; + + load( + url: string, + onLoad?: (geometry: Geometry, materials: Material[]) => void, + onProgress?: (event: ProgressEvent) => void, + onError?: (event: ErrorEvent) => void + ): void; + setTexturePath(value: string): void; + parse( + json: any, + texturePath?: string + ): { geometry: Geometry; materials?: Material[] }; +} + +export const DefaultLoadingManager: LoadingManager; + +/** + * Handles and keeps track of loaded and pending data. + */ +export class LoadingManager { + constructor( + onLoad?: () => void, + onProgress?: (url: string, loaded: number, total: number) => void, + onError?: () => void + ); + + onStart?: (url: string, loaded: number, total: number) => void; + + /** + * Will be called when load starts. + * The default is a function with empty body. + */ + onLoad: () => void; + + /** + * Will be called while load progresses. + * The default is a function with empty body. + */ + onProgress: (item: any, loaded: number, total: number) => void; + + /** + * Will be called when each element in the scene completes loading. + * The default is a function with empty body. + */ + onError: (url: string) => void; + + /** + * If provided, the callback will be passed each resource URL before a request is sent. + * The callback may return the original URL, or a new URL to override loading behavior. + * This behavior can be used to load assets from .ZIP files, drag-and-drop APIs, and Data URIs. + * @param callback URL modifier callback. Called with url argument, and must return resolvedURL. + */ + setURLModifier(callback?: (url: string) => string): void; + + /** + * Given a URL, uses the URL modifier callback (if any) and returns a resolved URL. + * If no URL modifier is set, returns the original URL. + * @param url the url to load + */ + resolveURL(url: string): string; + + itemStart(url: string): void; + itemEnd(url: string): void; + itemError(url: string): void; +} diff --git a/src/loaders/MaterialLoader.d.ts b/src/loaders/MaterialLoader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f49fe392fa091ac12ebed52faeda0de6c7b1eb78 --- /dev/null +++ b/src/loaders/MaterialLoader.d.ts @@ -0,0 +1,20 @@ +import { LoadingManager } from './LoadingManager'; +import { Texture } from './../textures/Texture'; +import { Material } from './../materials/Material'; + +export class MaterialLoader { + constructor(manager?: LoadingManager); + + manager: LoadingManager; + textures: { [key: string]: Texture }; + + load( + url: string, + onLoad: (material: Material) => void, + onProgress?: (event: ProgressEvent) => void, + onError?: (event: Error | ErrorEvent) => void + ): void; + setTextures(textures: { [key: string]: Texture }): void; + getTexture(name: string): Texture; + parse(json: any): Material; +} diff --git a/src/loaders/ObjectLoader.d.ts b/src/loaders/ObjectLoader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..75f77d0c26e6c6be5c26efb3c0d0cce563806212 --- /dev/null +++ b/src/loaders/ObjectLoader.d.ts @@ -0,0 +1,36 @@ +import { LoadingManager } from './LoadingManager'; +import { Object3D } from './../core/Object3D'; +import { Texture } from './../textures/Texture'; +import { Material } from './../materials/Material'; +import { AnimationClip } from './../animation/AnimationClip'; + +export class ObjectLoader { + constructor(manager?: LoadingManager); + + manager: LoadingManager; + texturePass: string; + crossOrigin: string; + + load( + url: string, + onLoad?: (object: Object3D) => void, + onProgress?: (event: ProgressEvent) => void, + onError?: (event: Error | ErrorEvent) => void + ): void; + setTexturePath(value: string): void; + setCrossOrigin(crossOrigin: string): void; + parse(json: any, onLoad?: (object: Object3D) => void): T; + parseGeometries(json: any): any[]; // Array of BufferGeometry or Geometry or Geometry2. + parseMaterials(json: any, textures: Texture[]): Material[]; // Array of Classes that inherits from Matrial. + parseAnimations(json: any): AnimationClip[]; + parseImages( + json: any, + onLoad: () => void + ): { [key: string]: HTMLImageElement }; + parseTextures(json: any, images: any): Texture[]; + parseObject( + data: any, + geometries: any[], + materials: Material[] + ): T; +} diff --git a/src/loaders/TextureLoader.d.ts b/src/loaders/TextureLoader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..96e5703420f77d2a15e761b80733ee675dd29def --- /dev/null +++ b/src/loaders/TextureLoader.d.ts @@ -0,0 +1,30 @@ +import { LoadingManager } from './LoadingManager'; +import { Texture } from './../textures/Texture'; + +/** + * Class for loading a texture. + * Unlike other loaders, this one emits events instead of using predefined callbacks. So if you're interested in getting notified when things happen, you need to add listeners to the object. + */ +export class TextureLoader { + constructor(manager?: LoadingManager); + + manager: LoadingManager; + crossOrigin: string; + withCredentials: string; + path: string; + + /** + * Begin loading from url + * + * @param url + */ + load( + url: string, + onLoad?: (texture: Texture) => void, + onProgress?: (event: ProgressEvent) => void, + onError?: (event: ErrorEvent) => void + ): Texture; + setCrossOrigin(crossOrigin: string): TextureLoader; + setWithCredentials(value: string): TextureLoader; + setPath(path: string): TextureLoader; +} diff --git a/src/materials/LineBasicMaterial.d.ts b/src/materials/LineBasicMaterial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f4c56c18feacd1e90e818000cb010cef58eebcdd --- /dev/null +++ b/src/materials/LineBasicMaterial.d.ts @@ -0,0 +1,20 @@ +import { Color } from './../math/Color'; +import { MaterialParameters, Material } from './Material'; + +export interface LineBasicMaterialParameters extends MaterialParameters { + color?: Color | string | number; + linewidth?: number; + linecap?: string; + linejoin?: string; +} + +export class LineBasicMaterial extends Material { + constructor(parameters?: LineBasicMaterialParameters); + + color: Color; + linewidth: number; + linecap: string; + linejoin: string; + + setValues(parameters: LineBasicMaterialParameters): void; +} diff --git a/src/materials/LineDashedMaterial.d.ts b/src/materials/LineDashedMaterial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d6e6a62cf158e833bac547289379d46bbf75fa5 --- /dev/null +++ b/src/materials/LineDashedMaterial.d.ts @@ -0,0 +1,22 @@ +import { Color } from './../math/Color'; +import { MaterialParameters } from './Material'; +import { LineBasicMaterial } from './LineBasicMaterial'; + +export interface LineDashedMaterialParameters extends MaterialParameters { + color?: Color | string | number; + linewidth?: number; + scale?: number; + dashSize?: number; + gapSize?: number; +} + +export class LineDashedMaterial extends LineBasicMaterial { + constructor(parameters?: LineDashedMaterialParameters); + + scale: number; + dashSize: number; + gapSize: number; + isLineDashedMaterial: boolean; + + setValues(parameters: LineDashedMaterialParameters): void; +} diff --git a/src/materials/Material.d.ts b/src/materials/Material.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..52f8061dd53645b68f0e558dbe931d3c64dea423 --- /dev/null +++ b/src/materials/Material.d.ts @@ -0,0 +1,279 @@ +import { Plane } from './../math/Plane'; +import { EventDispatcher } from './../core/EventDispatcher'; +import { + BlendingDstFactor, + BlendingEquation, + Blending, + BlendingSrcFactor, + DepthModes, + Side, + Colors, +} from '../constants'; + +// Materials ////////////////////////////////////////////////////////////////////////////////// +export let MaterialIdCount: number; + +export interface MaterialParameters { + alphaTest?: number; + blendDst?: BlendingDstFactor; + blendDstAlpha?: number; + blendEquation?: BlendingEquation; + blendEquationAlpha?: number; + blending?: Blending; + blendSrc?: BlendingSrcFactor | BlendingDstFactor; + blendSrcAlpha?: number; + clipIntersection?: boolean; + clippingPlanes?: Plane[]; + clipShadows?: boolean; + colorWrite?: boolean; + depthFunc?: DepthModes; + depthTest?: boolean; + depthWrite?: boolean; + fog?: boolean; + lights?: boolean; + name?: string; + opacity?: number; + overdraw?: number; + polygonOffset?: boolean; + polygonOffsetFactor?: number; + polygonOffsetUnits?: number; + precision?: 'highp' | 'mediump' | 'lowp' | null; + premultipliedAlpha?: boolean; + dithering?: boolean; + flatShading?: boolean; + side?: Side; + transparent?: boolean; + vertexColors?: Colors; + visible?: boolean; +} + +/** + * Materials describe the appearance of objects. They are defined in a (mostly) renderer-independent way, so you don't have to rewrite materials if you decide to use a different renderer. + */ +export class Material extends EventDispatcher { + constructor(); + + /** + * Sets the alpha value to be used when running an alpha test. Default is 0. + */ + alphaTest: number; + + /** + * Blending destination. It's one of the blending mode constants defined in Three.js. Default is {@link OneMinusSrcAlphaFactor}. + */ + blendDst: BlendingDstFactor; + + /** + * The tranparency of the .blendDst. Default is null. + */ + blendDstAlpha: number | null; + + /** + * Blending equation to use when applying blending. It's one of the constants defined in Three.js. Default is {@link AddEquation}. + */ + blendEquation: BlendingEquation; + + /** + * The tranparency of the .blendEquation. Default is null. + */ + blendEquationAlpha: number | null; + + /** + * Which blending to use when displaying objects with this material. Default is {@link NormalBlending}. + */ + blending: Blending; + + /** + * Blending source. It's one of the blending mode constants defined in Three.js. Default is {@link SrcAlphaFactor}. + */ + blendSrc: BlendingSrcFactor | BlendingDstFactor; + + /** + * The tranparency of the .blendSrc. Default is null. + */ + blendSrcAlpha: number | null; + + /** + * Changes the behavior of clipping planes so that only their intersection is clipped, rather than their union. Default is false. + */ + clipIntersection: boolean; + + /** + * User-defined clipping planes specified as THREE.Plane objects in world space. These planes apply to the objects this material is attached to. Points in space whose signed distance to the plane is negative are clipped (not rendered). See the WebGL / clipping /intersection example. Default is null. + */ + clippingPlanes: any; + + /** + * Defines whether to clip shadows according to the clipping planes specified on this material. Default is false. + */ + clipShadows: boolean; + + /** + * Whether to render the material's color. This can be used in conjunction with a mesh's .renderOrder property to create invisible objects that occlude other objects. Default is true. + */ + colorWrite: boolean; + + /** + * Which depth function to use. Default is {@link LessEqualDepth}. See the depth mode constants for all possible values. + */ + depthFunc: DepthModes; + + /** + * Whether to have depth test enabled when rendering this material. Default is true. + */ + depthTest: boolean; + + /** + * Whether rendering this material has any effect on the depth buffer. Default is true. + * When drawing 2D overlays it can be useful to disable the depth writing in order to layer several things together without creating z-index artifacts. + */ + depthWrite: boolean; + + /** + * Whether the material is affected by fog. Default is true. + */ + fog: boolean; + + /** + * Unique number of this material instance. + */ + id: number; + + /** + * Used to check whether this or derived classes are materials. Default is true. + * You should not change this, as it used internally for optimisation. + */ + isMaterial: boolean; + + /** + * Whether the material is affected by lights. Default is true. + */ + lights: boolean; + + /** + * Material name. Default is an empty string. + */ + name: string; + + /** + * Specifies that the material needs to be updated, WebGL wise. Set it to true if you made changes that need to be reflected in WebGL. + * This property is automatically set to true when instancing a new material. + */ + needsUpdate: boolean; + + /** + * Opacity. Default is 1. + */ + opacity: number; + + /** + * Enables/disables overdraw. If greater than zero, polygons are drawn slightly bigger in order to fix antialiasing gaps when using the CanvasRenderer. Default is 0. + */ + overdraw: number; + + /** + * Whether to use polygon offset. Default is false. This corresponds to the POLYGON_OFFSET_FILL WebGL feature. + */ + polygonOffset: boolean; + + /** + * Sets the polygon offset factor. Default is 0. + */ + polygonOffsetFactor: number; + + /** + * Sets the polygon offset units. Default is 0. + */ + polygonOffsetUnits: number; + + /** + * Override the renderer's default precision for this material. Can be "highp", "mediump" or "lowp". Defaults is null. + */ + precision: 'highp' | 'mediump' | 'lowp' | null; + + /** + * Whether to premultiply the alpha (transparency) value. See WebGL / Materials / Transparency for an example of the difference. Default is false. + */ + premultipliedAlpha: boolean; + + /** + * Whether to apply dithering to the color to remove the appearance of banding. Default is false. + */ + dithering: boolean; + + /** + * Define whether the material is rendered with flat shading. Default is false. + */ + flatShading: boolean; + + /** + * Defines which of the face sides will be rendered - front, back or both. + * Default is THREE.FrontSide. Other options are THREE.BackSide and THREE.DoubleSide. + */ + side: Side; + + /** + * Defines whether this material is transparent. This has an effect on rendering as transparent objects need special treatment and are rendered after non-transparent objects. + * When set to true, the extent to which the material is transparent is controlled by setting it's .opacity property. + * Default is false. + */ + transparent: boolean; + + /** + * Value is the string 'Material'. This shouldn't be changed, and can be used to find all objects of this type in a scene. + */ + type: string; + + /** + * UUID of this material instance. This gets automatically assigned, so this shouldn't be edited. + */ + uuid: string; + + /** + * Defines whether vertex coloring is used. Default is THREE.NoColors. Other options are THREE.VertexColors and THREE.FaceColors. + */ + vertexColors: Colors; + + /** + * Defines whether this material is visible. Default is true. + */ + visible: boolean; + + /** + * An object that can be used to store custom data about the Material. It should not hold references to functions as these will not be cloned. + */ + userData: any; + + /** + * Return a new material with the same parameters as this material. + */ + clone(): this; + + /** + * Copy the parameters from the passed material into this material. + * @param material + */ + copy(material: Material): this; + + /** + * This disposes the material. Textures of a material don't get disposed. These needs to be disposed by {@link Texture}. + */ + dispose(): void; + + /** + * Sets the properties based on the values. + * @param values A container with parameters. + */ + setValues(values: MaterialParameters): void; + + /** + * Convert the material to three.js JSON format. + * @param meta Object containing metadata such as textures or images for the material. + */ + toJSON(meta?: any): any; + + /** + * Call .dispatchEvent ( { type: 'update' }) on the material. + */ + update(): void; +} diff --git a/src/materials/Materials.d.ts b/src/materials/Materials.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fb9b2f4eeaf31b1653b171db2e73325c3a932794 --- /dev/null +++ b/src/materials/Materials.d.ts @@ -0,0 +1,18 @@ +export { ShadowMaterial } from './ShadowMaterial'; +export { SpriteMaterial } from './SpriteMaterial'; +export { RawShaderMaterial } from './RawShaderMaterial'; +export { ShaderMaterial } from './ShaderMaterial'; +export { PointsMaterial } from './PointsMaterial'; +export { MeshPhysicalMaterial } from './MeshPhysicalMaterial'; +export { MeshStandardMaterial } from './MeshStandardMaterial'; +export { MeshPhongMaterial } from './MeshPhongMaterial'; +//export { MeshToonMaterial } from './MeshToonMaterial'; +export { MeshNormalMaterial } from './MeshNormalMaterial'; +export { MeshLambertMaterial } from './MeshLambertMaterial'; +export { MeshDepthMaterial } from './MeshDepthMaterial'; +//export { MeshDistanceMaterial } from './MeshDistanceMaterial'; +export { MeshBasicMaterial } from './MeshBasicMaterial'; +//export { MeshMatcapMaterial } from './MeshMatcapMaterial'; +export { LineDashedMaterial } from './LineDashedMaterial'; +export { LineBasicMaterial } from './LineBasicMaterial'; +export { Material } from './Material'; diff --git a/src/materials/MeshBasicMaterial.d.ts b/src/materials/MeshBasicMaterial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..66f902f106278f41565b74dc0835358a27be1a64 --- /dev/null +++ b/src/materials/MeshBasicMaterial.d.ts @@ -0,0 +1,49 @@ +import { Color } from './../math/Color'; +import { Texture } from './../textures/Texture'; +import { MaterialParameters, Material } from './Material'; +import { Combine } from '../constants'; +/** + * parameters is an object with one or more properties defining the material's appearance. + */ +export interface MeshBasicMaterialParameters extends MaterialParameters { + color?: Color | string | number; + opacity?: number; + map?: Texture; + aoMap?: Texture; + aoMapIntensity?: number; + specularMap?: Texture; + alphaMap?: Texture; + envMap?: Texture; + combine?: Combine; + reflectivity?: number; + refractionRatio?: number; + wireframe?: boolean; + wireframeLinewidth?: number; + wireframeLinecap?: string; + wireframeLinejoin?: string; + skinning?: boolean; + morphTargets?: boolean; +} + +export class MeshBasicMaterial extends Material { + constructor(parameters?: MeshBasicMaterialParameters); + + color: Color; + map: Texture | null; + aoMap: Texture | null; + aoMapIntensity: number; + specularMap: Texture | null; + alphaMap: Texture | null; + envMap: Texture | null; + combine: Combine; + reflectivity: number; + refractionRatio: number; + wireframe: boolean; + wireframeLinewidth: number; + wireframeLinecap: string; + wireframeLinejoin: string; + skinning: boolean; + morphTargets: boolean; + + setValues(parameters: MeshBasicMaterialParameters): void; +} diff --git a/src/materials/MeshDepthMaterial.d.ts b/src/materials/MeshDepthMaterial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c30025de4e4c825e42eda6e4e47efee377689444 --- /dev/null +++ b/src/materials/MeshDepthMaterial.d.ts @@ -0,0 +1,17 @@ +import { DepthPackingStrategies } from '../constants'; +import { MaterialParameters, Material } from './Material'; + +export interface MeshDepthMaterialParameters extends MaterialParameters { + wireframe?: boolean; + wireframeLinewidth?: number; +} + +export class MeshDepthMaterial extends Material { + constructor(parameters?: MeshDepthMaterialParameters); + + wireframe: boolean; + wireframeLinewidth: number; + depthPacking: DepthPackingStrategies; + + setValues(parameters: MeshDepthMaterialParameters): void; +} diff --git a/src/materials/MeshLambertMaterial.d.ts b/src/materials/MeshLambertMaterial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3af761df20dd24d40509d36afdcfa0994fa3c677 --- /dev/null +++ b/src/materials/MeshLambertMaterial.d.ts @@ -0,0 +1,58 @@ +import { Color } from './../math/Color'; +import { Texture } from './../textures/Texture'; +import { MaterialParameters, Material } from './Material'; +import { Combine } from '../constants'; + +export interface MeshLambertMaterialParameters extends MaterialParameters { + color?: Color | string | number; + emissive?: Color | string | number; + emissiveIntensity?: number; + emissiveMap?: Texture; + map?: Texture; + lightMap?: Texture; + lightMapIntensity?: number; + aoMap?: Texture; + aoMapIntensity?: number; + specularMap?: Texture; + alphaMap?: Texture; + envMap?: Texture; + combine?: Combine; + reflectivity?: number; + refractionRatio?: number; + wireframe?: boolean; + wireframeLinewidth?: number; + wireframeLinecap?: string; + wireframeLinejoin?: string; + skinning?: boolean; + morphTargets?: boolean; + morphNormals?: boolean; +} + +export class MeshLambertMaterial extends Material { + constructor(parameters?: MeshLambertMaterialParameters); + + color: Color; + emissive: Color; + emissiveIntensity: number; + emissiveMap: Texture | null; + map: Texture | null; + lightMap: Texture | null; + lightMapIntensity: number; + aoMap: Texture | null; + aoMapIntensity: number; + specularMap: Texture | null; + alphaMap: Texture | null; + envMap: Texture | null; + combine: Combine; + reflectivity: number; + refractionRatio: number; + wireframe: boolean; + wireframeLinewidth: number; + wireframeLinecap: string; + wireframeLinejoin: string; + skinning: boolean; + morphTargets: boolean; + morphNormals: boolean; + + setValues(parameters: MeshLambertMaterialParameters): void; +} diff --git a/src/materials/MeshNormalMaterial.d.ts b/src/materials/MeshNormalMaterial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..203478320a19bd8b604bdead32351353f1bb0ba9 --- /dev/null +++ b/src/materials/MeshNormalMaterial.d.ts @@ -0,0 +1,19 @@ +import { MaterialParameters, Material } from './Material'; + +export interface MeshNormalMaterialParameters extends MaterialParameters { + /** Render geometry as wireframe. Default is false (i.e. render as smooth shaded). */ + wireframe?: boolean; + /** Controls wireframe thickness. Default is 1. */ + wireframeLinewidth?: number; + morphTargets?: boolean; +} + +export class MeshNormalMaterial extends Material { + constructor(parameters?: MeshNormalMaterialParameters); + + wireframe: boolean; + wireframeLinewidth: number; + morphTargets: boolean; + + setValues(parameters: MeshNormalMaterialParameters): void; +} diff --git a/src/materials/MeshPhongMaterial.d.ts b/src/materials/MeshPhongMaterial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..53fd0d980568644b230a39d3199c722b2f558894 --- /dev/null +++ b/src/materials/MeshPhongMaterial.d.ts @@ -0,0 +1,83 @@ +import { Color } from './../math/Color'; +import { Texture } from './../textures/Texture'; +import { Vector2 } from './../math/Vector2'; +import { MaterialParameters, Material } from './Material'; +import { Combine } from '../constants'; + +export interface MeshPhongMaterialParameters extends MaterialParameters { + /** geometry color in hexadecimal. Default is 0xffffff. */ + color?: Color | string | number; + specular?: Color | string | number; + shininess?: number; + opacity?: number; + map?: Texture; + lightMap?: Texture; + lightMapIntensity?: number; + aoMap?: Texture; + aoMapIntensity?: number; + emissive?: Color | string | number; + emissiveIntensity?: number; + emissiveMap?: Texture; + bumpMap?: Texture; + bumpScale?: number; + normalMap?: Texture; + normalScale?: Vector2; + displacementMap?: Texture; + displacementScale?: number; + displacementBias?: number; + specularMap?: Texture; + alphaMap?: Texture; + envMap?: Texture; + combine?: Combine; + reflectivity?: number; + refractionRatio?: number; + wireframe?: boolean; + wireframeLinewidth?: number; + wireframeLinecap?: string; + wireframeLinejoin?: string; + skinning?: boolean; + morphTargets?: boolean; + morphNormals?: boolean; +} + +export class MeshPhongMaterial extends Material { + constructor(parameters?: MeshPhongMaterialParameters); + + color: Color; + specular: Color; + shininess: number; + map: Texture | null; + lightMap: Texture | null; + lightMapIntensity: number; + aoMap: Texture | null; + aoMapIntensity: number; + emissive: Color; + emissiveIntensity: number; + emissiveMap: Texture | null; + bumpMap: Texture | null; + bumpScale: number; + normalMap: Texture | null; + normalScale: Vector2; + displacementMap: Texture | null; + displacementScale: number; + displacementBias: number; + specularMap: Texture | null; + alphaMap: Texture | null; + envMap: Texture | null; + combine: Combine; + reflectivity: number; + refractionRatio: number; + wireframe: boolean; + wireframeLinewidth: number; + wireframeLinecap: string; + wireframeLinejoin: string; + skinning: boolean; + morphTargets: boolean; + morphNormals: boolean; + /** + * @deprecated Use {@link MeshStandardMaterial THREE.MeshStandardMaterial} instead. + */ + metal: boolean; + + setValues(parameters: MeshPhongMaterialParameters): void; +} diff --git a/src/materials/MeshPhysicalMaterial.d.ts b/src/materials/MeshPhysicalMaterial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f2b464ad0062a222871a2f49c7721ba093701593 --- /dev/null +++ b/src/materials/MeshPhysicalMaterial.d.ts @@ -0,0 +1,20 @@ +import { + MeshStandardMaterialParameters, + MeshStandardMaterial, +} from './MeshStandardMaterial'; + +export interface MeshPhysicalMaterialParameters + extends MeshStandardMaterialParameters { + reflectivity?: number; + clearCoat?: number; + clearCoatRoughness?: number; +} + +export class MeshPhysicalMaterial extends MeshStandardMaterial { + constructor(parameters: MeshPhysicalMaterialParameters); + + defines: any; + reflectivity: number; + clearCoat: number; + clearCoatRoughness: number; +} diff --git a/src/materials/MeshStandardMaterial.d.ts b/src/materials/MeshStandardMaterial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7fca97f515a46bf331636754fcc6c362e7298d13 --- /dev/null +++ b/src/materials/MeshStandardMaterial.d.ts @@ -0,0 +1,73 @@ +import { Color } from './../math/Color'; +import { Texture } from './../textures/Texture'; +import { Vector2 } from './../math/Vector2'; +import { MaterialParameters, Material } from './Material'; + +export interface MeshStandardMaterialParameters extends MaterialParameters { + color?: Color | string | number; + roughness?: number; + metalness?: number; + map?: Texture; + lightMap?: Texture; + lightMapIntensity?: number; + aoMap?: Texture; + aoMapIntensity?: number; + emissive?: Color | string | number; + emissiveIntensity?: number; + emissiveMap?: Texture; + bumpMap?: Texture; + bumpScale?: number; + normalMap?: Texture; + normalScale?: Vector2; + displacementMap?: Texture; + displacementScale?: number; + displacementBias?: number; + roughnessMap?: Texture; + metalnessMap?: Texture; + alphaMap?: Texture; + envMap?: Texture; + envMapIntensity?: number; + refractionRatio?: number; + wireframe?: boolean; + wireframeLinewidth?: number; + skinning?: boolean; + morphTargets?: boolean; + morphNormals?: boolean; +} + +export class MeshStandardMaterial extends Material { + constructor(parameters?: MeshStandardMaterialParameters); + + defines: any; + color: Color; + roughness: number; + metalness: number; + map: Texture | null; + lightMap: Texture | null; + lightMapIntensity: number; + aoMap: Texture | null; + aoMapIntensity: number; + emissive: Color; + emissiveIntensity: number; + emissiveMap: Texture | null; + bumpMap: Texture | null; + bumpScale: number; + normalMap: Texture | null; + normalScale: number; + displacementMap: Texture | null; + displacementScale: number; + displacementBias: number; + roughnessMap: Texture | null; + metalnessMap: Texture | null; + alphaMap: Texture | null; + envMap: Texture | null; + envMapIntensity: number; + refractionRatio: number; + wireframe: boolean; + wireframeLinewidth: number; + skinning: boolean; + morphTargets: boolean; + morphNormals: boolean; + + setValues(parameters: MeshStandardMaterialParameters): void; +} diff --git a/src/materials/PointsMaterial.d.ts b/src/materials/PointsMaterial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a1333d270bc3158df503cba5cb86b25851483ee3 --- /dev/null +++ b/src/materials/PointsMaterial.d.ts @@ -0,0 +1,40 @@ +import { Material, MaterialParameters } from './Material'; +import { Color } from './../math/Color'; +import { Texture } from './../textures/Texture'; + +// MultiMaterial does not inherit the Material class in the original code. However, it should treat as Material class. +// See tests/canvas/canvas_materials.ts. +/** + * @deprecated Use an Array instead. + */ +export class MultiMaterial extends Material { + constructor(materials?: Material[]); + + isMultiMaterial: true; + + materials: Material[]; + + toJSON(meta: any): any; +} + +/** + * @deprecated Use {@link MultiMaterial} instead. + */ + +export interface PointsMaterialParameters extends MaterialParameters { + color?: Color | string | number; + map?: Texture; + size?: number; + sizeAttenuation?: boolean; +} + +export class PointsMaterial extends Material { + constructor(parameters?: PointsMaterialParameters); + + color: Color; + map: Texture | null; + size: number; + sizeAttenuation: boolean; + + setValues(parameters: PointsMaterialParameters): void; +} diff --git a/src/materials/RawShaderMaterial.d.ts b/src/materials/RawShaderMaterial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0d8f2454651adcb3b43783559441c3bcd4a9393a --- /dev/null +++ b/src/materials/RawShaderMaterial.d.ts @@ -0,0 +1,5 @@ +import { ShaderMaterialParameters, ShaderMaterial } from './ShaderMaterial'; + +export class RawShaderMaterial extends ShaderMaterial { + constructor(parameters?: ShaderMaterialParameters); +} diff --git a/src/materials/ShaderMaterial.d.ts b/src/materials/ShaderMaterial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..03e9189df177270a12e175dcd7424b7cc1a6069c --- /dev/null +++ b/src/materials/ShaderMaterial.d.ts @@ -0,0 +1,60 @@ +import { ShaderMaterialParameters } from './ShaderMaterial'; +import { IUniform } from '../renderers/shaders/UniformsLib'; +import { MaterialParameters, Material } from './Material'; + +/** + * @deprecated Use {@link PointsMaterial THREE.PointsMaterial} instead + */ +/** + * @deprecated Use {@link PointsMaterial THREE.PointsMaterial} instead + */ +/** + * @deprecated Use {@link PointsMaterial THREE.PointsMaterial} instead + */ + +export interface ShaderMaterialParameters extends MaterialParameters { + defines?: any; + uniforms?: any; + vertexShader?: string; + fragmentShader?: string; + lineWidth?: number; + wireframe?: boolean; + wireframeLinewidth?: number; + lights?: boolean; + clipping?: boolean; + skinning?: boolean; + morphTargets?: boolean; + morphNormals?: boolean; +} + +export class ShaderMaterial extends Material { + constructor(parameters?: ShaderMaterialParameters); + + defines: any; + uniforms: { [uniform: string]: IUniform }; + vertexShader: string; + fragmentShader: string; + linewidth: number; + wireframe: boolean; + wireframeLinewidth: number; + lights: boolean; + clipping: boolean; + skinning: boolean; + morphTargets: boolean; + morphNormals: boolean; + /** + * @deprecated Use {@link ShaderMaterial#extensions.derivatives extensions.derivatives} instead. + */ + derivatives: any; + extensions: { + derivatives: boolean; + fragDepth: boolean; + drawBuffers: boolean; + shaderTextureLOD: boolean; + }; + defaultAttributeValues: any; + index0AttributeName: string | undefined; + + setValues(parameters: ShaderMaterialParameters): void; + toJSON(meta: any): any; +} diff --git a/src/materials/ShadowMaterial.d.ts b/src/materials/ShadowMaterial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..691a7208fe53fc4020281abe7d9e47870738b7a0 --- /dev/null +++ b/src/materials/ShadowMaterial.d.ts @@ -0,0 +1,5 @@ +import { ShaderMaterialParameters, ShaderMaterial } from './ShaderMaterial'; + +export class ShadowMaterial extends ShaderMaterial { + constructor(parameters?: ShaderMaterialParameters); +} diff --git a/src/materials/SpriteMaterial.d.ts b/src/materials/SpriteMaterial.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..996db03f6a2d8aa995e106954cbf15cfcb191dd3 --- /dev/null +++ b/src/materials/SpriteMaterial.d.ts @@ -0,0 +1,21 @@ +import { Color } from './../math/Color'; +import { Texture } from './../textures/Texture'; +import { MaterialParameters, Material } from './Material'; + +export interface SpriteMaterialParameters extends MaterialParameters { + color?: Color | string | number; + map?: Texture; + rotation?: number; +} + +export class SpriteMaterial extends Material { + constructor(parameters?: SpriteMaterialParameters); + + color: Color; + map: Texture | null; + rotation: number; + isSpriteMaterial: true; + + setValues(parameters: SpriteMaterialParameters): void; + copy(source: SpriteMaterial): this; +} diff --git a/src/math/Box2.d.ts b/src/math/Box2.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fcc6ce117e22a4f21d6f56490727bc3a7f62e7be --- /dev/null +++ b/src/math/Box2.d.ts @@ -0,0 +1,41 @@ +import { Vector2 } from './Vector2'; + +// Math ////////////////////////////////////////////////////////////////////////////////// + +export class Box2 { + constructor(min?: Vector2, max?: Vector2); + + max: Vector2; + min: Vector2; + + set(min: Vector2, max: Vector2): Box2; + setFromPoints(points: Vector2[]): Box2; + setFromCenterAndSize(center: Vector2, size: Vector2): Box2; + clone(): this; + copy(box: Box2): this; + makeEmpty(): Box2; + isEmpty(): boolean; + getCenter(target: Vector2): Vector2; + getSize(target: Vector2): Vector2; + expandByPoint(point: Vector2): Box2; + expandByVector(vector: Vector2): Box2; + expandByScalar(scalar: number): Box2; + containsPoint(point: Vector2): boolean; + containsBox(box: Box2): boolean; + getParameter(point: Vector2): Vector2; + intersectsBox(box: Box2): boolean; + clampPoint(point: Vector2, target: Vector2): Vector2; + distanceToPoint(point: Vector2): number; + intersect(box: Box2): Box2; + union(box: Box2): Box2; + translate(offset: Vector2): Box2; + equals(box: Box2): boolean; + /** + * @deprecated Use {@link Box2#isEmpty .isEmpty()} instead. + */ + empty(): any; + /** + * @deprecated Use {@link Box2#intersectsBox .intersectsBox()} instead. + */ + isIntersectionBox(b: any): any; +} diff --git a/src/math/Box3.d.ts b/src/math/Box3.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..55e4a187f72b19d01969183669757a5094d6be79 --- /dev/null +++ b/src/math/Box3.d.ts @@ -0,0 +1,54 @@ +import { Vector3 } from './Vector3'; +import { Object3D } from './../core/Object3D'; +import { Sphere } from './Sphere'; +import { Plane } from './Plane'; +import { Matrix4 } from './Matrix4'; + +export class Box3 { + constructor(min?: Vector3, max?: Vector3); + + max: Vector3; + min: Vector3; + + set(min: Vector3, max: Vector3): this; + setFromArray(array: ArrayLike): this; + setFromPoints(points: Vector3[]): this; + setFromCenterAndSize(center: Vector3, size: Vector3): this; + setFromObject(object: Object3D): this; + clone(): this; + copy(box: Box3): this; + makeEmpty(): this; + isEmpty(): boolean; + getCenter(target: Vector3): Vector3; + getSize(target: Vector3): Vector3; + expandByPoint(point: Vector3): this; + expandByVector(vector: Vector3): this; + expandByScalar(scalar: number): this; + expandByObject(object: Object3D): this; + containsPoint(point: Vector3): boolean; + containsBox(box: Box3): boolean; + getParameter(point: Vector3): Vector3; + intersectsBox(box: Box3): boolean; + intersectsSphere(sphere: Sphere): boolean; + intersectsPlane(plane: Plane): boolean; + clampPoint(point: Vector3, target: Vector3): Vector3; + distanceToPoint(point: Vector3): number; + getBoundingSphere(target: Sphere): Sphere; + intersect(box: Box3): this; + union(box: Box3): this; + applyMatrix4(matrix: Matrix4): this; + translate(offset: Vector3): this; + equals(box: Box3): boolean; + /** + * @deprecated Use {@link Box3#isEmpty .isEmpty()} instead. + */ + empty(): any; + /** + * @deprecated Use {@link Box3#intersectsBox .intersectsBox()} instead. + */ + isIntersectionBox(b: any): any; + /** + * @deprecated Use {@link Box3#intersectsSphere .intersectsSphere()} instead. + */ + isIntersectionSphere(s: any): any; +} diff --git a/src/math/Color.d.ts b/src/math/Color.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f5f071a89fb945fcde2fd921a560c625ee612ee0 --- /dev/null +++ b/src/math/Color.d.ts @@ -0,0 +1,128 @@ +export interface HSL { + h: number; + s: number; + l: number; +} + +/** + * Represents a color. See also {@link ColorUtils}. + * + * @example + * var color = new THREE.Color( 0xff0000 ); + * + * @see src/math/Color.js + */ +export class Color { + constructor(color?: Color | string | number); + constructor(r: number, g: number, b: number); + + /** + * Red channel value between 0 and 1. Default is 1. + */ + r: number; + + /** + * Green channel value between 0 and 1. Default is 1. + */ + g: number; + + /** + * Blue channel value between 0 and 1. Default is 1. + */ + b: number; + + set(color: Color): Color; + set(color: number): Color; + set(color: string): Color; + setScalar(scalar: number): Color; + setHex(hex: number): Color; + + /** + * Sets this color from RGB values. + * @param r Red channel value between 0 and 1. + * @param g Green channel value between 0 and 1. + * @param b Blue channel value between 0 and 1. + */ + setRGB(r: number, g: number, b: number): Color; + + /** + * Sets this color from HSL values. + * Based on MochiKit implementation by Bob Ippolito. + * + * @param h Hue channel value between 0 and 1. + * @param s Saturation value channel between 0 and 1. + * @param l Value channel value between 0 and 1. + */ + setHSL(h: number, s: number, l: number): Color; + + /** + * Sets this color from a CSS context style string. + * @param contextStyle Color in CSS context style format. + */ + setStyle(style: string): Color; + + /** + * Clones this color. + */ + clone(): this; + + /** + * Copies given color. + * @param color Color to copy. + */ + copy(color: Color): this; + + /** + * Copies given color making conversion from gamma to linear space. + * @param color Color to copy. + */ + copyGammaToLinear(color: Color, gammaFactor?: number): Color; + + /** + * Copies given color making conversion from linear to gamma space. + * @param color Color to copy. + */ + copyLinearToGamma(color: Color, gammaFactor?: number): Color; + + /** + * Converts this color from gamma to linear space. + */ + convertGammaToLinear(): Color; + + /** + * Converts this color from linear to gamma space. + */ + convertLinearToGamma(): Color; + + /** + * Returns the hexadecimal value of this color. + */ + getHex(): number; + + /** + * Returns the string formated hexadecimal value of this color. + */ + getHexString(): string; + + getHSL(target: HSL): HSL; + + /** + * Returns the value of this color in CSS context style. + * Example: rgb(r, g, b) + */ + getStyle(): string; + + offsetHSL(h: number, s: number, l: number): this; + + add(color: Color): this; + addColors(color1: Color, color2: Color): this; + addScalar(s: number): this; + sub(color: Color): this; + multiply(color: Color): this; + multiplyScalar(s: number): this; + lerp(color: Color, alpha: number): this; + lerpHSL(color: Color, alpha: number): this; + equals(color: Color): boolean; + fromArray(rgb: number[], offset?: number): this; + toArray(array?: number[], offset?: number): number[]; +} diff --git a/src/math/Cylindrical.d.ts b/src/math/Cylindrical.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c32df09e2600b55228eb3272c4ea8dbe9b21c6bd --- /dev/null +++ b/src/math/Cylindrical.d.ts @@ -0,0 +1,14 @@ +import { Vector3 } from './Vector3'; + +export class Cylindrical { + constructor(radius?: number, theta?: number, y?: number); + + radius: number; + theta: number; + y: number; + + clone(): this; + copy(other: Cylindrical): this; + set(radius: number, theta: number, y: number): this; + setFromVector3(vec3: Vector3): this; +} diff --git a/src/math/Euler.d.ts b/src/math/Euler.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..07c4a36355e19abb2209e4e359ff55d11c8d76a7 --- /dev/null +++ b/src/math/Euler.d.ts @@ -0,0 +1,179 @@ +import { Matrix4 } from './Matrix4'; +import { Quaternion } from './Quaternion'; +import { Vector3 } from './Vector3'; + +export namespace ColorKeywords { + export const aliceblue: number; + export const antiquewhite: number; + export const aqua: number; + export const aquamarine: number; + export const azure: number; + export const beige: number; + export const bisque: number; + export const black: number; + export const blanchedalmond: number; + export const blue: number; + export const blueviolet: number; + export const brown: number; + export const burlywood: number; + export const cadetblue: number; + export const chartreuse: number; + export const chocolate: number; + export const coral: number; + export const cornflowerblue: number; + export const cornsilk: number; + export const crimson: number; + export const cyan: number; + export const darkblue: number; + export const darkcyan: number; + export const darkgoldenrod: number; + export const darkgray: number; + export const darkgreen: number; + export const darkgrey: number; + export const darkkhaki: number; + export const darkmagenta: number; + export const darkolivegreen: number; + export const darkorange: number; + export const darkorchid: number; + export const darkred: number; + export const darksalmon: number; + export const darkseagreen: number; + export const darkslateblue: number; + export const darkslategray: number; + export const darkslategrey: number; + export const darkturquoise: number; + export const darkviolet: number; + export const deeppink: number; + export const deepskyblue: number; + export const dimgray: number; + export const dimgrey: number; + export const dodgerblue: number; + export const firebrick: number; + export const floralwhite: number; + export const forestgreen: number; + export const fuchsia: number; + export const gainsboro: number; + export const ghostwhite: number; + export const gold: number; + export const goldenrod: number; + export const gray: number; + export const green: number; + export const greenyellow: number; + export const grey: number; + export const honeydew: number; + export const hotpink: number; + export const indianred: number; + export const indigo: number; + export const ivory: number; + export const khaki: number; + export const lavender: number; + export const lavenderblush: number; + export const lawngreen: number; + export const lemonchiffon: number; + export const lightblue: number; + export const lightcoral: number; + export const lightcyan: number; + export const lightgoldenrodyellow: number; + export const lightgray: number; + export const lightgreen: number; + export const lightgrey: number; + export const lightpink: number; + export const lightsalmon: number; + export const lightseagreen: number; + export const lightskyblue: number; + export const lightslategray: number; + export const lightslategrey: number; + export const lightsteelblue: number; + export const lightyellow: number; + export const lime: number; + export const limegreen: number; + export const linen: number; + export const magenta: number; + export const maroon: number; + export const mediumaquamarine: number; + export const mediumblue: number; + export const mediumorchid: number; + export const mediumpurple: number; + export const mediumseagreen: number; + export const mediumslateblue: number; + export const mediumspringgreen: number; + export const mediumturquoise: number; + export const mediumvioletred: number; + export const midnightblue: number; + export const mintcream: number; + export const mistyrose: number; + export const moccasin: number; + export const navajowhite: number; + export const navy: number; + export const oldlace: number; + export const olive: number; + export const olivedrab: number; + export const orange: number; + export const orangered: number; + export const orchid: number; + export const palegoldenrod: number; + export const palegreen: number; + export const paleturquoise: number; + export const palevioletred: number; + export const papayawhip: number; + export const peachpuff: number; + export const peru: number; + export const pink: number; + export const plum: number; + export const powderblue: number; + export const purple: number; + export const red: number; + export const rosybrown: number; + export const royalblue: number; + export const saddlebrown: number; + export const salmon: number; + export const sandybrown: number; + export const seagreen: number; + export const seashell: number; + export const sienna: number; + export const silver: number; + export const skyblue: number; + export const slateblue: number; + export const slategray: number; + export const slategrey: number; + export const snow: number; + export const springgreen: number; + export const steelblue: number; + export const tan: number; + export const teal: number; + export const thistle: number; + export const tomato: number; + export const turquoise: number; + export const violet: number; + export const wheat: number; + export const white: number; + export const whitesmoke: number; + export const yellow: number; + export const yellowgreen: number; +} + +export class Euler { + constructor(x?: number, y?: number, z?: number, order?: string); + + x: number; + y: number; + z: number; + order: string; + onChangeCallback: Function; + + set(x: number, y: number, z: number, order?: string): Euler; + clone(): this; + copy(euler: Euler): this; + setFromRotationMatrix(m: Matrix4, order?: string, update?: boolean): Euler; + setFromQuaternion(q: Quaternion, order?: string, update?: boolean): Euler; + setFromVector3(v: Vector3, order?: string): Euler; + reorder(newOrder: string): Euler; + equals(euler: Euler): boolean; + fromArray(xyzo: any[]): Euler; + toArray(array?: number[], offset?: number): number[]; + toVector3(optionalResult?: Vector3): Vector3; + onChange(callback: Function): this; + + static RotationOrders: string[]; + static DefaultOrder: string; +} diff --git a/src/math/Frustum.d.ts b/src/math/Frustum.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..837a5c561808da7e89bf922bb037061496cf055d --- /dev/null +++ b/src/math/Frustum.d.ts @@ -0,0 +1,43 @@ +import { Plane } from './Plane'; +import { Matrix4 } from './Matrix4'; +import { Object3D } from './../core/Object3D'; +import { Sprite } from './../objects/Sprite'; +import { Sphere } from './Sphere'; +import { Box3 } from './Box3'; +import { Vector3 } from './Vector3'; + +/** + * Frustums are used to determine what is inside the camera's field of view. They help speed up the rendering process. + */ +export class Frustum { + constructor( + p0?: Plane, + p1?: Plane, + p2?: Plane, + p3?: Plane, + p4?: Plane, + p5?: Plane + ); + + /** + * Array of 6 vectors. + */ + planes: Plane[]; + + set( + p0?: number, + p1?: number, + p2?: number, + p3?: number, + p4?: number, + p5?: number + ): Frustum; + clone(): this; + copy(frustum: Frustum): this; + setFromMatrix(m: Matrix4): Frustum; + intersectsObject(object: Object3D): boolean; + intersectsObject(sprite: Sprite): boolean; + intersectsSphere(sphere: Sphere): boolean; + intersectsBox(box: Box3): boolean; + containsPoint(point: Vector3): boolean; +} diff --git a/src/math/Interpolant.d.ts b/src/math/Interpolant.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1d3301a03086d6c19c72d5a8b713b3ce124a819b --- /dev/null +++ b/src/math/Interpolant.d.ts @@ -0,0 +1,15 @@ +export abstract class Interpolant { + constructor( + parameterPositions: any, + samplesValues: any, + sampleSize: number, + resultBuffer?: any + ); + + parameterPositions: any; + samplesValues: any; + valueSize: number; + resultBuffer: any; + + evaluate(time: number): any; +} diff --git a/src/math/Line3.d.ts b/src/math/Line3.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b4b85ea4b58da17ec375e79c63d15904ab9e4956 --- /dev/null +++ b/src/math/Line3.d.ts @@ -0,0 +1,26 @@ +import { Vector3 } from './Vector3'; +import { Matrix4 } from './Matrix4'; + +export class Line3 { + constructor(start?: Vector3, end?: Vector3); + + start: Vector3; + end: Vector3; + + set(start?: Vector3, end?: Vector3): Line3; + clone(): this; + copy(line: Line3): this; + getCenter(target: Vector3): Vector3; + delta(target: Vector3): Vector3; + distanceSq(): number; + distance(): number; + at(t: number, target: Vector3): Vector3; + closestPointToPointParameter(point: Vector3, clampToLine?: boolean): number; + closestPointToPoint( + point: Vector3, + clampToLine: boolean, + target: Vector3 + ): Vector3; + applyMatrix4(matrix: Matrix4): Line3; + equals(line: Line3): boolean; +} diff --git a/src/math/Math.d.ts b/src/math/Math.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2cc9fbb07307372f5b4a8f6e137662309ca8133d --- /dev/null +++ b/src/math/Math.d.ts @@ -0,0 +1,95 @@ +/** + * + * @see src/math/Math.js + */ +export namespace _Math { + export const DEG2RAD: number; + export const RAD2DEG: number; + + export function generateUUID(): string; + + /** + * Clamps the x to be between a and b. + * + * @param value Value to be clamped. + * @param min Minimum value + * @param max Maximum value. + */ + export function clamp(value: number, min: number, max: number): number; + export function euclideanModulo(n: number, m: number): number; + + /** + * Linear mapping of x from range [a1, a2] to range [b1, b2]. + * + * @param x Value to be mapped. + * @param a1 Minimum value for range A. + * @param a2 Maximum value for range A. + * @param b1 Minimum value for range B. + * @param b2 Maximum value for range B. + */ + export function mapLinear( + x: number, + a1: number, + a2: number, + b1: number, + b2: number + ): number; + + export function smoothstep(x: number, min: number, max: number): number; + + export function smootherstep(x: number, min: number, max: number): number; + + /** + * Random float from 0 to 1 with 16 bits of randomness. + * Standard Math.random() creates repetitive patterns when applied over larger space. + * + * @deprecated Use {@link Math#random Math.random()} + */ + export function random16(): number; + + /** + * Random integer from low to high interval. + */ + export function randInt(low: number, high: number): number; + + /** + * Random float from low to high interval. + */ + export function randFloat(low: number, high: number): number; + + /** + * Random float from - range / 2 to range / 2 interval. + */ + export function randFloatSpread(range: number): number; + + export function degToRad(degrees: number): number; + + export function radToDeg(radians: number): number; + + export function isPowerOfTwo(value: number): boolean; + + /** + * Returns a value linearly interpolated from two known points based + * on the given interval - t = 0 will return x and t = 1 will return y. + * + * @param x Start point. + * @param y End point. + * @param t interpolation factor in the closed interval [0, 1] + * @return {number} + */ + export function lerp(x: number, y: number, t: number): number; + + /** + * @deprecated Use {@link Math#floorPowerOfTwo .floorPowerOfTwo()} + */ + export function nearestPowerOfTwo(value: number): number; + + /** + * @deprecated Use {@link Math#ceilPowerOfTwo .ceilPowerOfTwo()} + */ + export function nextPowerOfTwo(value: number): number; + + export function floorPowerOfTwo(value: number): number; + + export function ceilPowerOfTwo(value: number): number; +} diff --git a/src/math/Matrix3.d.ts b/src/math/Matrix3.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..12bf2a555e793504356b8e964bc74fe326421d04 --- /dev/null +++ b/src/math/Matrix3.d.ts @@ -0,0 +1,132 @@ +import { Matrix4 } from './Matrix4'; +import { BufferAttribute } from './../core/BufferAttribute'; +import { Vector3 } from './Vector3'; + +/** + * ( interface Matrix<T> ) + */ +export interface Matrix { + /** + * Float32Array with matrix values. + */ + elements: Float32Array; + + /** + * identity():T; + */ + identity(): Matrix; + + /** + * copy(m:T):T; + */ + copy(m: this): this; + + /** + * multiplyScalar(s:number):T; + */ + multiplyScalar(s: number): Matrix; + + determinant(): number; + + /** + * getInverse(matrix:T, throwOnInvertible?:boolean):T; + */ + getInverse(matrix: Matrix, throwOnInvertible?: boolean): Matrix; + + /** + * transpose():T; + */ + transpose(): Matrix; + + /** + * clone():T; + */ + clone(): this; +} + +/** + * ( class Matrix3 implements Matrix<Matrix3> ) + */ +export class Matrix3 implements Matrix { + /** + * Creates an identity matrix. + */ + constructor(); + + /** + * Float32Array with matrix values. + */ + elements: Float32Array; + + set( + n11: number, + n12: number, + n13: number, + n21: number, + n22: number, + n23: number, + n31: number, + n32: number, + n33: number + ): Matrix3; + identity(): Matrix3; + clone(): this; + copy(m: Matrix3): this; + setFromMatrix4(m: Matrix4): Matrix3; + + /** + * @deprecated Use {@link Matrix3#applyToBufferAttribute matrix3.applyToBufferAttribute( attribute )} instead. + */ + applyToBuffer( + buffer: BufferAttribute, + offset?: number, + length?: number + ): BufferAttribute; + + applyToBufferAttribute(attribute: BufferAttribute): BufferAttribute; + + multiplyScalar(s: number): Matrix3; + determinant(): number; + getInverse(matrix: Matrix3, throwOnDegenerate?: boolean): Matrix3; + + /** + * Transposes this matrix in place. + */ + transpose(): Matrix3; + getNormalMatrix(matrix4: Matrix4): Matrix3; + + /** + * Transposes this matrix into the supplied array r, and returns itself. + */ + transposeIntoArray(r: number[]): number[]; + fromArray(array: number[], offset?: number): Matrix3; + toArray(): number[]; + + /** + * Multiplies this matrix by m. + */ + multiply(m: Matrix3): Matrix3; + + premultiply(m: Matrix3): Matrix3; + + /** + * Sets this matrix to a x b. + */ + multiplyMatrices(a: Matrix3, b: Matrix3): Matrix3; + + /** + * @deprecated Use {@link Vector3.applyMatrix3 vector.applyMatrix3( matrix )} instead. + */ + multiplyVector3(vector: Vector3): any; + + /** + * @deprecated This method has been removed completely. + */ + multiplyVector3Array(a: any): any; + getInverse(matrix: Matrix4, throwOnDegenerate?: boolean): Matrix3; + + /** + * @deprecated Use {@link Matrix3#toArray .toArray()} instead. + */ + flattenToArrayOffset(array: number[], offset: number): number[]; +} diff --git a/src/math/Matrix4.d.ts b/src/math/Matrix4.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9d466ea45e998e6ad7402791fa515a32e5a70fdd --- /dev/null +++ b/src/math/Matrix4.d.ts @@ -0,0 +1,270 @@ +import { Vector3 } from './Vector3'; +import { Euler } from './Euler'; +import { Quaternion } from './Quaternion'; +import { BufferAttribute } from './../core/BufferAttribute'; +import { Matrix } from './Matrix3'; +/** + * A 4x4 Matrix. + * + * @example + * // Simple rig for rotating around 3 axes + * var m = new THREE.Matrix4(); + * var m1 = new THREE.Matrix4(); + * var m2 = new THREE.Matrix4(); + * var m3 = new THREE.Matrix4(); + * var alpha = 0; + * var beta = Math.PI; + * var gamma = Math.PI/2; + * m1.makeRotationX( alpha ); + * m2.makeRotationY( beta ); + * m3.makeRotationZ( gamma ); + * m.multiplyMatrices( m1, m2 ); + * m.multiply( m3 ); + */ +export class Matrix4 implements Matrix { + constructor(); + + /** + * Float32Array with matrix values. + */ + elements: Float32Array; + + /** + * Sets all fields of this matrix. + */ + set( + n11: number, + n12: number, + n13: number, + n14: number, + n21: number, + n22: number, + n23: number, + n24: number, + n31: number, + n32: number, + n33: number, + n34: number, + n41: number, + n42: number, + n43: number, + n44: number + ): Matrix4; + + /** + * Resets this matrix to identity. + */ + identity(): Matrix4; + clone(): this; + copy(m: Matrix4): this; + copyPosition(m: Matrix4): Matrix4; + extractBasis(xAxis: Vector3, yAxis: Vector3, zAxis: Vector3): Matrix4; + makeBasis(xAxis: Vector3, yAxis: Vector3, zAxis: Vector3): Matrix4; + + /** + * Copies the rotation component of the supplied matrix m into this matrix rotation component. + */ + extractRotation(m: Matrix4): Matrix4; + makeRotationFromEuler(euler: Euler): Matrix4; + makeRotationFromQuaternion(q: Quaternion): Matrix4; + /** + * Constructs a rotation matrix, looking from eye towards center with defined up vector. + */ + lookAt(eye: Vector3, target: Vector3, up: Vector3): Matrix4; + + /** + * Multiplies this matrix by m. + */ + multiply(m: Matrix4): Matrix4; + + premultiply(m: Matrix4): Matrix4; + + /** + * Sets this matrix to a x b. + */ + multiplyMatrices(a: Matrix4, b: Matrix4): Matrix4; + + /** + * Sets this matrix to a x b and stores the result into the flat array r. + * r can be either a regular Array or a TypedArray. + * + * @deprecated This method has been removed completely. + */ + multiplyToArray(a: Matrix4, b: Matrix4, r: number[]): Matrix4; + + /** + * Multiplies this matrix by s. + */ + multiplyScalar(s: number): Matrix4; + + /** + * @deprecated Use {@link Matrix4#applyToBufferAttribute matrix4.applyToBufferAttribute( attribute )} instead. + */ + applyToBuffer( + buffer: BufferAttribute, + offset?: number, + length?: number + ): BufferAttribute; + + applyToBufferAttribute(attribute: BufferAttribute): BufferAttribute; + + /** + * Computes determinant of this matrix. + * Based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm + */ + determinant(): number; + + /** + * Transposes this matrix. + */ + transpose(): Matrix4; + + /** + * Sets the position component for this matrix from vector v. + */ + setPosition(v: Vector3): Matrix4; + + /** + * Sets this matrix to the inverse of matrix m. + * Based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm. + */ + getInverse(m: Matrix4, throwOnDegeneratee?: boolean): Matrix4; + + /** + * Multiplies the columns of this matrix by vector v. + */ + scale(v: Vector3): Matrix4; + + getMaxScaleOnAxis(): number; + /** + * Sets this matrix as translation transform. + */ + makeTranslation(x: number, y: number, z: number): Matrix4; + + /** + * Sets this matrix as rotation transform around x axis by theta radians. + * + * @param theta Rotation angle in radians. + */ + makeRotationX(theta: number): Matrix4; + + /** + * Sets this matrix as rotation transform around y axis by theta radians. + * + * @param theta Rotation angle in radians. + */ + makeRotationY(theta: number): Matrix4; + + /** + * Sets this matrix as rotation transform around z axis by theta radians. + * + * @param theta Rotation angle in radians. + */ + makeRotationZ(theta: number): Matrix4; + + /** + * Sets this matrix as rotation transform around axis by angle radians. + * Based on http://www.gamedev.net/reference/articles/article1199.asp. + * + * @param axis Rotation axis. + * @param theta Rotation angle in radians. + */ + makeRotationAxis(axis: Vector3, angle: number): Matrix4; + + /** + * Sets this matrix as scale transform. + */ + makeScale(x: number, y: number, z: number): Matrix4; + + /** + * Sets this matrix to the transformation composed of translation, rotation and scale. + */ + compose(translation: Vector3, rotation: Quaternion, scale: Vector3): Matrix4; + + /** + * Decomposes this matrix into the translation, rotation and scale components. + * If parameters are not passed, new instances will be created. + */ + decompose( + translation?: Vector3, + rotation?: Quaternion, + scale?: Vector3 + ): Object[]; // [Vector3, Quaternion, Vector3] + + /** + * Creates a frustum matrix. + */ + makePerspective( + left: number, + right: number, + bottom: number, + top: number, + near: number, + far: number + ): Matrix4; + + /** + * Creates a perspective projection matrix. + */ + makePerspective( + fov: number, + aspect: number, + near: number, + far: number + ): Matrix4; + + /** + * Creates an orthographic projection matrix. + */ + makeOrthographic( + left: number, + right: number, + top: number, + bottom: number, + near: number, + far: number + ): Matrix4; + equals(matrix: Matrix4): boolean; + fromArray(array: number[], offset?: number): Matrix4; + toArray(): number[]; + + /** + * @deprecated Use {@link Matrix4#copyPosition .copyPosition()} instead. + */ + extractPosition(m: Matrix4): Matrix4; + + /** + * @deprecated Use {@link Matrix4#makeRotationFromQuaternion .makeRotationFromQuaternion()} instead. + */ + setRotationFromQuaternion(q: Quaternion): Matrix4; + + /** + * @deprecated Use {@link Vector3#applyMatrix4 vector.applyMatrix4( matrix )} instead. + */ + multiplyVector3(v: any): any; + + /** + * @deprecated Use {@link Vector4#applyMatrix4 vector.applyMatrix4( matrix )} instead. + */ + multiplyVector4(v: any): any; + + /** + * @deprecated This method has been removed completely. + */ + multiplyVector3Array(array: number[]): number[]; + + /** + * @deprecated Use {@link Vector3#transformDirection Vector3.transformDirection( matrix )} instead. + */ + rotateAxis(v: any): void; + + /** + * @deprecated Use {@link Vector3#applyMatrix4 vector.applyMatrix4( matrix )} instead. + */ + crossVector(v: any): void; + + /** + * @deprecated Use {@link Matrix4#toArray .toArray()} instead. + */ + flattenToArrayOffset(array: number[], offset: number): number[]; +} diff --git a/src/math/Plane.d.ts b/src/math/Plane.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c620957b6614882d8a87a4d242cfa7029691fd4 --- /dev/null +++ b/src/math/Plane.d.ts @@ -0,0 +1,38 @@ +import { Vector3 } from './Vector3'; +import { Sphere } from './Sphere'; +import { Line3 } from './Line3'; +import { Box3 } from './Box3'; +import { Matrix4 } from './Matrix4'; +import { Matrix3 } from './Matrix3'; + +export class Plane { + constructor(normal?: Vector3, constant?: number); + + normal: Vector3; + constant: number; + + set(normal: Vector3, constant: number): Plane; + setComponents(x: number, y: number, z: number, w: number): Plane; + setFromNormalAndCoplanarPoint(normal: Vector3, point: Vector3): Plane; + setFromCoplanarPoints(a: Vector3, b: Vector3, c: Vector3): Plane; + clone(): this; + copy(plane: Plane): this; + normalize(): Plane; + negate(): Plane; + distanceToPoint(point: Vector3): number; + distanceToSphere(sphere: Sphere): number; + projectPoint(point: Vector3, target: Vector3): Vector3; + orthoPoint(point: Vector3, target: Vector3): Vector3; + intersectLine(line: Line3, target: Vector3): Vector3; + intersectsLine(line: Line3): boolean; + intersectsBox(box: Box3): boolean; + coplanarPoint(target: Vector3): Vector3; + applyMatrix4(matrix: Matrix4, optionalNormalMatrix?: Matrix3): Plane; + translate(offset: Vector3): Plane; + equals(plane: Plane): boolean; + + /** + * @deprecated Use {@link Plane#intersectsLine .intersectsLine()} instead. + */ + isIntersectionLine(l: any): any; +} diff --git a/src/math/Quaternion.d.ts b/src/math/Quaternion.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..84b42ed427a4a8a8c98f3df46cf78ac8babab5ef --- /dev/null +++ b/src/math/Quaternion.d.ts @@ -0,0 +1,126 @@ +import { Euler } from './Euler'; +import { Vector3 } from './Vector3'; +import { Matrix4 } from './Matrix4'; + +/** + * Implementation of a quaternion. This is used for rotating things without incurring in the dreaded gimbal lock issue, amongst other advantages. + * + * @example + * var quaternion = new THREE.Quaternion(); + * quaternion.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 ); + * var vector = new THREE.Vector3( 1, 0, 0 ); + * vector.applyQuaternion( quaternion ); + */ +export class Quaternion { + /** + * @param x x coordinate + * @param y y coordinate + * @param z z coordinate + * @param w w coordinate + */ + constructor(x?: number, y?: number, z?: number, w?: number); + + x: number; + y: number; + z: number; + w: number; + + /** + * Sets values of this quaternion. + */ + set(x: number, y: number, z: number, w: number): Quaternion; + + /** + * Clones this quaternion. + */ + clone(): this; + + /** + * Copies values of q to this quaternion. + */ + copy(q: Quaternion): this; + + /** + * Sets this quaternion from rotation specified by Euler angles. + */ + setFromEuler(euler: Euler, update?: boolean): Quaternion; + + /** + * Sets this quaternion from rotation specified by axis and angle. + * Adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm. + * Axis have to be normalized, angle is in radians. + */ + setFromAxisAngle(axis: Vector3, angle: number): Quaternion; + + /** + * Sets this quaternion from rotation component of m. Adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm. + */ + setFromRotationMatrix(m: Matrix4): Quaternion; + setFromUnitVectors(vFrom: Vector3, vTo: Vector3): Quaternion; + /** + * Inverts this quaternion. + */ + inverse(): Quaternion; + + conjugate(): Quaternion; + dot(v: Quaternion): number; + lengthSq(): number; + + /** + * Computes length of this quaternion. + */ + length(): number; + + /** + * Normalizes this quaternion. + */ + normalize(): Quaternion; + + /** + * Multiplies this quaternion by b. + */ + multiply(q: Quaternion): Quaternion; + premultiply(q: Quaternion): Quaternion; + + /** + * Sets this quaternion to a x b + * Adapted from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm. + */ + multiplyQuaternions(a: Quaternion, b: Quaternion): Quaternion; + + slerp(qb: Quaternion, t: number): Quaternion; + equals(v: Quaternion): boolean; + fromArray(n: number[]): Quaternion; + toArray(): number[]; + + fromArray(xyzw: number[], offset?: number): Quaternion; + toArray(xyzw?: number[], offset?: number): number[]; + + onChange(callback: Function): Quaternion; + onChangeCallback: Function; + + /** + * Adapted from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/. + */ + static slerp( + qa: Quaternion, + qb: Quaternion, + qm: Quaternion, + t: number + ): Quaternion; + + static slerpFlat( + dst: number[], + dstOffset: number, + src0: number[], + srcOffset: number, + src1: number[], + stcOffset1: number, + t: number + ): Quaternion; + + /** + * @deprecated Use {@link Vector#applyQuaternion vector.applyQuaternion( quaternion )} instead. + */ + multiplyVector3(v: any): any; +} diff --git a/src/math/Ray.d.ts b/src/math/Ray.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1d8c5c93258f2904fbdff2dbaffd3a5974602bf8 --- /dev/null +++ b/src/math/Ray.d.ts @@ -0,0 +1,59 @@ +import { Vector3 } from './Vector3'; +import { Sphere } from './Sphere'; +import { Plane } from './Plane'; +import { Box3 } from './Box3'; +import { Matrix4 } from './Matrix4'; + +export class Ray { + constructor(origin?: Vector3, direction?: Vector3); + + origin: Vector3; + direction: Vector3; + + set(origin: Vector3, direction: Vector3): Ray; + clone(): this; + copy(ray: Ray): this; + at(t: number, target: Vector3): Vector3; + lookAt(v: Vector3): Vector3; + recast(t: number): Ray; + closestPointToPoint(point: Vector3, target: Vector3): Vector3; + distanceToPoint(point: Vector3): number; + distanceSqToPoint(point: Vector3): number; + distanceSqToSegment( + v0: Vector3, + v1: Vector3, + optionalPointOnRay?: Vector3, + optionalPointOnSegment?: Vector3 + ): number; + intersectSphere(sphere: Sphere, target: Vector3): Vector3; + intersectsSphere(sphere: Sphere): boolean; + distanceToPlane(plane: Plane): number; + intersectPlane(plane: Plane, target: Vector3): Vector3; + intersectsPlane(plane: Plane): boolean; + intersectBox(box: Box3, target: Vector3): Vector3; + intersectsBox(box: Box3): boolean; + intersectTriangle( + a: Vector3, + b: Vector3, + c: Vector3, + backfaceCulling: boolean, + target: Vector3 + ): Vector3; + applyMatrix4(matrix4: Matrix4): Ray; + equals(ray: Ray): boolean; + + /** + * @deprecated Use {@link Ray#intersectsBox .intersectsBox()} instead. + */ + isIntersectionBox(b: any): any; + + /** + * @deprecated Use {@link Ray#intersectsPlane .intersectsPlane()} instead. + */ + isIntersectionPlane(p: any): any; + + /** + * @deprecated Use {@link Ray#intersectsSphere .intersectsSphere()} instead. + */ + isIntersectionSphere(s: any): any; +} diff --git a/src/math/Sphere.d.ts b/src/math/Sphere.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..70fefcfdff458aaee78fe841454cbbaab6163213 --- /dev/null +++ b/src/math/Sphere.d.ts @@ -0,0 +1,27 @@ +import { Vector3 } from './Vector3'; +import { Box3 } from './Box3'; +import { Plane } from './Plane'; +import { Matrix4 } from './Matrix4'; + +export class Sphere { + constructor(center?: Vector3, radius?: number); + + center: Vector3; + radius: number; + + set(center: Vector3, radius: number): Sphere; + setFromPoints(points: Vector3[], optionalCenter?: Vector3): Sphere; + clone(): this; + copy(sphere: Sphere): this; + empty(): boolean; + containsPoint(point: Vector3): boolean; + distanceToPoint(point: Vector3): number; + intersectsSphere(sphere: Sphere): boolean; + intersectsBox(box: Box3): boolean; + intersectsPlane(plane: Plane): boolean; + clampPoint(point: Vector3, target: Vector3): Vector3; + getBoundingBox(target: Box3): Box3; + applyMatrix4(matrix: Matrix4): Sphere; + translate(offset: Vector3): Sphere; + equals(sphere: Sphere): boolean; +} diff --git a/src/math/Spherical.d.ts b/src/math/Spherical.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..dc4d22317b9ee0f3263de511ef177c224bd8c496 --- /dev/null +++ b/src/math/Spherical.d.ts @@ -0,0 +1,15 @@ +import { Vector3 } from './Vector3'; + +export class Spherical { + constructor(radius?: number, phi?: number, theta?: number); + + radius: number; + phi: number; + theta: number; + + set(radius: number, phi: number, theta: number): Spherical; + clone(): this; + copy(other: Spherical): this; + makeSafe(): void; + setFromVector3(vec3: Vector3): Spherical; +} diff --git a/src/math/Triangle.d.ts b/src/math/Triangle.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6efed13569d016500d1c28c75614ee76486b98cd --- /dev/null +++ b/src/math/Triangle.d.ts @@ -0,0 +1,54 @@ +import { Vector3 } from './Vector3'; +import { Plane } from './Plane'; + +export interface SplineControlPoint { + x: number; + y: number; + z: number; +} + +export class Triangle { + constructor(a?: Vector3, b?: Vector3, c?: Vector3); + + a: Vector3; + b: Vector3; + c: Vector3; + + set(a: Vector3, b: Vector3, c: Vector3): Triangle; + setFromPointsAndIndices( + points: Vector3[], + i0: number, + i1: number, + i2: number + ): Triangle; + clone(): this; + copy(triangle: Triangle): this; + getArea(): number; + getMidpoint(target: Vector3): Vector3; + getNormal(target: Vector3): Vector3; + getPlane(target: Vector3): Plane; + getBarycoord(point: Vector3, target: Vector3): Vector3; + containsPoint(point: Vector3): boolean; + closestPointToPoint(point: Vector3, target: Vector3): Vector3; + equals(triangle: Triangle): boolean; + + static getNormal( + a: Vector3, + b: Vector3, + c: Vector3, + target: Vector3 + ): Vector3; + static getBarycoord( + point: Vector3, + a: Vector3, + b: Vector3, + c: Vector3, + target: Vector3 + ): Vector3; + static containsPoint( + point: Vector3, + a: Vector3, + b: Vector3, + c: Vector3 + ): boolean; +} diff --git a/src/math/Vector2.d.ts b/src/math/Vector2.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8ad975ca952fb48858340b438d63bd4ceae67ed4 --- /dev/null +++ b/src/math/Vector2.d.ts @@ -0,0 +1,440 @@ +import { Vector4 } from './Vector4'; +import { Matrix3 } from './Matrix3'; +import { BufferAttribute } from './../core/BufferAttribute'; + +/** + * ( interface Vector<T> ) + * + * Abstract interface of Vector2, Vector3 and Vector4. + * Currently the members of Vector is NOT type safe because it accepts different typed vectors. + * Those definitions will be changed when TypeScript innovates Generics to be type safe. + * + * @example + * var v:THREE.Vector = new THREE.Vector3(); + * v.addVectors(new THREE.Vector2(0, 1), new THREE.Vector2(2, 3)); // invalid but compiled successfully + */ +export interface Vector { + setComponent(index: number, value: number): this; + + getComponent(index: number): number; + + set(...args: number[]): this; + + setScalar(scalar: number): this; + + /** + * copy(v:T):T; + */ + copy(v: Vector): this; + + /** + * NOTE: The second argument is deprecated. + * + * add(v:T):T; + */ + add(v: Vector, w?: Vector): this; + + /** + * addVectors(a:T, b:T):T; + */ + addVectors(a: Vector, b: Vector): this; + + addScaledVector(vector: Vector, scale: number): this; + + /** + * Adds the scalar value s to this vector's values. + */ + addScalar(scalar: number): this; + + /** + * sub(v:T):T; + */ + sub(v: Vector): this; + + /** + * subVectors(a:T, b:T):T; + */ + subVectors(a: Vector, b: Vector): this; + + /** + * multiplyScalar(s:number):T; + */ + multiplyScalar(s: number): this; + + /** + * divideScalar(s:number):T; + */ + divideScalar(s: number): this; + + /** + * negate():T; + */ + negate(): this; + + /** + * dot(v:T):T; + */ + dot(v: Vector): number; + + /** + * lengthSq():number; + */ + lengthSq(): number; + + /** + * length():number; + */ + length(): number; + + /** + * normalize():T; + */ + normalize(): this; + + /** + * NOTE: Vector4 doesn't have the property. + * + * distanceTo(v:T):number; + */ + distanceTo?(v: Vector): number; + + /** + * NOTE: Vector4 doesn't have the property. + * + * distanceToSquared(v:T):number; + */ + distanceToSquared?(v: Vector): number; + + /** + * setLength(l:number):T; + */ + setLength(l: number): this; + + /** + * lerp(v:T, alpha:number):T; + */ + lerp(v: Vector, alpha: number): this; + + /** + * equals(v:T):boolean; + */ + equals(v: Vector): boolean; + + /** + * clone():T; + */ + clone(): this; +} + +/** + * 2D vector. + * + * ( class Vector2 implements Vector ) + */ +export class Vector2 implements Vector { + constructor(x?: number, y?: number); + + x: number; + y: number; + width: number; + height: number; + isVector2: true; + + /** + * Sets value of this vector. + */ + set(x: number, y: number): this; + + /** + * Sets the x and y values of this vector both equal to scalar. + */ + setScalar(scalar: number): this; + + /** + * Sets X component of this vector. + */ + setX(x: number): this; + + /** + * Sets Y component of this vector. + */ + setY(y: number): this; + + /** + * Sets a component of this vector. + */ + setComponent(index: number, value: number): this; + + /** + * Gets a component of this vector. + */ + getComponent(index: number): number; + + /** + * Returns a new Vector2 instance with the same `x` and `y` values. + */ + clone(): this; + + /** + * Copies value of v to this vector. + */ + copy(v: Vector2): this; + + /** + * Adds v to this vector. + */ + add(v: Vector2, w?: Vector2): this; + + /** + * Adds the scalar value s to this vector's x and y values. + */ + addScalar(s: number): this; + + /** + * Sets this vector to a + b. + */ + addVectors(a: Vector2, b: Vector2): this; + + /** + * Adds the multiple of v and s to this vector. + */ + addScaledVector(v: Vector2, s: number): this; + + /** + * Subtracts v from this vector. + */ + sub(v: Vector2): this; + + /** + * Subtracts s from this vector's x and y components. + */ + subScalar(s: number): this; + + /** + * Sets this vector to a - b. + */ + subVectors(a: Vector2, b: Vector2): this; + + /** + * Multiplies this vector by v. + */ + multiply(v: Vector2): this; + + /** + * Multiplies this vector by scalar s. + */ + multiplyScalar(scalar: number): this; + + /** + * Divides this vector by v. + */ + divide(v: Vector2): this; + + /** + * Divides this vector by scalar s. + * Set vector to ( 0, 0 ) if s == 0. + */ + divideScalar(s: number): this; + + /** + * Multiplies this vector (with an implicit 1 as the 3rd component) by m. + */ + applyMatrix3(m: Matrix3): this; + + /** + * If this vector's x or y value is greater than v's x or y value, replace that value with the corresponding min value. + */ + min(v: Vector2): this; + + /** + * If this vector's x or y value is less than v's x or y value, replace that value with the corresponding max value. + */ + max(v: Vector2): this; + + /** + * If this vector's x or y value is greater than the max vector's x or y value, it is replaced by the corresponding value. + * If this vector's x or y value is less than the min vector's x or y value, it is replaced by the corresponding value. + * @param min the minimum x and y values. + * @param max the maximum x and y values in the desired range. + */ + clamp(min: Vector2, max: Vector2): this; + + /** + * If this vector's x or y values are greater than the max value, they are replaced by the max value. + * If this vector's x or y values are less than the min value, they are replaced by the min value. + * @param min the minimum value the components will be clamped to. + * @param max the maximum value the components will be clamped to. + */ + clampScalar(min: number, max: number): this; + + /** + * If this vector's length is greater than the max value, it is replaced by the max value. + * If this vector's length is less than the min value, it is replaced by the min value. + * @param min the minimum value the length will be clamped to. + * @param max the maximum value the length will be clamped to. + */ + clampLength(min: number, max: number): this; + + /** + * The components of the vector are rounded down to the nearest integer value. + */ + floor(): this; + + /** + * The x and y components of the vector are rounded up to the nearest integer value. + */ + ceil(): this; + + /** + * The components of the vector are rounded to the nearest integer value. + */ + round(): this; + + /** + * The components of the vector are rounded towards zero (up if negative, down if positive) to an integer value. + */ + roundToZero(): this; + + /** + * Inverts this vector. + */ + negate(): this; + + /** + * Computes dot product of this vector and v. + */ + dot(v: Vector2): number; + + /** + * Computes squared length of this vector. + */ + lengthSq(): number; + + /** + * Computes length of this vector. + */ + length(): number; + + /** + * @deprecated Use {@link Vector2#manhattanLength .manhattanLength()} instead. + */ + lengthManhattan(): number; + + /** + * Computes the Manhattan length of this vector. + * + * @return {number} + * + * @see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry} + */ + manhattanLength(): number; + + /** + * Normalizes this vector. + */ + normalize(): this; + + /** + * computes the angle in radians with respect to the positive x-axis + */ + angle(): number; + + /** + * Computes distance of this vector to v. + */ + distanceTo(v: Vector2): number; + + /** + * Computes squared distance of this vector to v. + */ + distanceToSquared(v: Vector2): number; + + /** + * @deprecated Use {@link Vector2#manhattanDistanceTo .manhattanDistanceTo()} instead. + */ + distanceToManhattan(v: Vector2): number; + + /** + * Computes the Manhattan length (distance) from this vector to the given vector v + * + * @param {Vector2} v + * + * @return {number} + * + * @see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry} + */ + manhattanDistanceTo(v: Vector2): number; + + /** + * Normalizes this vector and multiplies it by l. + */ + setLength(length: number): this; + + /** + * Linearly interpolates between this vector and v, where alpha is the distance along the line - alpha = 0 will be this vector, and alpha = 1 will be v. + * @param v vector to interpolate towards. + * @param alpha interpolation factor in the closed interval [0, 1]. + */ + lerp(v: Vector2, alpha: number): this; + + /** + * Sets this vector to be the vector linearly interpolated between v1 and v2 where alpha is the distance along the line connecting the two vectors - alpha = 0 will be v1, and alpha = 1 will be v2. + * @param v1 the starting vector. + * @param v2 vector to interpolate towards. + * @param alpha interpolation factor in the closed interval [0, 1]. + */ + lerpVectors(v1: Vector2, v2: Vector2, alpha: number): this; + + /** + * Checks for strict equality of this vector and v. + */ + equals(v: Vector2): boolean; + + /** + * Sets this vector's x value to be array[offset] and y value to be array[offset + 1]. + * @param array the source array. + * @param offset (optional) offset into the array. Default is 0. + */ + fromArray(array: number[], offset?: number): this; + + /** + * Returns an array [x, y], or copies x and y into the provided array. + * @param array (optional) array to store the vector to. If this is not provided, a new array will be created. + * @param offset (optional) optional offset into the array. + */ + toArray(array?: number[], offset?: number): number[]; + + /** + * Sets this vector's x and y values from the attribute. + * @param attribute the source attribute. + * @param index index in the attribute. + */ + fromBufferAttribute(attribute: BufferAttribute, index: number): this; + + /** + * Rotates the vector around center by angle radians. + * @param center the point around which to rotate. + * @param angle the angle to rotate, in radians. + */ + rotateAround(center: Vector2, angle: number): this; + + /** + * Computes the Manhattan length of this vector. + * + * @return {number} + * + * @see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry} + */ + manhattanLength(): number; + + /** + * Computes the Manhattan length (distance) from this vector to the given vector v + * + * @param {Vector2} v + * + * @return {number} + * + * @see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry} + */ + manhattanDistanceTo(v: Vector2): number; +} diff --git a/src/math/Vector3.d.ts b/src/math/Vector3.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fd4f49b6ff700dac541cbab8b5188c56c23e4d93 --- /dev/null +++ b/src/math/Vector3.d.ts @@ -0,0 +1,255 @@ +import { Euler } from './Euler'; +import { Matrix3 } from './Matrix3'; +import { Matrix4 } from './Matrix4'; +import { Quaternion } from './Quaternion'; +import { Camera } from './../cameras/Camera'; +import { Spherical } from './Spherical'; +import { Cylindrical } from './Cylindrical'; +import { BufferAttribute } from './../core/BufferAttribute'; +import { Vector } from './Vector2'; +/** + * 3D vector. + * + * @example + * var a = new THREE.Vector3( 1, 0, 0 ); + * var b = new THREE.Vector3( 0, 1, 0 ); + * var c = new THREE.Vector3(); + * c.crossVectors( a, b ); + * + * @see src/math/Vector3.js + * + * ( class Vector3 implements Vector ) + */ +export class Vector3 implements Vector { + constructor(x?: number, y?: number, z?: number); + + x: number; + y: number; + z: number; + isVector3: true; + + /** + * Sets value of this vector. + */ + set(x: number, y: number, z: number): this; + + /** + * Sets all values of this vector. + */ + setScalar(scalar: number): this; + + /** + * Sets x value of this vector. + */ + setX(x: number): Vector3; + + /** + * Sets y value of this vector. + */ + setY(y: number): Vector3; + + /** + * Sets z value of this vector. + */ + setZ(z: number): Vector3; + + setComponent(index: number, value: number): this; + + getComponent(index: number): number; + + /** + * Clones this vector. + */ + clone(): this; + + /** + * Copies value of v to this vector. + */ + copy(v: Vector3): this; + + /** + * Adds v to this vector. + */ + add(a: Vector3, b?: Vector3): this; + + addScalar(s: number): this; + + addScaledVector(v: Vector3, s: number): this; + + /** + * Sets this vector to a + b. + */ + addVectors(a: Vector3, b: Vector3): this; + + /** + * Subtracts v from this vector. + */ + sub(a: Vector3): this; + + subScalar(s: number): this; + + /** + * Sets this vector to a - b. + */ + subVectors(a: Vector3, b: Vector3): this; + + multiply(v: Vector3): this; + + /** + * Multiplies this vector by scalar s. + */ + multiplyScalar(s: number): this; + + multiplyVectors(a: Vector3, b: Vector3): this; + + applyEuler(euler: Euler): this; + + applyAxisAngle(axis: Vector3, angle: number): this; + + applyMatrix3(m: Matrix3): this; + + applyMatrix4(m: Matrix4): this; + + applyQuaternion(q: Quaternion): this; + + project(camrea: Camera): this; + + unproject(camera: Camera): this; + + transformDirection(m: Matrix4): this; + + divide(v: Vector3): this; + + /** + * Divides this vector by scalar s. + * Set vector to ( 0, 0, 0 ) if s == 0. + */ + divideScalar(s: number): this; + + min(v: Vector3): this; + + max(v: Vector3): this; + + clamp(min: Vector3, max: Vector3): this; + + clampScalar(min: number, max: number): this; + + clampLength(min: number, max: number): this; + + floor(): this; + + ceil(): this; + + round(): this; + + roundToZero(): this; + + /** + * Inverts this vector. + */ + negate(): this; + + /** + * Computes dot product of this vector and v. + */ + dot(v: Vector3): number; + + /** + * Computes squared length of this vector. + */ + lengthSq(): number; + + /** + * Computes length of this vector. + */ + length(): number; + + /** + * Computes Manhattan length of this vector. + * http://en.wikipedia.org/wiki/Taxicab_geometry + * + * @deprecated Use {@link Vector3#manhattanLength .manhattanLength()} instead. + */ + lengthManhattan(): number; + + /** + * Computes the Manhattan length of this vector. + * + * @return {number} + * + * @see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry} + */ + manhattanLength(): number; + + /** + * Computes the Manhattan length (distance) from this vector to the given vector v + * + * @param {Vector3} v + * + * @return {number} + * + * @see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry} + */ + manhattanDistanceTo(v: Vector3): number; + + /** + * Normalizes this vector. + */ + normalize(): this; + + /** + * Normalizes this vector and multiplies it by l. + */ + setLength(l: number): this; + lerp(v: Vector3, alpha: number): this; + + lerpVectors(v1: Vector3, v2: Vector3, alpha: number): this; + + /** + * Sets this vector to cross product of itself and v. + */ + cross(a: Vector3, w?: Vector3): this; + + /** + * Sets this vector to cross product of a and b. + */ + crossVectors(a: Vector3, b: Vector3): this; + projectOnVector(v: Vector3): this; + projectOnPlane(planeNormal: Vector3): this; + reflect(vector: Vector3): this; + angleTo(v: Vector3): number; + + /** + * Computes distance of this vector to v. + */ + distanceTo(v: Vector3): number; + + /** + * Computes squared distance of this vector to v. + */ + distanceToSquared(v: Vector3): number; + + /** + * @deprecated Use {@link Vector3#manhattanDistanceTo .manhattanDistanceTo()} instead. + */ + distanceToManhattan(v: Vector3): number; + + setFromSpherical(s: Spherical): this; + setFromCylindrical(s: Cylindrical): this; + setFromMatrixPosition(m: Matrix4): this; + setFromMatrixScale(m: Matrix4): this; + setFromMatrixColumn(matrix: Matrix4, index: number): this; + + /** + * Checks for strict equality of this vector and v. + */ + equals(v: Vector3): boolean; + + fromArray(xyz: number[], offset?: number): Vector3; + toArray(xyz?: number[], offset?: number): number[]; + fromBufferAttribute( + attribute: BufferAttribute, + index: number, + offset?: number + ): this; +} diff --git a/src/math/Vector4.d.ts b/src/math/Vector4.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5045a20485342a543744373a9f8c587e195bfb54 --- /dev/null +++ b/src/math/Vector4.d.ts @@ -0,0 +1,187 @@ +import { Matrix4 } from './Matrix4'; +import { Quaternion } from './Quaternion'; +import { Matrix3 } from './Matrix3'; +import { BufferAttribute } from './../core/BufferAttribute'; +import { Vector } from './Vector2'; + +/** + * @deprecated use {@link Vector3 THREE.Vector3} instead. + */ + +/** + * 4D vector. + * + * ( class Vector4 implements Vector ) + */ +export class Vector4 implements Vector { + constructor(x?: number, y?: number, z?: number, w?: number); + + x: number; + y: number; + z: number; + w: number; + isVector4: true; + + /** + * Sets value of this vector. + */ + set(x: number, y: number, z: number, w: number): this; + + /** + * Sets all values of this vector. + */ + setScalar(scalar: number): this; + + /** + * Sets X component of this vector. + */ + setX(x: number): this; + + /** + * Sets Y component of this vector. + */ + setY(y: number): this; + + /** + * Sets Z component of this vector. + */ + setZ(z: number): this; + + /** + * Sets w component of this vector. + */ + setW(w: number): this; + + setComponent(index: number, value: number): this; + + getComponent(index: number): number; + + /** + * Clones this vector. + */ + clone(): this; + + /** + * Copies value of v to this vector. + */ + copy(v: Vector4): this; + + /** + * Adds v to this vector. + */ + add(v: Vector4, w?: Vector4): this; + + addScalar(scalar: number): this; + + /** + * Sets this vector to a + b. + */ + addVectors(a: Vector4, b: Vector4): this; + + addScaledVector(v: Vector4, s: number): this; + /** + * Subtracts v from this vector. + */ + sub(v: Vector4): this; + + subScalar(s: number): this; + + /** + * Sets this vector to a - b. + */ + subVectors(a: Vector4, b: Vector4): this; + + /** + * Multiplies this vector by scalar s. + */ + multiplyScalar(s: number): this; + + applyMatrix4(m: Matrix4): this; + + /** + * Divides this vector by scalar s. + * Set vector to ( 0, 0, 0 ) if s == 0. + */ + divideScalar(s: number): this; + + /** + * http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm + * @param q is assumed to be normalized + */ + setAxisAngleFromQuaternion(q: Quaternion): this; + + /** + * http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm + * @param m assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) + */ + setAxisAngleFromRotationMatrix(m: Matrix3): this; + + min(v: Vector4): this; + max(v: Vector4): this; + clamp(min: Vector4, max: Vector4): this; + clampScalar(min: number, max: number): this; + floor(): this; + ceil(): this; + round(): this; + roundToZero(): this; + + /** + * Inverts this vector. + */ + negate(): this; + + /** + * Computes dot product of this vector and v. + */ + dot(v: Vector4): number; + + /** + * Computes squared length of this vector. + */ + lengthSq(): number; + + /** + * Computes length of this vector. + */ + length(): number; + + /** + * Computes the Manhattan length of this vector. + * + * @return {number} + * + * @see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry} + */ + manhattanLength(): number; + + /** + * Normalizes this vector. + */ + normalize(): this; + /** + * Normalizes this vector and multiplies it by l. + */ + setLength(length: number): this; + + /** + * Linearly interpolate between this vector and v with alpha factor. + */ + lerp(v: Vector4, alpha: number): this; + + lerpVectors(v1: Vector4, v2: Vector4, alpha: number): this; + + /** + * Checks for strict equality of this vector and v. + */ + equals(v: Vector4): boolean; + + fromArray(xyzw: number[], offset?: number): this; + + toArray(xyzw?: number[], offset?: number): number[]; + + fromBufferAttribute( + attribute: BufferAttribute, + index: number, + offset?: number + ): this; +} diff --git a/src/math/interpolants/CubicInterpolant.d.ts b/src/math/interpolants/CubicInterpolant.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb083f8216b52c0cfae829f2d76fc7f1eed3e3e4 --- /dev/null +++ b/src/math/interpolants/CubicInterpolant.d.ts @@ -0,0 +1,12 @@ +import { Interpolant } from '../Interpolant'; + +export class CubicInterpolant extends Interpolant { + constructor( + parameterPositions: any, + samplesValues: any, + sampleSize: number, + resultBuffer?: any + ); + + interpolate_(i1: number, t0: number, t: number, t1: number): any; +} diff --git a/src/math/interpolants/DiscreteInterpolant.d.ts b/src/math/interpolants/DiscreteInterpolant.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb044037fe6015ba39e9d9919ba271a9063fcef4 --- /dev/null +++ b/src/math/interpolants/DiscreteInterpolant.d.ts @@ -0,0 +1,12 @@ +import { Interpolant } from '../Interpolant'; + +export class DiscreteInterpolant extends Interpolant { + constructor( + parameterPositions: any, + samplesValues: any, + sampleSize: number, + resultBuffer?: any + ); + + interpolate_(i1: number, t0: number, t: number, t1: number): any; +} diff --git a/src/math/interpolants/LinearInterpolant.d.ts b/src/math/interpolants/LinearInterpolant.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..45a3ca6449ee63dfd7a20d5f5cab46b161654e32 --- /dev/null +++ b/src/math/interpolants/LinearInterpolant.d.ts @@ -0,0 +1,12 @@ +import { Interpolant } from '../Interpolant'; + +export class LinearInterpolant extends Interpolant { + constructor( + parameterPositions: any, + samplesValues: any, + sampleSize: number, + resultBuffer?: any + ); + + interpolate_(i1: number, t0: number, t: number, t1: number): any; +} diff --git a/src/math/interpolants/QuaternionLinearInterpolant.d.ts b/src/math/interpolants/QuaternionLinearInterpolant.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4b9f19601f1ae2e9ab0b79bad35db0839656dfc1 --- /dev/null +++ b/src/math/interpolants/QuaternionLinearInterpolant.d.ts @@ -0,0 +1,12 @@ +import { Interpolant } from '../Interpolant'; + +export class QuaternionLinearInterpolant extends Interpolant { + constructor( + parameterPositions: any, + samplesValues: any, + sampleSize: number, + resultBuffer?: any + ); + + interpolate_(i1: number, t0: number, t: number, t1: number): any; +} diff --git a/src/objects/Bone.d.ts b/src/objects/Bone.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e6d323792c661b76aac0ce91c8b8f1d53d28cd87 --- /dev/null +++ b/src/objects/Bone.d.ts @@ -0,0 +1,9 @@ +import { Object3D } from './../core/Object3D'; + +// Objects ////////////////////////////////////////////////////////////////////////////////// + +export class Bone extends Object3D { + constructor(); + isBone: true; + type: 'Bone'; +} diff --git a/src/objects/Group.d.ts b/src/objects/Group.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..40b4c5f9bb44c5ffd19fd4a7314f800ac688f862 --- /dev/null +++ b/src/objects/Group.d.ts @@ -0,0 +1,7 @@ +import { Object3D } from './../core/Object3D'; + +export class Group extends Object3D { + constructor(); + type: 'Group'; + isGroup: true; +} diff --git a/src/objects/LOD.d.ts b/src/objects/LOD.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a7e22374b570b2454dc3d40e586bcff1735b08b3 --- /dev/null +++ b/src/objects/LOD.d.ts @@ -0,0 +1,23 @@ +import { Object3D } from './../core/Object3D'; +import { Raycaster } from './../core/Raycaster'; +import { Camera } from './../cameras/Camera'; +import { Intersection } from '../core/Raycaster'; + +export class LOD extends Object3D { + constructor(); + + type: 'LOD'; + + levels: { distance: number; object: Object3D }[]; + + addLevel(object: Object3D, distance?: number): void; + getObjectForDistance(distance: number): Object3D; + raycast(raycaster: Raycaster, intersects: Intersection[]): void; + update(camera: Camera): void; + toJSON(meta: any): any; + + /** + * @deprecated Use {@link LOD#levels .levels} instead. + */ + objects: any[]; +} diff --git a/src/objects/Line.d.ts b/src/objects/Line.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae75ff33277b44e839daf018596bd213c217ee9f --- /dev/null +++ b/src/objects/Line.d.ts @@ -0,0 +1,23 @@ +import { Geometry } from './../core/Geometry'; +import { Material } from './../materials/Material'; +import { Raycaster } from './../core/Raycaster'; +import { Object3D } from './../core/Object3D'; +import { BufferGeometry } from '../core/BufferGeometry'; +import { Intersection } from '../core/Raycaster'; + +export class Line extends Object3D { + constructor( + geometry?: Geometry | BufferGeometry, + material?: Material | Material[], + mode?: number + ); + + geometry: Geometry | BufferGeometry; + material: Material | Material[]; + + type: 'Line'; + isLine: true; + + computeLineDistances(): this; + raycast(raycaster: Raycaster, intersects: Intersection[]): void; +} diff --git a/src/objects/LineLoop.d.ts b/src/objects/LineLoop.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1eedd9254157865b521b9115259bdc9d27128f5a --- /dev/null +++ b/src/objects/LineLoop.d.ts @@ -0,0 +1,11 @@ +import { Line } from './Line'; +import { Geometry } from './../core/Geometry'; +import { Material } from './../materials/Material'; +import { BufferGeometry } from '../core/BufferGeometry'; + +export class LineLoop extends Line { + constructor( + geometry?: Geometry | BufferGeometry, + material?: Material | Material[] + ); +} diff --git a/src/objects/LineSegments.d.ts b/src/objects/LineSegments.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ab5fd856418c717599587d2dcede6774bf51bc92 --- /dev/null +++ b/src/objects/LineSegments.d.ts @@ -0,0 +1,21 @@ +import { Geometry } from './../core/Geometry'; +import { Material } from './../materials/Material'; +import { Line } from './Line'; +import { BufferGeometry } from '../core/BufferGeometry'; + +/** + * @deprecated + */ +export const LineStrip: number; +/** + * @deprecated + */ +export const LinePieces: number; + +export class LineSegments extends Line { + constructor( + geometry?: Geometry | BufferGeometry, + material?: Material | Material[], + mode?: number + ); +} diff --git a/src/objects/Mesh.d.ts b/src/objects/Mesh.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e7df5b49aaf142d63122eb436e2fbf7ea16c504 --- /dev/null +++ b/src/objects/Mesh.d.ts @@ -0,0 +1,27 @@ +import { Geometry } from './../core/Geometry'; +import { Material } from './../materials/Material'; +import { Raycaster } from './../core/Raycaster'; +import { Object3D } from './../core/Object3D'; +import { BufferGeometry } from '../core/BufferGeometry'; +import { Intersection } from '../core/Raycaster'; +import { TrianglesDrawModes } from '../constants'; + +export class Mesh extends Object3D { + constructor( + geometry?: Geometry | BufferGeometry, + material?: Material | Material[] + ); + + geometry: Geometry | BufferGeometry; + material: Material | Material[]; + drawMode: TrianglesDrawModes; + morphTargetInfluences?: number[]; + morphTargetDictionary?: { [key: string]: number }; + isMesh: true; + type: string; + + setDrawMode(drawMode: TrianglesDrawModes): void; + updateMorphTargets(): void; + raycast(raycaster: Raycaster, intersects: Intersection[]): void; + copy(source: this, recursive?: boolean): this; +} diff --git a/src/objects/Points.d.ts b/src/objects/Points.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7b2db4dc7ba43cd691efbfa41f7d6f57f8b436c9 --- /dev/null +++ b/src/objects/Points.d.ts @@ -0,0 +1,37 @@ +import { Geometry } from './../core/Geometry'; +import { Material } from './../materials/Material'; +import { Raycaster } from './../core/Raycaster'; +import { Object3D } from './../core/Object3D'; +import { BufferGeometry } from '../core/BufferGeometry'; +import { Intersection } from '../core/Raycaster'; + +/** + * A class for displaying particles in the form of variable size points. For example, if using the WebGLRenderer, the particles are displayed using GL_POINTS. + * + * @see src/objects/ParticleSystem.js + */ +export class Points extends Object3D { + /** + * @param geometry An instance of Geometry or BufferGeometry. + * @param material An instance of Material (optional). + */ + constructor( + geometry?: Geometry | BufferGeometry, + material?: Material | Material[] + ); + + type: 'Points'; + isPoints: true; + + /** + * An instance of Geometry or BufferGeometry, where each vertex designates the position of a particle in the system. + */ + geometry: Geometry | BufferGeometry; + + /** + * An instance of Material, defining the object's appearance. Default is a PointsMaterial with randomised colour. + */ + material: Material | Material[]; + + raycast(raycaster: Raycaster, intersects: Intersection[]): void; +} diff --git a/src/objects/Skeleton.d.ts b/src/objects/Skeleton.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae3a89ea83b334d4fa0b9ffc28badff91f22cd14 --- /dev/null +++ b/src/objects/Skeleton.d.ts @@ -0,0 +1,31 @@ +import { Bone } from './Bone'; +import { Matrix4 } from './../math/Matrix4'; +import { DataTexture } from './../textures/DataTexture'; + +/** + * @deprecated Use {@link Points THREE.Points} instead. + */ +/** + * @deprecated Use {@link Points THREE.Points} instead. + */ + +export class Skeleton { + constructor(bones: Bone[], boneInverses?: Matrix4[]); + + /** + * @deprecated This property has been removed completely. + */ + useVertexTexture: boolean; + identityMatrix: Matrix4; + bones: Bone[]; + boneTextureWidth: number; + boneTextureHeight: number; + boneMatrices: Float32Array; + boneTexture: DataTexture; + boneInverses: Matrix4[]; + + calculateInverses(bone: Bone): void; + pose(): void; + update(): void; + clone(): this; +} diff --git a/src/objects/SkinnedMesh.d.ts b/src/objects/SkinnedMesh.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2d5eb2f3c279ab6f99ec5c40ef7c9503f3457069 --- /dev/null +++ b/src/objects/SkinnedMesh.d.ts @@ -0,0 +1,24 @@ +import { Geometry } from './../core/Geometry'; +import { Material } from './../materials/Material'; +import { Matrix4 } from './../math/Matrix4'; +import { Skeleton } from './Skeleton'; +import { Mesh } from './Mesh'; +import { BufferGeometry } from '../core/BufferGeometry'; + +export class SkinnedMesh extends Mesh { + constructor( + geometry?: Geometry | BufferGeometry, + material?: Material | Material[], + useVertexTexture?: boolean + ); + + bindMode: string; + bindMatrix: Matrix4; + bindMatrixInverse: Matrix4; + skeleton: Skeleton; + + bind(skeleton: Skeleton, bindMatrix?: Matrix4): void; + pose(): void; + normalizeSkinWeights(): void; + updateMatrixWorld(force?: boolean): void; +} diff --git a/src/objects/Sprite.d.ts b/src/objects/Sprite.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d0009780c8377aafc9fe4e9a47b0dd1fd95dcad1 --- /dev/null +++ b/src/objects/Sprite.d.ts @@ -0,0 +1,18 @@ +import { Material } from './../materials/Material'; +import { Vector2 } from './../math/Vector2'; +import { Raycaster } from './../core/Raycaster'; +import { Object3D } from './../core/Object3D'; +import { Intersection } from '../core/Raycaster'; + +export class Sprite extends Object3D { + constructor(material?: Material); + + type: 'Sprite'; + isSprite: true; + + material: Material; + center: Vector2; + + raycast(raycaster: Raycaster, intersects: Intersection[]): void; + copy(source: this, recursive?: boolean): this; +} diff --git a/src/polyfills.d.ts b/src/polyfills.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6e210ae386b8cd79a68f03164228ee4203eacce --- /dev/null +++ b/src/polyfills.d.ts @@ -0,0 +1,16 @@ +// log handlers +export function warn(message?: any, ...optionalParams: any[]): void; +export function error(message?: any, ...optionalParams: any[]): void; +export function log(message?: any, ...optionalParams: any[]): void; + +// typed array parameters +type TypedArray = + | Int8Array + | Uint8Array + | Uint8ClampedArray + | Int16Array + | Uint16Array + | Int32Array + | Uint32Array + | Float32Array + | Float64Array; diff --git a/src/renderers/WebGLMultisampleRenderTarget.d.ts b/src/renderers/WebGLMultisampleRenderTarget.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a91cad1190ff66e7296a9cc3fa6ccaf01c09b732 --- /dev/null +++ b/src/renderers/WebGLMultisampleRenderTarget.d.ts @@ -0,0 +1,12 @@ +import { + WebGLRenderTarget, + WebGLRenderTargetOptions, +} from './WebGLRenderTarget'; + +export class WebGLMultisampleRenderTarget extends WebGLRenderTarget { + constructor( + width: number, + height: number, + options?: WebGLRenderTargetOptions + ); +} diff --git a/src/renderers/WebGLRenderTarget.d.ts b/src/renderers/WebGLRenderTarget.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b20b196022809fe7d73f73035b91b30856ee4292 --- /dev/null +++ b/src/renderers/WebGLRenderTarget.d.ts @@ -0,0 +1,81 @@ +import { Vector4 } from './../math/Vector4'; +import { Texture } from './../textures/Texture'; +import { EventDispatcher } from './../core/EventDispatcher'; +import { Wrapping, TextureFilter, TextureDataType } from '../constants'; + +export interface WebGLRenderTargetOptions { + wrapS?: Wrapping; + wrapT?: Wrapping; + magFilter?: TextureFilter; + minFilter?: TextureFilter; + format?: number; // RGBAFormat; + type?: TextureDataType; // UnsignedByteType; + anisotropy?: number; // 1; + depthBuffer?: boolean; // true; + stencilBuffer?: boolean; // true; + generateMipmaps?: boolean; // true; +} + +export class WebGLRenderTarget extends EventDispatcher { + constructor( + width: number, + height: number, + options?: WebGLRenderTargetOptions + ); + + uuid: string; + width: number; + height: number; + scissor: Vector4; + scissorTest: boolean; + viewport: Vector4; + texture: Texture; + depthBuffer: boolean; + stencilBuffer: boolean; + depthTexture: Texture; + /** + * @deprecated Use {@link Texture#wrapS texture.wrapS} instead. + */ + wrapS: any; + /** + * @deprecated Use {@link Texture#wrapT texture.wrapT} instead. + */ + wrapT: any; + /** + * @deprecated Use {@link Texture#magFilter texture.magFilter} instead. + */ + magFilter: any; + /** + * @deprecated Use {@link Texture#minFilter texture.minFilter} instead. + */ + minFilter: any; + /** + * @deprecated Use {@link Texture#anisotropy texture.anisotropy} instead. + */ + anisotropy: any; + /** + * @deprecated Use {@link Texture#offset texture.offset} instead. + */ + offset: any; + /** + * @deprecated Use {@link Texture#repeat texture.repeat} instead. + */ + repeat: any; + /** + * @deprecated Use {@link Texture#format texture.format} instead. + */ + format: any; + /** + * @deprecated Use {@link Texture#type texture.type} instead. + */ + type: any; + /** + * @deprecated Use {@link Texture#generateMipmaps texture.generateMipmaps} instead. + */ + generateMipmaps: any; + + setSize(width: number, height: number): void; + clone(): this; + copy(source: WebGLRenderTarget): this; + dispose(): void; +} diff --git a/src/renderers/WebGLRenderTargetCube.d.ts b/src/renderers/WebGLRenderTargetCube.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..877effb8661376d7572b9fa8f6b1a33978f234fd --- /dev/null +++ b/src/renderers/WebGLRenderTargetCube.d.ts @@ -0,0 +1,15 @@ +import { + WebGLRenderTargetOptions, + WebGLRenderTarget, +} from './WebGLRenderTarget'; + +export class WebGLRenderTargetCube extends WebGLRenderTarget { + constructor( + width: number, + height: number, + options?: WebGLRenderTargetOptions + ); + + activeCubeFace: number; // PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5 + activeMipMapLevel: number; +} diff --git a/src/renderers/WebGLRenderer.d.ts b/src/renderers/WebGLRenderer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2e70c1e27cb62528d25c1074c23b7f771ed524a9 --- /dev/null +++ b/src/renderers/WebGLRenderer.d.ts @@ -0,0 +1,401 @@ +import { Scene } from './../scenes/Scene'; +import { Camera } from './../cameras/Camera'; +import { WebGLExtensions } from './webgl/WebGLExtensions'; +import { WebGLInfo } from './webgl/WebGLInfo'; +import { WebGLShadowMap } from './webgl/WebGLShadowMap'; +import { WebGLCapabilities } from './webgl/WebGLCapabilities'; +import { WebGLProperties } from './webgl/WebGLProperties'; +import { WebGLRenderLists } from './webgl/WebGLRenderLists'; +import { WebGLState } from './webgl/WebGLState'; +import { Vector4 } from './../math/Vector4'; +import { Color } from './../math/Color'; +import { WebGLRenderTarget } from './WebGLRenderTarget'; +import { Object3D } from './../core/Object3D'; +import { Material } from './../materials/Material'; +import { Fog } from './../scenes/Fog'; +import { Texture } from './../textures/Texture'; +import { ToneMapping, ShadowMapType, CullFace } from '../constants'; +import { WebVRManager } from '../renderers/webvr/WebVRManager'; +import { RenderTarget } from './webgl/WebGLRenderLists'; + +export interface Renderer { + domElement: HTMLCanvasElement; + + render(scene: Scene, camera: Camera): void; + setSize(width: number, height: number, updateStyle?: boolean): void; +} + +export interface WebGLRendererParameters { + /** + * A Canvas where the renderer draws its output. + */ + canvas?: HTMLCanvasElement; + + /** + * A WebGL Rendering Context. + * (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext) + * Default is null + */ + context?: WebGLRenderingContext; + + /** + * shader precision. Can be "highp", "mediump" or "lowp". + */ + precision?: string; + + /** + * default is true. + */ + alpha?: boolean; + + /** + * default is true. + */ + premultipliedAlpha?: boolean; + + /** + * default is false. + */ + antialias?: boolean; + + /** + * default is true. + */ + stencil?: boolean; + + /** + * default is false. + */ + preserveDrawingBuffer?: boolean; + + /** + * default is 0x000000. + */ + clearColor?: number; + + /** + * default is 0. + */ + clearAlpha?: number; + + devicePixelRatio?: number; + + /** + * default is false. + */ + logarithmicDepthBuffer?: boolean; +} + +/** + * The WebGL renderer displays your beautifully crafted scenes using WebGL, if your device supports it. + * This renderer has way better performance than CanvasRenderer. + * + * @see src/renderers/WebGLRenderer.js + */ +export class WebGLRenderer implements Renderer { + /** + * parameters is an optional object with properties defining the renderer's behaviour. The constructor also accepts no parameters at all. In all cases, it will assume sane defaults when parameters are missing. + */ + constructor(parameters?: WebGLRendererParameters); + + /** + * A Canvas where the renderer draws its output. + * This is automatically created by the renderer in the constructor (if not provided already); you just need to add it to your page. + */ + domElement: HTMLCanvasElement; + + /** + * The HTML5 Canvas's 'webgl' context obtained from the canvas where the renderer will draw. + */ + context: WebGLRenderingContext; + + /** + * Defines whether the renderer should automatically clear its output before rendering. + */ + autoClear: boolean; + + /** + * If autoClear is true, defines whether the renderer should clear the color buffer. Default is true. + */ + autoClearColor: boolean; + + /** + * If autoClear is true, defines whether the renderer should clear the depth buffer. Default is true. + */ + autoClearDepth: boolean; + + /** + * If autoClear is true, defines whether the renderer should clear the stencil buffer. Default is true. + */ + autoClearStencil: boolean; + + /** + * Defines whether the renderer should sort objects. Default is true. + */ + sortObjects: boolean; + + clippingPlanes: any[]; + localClippingEnabled: boolean; + + extensions: WebGLExtensions; + + /** + * Default is false. + */ + gammaInput: boolean; + + /** + * Default is false. + */ + gammaOutput: boolean; + + physicallyCorrectLights: boolean; + toneMapping: ToneMapping; + toneMappingExposure: number; + toneMappingWhitePoint: number; + + /** + * Default is false. + */ + shadowMapDebug: boolean; + + /** + * Default is 8. + */ + maxMorphTargets: number; + + /** + * Default is 4. + */ + maxMorphNormals: number; + + info: WebGLInfo; + + shadowMap: WebGLShadowMap; + + pixelRation: number; + + capabilities: WebGLCapabilities; + properties: WebGLProperties; + renderLists: WebGLRenderLists; + state: WebGLState; + allocTextureUnit: any; + + vr: WebVRManager; + + /** + * Return the WebGL context. + */ + getContext(): WebGLRenderingContext; + getContextAttributes(): any; + forceContextLoss(): void; + + /** + * @deprecated Use {@link WebGLCapabilities#getMaxAnisotropy .capabilities.getMaxAnisotropy()} instead. + */ + getMaxAnisotropy(): number; + + /** + * @deprecated Use {@link WebGLCapabilities#precision .capabilities.precision} instead. + */ + getPrecision(): string; + + getPixelRatio(): number; + setPixelRatio(value: number): void; + + getDrawingBufferSize(): { width: number; height: number }; + setDrawingBufferSize(width: number, height: number, pixelRatio: number): void; + + getSize(): { width: number; height: number }; + + /** + * Resizes the output canvas to (width, height), and also sets the viewport to fit that size, starting in (0, 0). + */ + setSize(width: number, height: number, updateStyle?: boolean): void; + + getCurrentViewport(): Vector4; + /** + * Sets the viewport to render from (x, y) to (x + width, y + height). + */ + setViewport(x?: number, y?: number, width?: number, height?: number): void; + + /** + * Sets the scissor area from (x, y) to (x + width, y + height). + */ + setScissor(x: number, y: number, width: number, height: number): void; + + /** + * Enable the scissor test. When this is enabled, only the pixels within the defined scissor area will be affected by further renderer actions. + */ + setScissorTest(enable: boolean): void; + + /** + * Returns a THREE.Color instance with the current clear color. + */ + getClearColor(): Color; + + /** + * Sets the clear color, using color for the color and alpha for the opacity. + */ + setClearColor(color: Color, alpha?: number): void; + setClearColor(color: string, alpha?: number): void; + setClearColor(color: number, alpha?: number): void; + + /** + * Returns a float with the current clear alpha. Ranges from 0 to 1. + */ + getClearAlpha(): number; + + setClearAlpha(alpha: number): void; + + /** + * Tells the renderer to clear its color, depth or stencil drawing buffer(s). + * Arguments default to true + */ + clear(color?: boolean, depth?: boolean, stencil?: boolean): void; + + clearColor(): void; + clearDepth(): void; + clearStencil(): void; + clearTarget( + renderTarget: WebGLRenderTarget, + color: boolean, + depth: boolean, + stencil: boolean + ): void; + + /** + * @deprecated Use {@link WebGLState#reset .state.reset()} instead. + */ + resetGLState(): void; + dispose(): void; + + /** + * Tells the shadow map plugin to update using the passed scene and camera parameters. + * + * @param scene an instance of Scene + * @param camera — an instance of Camera + */ + renderBufferImmediate( + object: Object3D, + program: Object, + material: Material + ): void; + + renderBufferDirect( + camera: Camera, + fog: Fog, + material: Material, + geometryGroup: any, + object: Object3D + ): void; + + /** + * A build in function that can be used instead of requestAnimationFrame. For WebVR projects this function must be used. + * @param callback The function will be called every available frame. If `null` is passed it will stop any already ongoing animation. + */ + setAnimationLoop(callback: Function): void; + + /** + * @deprecated Use {@link WebGLRenderer#setAnimationLoop .setAnimationLoop()} instead. + */ + animate(callback: Function): void; + + /** + * Render a scene using a camera. + * The render is done to the renderTarget (if specified) or to the canvas as usual. + * If forceClear is true, the canvas will be cleared before rendering, even if the renderer's autoClear property is false. + */ + render( + scene: Scene, + camera: Camera, + renderTarget?: RenderTarget, + forceClear?: boolean + ): void; + + /** + * @deprecated + */ + setTexture(texture: Texture, slot: number): void; + setTexture2D(texture: Texture, slot: number): void; + setTextureCube(texture: Texture, slot: number): void; + getRenderTarget(): RenderTarget; + /** + * @deprecated Use {@link WebGLRenderer#getRenderTarget .getRenderTarget()} instead. + */ + getCurrentRenderTarget(): RenderTarget; + setRenderTarget(renderTarget?: RenderTarget): void; + readRenderTargetPixels( + renderTarget: RenderTarget, + x: number, + y: number, + width: number, + height: number, + buffer: any + ): void; + + /** + * @deprecated + */ + gammaFactor: number; + + /** + * @deprecated Use {@link WebGLShadowMap#enabled .shadowMap.enabled} instead. + */ + shadowMapEnabled: boolean; + + /** + * @deprecated Use {@link WebGLShadowMap#type .shadowMap.type} instead. + */ + shadowMapType: ShadowMapType; + + /** + * @deprecated Use {@link WebGLShadowMap#cullFace .shadowMap.cullFace} instead. + */ + shadowMapCullFace: CullFace; + + /** + * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'OES_texture_float' )} instead. + */ + supportsFloatTextures(): any; + + /** + * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'OES_texture_half_float' )} instead. + */ + supportsHalfFloatTextures(): any; + + /** + * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'OES_standard_derivatives' )} instead. + */ + supportsStandardDerivatives(): any; + + /** + * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'WEBGL_compressed_texture_s3tc' )} instead. + */ + supportsCompressedTextureS3TC(): any; + + /** + * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'WEBGL_compressed_texture_pvrtc' )} instead. + */ + supportsCompressedTexturePVRTC(): any; + + /** + * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'EXT_blend_minmax' )} instead. + */ + supportsBlendMinMax(): any; + + /** + * @deprecated Use {@link WebGLCapabilities#vertexTextures .capabilities.vertexTextures} instead. + */ + supportsVertexTextures(): any; + + /** + * @deprecated Use {@link WebGLExtensions#get .extensions.get( 'ANGLE_instanced_arrays' )} instead. + */ + supportsInstancedArrays(): any; + + /** + * @deprecated Use {@link WebGLRenderer#setScissorTest .setScissorTest()} instead. + */ + enableScissorTest(boolean: any): any; +} diff --git a/src/renderers/shaders/ShaderChunk.d.ts b/src/renderers/shaders/ShaderChunk.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8f9a246d183d99da9ca148988ffe09e9a94bb701 --- /dev/null +++ b/src/renderers/shaders/ShaderChunk.d.ts @@ -0,0 +1,115 @@ +// Renderers / Shaders ///////////////////////////////////////////////////////////////////// +export let ShaderChunk: { + [name: string]: string; + + alphamap_fragment: string; + alphamap_pars_fragment: string; + alphatest_fragment: string; + aomap_fragment: string; + aomap_pars_fragment: string; + begin_vertex: string; + beginnormal_vertex: string; + bsdfs: string; + bumpmap_pars_fragment: string; + clipping_planes_fragment: string; + clipping_planes_pars_fragment: string; + clipping_planes_pars_vertex: string; + clipping_planes_vertex: string; + color_fragment: string; + color_pars_fragment: string; + color_pars_vertex: string; + color_vertex: string; + common: string; + cube_frag: string; + cube_vert: string; + cube_uv_reflection_fragment: string; + defaultnormal_vertex: string; + depth_frag: string; + depth_vert: string; + distanceRGBA_frag: string; + distanceRGBA_vert: string; + displacementmap_vertex: string; + displacementmap_pars_vertex: string; + emissivemap_fragment: string; + emissivemap_pars_fragment: string; + encodings_pars_fragment: string; + encodings_fragment: string; + envmap_fragment: string; + envmap_pars_fragment: string; + envmap_pars_vertex: string; + envmap_vertex: string; + equirect_frag: string; + equirect_vert: string; + fog_fragment: string; + fog_pars_fragment: string; + linedashed_frag: string; + linedashed_vert: string; + lightmap_fragment: string; + lightmap_pars_fragment: string; + lights_lambert_vertex: string; + lights_pars_begin: string; + lights_pars_map: string; + lights_phong_fragment: string; + lights_phong_pars_fragment: string; + lights_physical_fragment: string; + lights_physical_pars_fragment: string; + lights_fragment_begin: string; + lights_fragment_maps: string; + lights_fragment_end: string; + logdepthbuf_fragment: string; + logdepthbuf_pars_fragment: string; + logdepthbuf_pars_vertex: string; + logdepthbuf_vertex: string; + map_fragment: string; + map_pars_fragment: string; + map_particle_fragment: string; + map_particle_pars_fragment: string; + meshbasic_frag: string; + meshbasic_vert: string; + meshlambert_frag: string; + meshlambert_vert: string; + meshphong_frag: string; + meshphong_vert: string; + meshphysical_frag: string; + meshphysical_vert: string; + metalnessmap_fragment: string; + metalnessmap_pars_fragment: string; + morphnormal_vertex: string; + morphtarget_pars_vertex: string; + morphtarget_vertex: string; + normal_flip: string; + normal_frag: string; + normal_fragment_begin: string; + normal_fragment_maps: string; + normal_vert: string; + normalmap_pars_fragment: string; + packing: string; + points_frag: string; + points_vert: string; + shadow_frag: string; + shadow_vert: string; + + premultiplied_alpha_fragment: string; + project_vertex: string; + roughnessmap_fragment: string; + roughnessmap_pars_fragment: string; + shadowmap_pars_fragment: string; + shadowmap_pars_vertex: string; + shadowmap_vertex: string; + shadowmask_pars_fragment: string; + skinbase_vertex: string; + skinning_pars_vertex: string; + skinning_vertex: string; + skinnormal_vertex: string; + specularmap_fragment: string; + specularmap_pars_fragment: string; + tonemapping_fragment: string; + tonemapping_pars_fragment: string; + uv2_pars_fragment: string; + uv2_pars_vertex: string; + uv2_vertex: string; + uv_pars_fragment: string; + uv_pars_vertex: string; + uv_vertex: string; + worldpos_vertex: string; +}; diff --git a/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js b/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js index c9537b82fba6320a4a30949165ca5b307ee3fc22..11be08c91e099558aaec918214b3b19b63e85a38 100644 --- a/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +++ b/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js @@ -61,7 +61,7 @@ vec4 LinearToRGBD( in vec4 value, in float maxRange ) { // M matrix, for encoding const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 ); vec4 LinearToLogLuv( in vec4 value ) { - vec3 Xp_Y_XYZp = value.rgb * cLogLuvM; + vec3 Xp_Y_XYZp = cLogLuvM * value.rgb; Xp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) ); vec4 vResult; vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z; @@ -79,7 +79,7 @@ vec4 LogLuvToLinear( in vec4 value ) { Xp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 ); Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y; Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z; - vec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM; + vec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb; return vec4( max( vRGB, 0.0 ), 1.0 ); } `; diff --git a/src/renderers/shaders/ShaderLib.d.ts b/src/renderers/shaders/ShaderLib.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..116d3059528b02241a779c2427cec097aadb7a94 --- /dev/null +++ b/src/renderers/shaders/ShaderLib.d.ts @@ -0,0 +1,24 @@ +import { IUniform } from './UniformsLib'; + +export interface Shader { + uniforms: { [uniform: string]: IUniform }; + vertexShader: string; + fragmentShader: string; +} + +export let ShaderLib: { + [name: string]: Shader; + basic: Shader; + lambert: Shader; + phong: Shader; + standard: Shader; + points: Shader; + dashed: Shader; + depth: Shader; + normal: Shader; + cube: Shader; + equirect: Shader; + depthRGBA: Shader; + distanceRGBA: Shader; + physical: Shader; +}; diff --git a/src/renderers/shaders/UniformsLib.d.ts b/src/renderers/shaders/UniformsLib.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ffdff66938639903cee5f2000f7aec3fb1ae78bc --- /dev/null +++ b/src/renderers/shaders/UniformsLib.d.ts @@ -0,0 +1,136 @@ +export interface IUniform { + value: any; +} + +export let UniformsLib: { + common: { + diffuse: IUniform; + opacity: IUniform; + map: IUniform; + uvTransform: IUniform; + alphaMap: IUniform; + }; + specularmap: { + specularMap: IUniform; + }; + envmap: { + envMap: IUniform; + flipEnvMap: IUniform; + reflectivity: IUniform; + refractionRatio: IUniform; + maxMipLevel: IUniform; + }; + aomap: { + aoMap: IUniform; + aoMapIntensity: IUniform; + }; + lightmap: { + lightMap: IUniform; + lightMapIntensity: IUniform; + }; + emissivemap: { + emissiveMap: IUniform; + }; + bumpmap: { + bumpMap: IUniform; + bumpScale: IUniform; + }; + normalmap: { + normalMap: IUniform; + normalScale: IUniform; + }; + displacementmap: { + displacementMap: IUniform; + displacementScale: IUniform; + displacementBias: IUniform; + }; + roughnessmap: { + roughnessMap: IUniform; + }; + metalnessmap: { + metalnessMap: IUniform; + }; + gradientmap: { + gradientMap: IUniform; + }; + fog: { + fogDensity: IUniform; + fogNear: IUniform; + fogFar: IUniform; + fogColor: IUniform; + }; + lights: { + ambientLightColor: IUniform; + directionalLights: { + value: any[]; + properties: { + direction: {}; + color: {}; + shadow: {}; + shadowBias: {}; + shadowRadius: {}; + shadowMapSize: {}; + }; + }; + directionalShadowMap: IUniform; + directionalShadowMatrix: IUniform; + spotLights: { + value: any[]; + properties: { + color: {}; + position: {}; + direction: {}; + distance: {}; + coneCos: {}; + penumbraCos: {}; + decay: {}; + shadow: {}; + shadowBias: {}; + shadowRadius: {}; + shadowMapSize: {}; + }; + }; + spotShadowMap: IUniform; + spotShadowMatrix: IUniform; + pointLights: { + value: any[]; + properties: { + color: {}; + position: {}; + decay: {}; + distance: {}; + shadow: {}; + shadowBias: {}; + shadowRadius: {}; + shadowMapSize: {}; + }; + }; + pointShadowMap: IUniform; + pointShadowMatrix: IUniform; + hemisphereLights: { + value: any[]; + properties: { + direction: {}; + skycolor: {}; + groundColor: {}; + }; + }; + rectAreaLights: { + value: any[]; + properties: { + color: {}; + position: {}; + width: {}; + height: {}; + }; + }; + }; + points: { + diffuse: IUniform; + opacity: IUniform; + size: IUniform; + scale: IUniform; + map: IUniform; + uvTransform: IUniform; + }; +}; diff --git a/src/renderers/shaders/UniformsUtils.d.ts b/src/renderers/shaders/UniformsUtils.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..e9b243050790a90381632455da48ff1fccaf8617 --- /dev/null +++ b/src/renderers/shaders/UniformsUtils.d.ts @@ -0,0 +1,4 @@ +export namespace UniformsUtils { + export function merge(uniforms: any[]): any; + export function clone(uniforms_src: any): any; +} diff --git a/src/renderers/webgl/WebGLBufferRenderer.d.ts b/src/renderers/webgl/WebGLBufferRenderer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6e6790f1b28cdd83768bd83ed964c8e53a10e067 --- /dev/null +++ b/src/renderers/webgl/WebGLBufferRenderer.d.ts @@ -0,0 +1,8 @@ +// Renderers / WebGL ///////////////////////////////////////////////////////////////////// +export class WebGLBufferRenderer { + constructor(_gl: WebGLRenderingContext, extensions: any, _infoRender: any); + + setMode(value: any): void; + render(start: any, count: number): void; + renderInstances(geometry: any): void; +} diff --git a/src/renderers/webgl/WebGLCapabilities.d.ts b/src/renderers/webgl/WebGLCapabilities.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1833f3d6e212f19ce7812c4a2a82ba119a3d0856 --- /dev/null +++ b/src/renderers/webgl/WebGLCapabilities.d.ts @@ -0,0 +1,29 @@ +export interface WebGLCapabilitiesParameters { + precision?: any; + logarithmicDepthBuffer?: any; +} + +export class WebGLCapabilities { + constructor( + gl: WebGLRenderingContext, + extensions: any, + parameters: WebGLCapabilitiesParameters + ); + + precision: any; + logarithmicDepthBuffer: any; + maxTextures: any; + maxVertexTextures: any; + maxTextureSize: any; + maxCubemapSize: any; + maxAttributes: any; + maxVertexUniforms: any; + maxVaryings: any; + maxFragmentUniforms: any; + vertexTextures: any; + floatFragmentTextures: any; + floatVertexTextures: any; + + getMaxAnisotropy(): number; + getMaxPrecision(precision: string): string; +} diff --git a/src/renderers/webgl/WebGLClipping.d.ts b/src/renderers/webgl/WebGLClipping.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..980387c498e5b4c8ef3b68044b148bea194d2897 --- /dev/null +++ b/src/renderers/webgl/WebGLClipping.d.ts @@ -0,0 +1,17 @@ +import { Camera } from './../../cameras/Camera'; + +export class WebGLClipping { + uniform: { value: any; needsUpdate: boolean }; + numPlanes: number; + + init(planes: any[], enableLocalClipping: boolean, camera: Camera): boolean; + beginShadows(): void; + endShadows(): void; + setState( + planes: any[], + clipShadows: boolean, + camera: Camera, + cache: boolean, + fromCache: boolean + ): void; +} diff --git a/src/renderers/webgl/WebGLExtensions.d.ts b/src/renderers/webgl/WebGLExtensions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9837ad6ec02598cc2d605fe48ac665a3c3e9618e --- /dev/null +++ b/src/renderers/webgl/WebGLExtensions.d.ts @@ -0,0 +1,5 @@ +export class WebGLExtensions { + constructor(gl: WebGLRenderingContext); + + get(name: string): any; +} diff --git a/src/renderers/webgl/WebGLGeometries.d.ts b/src/renderers/webgl/WebGLGeometries.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b2deb4c2ca7499d7923cfed85c30b6ebbebdfc0b --- /dev/null +++ b/src/renderers/webgl/WebGLGeometries.d.ts @@ -0,0 +1,5 @@ +export class WebGLGeometries { + constructor(gl: WebGLRenderingContext, extensions: any, _infoRender: any); + + get(object: any): any; +} diff --git a/src/renderers/webgl/WebGLIndexedBufferRenderer.d.ts b/src/renderers/webgl/WebGLIndexedBufferRenderer.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..924b44504cfc53499ce568d45faafc3f509f58e3 --- /dev/null +++ b/src/renderers/webgl/WebGLIndexedBufferRenderer.d.ts @@ -0,0 +1,8 @@ +export class WebGLIndexedBufferRenderer { + constructor(gl: WebGLRenderingContext, properties: any, info: any); + + setMode(value: any): void; + setIndex(index: any): void; + render(start: any, count: number): void; + renderInstances(geometry: any, start: any, count: number): void; +} diff --git a/src/renderers/webgl/WebGLInfo.d.ts b/src/renderers/webgl/WebGLInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..dd13fc337c6aba38e62e8addf70ade973a82cd56 --- /dev/null +++ b/src/renderers/webgl/WebGLInfo.d.ts @@ -0,0 +1,21 @@ +import { WebGLProgram } from './WebGLProgram'; + +/** + * An object with a series of statistical information about the graphics board memory and the rendering process. + */ +export class WebGLInfo { + autoReset: boolean; + memory: { + geometries: number; + textures: number; + }; + programs: WebGLProgram[] | null; + render: { + calls: number; + frame: number; + lines: number; + points: number; + triangles: number; + }; + reset(): void; +} diff --git a/src/renderers/webgl/WebGLLights.d.ts b/src/renderers/webgl/WebGLLights.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9c901da896b5e9a2a6aa4d0aca2740e6f18e061f --- /dev/null +++ b/src/renderers/webgl/WebGLLights.d.ts @@ -0,0 +1,5 @@ +export class WebGLLights { + constructor(gl: WebGLRenderingContext, properties: any, info: any); + + get(light: any): any; +} diff --git a/src/renderers/webgl/WebGLObjects.d.ts b/src/renderers/webgl/WebGLObjects.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c5276504525169b87a7878ad3c8b649c7f20c751 --- /dev/null +++ b/src/renderers/webgl/WebGLObjects.d.ts @@ -0,0 +1,7 @@ +export class WebGLObjects { + constructor(gl: WebGLRenderingContext, properties: any, info: any); + + getAttributeBuffer(attribute: any): any; + getWireframeAttribute(geometry: any): any; + update(object: any): void; +} diff --git a/src/renderers/webgl/WebGLProgram.d.ts b/src/renderers/webgl/WebGLProgram.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c0ec129795bc068bd2b4d8f22e15c7e566f0bcbb --- /dev/null +++ b/src/renderers/webgl/WebGLProgram.d.ts @@ -0,0 +1,32 @@ +import { WebGLRenderer, WebGLRendererParameters } from './../WebGLRenderer'; +import { ShaderMaterial } from './../../materials/ShaderMaterial'; +import { WebGLShader } from './WebGLShader'; +import { WebGLUniforms } from './WebGLUniforms'; + +export class WebGLProgram { + constructor( + renderer: WebGLRenderer, + code: string, + material: ShaderMaterial, + parameters: WebGLRendererParameters + ); + + id: number; + code: string; + usedTimes: number; + program: any; + vertexShader: WebGLShader; + fragmentShader: WebGLShader; + /** + * @deprecated Use {@link WebGLProgram#getUniforms getUniforms()} instead. + */ + uniforms: any; + /** + * @deprecated Use {@link WebGLProgram#getAttributes getAttributes()} instead. + */ + attributes: any; + + getUniforms(): WebGLUniforms; + getAttributes(): any; + destroy(): void; +} diff --git a/src/renderers/webgl/WebGLPrograms.d.ts b/src/renderers/webgl/WebGLPrograms.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..862a97be8bb813d17290bf77d7f0297e3c6e102e --- /dev/null +++ b/src/renderers/webgl/WebGLPrograms.d.ts @@ -0,0 +1,24 @@ +import { WebGLRenderer } from './../WebGLRenderer'; +import { WebGLProgram } from './WebGLProgram'; +import { ShaderMaterial } from './../../materials/ShaderMaterial'; + +export class WebGLPrograms { + constructor(renderer: WebGLRenderer, capabilities: any); + + programs: WebGLProgram[]; + + getParameters( + material: ShaderMaterial, + lights: any, + fog: any, + nClipPlanes: number, + object: any + ): any; + getProgramCode(material: ShaderMaterial, parameters: any): string; + acquireProgram( + material: ShaderMaterial, + parameters: any, + code: string + ): WebGLProgram; + releaseProgram(program: WebGLProgram): void; +} diff --git a/src/renderers/webgl/WebGLProperties.d.ts b/src/renderers/webgl/WebGLProperties.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..63f1423b01c3900dfd421cd1318ef15c4bd2c3c4 --- /dev/null +++ b/src/renderers/webgl/WebGLProperties.d.ts @@ -0,0 +1,7 @@ +export class WebGLProperties { + constructor(); + + get(object: any): any; + delete(object: any): void; + clear(): void; +} diff --git a/src/renderers/webgl/WebGLRenderLists.d.ts b/src/renderers/webgl/WebGLRenderLists.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..159e63dd8ab3cc4e87d279205f0786debed8f65d --- /dev/null +++ b/src/renderers/webgl/WebGLRenderLists.d.ts @@ -0,0 +1,45 @@ +import { Object3D } from './../../core/Object3D'; +import { Geometry } from './../../core/Geometry'; +import { Material } from './../../materials/Material'; +import { WebGLProgram } from './WebGLProgram'; +import { Group } from './../../objects/Group'; +import { Scene } from './../../scenes/Scene'; +import { Camera } from './../../cameras/Camera'; +import { BufferGeometry } from '../../core/BufferGeometry'; + +export interface RenderTarget {} // not defined in the code, used in LightShadow and WebGRenderer classes + +export interface RenderItem { + id: number; + object: Object3D; + geometry: Geometry | BufferGeometry; + material: Material; + program: WebGLProgram; + renderOrder: number; + z: number; + group: Group; +} + +export class WebGLRenderList { + opaque: Array; + transparent: Array; + init(): void; + push( + object: Object3D, + geometry: Geometry | BufferGeometry, + material: Material, + z: number, + group: Group + ): void; + + sort(): void; +} + +export class WebGLRenderLists { + dispose(): void; + /** + * + * returns { : } + */ + get(scene: Scene, camera: Camera): WebGLRenderList; +} diff --git a/src/renderers/webgl/WebGLShader.d.ts b/src/renderers/webgl/WebGLShader.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f02159dc86a7e9d826f0b97e00c11002ae0aeabf --- /dev/null +++ b/src/renderers/webgl/WebGLShader.d.ts @@ -0,0 +1,3 @@ +export class WebGLShader { + constructor(gl: any, type: string, string: string); +} diff --git a/src/renderers/webgl/WebGLShadowMap.d.ts b/src/renderers/webgl/WebGLShadowMap.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6afe049764d5cbb59f168c970684e8c1147659a8 --- /dev/null +++ b/src/renderers/webgl/WebGLShadowMap.d.ts @@ -0,0 +1,25 @@ +import { Scene } from './../../scenes/Scene'; +import { Camera } from './../../cameras/Camera'; +import { WebGLRenderer } from '../WebGLRenderer'; +import { ShadowMapType } from '../../constants'; + +export class WebGLShadowMap { + constructor( + _renderer: WebGLRenderer, + _lights: any[], + _objects: any[], + capabilities: any + ); + + enabled: boolean; + autoUpdate: boolean; + needsUpdate: boolean; + type: ShadowMapType; + + render(scene: Scene, camera: Camera): void; + + /** + * @deprecated Use {@link WebGLShadowMap#renderReverseSided .shadowMap.renderReverseSided} instead. + */ + cullFace: any; +} diff --git a/src/renderers/webgl/WebGLState.d.ts b/src/renderers/webgl/WebGLState.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..fdcfc23115fac668091686058f09d355631b3b77 --- /dev/null +++ b/src/renderers/webgl/WebGLState.d.ts @@ -0,0 +1,96 @@ +import { CullFace } from '../../constants'; + +export class WebGLColorBuffer { + constructor(gl: any, state: any); + + setMask(colorMask: number): void; + setLocked(lock: boolean): void; + setClear(r: number, g: number, b: number, a: number): void; + reset(): void; +} + +export class WebGLDepthBuffer { + constructor(gl: any, state: any); + + setTest(depthTest: boolean): void; + setMask(depthMask: number): void; + setFunc(depthFunc: number): void; + setLocked(lock: boolean): void; + setClear(depth: any): void; + reset(): void; +} + +export class WebGLStencilBuffer { + constructor(gl: any, state: any); + + setTest(stencilTest: boolean): void; + setMask(stencilMask: number): void; + setFunc(stencilFunc: number, stencilRef: any, stencilMask: number): void; + setOp(stencilFail: any, stencilZFail: any, stencilZPass: any): void; + setLocked(lock: boolean): void; + setClear(stencil: any): void; + reset(): void; +} + +export class WebGLState { + constructor(gl: any, extensions: any, paramThreeToGL: Function); + + buffers: { + color: WebGLColorBuffer; + depth: WebGLDepthBuffer; + stencil: WebGLStencilBuffer; + }; + + init(): void; + initAttributes(): void; + enableAttribute(attribute: string): void; + enableAttributeAndDivisor( + attribute: string, + meshPerAttribute: any, + extension: any + ): void; + disableUnusedAttributes(): void; + enable(id: string): void; + disable(id: string): void; + getCompressedTextureFormats(): any[]; + setBlending( + blending: number, + blendEquation?: number, + blendSrc?: number, + blendDst?: number, + blendEquationAlpha?: number, + blendSrcAlpha?: number, + blendDstAlpha?: number, + premultiplyAlpha?: boolean + ): void; + setColorWrite(colorWrite: number): void; + setDepthTest(depthTest: number): void; + setDepthWrite(depthWrite: number): void; + setDepthFunc(depthFunc: Function): void; + setStencilTest(stencilTest: boolean): void; + setStencilWrite(stencilWrite: any): void; + setStencilFunc( + stencilFunc: Function, + stencilRef: any, + stencilMask: number + ): void; + setStencilOp(stencilFail: any, stencilZFail: any, stencilZPass: any): void; + setFlipSided(flipSided: number): void; + setCullFace(cullFace: CullFace): void; + setLineWidth(width: number): void; + setPolygonOffset(polygonoffset: number, factor: number, units: number): void; + setScissorTest(scissorTest: boolean): void; + getScissorTest(): boolean; + activeTexture(webglSlot: any): void; + bindTexture(webglType: any, webglTexture: any): void; + // Same interface as https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/compressedTexImage2D + compressedTexImage2D(): void; + // Same interface as https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D + texImage2D(): void; + clearColor(r: number, g: number, b: number, a: number): void; + clearDepth(depth: number): void; + clearStencil(stencil: any): void; + scissor(scissor: any): void; + viewport(viewport: any): void; + reset(): void; +} diff --git a/src/renderers/webgl/WebGLTextures.d.ts b/src/renderers/webgl/WebGLTextures.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a00856355d7a8a0dce63e198b11b0e99de8cf1de --- /dev/null +++ b/src/renderers/webgl/WebGLTextures.d.ts @@ -0,0 +1,17 @@ +export class WebGLTextures { + constructor( + gl: any, + extensions: any, + state: any, + properties: any, + capabilities: any, + paramThreeToGL: Function, + info: any + ); + + setTexture2D(texture: any, slot: number): void; + setTextureCube(texture: any, slot: number): void; + setTextureCubeDynamic(texture: any, slot: number): void; + setupRenderTarget(renderTarget: any): void; + updateRenderTargetMipmap(renderTarget: any): void; +} diff --git a/src/renderers/webgl/WebGLUniforms.d.ts b/src/renderers/webgl/WebGLUniforms.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..18bd27e52e23a62598f43141b013885cc1b5852e --- /dev/null +++ b/src/renderers/webgl/WebGLUniforms.d.ts @@ -0,0 +1,17 @@ +import { WebGLProgram } from './WebGLProgram'; +import { WebGLRenderer } from './../WebGLRenderer'; + +export class WebGLUniforms { + constructor(gl: any, program: WebGLProgram, renderer: WebGLRenderer); + + renderer: WebGLRenderer; + + setValue(gl: any, value: any, renderer?: any): void; + set(gl: any, object: any, name: string): void; + setOptional(gl: any, object: any, name: string): void; + + static upload(gl: any, seq: any, values: any[], renderer: any): void; + static seqWithValue(seq: any, values: any[]): any[]; + static splitDynamic(seq: any, values: any[]): any[]; + static evalDynamic(seq: any, values: any[], object: any, camera: any): any[]; +} diff --git a/src/renderers/webvr/WebVRManager.d.ts b/src/renderers/webvr/WebVRManager.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..6aaac32146ea85e4ed1e98cd84011c7756d1fde2 --- /dev/null +++ b/src/renderers/webvr/WebVRManager.d.ts @@ -0,0 +1,13 @@ +import { Object3D } from '../../core/Object3D'; +import { PerspectiveCamera } from '../../cameras/PerspectiveCamera'; +import { ArrayCamera } from '../../cameras/ArrayCamera'; + +export interface WebVRManager { + enabled: boolean; + getDevice(): VRDisplay | null; + setDevice(device: VRDisplay | null): void; + setPoseTarget(object: Object3D | null): void; + getCamera(camera: PerspectiveCamera): PerspectiveCamera | ArrayCamera; + submitFrame(): void; + dispose(): void; +} diff --git a/src/scenes/Fog.d.ts b/src/scenes/Fog.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ca8b3dbddb4100588f4fe574964e5a6d0856785c --- /dev/null +++ b/src/scenes/Fog.d.ts @@ -0,0 +1,36 @@ +import { Color } from './../math/Color'; + +export interface IFog { + name: string; + color: Color; + clone(): this; + toJSON(): any; +} + +/** + * This class contains the parameters that define linear fog, i.e., that grows linearly denser with the distance. + */ +export class Fog implements IFog { + constructor(hex: number, near?: number, far?: number); + + name: string; + + /** + * Fog color. + */ + color: Color; + + /** + * The minimum distance to start applying fog. Objects that are less than 'near' units from the active camera won't be affected by fog. + */ + near: number; + + /** + * The maximum distance at which fog stops being calculated and applied. Objects that are more than 'far' units away from the active camera won't be affected by fog. + * Default is 1000. + */ + far: number; + + clone(): this; + toJSON(): any; +} diff --git a/src/scenes/FogExp2.d.ts b/src/scenes/FogExp2.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d42fbb59c6518fdfdd1186ab2e6eb538ad91490f --- /dev/null +++ b/src/scenes/FogExp2.d.ts @@ -0,0 +1,20 @@ +import { Color } from './../math/Color'; +import { IFog } from './Fog'; +/** + * This class contains the parameters that define linear fog, i.e., that grows exponentially denser with the distance. + */ +export class FogExp2 implements IFog { + constructor(hex: number | string, density?: number); + + name: string; + color: Color; + + /** + * Defines how fast the fog will grow dense. + * Default is 0.00025. + */ + density: number; + + clone(): this; + toJSON(): any; +} diff --git a/src/scenes/Scene.d.ts b/src/scenes/Scene.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b5538698695e4e84a46b45de938c8432be738682 --- /dev/null +++ b/src/scenes/Scene.d.ts @@ -0,0 +1,32 @@ +import { WebGLRenderer } from './../renderers/WebGLRenderer'; +import { Camera } from './../cameras/Camera'; +import { IFog } from './Fog'; +import { Material } from './../materials/Material'; +import { Object3D } from './../core/Object3D'; +import { Color } from '../math/Color'; +import { Texture } from '../textures/Texture'; +// Scenes ///////////////////////////////////////////////////////////////////// + +/** + * Scenes allow you to set up what and where is to be rendered by three.js. This is where you place objects, lights and cameras. + */ +export class Scene extends Object3D { + constructor(); + + type: 'Scene'; + + /** + * A fog instance defining the type of fog that affects everything rendered in the scene. Default is null. + */ + fog: IFog | null; + + /** + * If not null, it will force everything in the scene to be rendered with that material. Default is null. + */ + overrideMaterial: Material | null; + autoUpdate: boolean; + background: null | Color | Texture; + + copy(source: this, recursive?: boolean): this; + toJSON(meta?: any): any; +} diff --git a/src/textures/CanvasTexture.d.ts b/src/textures/CanvasTexture.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ddd2791669810dc9798a8a026e64c8a3b4d6b90a --- /dev/null +++ b/src/textures/CanvasTexture.d.ts @@ -0,0 +1,22 @@ +import { Texture } from './Texture'; +import { + Mapping, + Wrapping, + TextureFilter, + PixelFormat, + TextureDataType, +} from '../constants'; + +export class CanvasTexture extends Texture { + constructor( + canvas: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + format?: PixelFormat, + type?: TextureDataType, + anisotropy?: number + ); +} diff --git a/src/textures/CompressedTexture.d.ts b/src/textures/CompressedTexture.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..23f26cc795fae6e1fbb01efc233e431f174a47fa --- /dev/null +++ b/src/textures/CompressedTexture.d.ts @@ -0,0 +1,28 @@ +import { Texture } from './Texture'; +import { + Mapping, + Wrapping, + TextureFilter, + PixelFormat, + TextureDataType, + TextureEncoding, +} from '../constants'; + +export class CompressedTexture extends Texture { + constructor( + mipmaps: ImageData[], + width: number, + height: number, + format?: PixelFormat, + type?: TextureDataType, + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + anisotropy?: number, + encoding?: TextureEncoding + ); + + image: { width: number; height: number }; +} diff --git a/src/textures/CubeTexture.d.ts b/src/textures/CubeTexture.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..23831bbb95a33c911c21943a582bc771d0448879 --- /dev/null +++ b/src/textures/CubeTexture.d.ts @@ -0,0 +1,26 @@ +import { Texture } from './Texture'; +import { + Mapping, + Wrapping, + TextureFilter, + PixelFormat, + TextureDataType, + TextureEncoding, +} from '../constants'; + +export class CubeTexture extends Texture { + constructor( + images?: any[], // HTMLImageElement or HTMLCanvasElement + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + format?: PixelFormat, + type?: TextureDataType, + anisotropy?: number, + encoding?: TextureEncoding + ); + + images: any; // returns and sets the value of Texture.image in the codde ? +} diff --git a/src/textures/DataTexture.d.ts b/src/textures/DataTexture.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c8fecb06a2f1668844dec5338696b591a1bc3c89 --- /dev/null +++ b/src/textures/DataTexture.d.ts @@ -0,0 +1,29 @@ +import { Texture } from './Texture'; +import { + Mapping, + Wrapping, + TextureFilter, + PixelFormat, + TextureDataType, + TextureEncoding, +} from '../constants'; +import { TypedArray } from '../polyfills'; + +export class DataTexture extends Texture { + constructor( + data: ArrayBuffer | TypedArray, + width: number, + height: number, + format?: PixelFormat, + type?: TextureDataType, + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + anisotropy?: number, + encoding?: TextureEncoding + ); + + image: ImageData; +} diff --git a/src/textures/DataTexture3D.d.ts b/src/textures/DataTexture3D.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..97083f131cf9758ea9703158a331a991813474c4 --- /dev/null +++ b/src/textures/DataTexture3D.d.ts @@ -0,0 +1,12 @@ +import { Texture } from './Texture'; +import { NearestFilter } from '../constants'; +import { TypedArray } from '../polyfills'; + +export class DataTexture3D extends Texture { + constructor( + data: ArrayBuffer | TypedArray, + width: number, + heighht: number, + depth?: number + ); +} diff --git a/src/textures/DepthTexture.d.ts b/src/textures/DepthTexture.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..121333102da7b35a817e6067bd8a877ecefffb63 --- /dev/null +++ b/src/textures/DepthTexture.d.ts @@ -0,0 +1,25 @@ +import { Texture } from './Texture'; +import { + Mapping, + Wrapping, + TextureFilter, + PixelFormat, + TextureDataType, + TextureEncoding, +} from '../constants'; + +export class DepthTexture extends Texture { + constructor( + width: number, + heighht: number, + type?: TextureDataType, + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + anisotropy?: number + ); + + image: { width: number; height: number }; +} diff --git a/src/textures/Texture.d.ts b/src/textures/Texture.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b1b1ac85bf99b9b909b76c463c253914d444f8f9 --- /dev/null +++ b/src/textures/Texture.d.ts @@ -0,0 +1,63 @@ +import { Vector2, Vector } from './../math/Vector2'; +import { EventDispatcher } from './../core/EventDispatcher'; +import { + Mapping, + Wrapping, + TextureFilter, + PixelFormat, + TextureDataType, + TextureEncoding, +} from '../constants'; + +// Textures ///////////////////////////////////////////////////////////////////// +export let TextureIdCount: number; + +export class Texture extends EventDispatcher { + constructor( + image?: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + format?: PixelFormat, + type?: TextureDataType, + anisotropy?: number, + encoding?: TextureEncoding + ); + + id: number; + uuid: string; + name: string; + sourceFile: string; + image: any; // HTMLImageElement or ImageData or { width: number, height: number } in some children; + mipmaps: ImageData[]; + mapping: Mapping; + wrapS: Wrapping; + wrapT: Wrapping; + magFilter: TextureFilter; + minFilter: TextureFilter; + anisotropy: number; + format: PixelFormat; + type: TextureDataType; + offset: Vector2; + repeat: Vector2; + center: Vector2; + rotation: number; + generateMipmaps: boolean; + premultiplyAlpha: boolean; + flipY: boolean; + unpackAlignment: number; + encoding: TextureEncoding; + version: number; + needsUpdate: boolean; + onUpdate: () => void; + static DEFAULT_IMAGE: any; + static DEFAULT_MAPPING: any; + + clone(): this; + copy(source: Texture): this; + toJSON(meta: any): any; + dispose(): void; + transformUv(uv: Vector): void; +} diff --git a/src/textures/VideoTexture.d.ts b/src/textures/VideoTexture.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f56779903818f9ddc8cc979dff5217bc4b5c9959 --- /dev/null +++ b/src/textures/VideoTexture.d.ts @@ -0,0 +1,23 @@ +import { Texture } from './Texture'; +import { + Mapping, + Wrapping, + TextureFilter, + PixelFormat, + TextureDataType, + TextureEncoding, +} from '../constants'; + +export class VideoTexture extends Texture { + constructor( + video: HTMLVideoElement, + mapping?: Mapping, + wrapS?: Wrapping, + wrapT?: Wrapping, + magFilter?: TextureFilter, + minFilter?: TextureFilter, + format?: PixelFormat, + type?: TextureDataType, + anisotropy?: number + ); +} diff --git a/test/unit/example/exporters/GLTFExporter.tests.js b/test/unit/example/exporters/GLTFExporter.tests.js index 227170774666af4880ca197922a09e06be6c38b3..7afea17b27a2c503a35f072fb4f5249348082dd8 100644 --- a/test/unit/example/exporters/GLTFExporter.tests.js +++ b/test/unit/example/exporters/GLTFExporter.tests.js @@ -5,6 +5,19 @@ import * as GLTFExporter from '../../../../examples/js/exporters/GLTFExporter'; +import { AnimationClip } from '../../../../src/animation/AnimationClip'; +import { BufferAttribute } from '../../../../src/core/BufferAttribute'; +import { BufferGeometry } from '../../../../src/core/BufferGeometry'; +import { Mesh } from '../../../../src/objects/Mesh'; +import { Object3D } from '../../../../src/core/Object3D'; +import { NumberKeyframeTrack } from '../../../../src/animation/tracks/NumberKeyframeTrack'; +import { VectorKeyframeTrack } from '../../../../src/animation/tracks/VectorKeyframeTrack'; +import { + InterpolateLinear, + InterpolateSmooth, + InterpolateDiscrete +} from '../../../../src/constants.js'; + export default QUnit.module( 'Exporters', () => { QUnit.module( 'GLTFExporter', () => { @@ -156,6 +169,172 @@ export default QUnit.module( 'Exporters', () => { } ); + QUnit.test( 'parse - individual morph targets', ( assert ) => { + + var done = assert.async(); + + // Creates a geometry with four (4) morph targets, three (3) of which are + // animated by an animation clip. Because glTF requires all morph targets + // to be animated in unison, the exporter should write an empty track for + // the fourth target. + + var geometry = new THREE.BufferGeometry(); + var position = new THREE.BufferAttribute( new Float32Array( [ 0, 0, 0, 0, 0, 1, 1, 0, 1 ] ), 3 ); + geometry.addAttribute( 'position', position ); + geometry.morphAttributes.position = [ position, position, position, position ]; + + var mesh = new THREE.Mesh( geometry ); + mesh.morphTargetDictionary.a = 0; + mesh.morphTargetDictionary.b = 1; + mesh.morphTargetDictionary.c = 2; + mesh.morphTargetDictionary.d = 3; + + var timesA = [ 0, 1, 2 ]; + var timesB = [ 2, 3, 4 ]; + var timesC = [ 4, 5, 6 ]; + var valuesA = [ 0, 1, 0 ]; + var valuesB = [ 0, 1, 0 ]; + var valuesC = [ 0, 1, 0 ]; + var trackA = new THREE.VectorKeyframeTrack( '.morphTargetInfluences[a]', timesA, valuesA, THREE.InterpolateLinear ); + var trackB = new THREE.VectorKeyframeTrack( '.morphTargetInfluences[b]', timesB, valuesB, THREE.InterpolateLinear ); + var trackC = new THREE.VectorKeyframeTrack( '.morphTargetInfluences[c]', timesC, valuesC, THREE.InterpolateLinear ); + + var clip = new THREE.AnimationClip( 'clip1', undefined, [ trackA, trackB, trackC ] ); + + var exporter = new THREE.GLTFExporter(); + + exporter.parse( mesh, function ( gltf ) { + + assert.equal( 1, gltf.animations.length, 'one animation' ); + assert.equal( 1, gltf.animations[ 0 ].channels.length, 'one channel' ); + assert.equal( 1, gltf.animations[ 0 ].samplers.length, 'one sampler' ); + + var channel = gltf.animations[ 0 ].channels[ 0 ]; + var sampler = gltf.animations[ 0 ].samplers[ 0 ]; + + assert.smartEqual( channel, { sampler: 0, target: { node: 0, path: 'weights' } } ); + assert.equal( sampler.interpolation, 'LINEAR' ); + + var input = gltf.accessors[ sampler.input ]; + var output = gltf.accessors[ sampler.output ]; + + assert.equal( input.count, 7 ); + assert.equal( input.type, 'SCALAR' ); + assert.smartEqual( input.min, [ 0 ] ); + assert.smartEqual( input.max, [ 6 ] ); + + assert.equal( output.count, 28 ); // 4 targets * 7 frames + assert.equal( output.type, 'SCALAR' ); + assert.smartEqual( output.min, [ 0 ] ); + assert.smartEqual( output.max, [ 1 ] ); + + done(); + + }, { animations: [ clip ] } ); + + } ); + + QUnit.test( 'utils - insertKeyframe', ( assert ) => { + + var track; + var index; + + function createTrack () { + return new VectorKeyframeTrack( + 'foo.bar', + [ 5, 10, 15, 20, 25, 30 ], + [ 0, 5, 1, 4, 2, 3, 3, 2, 4, 1, 5, 0 ], + InterpolateLinear + ); + } + + track = createTrack(); + index = THREE.GLTFExporter.Utils.insertKeyframe( track, 0 ); + assert.equal( index, 0, 'prepend - index' ); + assert.smartEqual( Array.from( track.times ), [ 0, 5, 10, 15, 20, 25, 30 ], 'prepend - time' ); + assert.smartEqual( Array.from( track.values ), [ 0, 5, 0, 5, 1, 4, 2, 3, 3, 2, 4, 1, 5, 0 ], 'prepend - value' ); + + track = createTrack(); + index = THREE.GLTFExporter.Utils.insertKeyframe( track, 7.5 ); + assert.equal( index, 1, 'insert - index (linear)' ); + assert.smartEqual( Array.from( track.times ), [ 5, 7.5, 10, 15, 20, 25, 30 ], 'insert - time (linear)' ); + assert.smartEqual( Array.from( track.values ), [ 0, 5, 0.5, 4.5, 1, 4, 2, 3, 3, 2, 4, 1, 5, 0 ], 'insert - value (linear)' ); + + track = createTrack(); + track.setInterpolation( InterpolateDiscrete ); + index = THREE.GLTFExporter.Utils.insertKeyframe( track, 16 ); + assert.equal( index, 3, 'insert - index (linear)' ); + assert.smartEqual( Array.from( track.times ), [ 5, 10, 15, 16, 20, 25, 30 ], 'insert - time (discrete)' ); + assert.smartEqual( Array.from( track.values ), [ 0, 5, 1, 4, 2, 3, 2, 3, 3, 2, 4, 1, 5, 0 ], 'insert - value (discrete)' ); + + track = createTrack(); + index = THREE.GLTFExporter.Utils.insertKeyframe( track, 100 ); + assert.equal( index, 6, 'append - index' ); + assert.smartEqual( Array.from( track.times ), [ 5, 10, 15, 20, 25, 30, 100 ], 'append time' ); + assert.smartEqual( Array.from( track.values ), [ 0, 5, 1, 4, 2, 3, 3, 2, 4, 1, 5, 0, 5, 0 ], 'append value' ); + + track = createTrack(); + index = THREE.GLTFExporter.Utils.insertKeyframe( track, 15 ); + assert.equal( index, 2, 'existing - index' ); + assert.smartEqual( Array.from( track.times ), [ 5, 10, 15, 20, 25, 30 ], 'existing - time' ); + assert.smartEqual( Array.from( track.values ), [ 0, 5, 1, 4, 2, 3, 3, 2, 4, 1, 5, 0 ], 'existing - value' ); + + track = createTrack(); + index = THREE.GLTFExporter.Utils.insertKeyframe( track, 20.000005 ); + assert.equal( index, 3, 'tolerance - index' ); + assert.smartEqual( Array.from( track.times ), [ 5, 10, 15, 20, 25, 30 ], 'tolerance - time' ); + assert.smartEqual( Array.from( track.values ), [ 0, 5, 1, 4, 2, 3, 3, 2, 4, 1, 5, 0 ], 'tolerance - value' ); + + } ); + + QUnit.test( 'utils - mergeMorphTargetTracks', ( assert ) => { + + var trackA = new NumberKeyframeTrack( + 'foo.morphTargetInfluences[a]', + [ 5, 10, 15, 20, 25, 30 ], + [ 0, 0.2, 0.4, 0.6, 0.8, 1.0 ], + InterpolateLinear + ); + + var trackB = new NumberKeyframeTrack( + 'foo.morphTargetInfluences[b]', + [ 10, 50 ], + [ 0.25, 0.75 ], + InterpolateLinear + ); + + var geometry = new BufferGeometry(); + var position = new BufferAttribute( new Float32Array( [ 0, 0, 0, 0, 0, 1, 1, 0, 1 ] ), 3 ); + geometry.addAttribute( 'position', position ); + geometry.morphAttributes.position = [ position, position ]; + + var mesh = new Mesh( geometry ); + mesh.name = 'foo'; + mesh.morphTargetDictionary.a = 0; + mesh.morphTargetDictionary.b = 1; + + var root = new Object3D(); + root.add( mesh ); + + var clip = new AnimationClip( 'waltz', undefined, [ trackA, trackB ] ); + clip = THREE.GLTFExporter.Utils.mergeMorphTargetTracks( clip, root ); + + assert.equal( clip.tracks.length, 1, 'tracks are merged' ); + + var track = clip.tracks[ 0 ]; + + assert.smartEqual( Array.from( track.times ), [ 5, 10, 15, 20, 25, 30, 50 ], 'all keyframes are present' ); + + var expectedValues = [ 0, 0.25, 0.2, 0.25, 0.4, 0.3125, 0.6, 0.375, 0.8, 0.4375, 1.0, 0.5, 1.0, 0.75 ]; + + for ( var i = 0; i < track.values.length; i ++ ) { + + assert.numEqual( track.values[ i ], expectedValues[ i ], 'all values are merged or interpolated - ' + i ); + + } + + } ); + } ); } );