提交 aaf3fd8b 编写于 作者: A alteredq

Merge remote-tracking branch 'remotes/mrdoob/dev' into dev

.DS_Store
*.swp
.project
\ No newline at end of file
.project
utils/node_modules/*
\ No newline at end of file
此差异已折叠。
此差异已折叠。
......@@ -21,7 +21,7 @@ b.vertices.length+1;v=e.clone();p=e.clone();m>=o&&m>=q&&m>=r||q>=o&&q>=m&&q>=r?(
f.lerpSelf(e.vertexColors[1],0.5),g=e.vertexColors[2].clone(),g.lerpSelf(e.vertexColors[3],0.5),v.vertexColors[1].copy(f),v.vertexColors[2].copy(g),p.vertexColors[0].copy(f),p.vertexColors[3].copy(g)),e=0):(m=l.clone(),m.lerpSelf(n,0.5),l=k.clone(),l.lerpSelf(j,0.5),v.a=f,v.b=g,v.c=s,v.d=t,p.a=t,p.b=s,p.c=h,p.d=i,4===e.vertexNormals.length&&(f=e.vertexNormals[1].clone(),f.lerpSelf(e.vertexNormals[2],0.5),g=e.vertexNormals[3].clone(),g.lerpSelf(e.vertexNormals[0],0.5),v.vertexNormals[2].copy(f),v.vertexNormals[3].copy(g),
p.vertexNormals[0].copy(g),p.vertexNormals[1].copy(f)),4===e.vertexColors.length&&(f=e.vertexColors[1].clone(),f.lerpSelf(e.vertexColors[2],0.5),g=e.vertexColors[3].clone(),g.lerpSelf(e.vertexColors[0],0.5),v.vertexColors[2].copy(f),v.vertexColors[3].copy(g),p.vertexColors[0].copy(g),p.vertexColors[1].copy(f)),e=1);x.push(v,p);b.vertices.push(m,l);f=0;for(g=b.faceVertexUvs.length;f<g;f++)b.faceVertexUvs[f].length&&(j=b.faceVertexUvs[f][c],p=j[0],h=j[1],v=j[2],j=j[3],0===e?(l=p.clone(),l.lerpSelf(h,
0.5),n=v.clone(),n.lerpSelf(j,0.5),p=[p.clone(),l.clone(),n.clone(),j.clone()],h=[l.clone(),h.clone(),v.clone(),n.clone()]):(l=h.clone(),l.lerpSelf(v,0.5),n=j.clone(),n.lerpSelf(p,0.5),p=[p.clone(),h.clone(),l.clone(),n.clone()],h=[n.clone(),l.clone(),v.clone(),j.clone()]),z[f].push(p,h))}else{x.push(e);f=0;for(g=b.faceVertexUvs.length;f<g;f++)z[f].push(b.faceVertexUvs[f][c])}b.faces=x;b.faceVertexUvs=z}};THREE.GeometryUtils.random=THREE.Math.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
THREE.ImageUtils={crossOrigin:"anonymous",loadTexture:function(b,a,c,d){var e=new THREE.Texture(void 0,a),a=new THREE.ImageLoader;a.addEventListener("load",function(a){e.image=a.content;e.needsUpdate=!0;c&&c()});a.addEventListener("error",function(a){d&&d(a.message)});a.crossOrigin=this.crossOrigin;a.load(b);return e},loadTextureCube:function(b,a,c){var d,e=[],f=new THREE.Texture(e,a),a=e.loadCount=0;for(d=b.length;a<d;++a)e[a]=new Image,e[a].onload=function(){e.loadCount+=1;6===e.loadCount&&(f.needsUpdate=
THREE.ImageUtils={crossOrigin:"anonymous",loadTexture:function(b,a,c,d){var e=new THREE.Texture(void 0,a),a=new THREE.ImageLoader;a.addEventListener("load",function(a){e.image=a.content;e.needsUpdate=!0;c&&c(e)});a.addEventListener("error",function(a){d&&d(a.message)});a.crossOrigin=this.crossOrigin;a.load(b);return e},loadTextureCube:function(b,a,c){var d,e=[],f=new THREE.Texture(e,a),a=e.loadCount=0;for(d=b.length;a<d;++a)e[a]=new Image,e[a].onload=function(){e.loadCount+=1;6===e.loadCount&&(f.needsUpdate=
!0,c&&c())},e[a].crossOrigin=this.crossOrigin,e[a].src=b[a];return f},getNormalMap:function(b,a){var c=function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},a=a|1,d=b.width,e=b.height,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(b,0,0);for(var h=g.getImageData(0,0,d,e).data,i=g.createImageData(d,e),j=i.data,l=0;l<d;l++)for(var n=0;n<e;n++){var k=0>n-1?0:n-1,m=n+1>e-1?e-1:n+1,o=0>l-1?0:l-1,q=l+1>d-1?d-1:l+1,r=[],s=[0,
0,h[4*(n*d+l)]/255*a];r.push([-1,0,h[4*(n*d+o)]/255*a]);r.push([-1,-1,h[4*(k*d+o)]/255*a]);r.push([0,-1,h[4*(k*d+l)]/255*a]);r.push([1,-1,h[4*(k*d+q)]/255*a]);r.push([1,0,h[4*(n*d+q)]/255*a]);r.push([1,1,h[4*(m*d+q)]/255*a]);r.push([0,1,h[4*(m*d+l)]/255*a]);r.push([-1,1,h[4*(m*d+o)]/255*a]);k=[];o=r.length;for(m=0;m<o;m++){var q=r[m],t=r[(m+1)%o],q=[q[0]-s[0],q[1]-s[1],q[2]-s[2]],t=[t[0]-s[0],t[1]-s[1],t[2]-s[2]];k.push(c([q[1]*t[2]-q[2]*t[1],q[2]*t[0]-q[0]*t[2],q[0]*t[1]-q[1]*t[0]]))}r=[0,0,0];for(m=
0;m<k.length;m++)r[0]+=k[m][0],r[1]+=k[m][1],r[2]+=k[m][2];r[0]/=k.length;r[1]/=k.length;r[2]/=k.length;s=4*(n*d+l);j[s]=255*((r[0]+1)/2)|0;j[s+1]=255*((r[1]+1)/2)|0;j[s+2]=255*r[2]|0;j[s+3]=255}g.putImageData(i,0,0);return f},generateDataTexture:function(b,a,c){for(var d=b*a,e=new Uint8Array(3*d),f=Math.floor(255*c.r),g=Math.floor(255*c.g),c=Math.floor(255*c.b),h=0;h<d;h++)e[3*h]=f,e[3*h+1]=g,e[3*h+2]=c;b=new THREE.DataTexture(e,b,a,THREE.RGBFormat);b.needsUpdate=!0;return b}};
......
此差异已折叠。
......@@ -146,16 +146,21 @@ Sets this vector to cross product of *a* and *b*.
Sets this vector to cross product of itself and *v*.
</div>
<h3>.setPositionFromMatrix( [page:Matrix4 m] ) [page:Vector3]</h3>
<h3>.getPositionFromMatrix( [page:Matrix4 m] ) [page:Vector3]</h3>
<div>
Sets this vector extracting position from matrix transform.
</div>
<h3>.setRotationFromMatrix( [page:Matrix4 m] ) [page:Vector3]</h3>
<h3>.getRotationFromMatrix( [page:Matrix4 m] ) [page:Vector3]</h3>
<div>
Sets this vector extracting Euler angles rotation from matrix transform.
</div>
<h3>.getScaleFromMatrix( [page:Matrix4 m] ) [page:Vector3]</h3>
<div>
Sets this vector extracting scale from matrix transform.
</div>
<h3>.equals( [page:Vector3 v] ) [page:Vector3]</h3>
<div>
Checks for strict equality of this vector and *v*.
......
......@@ -53,6 +53,14 @@ SimplexNoise.prototype.dot = function(g, x, y) {
return g[0]*x + g[1]*y;
};
SimplexNoise.prototype.dot3 = function(g, x, y, z) {
return g[0]*x + g[1]*y + g[2]*z;
}
SimplexNoise.prototype.dot4 = function(g, x, y, z, w) {
return g[0]*x + g[1]*y + g[2]*z + g[3]*w;
};
SimplexNoise.prototype.noise = function(xin, yin) {
var n0, n1, n2; // Noise contributions from the three corners
// Skew the input space to determine which simplex cell we're in
......@@ -166,25 +174,25 @@ SimplexNoise.prototype.noise3d = function(xin, yin, zin) {
if(t0<0) n0 = 0.0;
else {
t0 *= t0;
n0 = t0 * t0 * this.dot(this.grad3[gi0], x0, y0, z0);
n0 = t0 * t0 * this.dot3(this.grad3[gi0], x0, y0, z0);
}
var t1 = 0.6 - x1*x1 - y1*y1 - z1*z1;
if(t1<0) n1 = 0.0;
else {
t1 *= t1;
n1 = t1 * t1 * this.dot(this.grad3[gi1], x1, y1, z1);
n1 = t1 * t1 * this.dot3(this.grad3[gi1], x1, y1, z1);
}
var t2 = 0.6 - x2*x2 - y2*y2 - z2*z2;
if(t2<0) n2 = 0.0;
else {
t2 *= t2;
n2 = t2 * t2 * this.dot(this.grad3[gi2], x2, y2, z2);
n2 = t2 * t2 * this.dot3(this.grad3[gi2], x2, y2, z2);
}
var t3 = 0.6 - x3*x3 - y3*y3 - z3*z3;
if(t3<0) n3 = 0.0;
else {
t3 *= t3;
n3 = t3 * t3 * this.dot(this.grad3[gi3], x3, y3, z3);
n3 = t3 * t3 * this.dot3(this.grad3[gi3], x3, y3, z3);
}
// Add contributions from each corner to get the final noise value.
// The result is scaled to stay just inside [-1,1]
......@@ -286,30 +294,30 @@ SimplexNoise.prototype.noise4d = function( x, y, z, w ) {
if(t0<0) n0 = 0.0;
else {
t0 *= t0;
n0 = t0 * t0 * this.dot(grad4[gi0], x0, y0, z0, w0);
n0 = t0 * t0 * this.dot4(grad4[gi0], x0, y0, z0, w0);
}
var t1 = 0.6 - x1*x1 - y1*y1 - z1*z1 - w1*w1;
if(t1<0) n1 = 0.0;
else {
t1 *= t1;
n1 = t1 * t1 * this.dot(grad4[gi1], x1, y1, z1, w1);
n1 = t1 * t1 * this.dot4(grad4[gi1], x1, y1, z1, w1);
}
var t2 = 0.6 - x2*x2 - y2*y2 - z2*z2 - w2*w2;
if(t2<0) n2 = 0.0;
else {
t2 *= t2;
n2 = t2 * t2 * this.dot(grad4[gi2], x2, y2, z2, w2);
n2 = t2 * t2 * this.dot4(grad4[gi2], x2, y2, z2, w2);
} var t3 = 0.6 - x3*x3 - y3*y3 - z3*z3 - w3*w3;
if(t3<0) n3 = 0.0;
else {
t3 *= t3;
n3 = t3 * t3 * this.dot(grad4[gi3], x3, y3, z3, w3);
n3 = t3 * t3 * this.dot4(grad4[gi3], x3, y3, z3, w3);
}
var t4 = 0.6 - x4*x4 - y4*y4 - z4*z4 - w4*w4;
if(t4<0) n4 = 0.0;
else {
t4 *= t4;
n4 = t4 * t4 * this.dot(grad4[gi4], x4, y4, z4, w4);
n4 = t4 * t4 * this.dot4(grad4[gi4], x4, y4, z4, w4);
}
// Sum up and scale the result to cover the range [-1,1]
return 27.0 * (n0 + n1 + n2 + n3 + n4);
......
......@@ -66,7 +66,7 @@ THREE.VTKLoader.prototype = {
// float float float
pattern = /([\d|\.|\+|\-|e]+)[ ]+([\d|\.|\+|\-|e]+)[ ]+([\d|\.|\+|\-|e]+)/g;
pattern = /([\+|\-]?[\d]+[\.][\d|\-|e]+)[ ]+([\+|\-]?[\d]+[\.][\d|\-|e]+)[ ]+([\+|\-]?[\d]+[\.][\d|\-|e]+)/g;
while ( ( result = pattern.exec( data ) ) != null ) {
......
......@@ -198,7 +198,7 @@ UI.Panel = function ( position ) {
this.dom = document.createElement( 'div' );
this.dom.style.position = position || 'relative';
this.dom.addEventListener( 'mousedown', function ( event ) { event.preventDefault() }, false );
// this.dom.addEventListener( 'mousedown', function ( event ) { event.preventDefault() }, false );
return this;
};
......@@ -243,99 +243,58 @@ UI.Text.prototype.setText = function ( value ) {
};
// IntNumber
// Color
UI.IntNumber = function ( position ) {
UI.Color = function ( position ) {
UI.Element.call( this );
this.dom = document.createElement( 'span' );
this.dom.style.position = position || 'relative';
this.dom.textContent = '0.00';
this.dom.style.marginTop = '2px';
this.dom.style.color = '#0080f0';
this.dom.style.fontSize = '12px';
this.dom.style.textDecoration = 'underline';
this.onChangeCallback = null;
var scope = this;
var onMouseDownValue, onMouseDownScreenX, onMouseDownScreenY;
var onMouseDown = function ( event ) {
event.preventDefault();
onMouseDownValue = parseInt( scope.dom.textContent );
onMouseDownScreenX = event.screenX;
onMouseDownScreenY = event.screenY;
document.addEventListener( 'mousemove', onMouseMove, false );
document.addEventListener( 'mouseup', onMouseUp, false );
}
var onMouseMove = function ( event ) {
var dx = event.screenX - onMouseDownScreenX;
var dy = event.screenY - onMouseDownScreenY;
scope.dom.textContent = ( onMouseDownValue + ( dx - dy ) / ( event.shiftKey ? 10 : 100 ) ).toFixed( 0 );
scope.onChangeCallback();
}
var onMouseUp = function ( event ) {
document.removeEventListener( 'mousemove', onMouseMove, false );
document.removeEventListener( 'mouseup', onMouseUp, false );
}
this.dom.addEventListener( 'mousedown', onMouseDown, false );
this.dom.style.width = '64px';
this.dom.style.height = '16px';
this.dom.style.backgroundColor = '#000000';
return this;
};
UI.IntNumber.prototype = new UI.Element();
UI.IntNumber.prototype.constructor = UI.IntNumber;
UI.IntNumber.prototype.getValue = function () {
UI.Color.prototype = new UI.Element();
UI.Color.prototype.constructor = UI.Color;
return parseInt( this.dom.textContent );
UI.Color.prototype.getValue = function () {
};
UI.IntNumber.prototype.setValue = function ( value ) {
this.dom.textContent = value.toFixed( 0 );
return this;
return this.dom.style.backgroundColor;
};
UI.IntNumber.prototype.onChange = function ( callback ) {
UI.Color.prototype.setValue = function ( value ) {
this.onChangeCallback = callback;
this.dom.style.backgroundColor = value;
return this;
};
// Number
// FloatNumber
UI.FloatNumber = function ( position ) {
UI.Number = function ( position ) {
UI.Element.call( this );
this.dom = document.createElement( 'span' );
this.dom = document.createElement( 'input' );
this.dom.style.position = position || 'relative';
this.dom.textContent = '0.00';
this.dom.style.marginTop = '2px';
this.dom.style.marginTop = '0px';
this.dom.style.color = '#0080f0';
this.dom.style.fontSize = '12px';
this.dom.style.textDecoration = 'underline';
this.dom.style.backgroundColor = 'transparent';
this.dom.style.border = '0px';
this.dom.value = '0.00';
this.min = - Infinity;
this.max = Infinity;
this.onChangeCallback = null;
......@@ -344,9 +303,9 @@ UI.FloatNumber = function ( position ) {
var onMouseDown = function ( event ) {
event.preventDefault();
// event.preventDefault();
onMouseDownValue = parseFloat( scope.dom.textContent );
onMouseDownValue = parseFloat( scope.dom.value );
onMouseDownScreenX = event.screenX;
onMouseDownScreenY = event.screenY;
......@@ -357,10 +316,12 @@ UI.FloatNumber = function ( position ) {
var onMouseMove = function ( event ) {
var dx = event.screenX - onMouseDownScreenX;
var dy = event.screenY - onMouseDownScreenY;
var distance = ( event.screenX - onMouseDownScreenX ) - ( event.screenY - onMouseDownScreenY );
var amount = event.shiftKey ? 10 : 100;
var number = onMouseDownValue + ( distance / amount );
scope.dom.textContent = ( onMouseDownValue + ( dx - dy ) / ( event.shiftKey ? 10 : 100 ) ).toFixed( 2 );
scope.dom.value = Math.min( scope.max, Math.max( scope.min, number ) ).toFixed( 2 );
scope.onChangeCallback();
}
......@@ -373,28 +334,54 @@ UI.FloatNumber = function ( position ) {
}
this.dom.addEventListener( 'mousedown', onMouseDown, false );
this.dom.addEventListener( 'change', function ( event ) {
var number = parseFloat( scope.dom.value );
if ( number !== NaN ) {
scope.dom.value = number.toFixed( 2 );
scope.onChangeCallback();
}
}, false );
return this;
};
UI.FloatNumber.prototype = new UI.Element();
UI.FloatNumber.prototype.constructor = UI.FloatNumber;
UI.Number.prototype = new UI.Element();
UI.Number.prototype.constructor = UI.Number;
UI.Number.prototype.getValue = function () {
UI.FloatNumber.prototype.getValue = function () {
return parseFloat( this.dom.value );
};
return parseFloat( this.dom.textContent );
UI.Number.prototype.setValue = function ( value ) {
this.dom.value = value.toFixed( 2 );
return this;
};
UI.Number.prototype.setMin = function ( value ) {
this.min = value;
return this;
};
UI.FloatNumber.prototype.setValue = function ( value ) {
UI.Number.prototype.setMax = function ( value ) {
this.dom.textContent = value.toFixed( 2 );
this.max = value;
return this;
};
UI.FloatNumber.prototype.onChange = function ( callback ) {
UI.Number.prototype.onChange = function ( callback ) {
this.onChangeCallback = callback;
return this;
......
......@@ -109,9 +109,9 @@ Sidebar.Properties.Geometry = function ( signals ) {
var hasFaceColor = face.color;
var hasFaceVertexColor = face.vertexColors[ 0 ] !== undefined;
var faceType = 0
faceType = setBit( faceType, 0, ! isTriangle );
var faceType = 0;
faceType = setBit( faceType, 0, ! isTriangle );
// faceType = setBit( faceType, 1, hasMaterial );
// faceType = setBit( faceType, 2, hasFaceUv );
// faceType = setBit( faceType, 3, hasFaceVertexUv );
......
......@@ -17,17 +17,30 @@ Sidebar.Properties.Material = function ( signals ) {
container.add( new UI.HorizontalRule() );
container.add( new UI.Text().setText( 'Color' ).setColor( '#666' ) );
var materialColor = new UI.Text( 'absolute' ).setLeft( '90px' ).setColor( '#444' ).setFontSize( '12px' );
var materialColor = new UI.Color( 'absolute' ).setLeft( '90px' );
container.add( materialColor );
container.add( new UI.HorizontalRule() );
container.add( new UI.Text().setText( 'Ambient' ).setColor( '#666' ) );
var materialAmbient = new UI.Color( 'absolute' ).setLeft( '90px' );
container.add( materialAmbient );
container.add( new UI.HorizontalRule() );
container.add( new UI.Text().setText( 'Specular' ).setColor( '#666' ) );
var materialSpecular = new UI.Color( 'absolute' ).setLeft( '90px' );
container.add( materialSpecular );
container.add( new UI.HorizontalRule() );
container.add( new UI.Text().setText( 'Map' ).setColor( '#666' ) );
var materialMap = new UI.Text( 'absolute' ).setLeft( '90px' ).setColor( '#444' ).setFontSize( '12px' );
container.add( materialMap );
container.add( new UI.HorizontalRule() );
container.add( new UI.Text().setText( 'Opacity' ).setColor( '#666' ) );
var materialOpacity = new UI.FloatNumber( 'absolute' ).setLeft( '90px' ).setFontSize( '12px' ).onChange( update );
var materialOpacity = new UI.Number( 'absolute' ).setLeft( '90px' ).setWidth( '60px' ).setMin( 0 ).setMax( 1 ).onChange( update );
container.add( materialOpacity );
container.add( new UI.HorizontalRule() );
......@@ -61,7 +74,9 @@ Sidebar.Properties.Material = function ( signals ) {
materialName.setText( object.material.name );
materialClass.setText( getMaterialInstanceName( object.material ) );
materialColor.setText( '#' + object.material.color.getHex().toString(16) );
materialColor.setValue( '#' + object.material.color.getHex().toString( 16 ) );
if ( object.material.ambient ) materialAmbient.setValue( '#' + object.material.ambient.getHex().toString( 16 ) );
if ( object.material.specular ) materialSpecular.setValue( '#' + object.material.specular.getHex().toString( 16 ) );
materialMap.setText( object.material.map );
materialOpacity.setValue( object.material.opacity );
materialTransparent.setText( object.material.transparent );
......
......@@ -12,23 +12,23 @@ Sidebar.Properties.Object3D = function ( signals ) {
container.add( new UI.HorizontalRule() );
container.add( new UI.Text().setText( 'Position' ).setColor( '#666' ) );
var positionX = new UI.FloatNumber( 'absolute' ).setLeft( '90px' ).onChange( update );
var positionY = new UI.FloatNumber( 'absolute' ).setLeft( '160px' ).onChange( update );
var positionZ = new UI.FloatNumber( 'absolute' ).setLeft( '230px' ).onChange( update );
var positionX = new UI.Number( 'absolute' ).setLeft( '90px' ).setWidth( '50px' ).onChange( update );
var positionY = new UI.Number( 'absolute' ).setLeft( '150px' ).setWidth( '50px' ).onChange( update );
var positionZ = new UI.Number( 'absolute' ).setLeft( '210px' ).setWidth( '50px' ).onChange( update );
container.add( positionX, positionY, positionZ );
container.add( new UI.HorizontalRule() );
container.add( new UI.Text().setText( 'Rotation' ).setColor( '#666' ) );
var rotationX = new UI.FloatNumber( 'absolute' ).setLeft( '90px' ).onChange( update );
var rotationY = new UI.FloatNumber( 'absolute' ).setLeft( '160px' ).onChange( update );
var rotationZ = new UI.FloatNumber( 'absolute' ).setLeft( '230px' ).onChange( update );
var rotationX = new UI.Number( 'absolute' ).setLeft( '90px' ).setWidth( '50px' ).onChange( update );
var rotationY = new UI.Number( 'absolute' ).setLeft( '150px' ).setWidth( '50px' ).onChange( update );
var rotationZ = new UI.Number( 'absolute' ).setLeft( '210px' ).setWidth( '50px' ).onChange( update );
container.add( rotationX, rotationY, rotationZ );
container.add( new UI.HorizontalRule() );
container.add( new UI.Text().setText( 'Scale' ).setColor( '#666' ) );
var scaleX = new UI.FloatNumber( 'absolute' ).setValue( 1 ).setLeft( '90px' ).onChange( update );
var scaleY = new UI.FloatNumber( 'absolute' ).setValue( 1 ).setLeft( '160px' ).onChange( update );
var scaleZ = new UI.FloatNumber( 'absolute' ).setValue( 1 ).setLeft( '230px' ).onChange( update );
var scaleX = new UI.Number( 'absolute' ).setValue( 1 ).setLeft( '90px' ).setWidth( '50px' ).onChange( update );
var scaleY = new UI.Number( 'absolute' ).setValue( 1 ).setLeft( '150px' ).setWidth( '50px' ).onChange( update );
var scaleZ = new UI.Number( 'absolute' ).setValue( 1 ).setLeft( '210px' ).setWidth( '50px' ).onChange( update );
container.add( scaleX, scaleY, scaleZ );
container.add( new UI.Break(), new UI.Break(), new UI.Break() );
......
......@@ -121,6 +121,9 @@ var Viewport = function ( signals ) {
signals.objectChanged.add( function ( object ) {
object.updateMatrix();
object.updateMatrixWorld();
selectionBox.matrixWorld.copy( object.matrixWorld );
render();
......
......@@ -80,10 +80,20 @@ THREE.Ray = function ( origin, direction, near, far ) {
};
this.intersectObject = function ( object ) {
this.intersectObject = function ( object, recursive ) {
var intersect, intersects = [];
if ( recursive === true ) {
for ( var i = 0, l = object.children.length; i < l; i ++ ) {
Array.prototype.push.apply( intersects, this.intersectObject( object.children[ i ], recursive ) );
}
}
if ( object instanceof THREE.Particle ) {
distance = distanceFromIntersection( this.origin, this.direction, object.matrixWorld.getPosition() );
......@@ -125,7 +135,7 @@ THREE.Ray = function ( origin, direction, near, far ) {
// Checking faces
var f, fl, face, dot, scalar,
rangeSq = this.range*this.range,
rangeSq = this.range * this.range,
geometry = object.geometry,
vertices = geometry.vertices,
objMatrix;
......@@ -226,13 +236,13 @@ THREE.Ray = function ( origin, direction, near, far ) {
};
this.intersectObjects = function ( objects ) {
this.intersectObjects = function ( objects, recursive ) {
var intersects = [];
for ( var i = 0, l = objects.length; i < l; i ++ ) {
Array.prototype.push.apply( intersects, this.intersectObject( objects[ i ] ) );
Array.prototype.push.apply( intersects, this.intersectObject( objects[ i ], recursive ) );
}
......
......@@ -18,7 +18,7 @@ THREE.ImageUtils = {
texture.image = event.content;
texture.needsUpdate = true;
if ( onLoad ) onLoad();
if ( onLoad ) onLoad( texture );
} );
......
.DS_Store
\ No newline at end of file
test:
node test/test.js
.PHONY: test
\ No newline at end of file
module.exports = require('./lib/argsparser');
/**
* Parser arguments array
* @param {Array} args optional arguments arrray.
* @return {Object} opts key value hash.
* @export
*/
exports.parse = function(args) {
// args is optional, default is process.argv
args = args || process.argv;
var opts = {}, curSwitch;
args.forEach(function(arg) {
// its a switch
if (/^(-|--)/.test(arg) || !curSwitch) {
opts[arg] = true;
curSwitch = arg;
// this arg is a data
} else {
if (arg === 'false') {
arg = false;
} else if (arg === 'true') {
arg = true;
} else if (!isNaN(arg)) {
arg = Number(arg);
}
// it was a boolean switch per default,
// now it has got a val
if (typeof opts[curSwitch] === 'boolean') {
opts[curSwitch] = arg;
} else if (Array.isArray(opts[curSwitch])) {
opts[curSwitch].push(arg);
} else {
opts[curSwitch] = [opts[curSwitch], arg];
}
}
});
return opts;
};
{
"name": "argsparser",
"description": "A tiny command line arguments parser",
"version": "0.0.6",
"author": "Oleg Slobodskoi <oleg008@gmail.com>",
"repository": {
"type": "git",
"url": "http://github.com/kof/node-argsparser.git"
},
"keywords": [ "arguments", "options", "command line", "parser" ],
"engines": { "node": ">= 0.2.0" },
"scripts": { "test": "node ./test/test.js" },
"licenses": [
{
"type": "MIT",
"url" : "http://www.opensource.org/licenses/mit-license.php"
}
]
}
## Yet another tiny arguments parser for node
## Features
* extremely tiny
* instead to parse all possible spellings, it uses just some simple rules
## How this parser works
The target is to get a key-value object from an array. A key can be the first element or element prefixed by "-" and "--" (switch).
So the parser loops through the array and looks for keys. After he could detect an a key all next elements will be added as a value of this key until he find another key.
If there is no value, then the key is true (boolean). If there are a lot of values, then the key is an array.
## Examples
node script.js -> {"node": "script.js"}
node script.js -o -> {"node": "script.js", "-o": true}
node script.js -o test -> {"node": "script.js", "-o": "test"}
node script.js -a testa --b testb -> {node: "script.js", "-a": "testa", "--b": "testb"}
node script.js -paths /test.js /test1.js -> {node: "script.js", "-paths": ["/test.js", "/test1.js"]}
## Usage
// per default it parses process.argv
var args = require( "argsparser" ).parse(); // {"node": "/path/to/your/script.js"}
// optional you can pass your own arguments array
var args = require( "argsparser" ).parse(["-a", "test"]); // {"-a": "test"}
## Installation
npm install argsparser
\ No newline at end of file
var a = require('assert'),
util = require('util'),
parse = require('../lib/argsparser').parse;
util.print('Run tests...\n');
a.deepEqual(parse(), {node: __filename}, 'node script.js');
a.deepEqual(parse(['-o']), {'-o': true}, 'node script.js -o');
a.deepEqual(parse(['-o', 'true']), {'-o': true}, 'node script.js -o true');
a.deepEqual(parse(['-o', 'false']), {'-o': false}, 'node script.js -o false');
a.deepEqual(parse(['-o', '123']), {'-o': 123}, 'node script.js -o 123');
a.deepEqual(parse(['--token', 'bla--bla']), {'--token': 'bla--bla'}, 'node script.js --token bla--bla');
a.deepEqual(parse(['-o', '123.456']), {'-o': 123.456}, 'node script.js -o 123.456');
a.deepEqual(parse(['-o', 'test']), {'-o': 'test'}, 'node script.js -o test');
a.deepEqual(parse(['-a', 'testa', '-b', 'testb']), {'-a': 'testa', '-b': 'testb'}, 'node script.js -a testa -b testb');
a.deepEqual(parse(['--a', 'testa', '--b', 'testb']), {'--a': 'testa', '--b': 'testb'}, 'node script.js --a testa --b testb ');
a.deepEqual(parse(['-a', 'testa', '--b', 'testb']), {'-a': 'testa', '--b': 'testb'}, 'node script.js -a testa --b testb');
a.deepEqual(parse(['--a', 'testa', '-b', 'testb']), {'--a': 'testa', '-b': 'testb'}, 'node script.js --a testa -b testb');
a.deepEqual(parse(['-paths', '/test.js', '/test1.js']), {'-paths': ['/test.js', '/test1.js']}, 'node script.js -paths /test.js /test1.js');
a.deepEqual(parse(['--paths', '/test.js', '/test1.js']), {'--paths': ['/test.js', '/test1.js']}, 'node script.js --paths /test.js /test1.js');
a.deepEqual(parse(['--paths', '/test.js', '/test1.js', '-a', 'testa']), {'--paths': ['/test.js', '/test1.js'], '-a': 'testa'}, 'node script.js --paths /test.js /test1.js -a testa');
a.deepEqual(parse(['--port', '80', '8080']), {'--port': [80, 8080]}, 'node server.js --port 80 8080');
util.print('All tests ok\n');
.DS_Store
.tmp*~
*.local.*
.pinf-*
\ No newline at end of file
此差异已折叠。
此差异已折叠。
#!/usr/bin/env node
// -*- js -*-
global.sys = require(/^v0\.[012]/.test(process.version) ? "sys" : "util");
var fs = require("fs");
var uglify = require("uglify-js"), // symlink ~/.node_libraries/uglify-js.js to ../uglify-js.js
consolidator = uglify.consolidator,
jsp = uglify.parser,
pro = uglify.uglify;
var options = {
ast: false,
consolidate: false,
mangle: true,
mangle_toplevel: false,
no_mangle_functions: false,
squeeze: true,
make_seqs: true,
dead_code: true,
verbose: false,
show_copyright: true,
out_same_file: false,
max_line_length: 32 * 1024,
unsafe: false,
reserved_names: null,
defines: { },
lift_vars: false,
codegen_options: {
ascii_only: false,
beautify: false,
indent_level: 4,
indent_start: 0,
quote_keys: false,
space_colon: false,
inline_script: false
},
make: false,
output: true // stdout
};
var args = jsp.slice(process.argv, 2);
var filename;
out: while (args.length > 0) {
var v = args.shift();
switch (v) {
case "-b":
case "--beautify":
options.codegen_options.beautify = true;
break;
case "-c":
case "--consolidate-primitive-values":
options.consolidate = true;
break;
case "-i":
case "--indent":
options.codegen_options.indent_level = args.shift();
break;
case "-q":
case "--quote-keys":
options.codegen_options.quote_keys = true;
break;
case "-mt":
case "--mangle-toplevel":
options.mangle_toplevel = true;
break;
case "-nmf":
case "--no-mangle-functions":
options.no_mangle_functions = true;
break;
case "--no-mangle":
case "-nm":
options.mangle = false;
break;
case "--no-squeeze":
case "-ns":
options.squeeze = false;
break;
case "--no-seqs":
options.make_seqs = false;
break;
case "--no-dead-code":
options.dead_code = false;
break;
case "--no-copyright":
case "-nc":
options.show_copyright = false;
break;
case "-o":
case "--output":
options.output = args.shift();
break;
case "--overwrite":
options.out_same_file = true;
break;
case "-v":
case "--verbose":
options.verbose = true;
break;
case "--ast":
options.ast = true;
break;
case "--unsafe":
options.unsafe = true;
break;
case "--max-line-len":
options.max_line_length = parseInt(args.shift(), 10);
break;
case "--reserved-names":
options.reserved_names = args.shift().split(",");
break;
case "--lift-vars":
options.lift_vars = true;
break;
case "-d":
case "--define":
var defarg = args.shift();
try {
var defsym = function(sym) {
// KEYWORDS_ATOM doesn't include NaN or Infinity - should we check
// for them too ?? We don't check reserved words and the like as the
// define values are only substituted AFTER parsing
if (jsp.KEYWORDS_ATOM.hasOwnProperty(sym)) {
throw "Don't define values for inbuilt constant '"+sym+"'";
}
return sym;
},
defval = function(v) {
if (v.match(/^"(.*)"$/) || v.match(/^'(.*)'$/)) {
return [ "string", RegExp.$1 ];
}
else if (!isNaN(parseFloat(v))) {
return [ "num", parseFloat(v) ];
}
else if (v.match(/^[a-z\$_][a-z\$_0-9]*$/i)) {
return [ "name", v ];
}
else if (!v.match(/"/)) {
return [ "string", v ];
}
else if (!v.match(/'/)) {
return [ "string", v ];
}
throw "Can't understand the specified value: "+v;
};
if (defarg.match(/^([a-z_\$][a-z_\$0-9]*)(=(.*))?$/i)) {
var sym = defsym(RegExp.$1),
val = RegExp.$2 ? defval(RegExp.$2.substr(1)) : [ 'name', 'true' ];
options.defines[sym] = val;
}
else {
throw "The --define option expects SYMBOL[=value]";
}
} catch(ex) {
sys.print("ERROR: In option --define "+defarg+"\n"+ex+"\n");
process.exit(1);
}
break;
case "--define-from-module":
var defmodarg = args.shift(),
defmodule = require(defmodarg),
sym,
val;
for (sym in defmodule) {
if (defmodule.hasOwnProperty(sym)) {
options.defines[sym] = function(val) {
if (typeof val == "string")
return [ "string", val ];
if (typeof val == "number")
return [ "num", val ];
if (val === true)
return [ 'name', 'true' ];
if (val === false)
return [ 'name', 'false' ];
if (val === null)
return [ 'name', 'null' ];
if (val === undefined)
return [ 'name', 'undefined' ];
sys.print("ERROR: In option --define-from-module "+defmodarg+"\n");
sys.print("ERROR: Unknown object type for: "+sym+"="+val+"\n");
process.exit(1);
return null;
}(defmodule[sym]);
}
}
break;
case "--ascii":
options.codegen_options.ascii_only = true;
break;
case "--make":
options.make = true;
break;
case "--inline-script":
options.codegen_options.inline_script = true;
break;
default:
filename = v;
break out;
}
}
if (options.verbose) {
pro.set_logger(function(msg){
sys.debug(msg);
});
}
jsp.set_logger(function(msg){
sys.debug(msg);
});
if (options.make) {
options.out_same_file = false; // doesn't make sense in this case
var makefile = JSON.parse(fs.readFileSync(filename || "Makefile.uglify.js").toString());
output(makefile.files.map(function(file){
var code = fs.readFileSync(file.name);
if (file.module) {
code = "!function(exports, global){global = this;\n" + code + "\n;this." + file.module + " = exports;}({})";
}
else if (file.hide) {
code = "(function(){" + code + "}());";
}
return squeeze_it(code);
}).join("\n"));
}
else if (filename) {
fs.readFile(filename, "utf8", function(err, text){
if (err) throw err;
output(squeeze_it(text));
});
}
else {
var stdin = process.openStdin();
stdin.setEncoding("utf8");
var text = "";
stdin.on("data", function(chunk){
text += chunk;
});
stdin.on("end", function() {
output(squeeze_it(text));
});
}
function output(text) {
var out;
if (options.out_same_file && filename)
options.output = filename;
if (options.output === true) {
out = process.stdout;
} else {
out = fs.createWriteStream(options.output, {
flags: "w",
encoding: "utf8",
mode: 0644
});
}
out.write(text.replace(/;*$/, ";"));
if (options.output !== true) {
out.end();
}
};
// --------- main ends here.
function show_copyright(comments) {
var ret = "";
for (var i = 0; i < comments.length; ++i) {
var c = comments[i];
if (c.type == "comment1") {
ret += "//" + c.value + "\n";
} else {
ret += "/*" + c.value + "*/";
}
}
return ret;
};
function squeeze_it(code) {
var result = "";
if (options.show_copyright) {
var tok = jsp.tokenizer(code), c;
c = tok();
result += show_copyright(c.comments_before);
}
try {
var ast = time_it("parse", function(){ return jsp.parse(code); });
if (options.consolidate) ast = time_it("consolidate", function(){
return consolidator.ast_consolidate(ast);
});
if (options.lift_vars) {
ast = time_it("lift", function(){ return pro.ast_lift_variables(ast); });
}
if (options.mangle) ast = time_it("mangle", function(){
return pro.ast_mangle(ast, {
toplevel : options.mangle_toplevel,
defines : options.defines,
except : options.reserved_names,
no_functions : options.no_mangle_functions
});
});
if (options.squeeze) ast = time_it("squeeze", function(){
ast = pro.ast_squeeze(ast, {
make_seqs : options.make_seqs,
dead_code : options.dead_code,
keep_comps : !options.unsafe
});
if (options.unsafe)
ast = pro.ast_squeeze_more(ast);
return ast;
});
if (options.ast)
return sys.inspect(ast, null, null);
result += time_it("generate", function(){ return pro.gen_code(ast, options.codegen_options) });
if (!options.codegen_options.beautify && options.max_line_length) {
result = time_it("split", function(){ return pro.split_lines(result, options.max_line_length) });
}
return result;
} catch(ex) {
sys.debug(ex.stack);
sys.debug(sys.inspect(ex));
sys.debug(JSON.stringify(ex));
process.exit(1);
}
};
function time_it(name, cont) {
if (!options.verbose)
return cont();
var t1 = new Date().getTime();
try { return cont(); }
finally { sys.debug("// " + name + ": " + ((new Date().getTime() - t1) / 1000).toFixed(3) + " sec."); }
};
html { font-family: "Lucida Grande","Trebuchet MS",sans-serif; font-size: 12pt; }
body { max-width: 60em; }
.title { text-align: center; }
.todo { color: red; }
.done { color: green; }
.tag { background-color:lightblue; font-weight:normal }
.target { }
.timestamp { color: grey }
.timestamp-kwd { color: CadetBlue }
p.verse { margin-left: 3% }
pre {
border: 1pt solid #AEBDCC;
background-color: #F3F5F7;
padding: 5pt;
font-family: monospace;
font-size: 90%;
overflow:auto;
}
pre.src {
background-color: #eee; color: #112; border: 1px solid #000;
}
table { border-collapse: collapse; }
td, th { vertical-align: top; }
dt { font-weight: bold; }
div.figure { padding: 0.5em; }
div.figure p { text-align: center; }
.linenr { font-size:smaller }
.code-highlighted {background-color:#ffff00;}
.org-info-js_info-navigation { border-style:none; }
#org-info-js_console-label { font-size:10px; font-weight:bold;
white-space:nowrap; }
.org-info-js_search-highlight {background-color:#ffff00; color:#000000;
font-weight:bold; }
sup {
vertical-align: baseline;
position: relative;
top: -0.5em;
font-size: 80%;
}
sup a:link, sup a:visited {
text-decoration: none;
color: #c00;
}
sup a:before { content: "["; color: #999; }
sup a:after { content: "]"; color: #999; }
h1.title { border-bottom: 4px solid #000; padding-bottom: 5px; margin-bottom: 2em; }
#postamble {
color: #777;
font-size: 90%;
padding-top: 1em; padding-bottom: 1em; border-top: 1px solid #999;
margin-top: 2em;
padding-left: 2em;
padding-right: 2em;
text-align: right;
}
#postamble p { margin: 0; }
#footnotes { border-top: 1px solid #000; }
h1 { font-size: 200% }
h2 { font-size: 175% }
h3 { font-size: 150% }
h4 { font-size: 125% }
h1, h2, h3, h4 { font-family: "Bookman",Georgia,"Times New Roman",serif; font-weight: normal; }
@media print {
html { font-size: 11pt; }
}
var jsp = require("./parse-js"),
pro = require("./process");
var BY_TYPE = {};
function HOP(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
};
function AST_Node(parent) {
this.parent = parent;
};
AST_Node.prototype.init = function(){};
function DEFINE_NODE_CLASS(type, props, methods) {
var base = methods && methods.BASE || AST_Node;
if (!base) base = AST_Node;
function D(parent, data) {
base.apply(this, arguments);
if (props) props.forEach(function(name, i){
this["_" + name] = data[i];
});
this.init();
};
var P = D.prototype = new AST_Node;
P.node_type = function(){ return type };
if (props) props.forEach(function(name){
var propname = "_" + name;
P["set_" + name] = function(val) {
this[propname] = val;
return this;
};
P["get_" + name] = function() {
return this[propname];
};
});
if (type != null) BY_TYPE[type] = D;
if (methods) for (var i in methods) if (HOP(methods, i)) {
P[i] = methods[i];
}
return D;
};
var AST_String_Node = DEFINE_NODE_CLASS("string", ["value"]);
var AST_Number_Node = DEFINE_NODE_CLASS("num", ["value"]);
var AST_Name_Node = DEFINE_NODE_CLASS("name", ["value"]);
var AST_Statlist_Node = DEFINE_NODE_CLASS(null, ["body"]);
var AST_Root_Node = DEFINE_NODE_CLASS("toplevel", null, { BASE: AST_Statlist_Node });
var AST_Block_Node = DEFINE_NODE_CLASS("block", null, { BASE: AST_Statlist_Node });
var AST_Splice_Node = DEFINE_NODE_CLASS("splice", null, { BASE: AST_Statlist_Node });
var AST_Var_Node = DEFINE_NODE_CLASS("var", ["definitions"]);
var AST_Const_Node = DEFINE_NODE_CLASS("const", ["definitions"]);
var AST_Try_Node = DEFINE_NODE_CLASS("try", ["body", "catch", "finally"]);
var AST_Throw_Node = DEFINE_NODE_CLASS("throw", ["exception"]);
var AST_New_Node = DEFINE_NODE_CLASS("new", ["constructor", "arguments"]);
var AST_Switch_Node = DEFINE_NODE_CLASS("switch", ["expression", "branches"]);
var AST_Switch_Branch_Node = DEFINE_NODE_CLASS(null, ["expression", "body"]);
var AST_Break_Node = DEFINE_NODE_CLASS("break", ["label"]);
var AST_Continue_Node = DEFINE_NODE_CLASS("continue", ["label"]);
var AST_Assign_Node = DEFINE_NODE_CLASS("assign", ["operator", "lvalue", "rvalue"]);
var AST_Dot_Node = DEFINE_NODE_CLASS("dot", ["expression", "name"]);
var AST_Call_Node = DEFINE_NODE_CLASS("call", ["function", "arguments"]);
var AST_Lambda_Node = DEFINE_NODE_CLASS(null, ["name", "arguments", "body"])
var AST_Function_Node = DEFINE_NODE_CLASS("function", null, AST_Lambda_Node);
var AST_Defun_Node = DEFINE_NODE_CLASS("defun", null, AST_Lambda_Node);
var AST_If_Node = DEFINE_NODE_CLASS("if", ["condition", "then", "else"]);
此差异已折叠。
此差异已折叠。
var jsp = require("./parse-js"),
pro = require("./process"),
slice = jsp.slice,
member = jsp.member,
curry = jsp.curry,
MAP = pro.MAP,
PRECEDENCE = jsp.PRECEDENCE,
OPERATORS = jsp.OPERATORS;
function ast_squeeze_more(ast) {
var w = pro.ast_walker(), walk = w.walk, scope;
function with_scope(s, cont) {
var save = scope, ret;
scope = s;
ret = cont();
scope = save;
return ret;
};
function _lambda(name, args, body) {
return [ this[0], name, args, with_scope(body.scope, curry(MAP, body, walk)) ];
};
return w.with_walkers({
"toplevel": function(body) {
return [ this[0], with_scope(this.scope, curry(MAP, body, walk)) ];
},
"function": _lambda,
"defun": _lambda,
"new": function(ctor, args) {
if (ctor[0] == "name") {
if (ctor[1] == "Array" && !scope.has("Array")) {
if (args.length != 1) {
return [ "array", args ];
} else {
return walk([ "call", [ "name", "Array" ], args ]);
}
} else if (ctor[1] == "Object" && !scope.has("Object")) {
if (!args.length) {
return [ "object", [] ];
} else {
return walk([ "call", [ "name", "Object" ], args ]);
}
} else if ((ctor[1] == "RegExp" || ctor[1] == "Function" || ctor[1] == "Error") && !scope.has(ctor[1])) {
return walk([ "call", [ "name", ctor[1] ], args]);
}
}
},
"call": function(expr, args) {
if (expr[0] == "dot" && expr[1][0] == "string" && args.length == 1
&& (args[0][1] > 0 && expr[2] == "substring" || expr[2] == "substr")) {
return [ "call", [ "dot", expr[1], "slice"], args];
}
if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) {
// foo.toString() ==> foo+""
return [ "binary", "+", expr[1], [ "string", "" ]];
}
if (expr[0] == "name") {
if (expr[1] == "Array" && args.length != 1 && !scope.has("Array")) {
return [ "array", args ];
}
if (expr[1] == "Object" && !args.length && !scope.has("Object")) {
return [ "object", [] ];
}
if (expr[1] == "String" && !scope.has("String")) {
return [ "binary", "+", args[0], [ "string", "" ]];
}
}
}
}, function() {
return walk(pro.ast_add_scope(ast));
});
};
exports.ast_squeeze_more = ast_squeeze_more;
{
"name" : "uglify-js",
"description" : "JavaScript parser and compressor/beautifier toolkit",
"author" : {
"name" : "Mihai Bazon",
"email" : "mihai.bazon@gmail.com",
"url" : "http://mihai.bazon.net/blog"
},
"version" : "1.2.6",
"main" : "./uglify-js.js",
"bin" : {
"uglifyjs" : "./bin/uglifyjs"
},
"repository": {
"type": "git",
"url": "git@github.com:mishoo/UglifyJS.git"
}
}
{
"name" : "uglify-js",
"description" : "JavaScript parser and compressor/beautifier toolkit",
"author" : {
"name" : "Mihai Bazon",
"email" : "mihai.bazon@gmail.com",
"url" : "http://mihai.bazon.net/blog"
},
"version" : "1.2.3",
"main" : "./uglify-js.js",
"bin" : {
"uglifyjs" : "./bin/uglifyjs"
},
"repository": {
"type": "git",
"url": "git@github.com:mishoo/UglifyJS.git"
}
}
#! /usr/bin/env node
global.sys = require("sys");
var fs = require("fs");
var jsp = require("../lib/parse-js");
var pro = require("../lib/process");
var filename = process.argv[2];
fs.readFile(filename, "utf8", function(err, text){
try {
var ast = time_it("parse", function(){ return jsp.parse(text); });
ast = time_it("mangle", function(){ return pro.ast_mangle(ast); });
ast = time_it("squeeze", function(){ return pro.ast_squeeze(ast); });
var gen = time_it("generate", function(){ return pro.gen_code(ast, false); });
sys.puts(gen);
} catch(ex) {
sys.debug(ex.stack);
sys.debug(sys.inspect(ex));
sys.debug(JSON.stringify(ex));
}
});
function time_it(name, cont) {
var t1 = new Date().getTime();
try { return cont(); }
finally { sys.debug("// " + name + ": " + ((new Date().getTime() - t1) / 1000).toFixed(3) + " sec."); }
};
(function(){var a=function(){};return new a(1,2,3,4)})()
(function(){function a(){}(function(){return new a(1,2,3)})()})()
a=1,b=a,c=1,d=b,e=d,longname=2;if(longname+1){x=3;if(x)var z=7}z=1,y=1,x=1,g+=1,h=g,++i,j=i,i++,j=i+17
\ No newline at end of file
var a=a+"a"+"b"+1+c,b=a+"c"+"ds"+123+c,c=a+"c"+123+d+"ds"+c
\ No newline at end of file
function bar(){return--x}function foo(){while(bar());}function mak(){for(;;);}var x=5
a=func(),b=z;for(a++;i<10;i++)alert(i);var z=1;g=2;for(;i<10;i++)alert(i);var a=2;for(var i=1;i<10;i++)alert(i)
\ No newline at end of file
function a(a){return a==1?2:17}
\ No newline at end of file
function x(a){return typeof a=="object"?a:a===42?0:a*2}function y(a){return typeof a=="object"?a:null}
function f(){var a;return(a="a")?a:a}f()
\ No newline at end of file
new(A,B),new(A||B),new(X?A:B)
\ No newline at end of file
var a=/^(?:(\w+):)?(?:\/\/(?:(?:([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#])(?::(\d))?)?(..?$|(?:[^?#\/]\/))([^?#]*)(?:\?([^#]))?(?:#(.))?/
\ No newline at end of file
var a={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"}
var a=0;switch(a){case 0:a++}
\ No newline at end of file
o={".5":.5},o={.5:.5},o={.5:.5}
\ No newline at end of file
result=function(){return 1}()
\ No newline at end of file
var a={};a["this"]=1,a.that=2
\ No newline at end of file
function bar(a){try{foo()}catch(b){alert("Exception caught (foo not defined)")}alert(a)}bar(10)
typeof a=="string",b+""!=c+"",d<e==f<g
\ No newline at end of file
(function(){
var Array = function(){};
return new Array(1, 2, 3, 4);
})();
(function(){
return new Array(1, 2, 3, 4);
function Array() {};
})();
(function(){
(function(){
return new Array(1, 2, 3);
})();
function Array(){};
})();
a=1;
b=a;
c=1;
d=b;
e=d;
longname=2;
if (longname+1) {
x=3;
if (x) var z = 7;
}
z=1,y=1,x=1
g+=1;
h=g;
++i;
j=i;
i++;
j=i+17;
\ No newline at end of file
var a = a + "a" + "b" + 1 + c;
var b = a + "c" + "ds" + 123 + c;
var c = a + "c" + 123 + d + "ds" + c;
\ No newline at end of file
// test that the calculation is fold to 13
var a = 1 + 2 * 6;
// test that it isn't replaced with 0.3333 because that is more characters
var b = 1/3;
\ No newline at end of file
var x = 5;
function bar() { return --x; }
function foo() { while (bar()); }
function mak() { for(;;); }
a=func();
b=z;
for (a++; i < 10; i++) { alert(i); }
var z=1;
g=2;
for (; i < 10; i++) { alert(i); }
var a = 2;
for (var i = 1; i < 10; i++) { alert(i); }
var a = 1;
if (a == 1) {
a = 2;
} else {
a = 17;
}
function a(b) {
if (b == 1) {
return 2;
} else {
return 17;
}
return 3;
}
\ No newline at end of file
function x(a) {
if (typeof a === 'object')
return a;
if (a === 42)
return 0;
return a * 2;
}
function y(a) {
if (typeof a === 'object')
return a;
return null;
};
function f() { var a; if (a = 'a') { return a; } else { return a; } }; f();
\ No newline at end of file
new (A, B)
new (A || B)
new (X ? A : B)
\ No newline at end of file
var a = /^(?:(\w+):)?(?:\/\/(?:(?:([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#])(?::(\d))?)?(..?$|(?:[^?#\/]\/))([^?#]*)(?:\?([^#]))?(?:#(.))?/;
\ No newline at end of file
var a = {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\'};
\ No newline at end of file
var a = 0;
switch(a) {
case 0:
a++;
break;
}
\ No newline at end of file
label1 : {
label2 : {
break label2;
console.log(2);
}
console.log(1);
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册