提交 5bac4800 编写于 作者: M Mr.doob

Updated builds.

上级 1879afff
......@@ -27029,6 +27029,133 @@ THREE.FontUtils.generateShapes = function ( text, parameters ) {
self._typeface_js = { faces: THREE.FontUtils.faces, loadFace: THREE.FontUtils.loadFace };
THREE.typeface_js = self._typeface_js;
// File:src/extras/audio/Audio.js
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.Audio = function ( listener ) {
THREE.Object3D.call( this );
this.type = 'Audio';
this.context = listener.context;
this.source = this.context.createBufferSource();
this.gain = this.context.createGain();
this.gain.connect( this.context.destination );
this.panner = this.context.createPanner();
this.panner.connect( this.gain );
};
THREE.Audio.prototype = Object.create( THREE.Object3D.prototype );
THREE.Audio.prototype.load = function ( file ) {
var scope = this;
var request = new XMLHttpRequest();
request.open( 'GET', file, true );
request.responseType = 'arraybuffer';
request.onload = function ( e ) {
scope.context.decodeAudioData( this.response, function ( buffer ) {
scope.source.buffer = buffer;
scope.source.connect( scope.panner );
scope.source.start();
} );
};
request.send();
return this;
};
THREE.Audio.prototype.setRefDistance = function ( value ) {
this.panner.refDistance = value;
};
THREE.Audio.prototype.setRolloffFactor = function ( value ) {
this.panner.rolloffFactor = value;
};
THREE.Audio.prototype.updateMatrixWorld = ( function () {
var position = new THREE.Vector3();
return function ( force ) {
THREE.Object3D.prototype.updateMatrixWorld.call( this, force );
position.setFromMatrixPosition( this.matrixWorld );
this.panner.setPosition( position.x, position.y, position.z );
};
} )();
// File:src/extras/audio/AudioListener.js
/**
* @author mrdoob / http://mrdoob.com/
*/
THREE.AudioListener = function () {
THREE.Object3D.call( this );
this.type = 'AudioListener';
this.context = new AudioContext();
};
THREE.AudioListener.prototype = Object.create( THREE.Object3D.prototype );
THREE.AudioListener.prototype.updateMatrixWorld = ( function () {
var position = new THREE.Vector3();
var quaternion = new THREE.Quaternion();
var scale = new THREE.Vector3();
var orientation = new THREE.Vector3();
var velocity = new THREE.Vector3();
var positionPrev = new THREE.Vector3();
return function ( force ) {
THREE.Object3D.prototype.updateMatrixWorld.call( this, force );
var listener = this.context.listener;
this.matrixWorld.decompose( position, quaternion, scale );
orientation.set( 0, 0, -1 ).applyQuaternion( quaternion );
velocity.subVectors( position, positionPrev );
listener.setPosition( position.x, position.y, position.z );
listener.setOrientation( orientation.x, orientation.y, orientation.z, this.up.x, this.up.y, this.up.z );
listener.setVelocity( velocity.x, velocity.y, velocity.z );
positionPrev.copy( position );
};
} )();
// File:src/extras/core/Curve.js
/**
......@@ -31721,6 +31848,8 @@ THREE.LatheGeometry.prototype = Object.create( THREE.Geometry.prototype );
THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments ) {
console.info( 'THREE.PlaneGeometry: Consider using THREE.PlaneBufferGeometry for lower memory footprint.' );
THREE.Geometry.call( this );
this.type = 'PlaneGeometry';
......
......@@ -623,10 +623,14 @@ s,r,v,n)}return{offset:x.ha*c,path:e}}}};
THREE.FontUtils.generateShapes=function(a,b){b=b||{};var c=void 0!==b.curveSegments?b.curveSegments:4,d=void 0!==b.font?b.font:"helvetiker",e=void 0!==b.weight?b.weight:"normal",g=void 0!==b.style?b.style:"normal";THREE.FontUtils.size=void 0!==b.size?b.size:100;THREE.FontUtils.divisions=c;THREE.FontUtils.face=d;THREE.FontUtils.weight=e;THREE.FontUtils.style=g;c=THREE.FontUtils.drawText(a).paths;d=[];e=0;for(g=c.length;e<g;e++)Array.prototype.push.apply(d,c[e].toShapes());return d};
(function(a){var b=function(a){for(var b=a.length,e=0,g=b-1,f=0;f<b;g=f++)e+=a[g].x*a[f].y-a[f].x*a[g].y;return 0.5*e};a.Triangulate=function(a,d){var e=a.length;if(3>e)return null;var g=[],f=[],h=[],k,m,n;if(0<b(a))for(m=0;m<e;m++)f[m]=m;else for(m=0;m<e;m++)f[m]=e-1-m;var q=2*e;for(m=e-1;2<e;){if(0>=q--){console.log("Warning, unable to triangulate polygon!");break}k=m;e<=k&&(k=0);m=k+1;e<=m&&(m=0);n=m+1;e<=n&&(n=0);var s;a:{var t=s=void 0,r=void 0,p=void 0,v=void 0,x=void 0,u=void 0,E=void 0,y=
void 0,t=a[f[k]].x,r=a[f[k]].y,p=a[f[m]].x,v=a[f[m]].y,x=a[f[n]].x,u=a[f[n]].y;if(1E-10>(p-t)*(u-r)-(v-r)*(x-t))s=!1;else{var z=void 0,B=void 0,D=void 0,w=void 0,A=void 0,N=void 0,P=void 0,K=void 0,R=void 0,M=void 0,R=K=P=y=E=void 0,z=x-p,B=u-v,D=t-x,w=r-u,A=p-t,N=v-r;for(s=0;s<e;s++)if(E=a[f[s]].x,y=a[f[s]].y,!(E===t&&y===r||E===p&&y===v||E===x&&y===u)&&(P=E-t,K=y-r,R=E-p,M=y-v,E-=x,y-=u,R=z*M-B*R,P=A*K-N*P,K=D*y-w*E,-1E-10<=R&&-1E-10<=K&&-1E-10<=P)){s=!1;break a}s=!0}}if(s){g.push([a[f[k]],a[f[m]],
a[f[n]]]);h.push([f[k],f[m],f[n]]);k=m;for(n=m+1;n<e;k++,n++)f[k]=f[n];e--;q=2*e}}return d?h:g};a.Triangulate.area=b;return a})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};THREE.typeface_js=self._typeface_js;THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(a){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){a=this.getUtoTmapping(a);return this.getPoint(a)};
THREE.Curve.prototype.getPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPoint(b/a));return c};THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPointAt(b/a));return c};THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]};
THREE.Curve.prototype.getLengths=function(a){a||(a=this.__arcLengthDivisions?this.__arcLengthDivisions:200);if(this.cacheArcLengths&&this.cacheArcLengths.length==a+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var b=[],c,d=this.getPoint(0),e,g=0;b.push(0);for(e=1;e<=a;e++)c=this.getPoint(e/a),g+=c.distanceTo(d),b.push(g),d=c;return this.cacheArcLengths=b};THREE.Curve.prototype.updateArcLengths=function(){this.needsUpdate=!0;this.getLengths()};
THREE.Curve.prototype.getUtoTmapping=function(a,b){var c=this.getLengths(),d=0,e=c.length,g;g=b?b:a*c[e-1];for(var f=0,h=e-1,k;f<=h;)if(d=Math.floor(f+(h-f)/2),k=c[d]-g,0>k)f=d+1;else if(0<k)h=d-1;else{h=d;break}d=h;if(c[d]==g)return d/(e-1);f=c[d];return c=(d+(g-f)/(c[d+1]-f))/(e-1)};THREE.Curve.prototype.getTangent=function(a){var b=a-1E-4;a+=1E-4;0>b&&(b=0);1<a&&(a=1);b=this.getPoint(b);return this.getPoint(a).clone().sub(b).normalize()};
a[f[n]]]);h.push([f[k],f[m],f[n]]);k=m;for(n=m+1;n<e;k++,n++)f[k]=f[n];e--;q=2*e}}return d?h:g};a.Triangulate.area=b;return a})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};THREE.typeface_js=self._typeface_js;
THREE.Audio=function(a){THREE.Object3D.call(this);this.type="Audio";this.context=a.context;this.source=this.context.createBufferSource();this.gain=this.context.createGain();this.gain.connect(this.context.destination);this.panner=this.context.createPanner();this.panner.connect(this.gain)};THREE.Audio.prototype=Object.create(THREE.Object3D.prototype);
THREE.Audio.prototype.load=function(a){var b=this,c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="arraybuffer";c.onload=function(a){b.context.decodeAudioData(this.response,function(a){b.source.buffer=a;b.source.connect(b.panner);b.source.start()})};c.send();return this};THREE.Audio.prototype.setRefDistance=function(a){this.panner.refDistance=a};THREE.Audio.prototype.setRolloffFactor=function(a){this.panner.rolloffFactor=a};
THREE.Audio.prototype.updateMatrixWorld=function(){var a=new THREE.Vector3;return function(b){THREE.Object3D.prototype.updateMatrixWorld.call(this,b);a.setFromMatrixPosition(this.matrixWorld);this.panner.setPosition(a.x,a.y,a.z)}}();THREE.AudioListener=function(){THREE.Object3D.call(this);this.type="AudioListener";this.context=new AudioContext};THREE.AudioListener.prototype=Object.create(THREE.Object3D.prototype);
THREE.AudioListener.prototype.updateMatrixWorld=function(){var a=new THREE.Vector3,b=new THREE.Quaternion,c=new THREE.Vector3,d=new THREE.Vector3,e=new THREE.Vector3,g=new THREE.Vector3;return function(f){THREE.Object3D.prototype.updateMatrixWorld.call(this,f);f=this.context.listener;this.matrixWorld.decompose(a,b,c);d.set(0,0,-1).applyQuaternion(b);e.subVectors(a,g);f.setPosition(a.x,a.y,a.z);f.setOrientation(d.x,d.y,d.z,this.up.x,this.up.y,this.up.z);f.setVelocity(e.x,e.y,e.z);g.copy(a)}}();
THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(a){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){a=this.getUtoTmapping(a);return this.getPoint(a)};THREE.Curve.prototype.getPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPoint(b/a));return c};THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPointAt(b/a));return c};
THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]};THREE.Curve.prototype.getLengths=function(a){a||(a=this.__arcLengthDivisions?this.__arcLengthDivisions:200);if(this.cacheArcLengths&&this.cacheArcLengths.length==a+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var b=[],c,d=this.getPoint(0),e,g=0;b.push(0);for(e=1;e<=a;e++)c=this.getPoint(e/a),g+=c.distanceTo(d),b.push(g),d=c;return this.cacheArcLengths=b};
THREE.Curve.prototype.updateArcLengths=function(){this.needsUpdate=!0;this.getLengths()};THREE.Curve.prototype.getUtoTmapping=function(a,b){var c=this.getLengths(),d=0,e=c.length,g;g=b?b:a*c[e-1];for(var f=0,h=e-1,k;f<=h;)if(d=Math.floor(f+(h-f)/2),k=c[d]-g,0>k)f=d+1;else if(0<k)h=d-1;else{h=d;break}d=h;if(c[d]==g)return d/(e-1);f=c[d];return c=(d+(g-f)/(c[d+1]-f))/(e-1)};THREE.Curve.prototype.getTangent=function(a){var b=a-1E-4;a+=1E-4;0>b&&(b=0);1<a&&(a=1);b=this.getPoint(b);return this.getPoint(a).clone().sub(b).normalize()};
THREE.Curve.prototype.getTangentAt=function(a){a=this.getUtoTmapping(a);return this.getTangent(a)};
THREE.Curve.Utils={tangentQuadraticBezier:function(a,b,c,d){return 2*(1-a)*(c-b)+2*a*(d-c)},tangentCubicBezier:function(a,b,c,d,e){return-3*b*(1-a)*(1-a)+3*c*(1-a)*(1-a)-6*a*c*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*e},tangentSpline:function(a,b,c,d,e){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,b,c,d,e){a=0.5*(c-a);d=0.5*(d-b);var g=e*e;return(2*b-2*c+a+d)*e*g+(-3*b+3*c-2*a-d)*g+a*e+b}};
THREE.Curve.create=function(a,b){a.prototype=Object.create(THREE.Curve.prototype);a.prototype.getPoint=b;return a};THREE.CurvePath=function(){this.curves=[];this.bends=[];this.autoClose=!1};THREE.CurvePath.prototype=Object.create(THREE.Curve.prototype);THREE.CurvePath.prototype.add=function(a){this.curves.push(a)};THREE.CurvePath.prototype.checkConnection=function(){};
......@@ -723,7 +727,7 @@ THREE.ShapeGeometry.prototype.addShape=function(a,b){void 0===b&&(b={});var c=b.
k=k.concat(f);m=k.length;g=n.length;for(e=0;e<m;e++)f=k[e],this.vertices.push(new THREE.Vector3(f.x,f.y,0));for(e=0;e<g;e++)m=n[e],k=m[0]+h,f=m[1]+h,m=m[2]+h,this.faces.push(new THREE.Face3(k,f,m,null,null,c)),this.faceVertexUvs[0].push(d.generateBottomUV(this,a,b,k,f,m))};
THREE.LatheGeometry=function(a,b,c,d){THREE.Geometry.call(this);this.type="LatheGeometry";this.parameters={points:a,segments:b,phiStart:c,phiLength:d};b=b||12;c=c||0;d=d||2*Math.PI;for(var e=1/(a.length-1),g=1/b,f=0,h=b;f<=h;f++)for(var k=c+f*g*d,m=Math.cos(k),n=Math.sin(k),k=0,q=a.length;k<q;k++){var s=a[k],t=new THREE.Vector3;t.x=m*s.x-n*s.y;t.y=n*s.x+m*s.y;t.z=s.z;this.vertices.push(t)}c=a.length;f=0;for(h=b;f<h;f++)for(k=0,q=a.length-1;k<q;k++){b=n=k+c*f;d=n+c;var m=n+1+c,n=n+1,s=f*g,t=k*e,r=
s+g,p=t+e;this.faces.push(new THREE.Face3(b,d,n));this.faceVertexUvs[0].push([new THREE.Vector2(s,t),new THREE.Vector2(r,t),new THREE.Vector2(s,p)]);this.faces.push(new THREE.Face3(d,m,n));this.faceVertexUvs[0].push([new THREE.Vector2(r,t),new THREE.Vector2(r,p),new THREE.Vector2(s,p)])}this.mergeVertices();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=Object.create(THREE.Geometry.prototype);
THREE.PlaneGeometry=function(a,b,c,d){THREE.Geometry.call(this);this.type="PlaneGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};this.fromBufferGeometry(new THREE.PlaneBufferGeometry(a,b,c,d))};THREE.PlaneGeometry.prototype=Object.create(THREE.Geometry.prototype);
THREE.PlaneGeometry=function(a,b,c,d){console.info("THREE.PlaneGeometry: Consider using THREE.PlaneBufferGeometry for lower memory footprint.");THREE.Geometry.call(this);this.type="PlaneGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};this.fromBufferGeometry(new THREE.PlaneBufferGeometry(a,b,c,d))};THREE.PlaneGeometry.prototype=Object.create(THREE.Geometry.prototype);
THREE.PlaneBufferGeometry=function(a,b,c,d){THREE.BufferGeometry.call(this);this.type="PlaneBufferGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};var e=a/2,g=b/2;c=c||1;d=d||1;var f=c+1,h=d+1,k=a/c,m=b/d;b=new Float32Array(f*h*3);a=new Float32Array(f*h*3);for(var n=new Float32Array(f*h*2),q=0,s=0,t=0;t<h;t++)for(var r=t*m-g,p=0;p<f;p++)b[q]=p*k-e,b[q+1]=-r,a[q+2]=1,n[s]=p/c,n[s+1]=1-t/d,q+=3,s+=2;q=0;e=new (65535<b.length/3?Uint32Array:Uint16Array)(c*d*6);for(t=0;t<d;t++)for(p=
0;p<c;p++)g=p+f*(t+1),h=p+1+f*(t+1),k=p+1+f*t,e[q]=p+f*t,e[q+1]=g,e[q+2]=k,e[q+3]=g,e[q+4]=h,e[q+5]=k,q+=6;this.addAttribute("index",new THREE.BufferAttribute(e,1));this.addAttribute("position",new THREE.BufferAttribute(b,3));this.addAttribute("normal",new THREE.BufferAttribute(a,3));this.addAttribute("uv",new THREE.BufferAttribute(n,2))};THREE.PlaneBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype);
THREE.RingGeometry=function(a,b,c,d,e,g){THREE.Geometry.call(this);this.type="RingGeometry";this.parameters={innerRadius:a,outerRadius:b,thetaSegments:c,phiSegments:d,thetaStart:e,thetaLength:g};a=a||0;b=b||50;e=void 0!==e?e:0;g=void 0!==g?g:2*Math.PI;c=void 0!==c?Math.max(3,c):8;d=void 0!==d?Math.max(1,d):8;var f,h=[],k=a,m=(b-a)/d;for(a=0;a<d+1;a++){for(f=0;f<c+1;f++){var n=new THREE.Vector3,q=e+f/c*g;n.x=k*Math.cos(q);n.y=k*Math.sin(q);this.vertices.push(n);h.push(new THREE.Vector2((n.x/b+1)/2,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册