language
stringclasses
1 value
owner
stringlengths
2
15
repo
stringlengths
2
21
sha
stringlengths
45
45
message
stringlengths
7
36.3k
path
stringlengths
1
199
patch
stringlengths
15
102k
is_multipart
bool
2 classes
Other
mrdoob
three.js
01852d283b95a56e9c930c3db35fc06f346975f4.json
add some improvements to frustum
build/custom/ThreeCanvas.js
@@ -959,13 +959,17 @@ THREE.Frustum.prototype.setFromMatrix = function ( m ) { var i, plane, planes = this.planes; var me = m.elements; - - planes[ 0 ].set( me[3] - me[0], me[7] - me[4], me[11] - me[8], me[15] - me[12] ); - planes[ 1 ].set( me[3] + me[0], me[7] + me[4], me[11] + me[8], me[15] + me[12] ); - planes[ 2 ].set( me[3] + me[1], me[7] + me[5], me[11] + me[9], me[15] + me[13] ); - planes[ 3 ].set( me[3] - me[1], me[7] - me[5], me[11] - me[9], me[15] - me[13] ); - planes[ 4 ].set( me[3] - me[2], me[7] - me[6], me[11] - me[10], me[15] - me[14] ); - planes[ 5 ].set( me[3] + me[2], me[7] + me[6], me[11] + me[10], me[15] + me[14] ); + var me0 = me[0], me1 = me[1], me2 = me[2], me3 = me[3]; + var me4 = me[4], me5 = me[5], me6 = me[6], me7 = me[7]; + var me8 = me[8], me9 = me[9], me10 = me[10], me11 = me[11]; + var me12 = me[12], me13 = me[13], me14 = me[14], me15 = me[15]; + + planes[ 0 ].set( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ); + planes[ 1 ].set( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ); + planes[ 2 ].set( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ); + planes[ 3 ].set( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ); + planes[ 4 ].set( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ); + planes[ 5 ].set( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ); for ( i = 0; i < 6; i ++ ) {
true
Other
mrdoob
three.js
01852d283b95a56e9c930c3db35fc06f346975f4.json
add some improvements to frustum
build/custom/ThreeDOM.js
@@ -959,13 +959,17 @@ THREE.Frustum.prototype.setFromMatrix = function ( m ) { var i, plane, planes = this.planes; var me = m.elements; - - planes[ 0 ].set( me[3] - me[0], me[7] - me[4], me[11] - me[8], me[15] - me[12] ); - planes[ 1 ].set( me[3] + me[0], me[7] + me[4], me[11] + me[8], me[15] + me[12] ); - planes[ 2 ].set( me[3] + me[1], me[7] + me[5], me[11] + me[9], me[15] + me[13] ); - planes[ 3 ].set( me[3] - me[1], me[7] - me[5], me[11] - me[9], me[15] - me[13] ); - planes[ 4 ].set( me[3] - me[2], me[7] - me[6], me[11] - me[10], me[15] - me[14] ); - planes[ 5 ].set( me[3] + me[2], me[7] + me[6], me[11] + me[10], me[15] + me[14] ); + var me0 = me[0], me1 = me[1], me2 = me[2], me3 = me[3]; + var me4 = me[4], me5 = me[5], me6 = me[6], me7 = me[7]; + var me8 = me[8], me9 = me[9], me10 = me[10], me11 = me[11]; + var me12 = me[12], me13 = me[13], me14 = me[14], me15 = me[15]; + + planes[ 0 ].set( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ); + planes[ 1 ].set( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ); + planes[ 2 ].set( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ); + planes[ 3 ].set( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ); + planes[ 4 ].set( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ); + planes[ 5 ].set( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ); for ( i = 0; i < 6; i ++ ) {
true
Other
mrdoob
three.js
01852d283b95a56e9c930c3db35fc06f346975f4.json
add some improvements to frustum
build/custom/ThreeSVG.js
@@ -959,13 +959,17 @@ THREE.Frustum.prototype.setFromMatrix = function ( m ) { var i, plane, planes = this.planes; var me = m.elements; - - planes[ 0 ].set( me[3] - me[0], me[7] - me[4], me[11] - me[8], me[15] - me[12] ); - planes[ 1 ].set( me[3] + me[0], me[7] + me[4], me[11] + me[8], me[15] + me[12] ); - planes[ 2 ].set( me[3] + me[1], me[7] + me[5], me[11] + me[9], me[15] + me[13] ); - planes[ 3 ].set( me[3] - me[1], me[7] - me[5], me[11] - me[9], me[15] - me[13] ); - planes[ 4 ].set( me[3] - me[2], me[7] - me[6], me[11] - me[10], me[15] - me[14] ); - planes[ 5 ].set( me[3] + me[2], me[7] + me[6], me[11] + me[10], me[15] + me[14] ); + var me0 = me[0], me1 = me[1], me2 = me[2], me3 = me[3]; + var me4 = me[4], me5 = me[5], me6 = me[6], me7 = me[7]; + var me8 = me[8], me9 = me[9], me10 = me[10], me11 = me[11]; + var me12 = me[12], me13 = me[13], me14 = me[14], me15 = me[15]; + + planes[ 0 ].set( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ); + planes[ 1 ].set( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ); + planes[ 2 ].set( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ); + planes[ 3 ].set( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ); + planes[ 4 ].set( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ); + planes[ 5 ].set( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ); for ( i = 0; i < 6; i ++ ) {
true
Other
mrdoob
three.js
01852d283b95a56e9c930c3db35fc06f346975f4.json
add some improvements to frustum
build/custom/ThreeWebGL.js
@@ -959,13 +959,17 @@ THREE.Frustum.prototype.setFromMatrix = function ( m ) { var i, plane, planes = this.planes; var me = m.elements; - - planes[ 0 ].set( me[3] - me[0], me[7] - me[4], me[11] - me[8], me[15] - me[12] ); - planes[ 1 ].set( me[3] + me[0], me[7] + me[4], me[11] + me[8], me[15] + me[12] ); - planes[ 2 ].set( me[3] + me[1], me[7] + me[5], me[11] + me[9], me[15] + me[13] ); - planes[ 3 ].set( me[3] - me[1], me[7] - me[5], me[11] - me[9], me[15] - me[13] ); - planes[ 4 ].set( me[3] - me[2], me[7] - me[6], me[11] - me[10], me[15] - me[14] ); - planes[ 5 ].set( me[3] + me[2], me[7] + me[6], me[11] + me[10], me[15] + me[14] ); + var me0 = me[0], me1 = me[1], me2 = me[2], me3 = me[3]; + var me4 = me[4], me5 = me[5], me6 = me[6], me7 = me[7]; + var me8 = me[8], me9 = me[9], me10 = me[10], me11 = me[11]; + var me12 = me[12], me13 = me[13], me14 = me[14], me15 = me[15]; + + planes[ 0 ].set( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ); + planes[ 1 ].set( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ); + planes[ 2 ].set( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ); + planes[ 3 ].set( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ); + planes[ 4 ].set( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ); + planes[ 5 ].set( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ); for ( i = 0; i < 6; i ++ ) {
true
Other
mrdoob
three.js
01852d283b95a56e9c930c3db35fc06f346975f4.json
add some improvements to frustum
src/core/Frustum.js
@@ -23,13 +23,17 @@ THREE.Frustum.prototype.setFromMatrix = function ( m ) { var i, plane, planes = this.planes; var me = m.elements; - - planes[ 0 ].set( me[3] - me[0], me[7] - me[4], me[11] - me[8], me[15] - me[12] ); - planes[ 1 ].set( me[3] + me[0], me[7] + me[4], me[11] + me[8], me[15] + me[12] ); - planes[ 2 ].set( me[3] + me[1], me[7] + me[5], me[11] + me[9], me[15] + me[13] ); - planes[ 3 ].set( me[3] - me[1], me[7] - me[5], me[11] - me[9], me[15] - me[13] ); - planes[ 4 ].set( me[3] - me[2], me[7] - me[6], me[11] - me[10], me[15] - me[14] ); - planes[ 5 ].set( me[3] + me[2], me[7] + me[6], me[11] + me[10], me[15] + me[14] ); + var me0 = me[0], me1 = me[1], me2 = me[2], me3 = me[3]; + var me4 = me[4], me5 = me[5], me6 = me[6], me7 = me[7]; + var me8 = me[8], me9 = me[9], me10 = me[10], me11 = me[11]; + var me12 = me[12], me13 = me[13], me14 = me[14], me15 = me[15]; + + planes[ 0 ].set( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ); + planes[ 1 ].set( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ); + planes[ 2 ].set( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ); + planes[ 3 ].set( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ); + planes[ 4 ].set( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ); + planes[ 5 ].set( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ); for ( i = 0; i < 6; i ++ ) {
true
Other
mrdoob
three.js
01852d283b95a56e9c930c3db35fc06f346975f4.json
add some improvements to frustum
src/core/Matrix4.js
@@ -9,6 +9,7 @@ * @author timknip / http://www.floorplanner.com/ */ + THREE.Matrix4 = function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) { this.elements = new Float32Array(16);
true
Other
mrdoob
three.js
902e31621eaa0e3567942eec57be79529a70850a.json
TrackballCamera first version, rotation only
src/extras/cameras/TrackballCamera.js
@@ -0,0 +1,199 @@ +/** + * @author Eberhard Gräther / http://egraether.com/ + + * parameters = { + * fov: <float>, + * aspect: <float>, + * near: <float>, + * far: <float>, + * target: <THREE.Object3D>, + + * radius: <float>, + + * zoomSpeed: <float>, + * panSpeed: <float>, + + * noZoom: <bool>, + * noPan: <bool>, + + * domElement: <HTMLElement>, + * } + */ + +THREE.TrackballCamera = function ( parameters ) { + + THREE.Camera.call( this, parameters.fov, parameters.aspect, parameters.near, parameters.far, parameters.target ); + + this.radius = ( window.innerWidth + window.innerHeight ) / 4; + + this.zoomSpeed = 1.0; + this.panSpeed = 1.0; + + this.noZoom = false; + this.noPan = false; + + this.domElement = document; + + if ( parameters ) { + + if ( parameters.radius !== undefined ) this.radius = parameters.radius; + + if ( parameters.zoomSpeed !== undefined ) this.zoomSpeed = parameters.zoomSpeed; + if ( parameters.panSpeed !== undefined ) this.panSpeed = parameters.panSpeed; + + if ( parameters.noZoom !== undefined ) this.noZoom = parameters.noZoom; + if ( parameters.noPan !== undefined ) this.noPan = parameters.noPan; + + if ( parameters.domElement !== undefined ) this.domElement = parameters.domElement; + + } + + this.useTarget = true; + + this.mouseDragOn = false; + + this.screen = this.getScreenDimensions(); + + this.start = new THREE.Vector3(); + this.end = new THREE.Vector3(); + + function bind( scope, fn ) { + + return function () { + + fn.apply( scope, arguments ); + + }; + + }; + + this.domElement.addEventListener( 'mousemove', bind( this, this.mousemove ), false ); + this.domElement.addEventListener( 'mousedown', bind( this, this.mousedown ), false ); + this.domElement.addEventListener( 'mouseup', bind( this, this.mouseup ), false ); + + window.addEventListener( 'keydown', bind( this, this.keydown ), false ); + window.addEventListener( 'keyup', bind( this, this.keyup ), false ); + +}; + +THREE.TrackballCamera.prototype = new THREE.Camera(); +THREE.TrackballCamera.prototype.constructor = THREE.TrackballCamera; +THREE.TrackballCamera.prototype.supr = THREE.Camera.prototype; + +THREE.TrackballCamera.prototype.handleEvent = function ( event ) { + + if ( typeof this[ event.type ] == 'function' ) { + + this[ event.type ]( event ); + + } + +}; + +THREE.TrackballCamera.prototype.keydown = function( event ) { + + + +}; + +THREE.TrackballCamera.prototype.keyup = function( event ) { + + + +}; + +THREE.TrackballCamera.prototype.mousedown = function(event) { + + event.preventDefault(); + event.stopPropagation(); + + this.mouseDragOn = true; + + this.start = this.getMouseProjectionOnBall( event.clientX, event.clientY ); + +}; + +THREE.TrackballCamera.prototype.mousemove = function( event ) { + + if ( this.mouseDragOn ) { + + this.end = this.getMouseProjectionOnBall( event.clientX, event.clientY ); + + var angle = Math.acos( this.start.dot( this.end ) / this.start.length() / this.end.length() ); + + if ( angle ) { + + var axis = (new THREE.Vector3()).cross( this.end, this.start ).normalize(), + quaternion = new THREE.Quaternion(); + + quaternion.setFromAxisAngle( axis, angle ); + + quaternion.multiplyVector3( this.position ); + quaternion.multiplyVector3( this.up ); + + } + + } + +}; + +THREE.TrackballCamera.prototype.mouseup = function( event ) { + + event.preventDefault(); + event.stopPropagation(); + + this.mouseDragOn = false; + +}; + +THREE.TrackballCamera.prototype.getScreenDimensions = function() { + + if ( this.domElement != document ) { + + return { + width : this.domElement.offsetWidth, + height : this.domElement.offsetHeight, + offsetLeft : this.domElement.offsetLeft, + offsetTop : this.domElement.offsetTop + }; + + } else { + + return { + width : window.innerWidth, + height : window.innerHeight, + offsetLeft : 0, + offsetTop : 0 + }; + + } + +}; + +THREE.TrackballCamera.prototype.getMouseProjectionOnBall = function( clientX, clientY ) { + + var mouse = new THREE.Vector3( + ( clientX - this.screen.width * 0.5 - this.screen.offsetLeft ) / this.radius, + ( this.screen.height * 0.5 + this.screen.offsetTop - clientY ) / this.radius, + 0.0 + ); + + var length = mouse.length(); + + if ( length > 1.0 ) { + + mouse.divideScalar( length ); + + } else { + + mouse.z = Math.sqrt( 1.0 - length * length ); + + } + + var projection = this.up.clone().setLength( mouse.y ); + projection.addSelf( this.up.clone().crossSelf( this.position ).setLength( mouse.x ) ); + projection.addSelf( this.position.clone().setLength( mouse.z ) ); + + return projection; + +};
false
Other
mrdoob
three.js
d9379fc8a5034efd664c8dfd7e9ce39a98dd85ef.json
condense uvgen as suggested by @AnthorNet in #1811
src/extras/geometries/ExtrudeGeometry.js
@@ -88,7 +88,9 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) { var material = options.material; var extrudeMaterial = options.extrudeMaterial; - var uvGenerator = options.uvGenerator || null; + + // Use default WorldUVGenerator if no UV generators are specified. + var uvgen = options.UVGenerator !== undefined ? options.UVGenerator : THREE.ExtrudeGeometry.WorldUVGenerator; var shapebb = this.shapebb; //shapebb = shape.getBoundingBox(); @@ -525,9 +527,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) { } - // choose UV generator - var uvgen = uvGenerator /* specified */ || - THREE.ExtrudeGeometry.WorldUVGenerator; /* default */ + //// /// Handle Faces
false
Other
mrdoob
three.js
24dcc76bf73d0af5cc25ce2586b44e1301ce0e91.json
fix subdivision example
examples/webgl_geometry_subdivison.html
@@ -406,10 +406,6 @@ group.rotation.x = cube.rotation.x += ( targetXRotation - cube.rotation.x ) * 0.05; group.rotation.y = cube.rotation.y += ( targetYRotation - cube.rotation.y ) * 0.05; - cube.updateMatrixWorld(); - group.updateMatrixWorld(); - - renderer.render( scene, camera ); }
false
Other
mrdoob
three.js
ed7fcf7cb357e4bdb3ea3e886ee3886bb77b8851.json
Update Subdivision model loading
examples/webgl_geometry_subdivison.html
@@ -73,14 +73,7 @@ } - var loader = new THREE.JSONLoader(); - loader.load( 'obj/WaltHeadLo.js', function ( geometry ) { - - THREE.WaltHead = function() { - return geometry; - }; - - } ); + var geometriesParams = [ @@ -96,10 +89,24 @@ font: "helvetiker" }]}, - {type: 'PlaneGeometry', args: [ 200, 200, 4, 4 ] }, - {type: 'WaltHead', args: [ ], scale: 6 } + {type: 'PlaneGeometry', args: [ 200, 200, 4, 4 ] } + ]; + + if (location.protocol !== "file:") { + var loader = new THREE.JSONLoader(); + loader.load( 'obj/WaltHeadLo.js', function ( geometry ) { + + geometriesParams.push({type: 'WaltHead', args: [ ], scale: 6 }); + + THREE.WaltHead = function() { + return geometry; + }; + + } ); + + } var info; @@ -398,7 +405,11 @@ group.rotation.x = cube.rotation.x += ( targetXRotation - cube.rotation.x ) * 0.05; group.rotation.y = cube.rotation.y += ( targetYRotation - cube.rotation.y ) * 0.05; - + + cube.updateMatrixWorld(); + group.updateMatrixWorld(); + + renderer.render( scene, camera ); }
false
Other
mrdoob
three.js
b11e805560f6f10de27ee46c21505ca22fb31f0c.json
add degreesToRadians / radiansToDegrees to Math.
src/math/Math.js
@@ -67,4 +67,20 @@ THREE.Math = { } + degreesToRadians: function( degrees ) { + + return degrees * THREE.Math.__d2r; + + }; + + radiansToDegrees: function( radians ) { + + return radians * THREE.Math.__r2d; + + }; + + }; + +THREE.Math.__d2r = Math.PI / 180; +THREE.Math.__r2d = 180 / Math.PI;
false
Other
mrdoob
three.js
e4c0c6878dc857ad19c8e9fde5f1615aa48e6883.json
Remove .getNormalVector() from Curve.js
src/extras/core/Curve.js
@@ -1,7 +1,7 @@ /** * @author zz85 / http://www.lab4games.net/zz85/blog * Extensible curve object - * + * * Some common of Curve methods * .getPoint(t), getTangent(t) * .getPointAt(u), getTagentAt(u) @@ -110,8 +110,8 @@ THREE.Curve.prototype.getLengths = function ( divisions ) { if ( !divisions ) divisions = (this.__arcLengthDivisions) ? (this.__arcLengthDivisions): 200; - if ( this.cacheArcLengths - && ( this.cacheArcLengths.length == divisions + 1 ) + if ( this.cacheArcLengths + && ( this.cacheArcLengths.length == divisions + 1 ) && !this.needsUpdate) { //console.log( "cached", this.cacheArcLengths ); @@ -231,22 +231,10 @@ THREE.Curve.prototype.getUtoTmapping = function ( u, distance ) { }; - -// In 2D space, there are actually 2 normal vectors, -// and in 3D space, infinte -// TODO this should be depreciated. -THREE.Curve.prototype.getNormalVector = function( t ) { - - var vec = this.getTangent( t ); - - return new THREE.Vector2( -vec.y , vec.x ); - -}; - // Returns a unit vector tangent at t -// In case any sub curve does not implement its tangent / normal finding, -// we get 2 points with a small delta and find a gradient of the 2 points -// which seems to make a reasonable approximation +// In case any sub curve does 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 THREE.Curve.prototype.getTangent = function( t ) { @@ -261,7 +249,7 @@ THREE.Curve.prototype.getTangent = function( t ) { var pt1 = this.getPoint( t1 ); var pt2 = this.getPoint( t2 ); - + var vec = pt2.clone().subSelf(pt1); return vec.normalize(); @@ -715,7 +703,7 @@ THREE.SplineCurve3 = THREE.Curve.create( // v.z = THREE.Curve.Utils.tangentSpline( t, pt0.z, pt1.z, pt2.z, pt3.z ); // return v; - + // } /************************************************************** @@ -741,7 +729,7 @@ THREE.ClosedSplineCurve3 = THREE.Curve.create( intPoint = Math.floor( point ); weight = point - intPoint; - + intPoint += intPoint > 0 ? 0 : ( Math.floor( Math.abs( intPoint ) / points.length ) + 1 ) * points.length; c[ 0 ] = ( intPoint - 1 ) % points.length; c[ 1 ] = ( intPoint ) % points.length; @@ -751,7 +739,7 @@ THREE.ClosedSplineCurve3 = THREE.Curve.create( v.x = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].x, points[ c[ 1 ] ].x, points[ c[ 2 ] ].x, points[ c[ 3 ] ].x, weight ); v.y = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].y, points[ c[ 1 ] ].y, points[ c[ 2 ] ].y, points[ c[ 3 ] ].y, weight ); v.z = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].z, points[ c[ 1 ] ].z, points[ c[ 2 ] ].z, points[ c[ 3 ] ].z, weight ); - + return v; }
false
Other
mrdoob
three.js
49cdafe26e9b38410def197126b0b4bf3c16b957.json
integrate Sphere class into Raycaster
src/core/Raycaster.js
@@ -12,6 +12,8 @@ }; + var sphere = new THREE.Sphere(); + var originCopy = new THREE.Vector3(); var localOriginCopy = new THREE.Vector3(); @@ -76,15 +78,12 @@ } else if ( object instanceof THREE.Mesh ) { - // Checking boundingSphere - - var scaledRadius = object.geometry.boundingSphere.radius * object.matrixWorld.getMaxScaleOnAxis(); - - // Checking distance to raycaster - - var distance = raycaster.ray.distanceToPoint( object.matrixWorld.getPosition() ); - - if ( distance > scaledRadius) { + // Checking boundingSphere distance to ray + sphere.set( + object.matrixWorld.getPosition(), + object.geometry.boundingSphere.radius* object.matrixWorld.getMaxScaleOnAxis() ); + + if ( ! raycaster.ray.isIntersectionSphere( sphere ) ) { return intersects;
false
Other
mrdoob
three.js
d782e3a17e3c0bff7151e5270aefd8ea1151bbfd.json
adopt Box3 in BufferGeometry.
src/core/BufferGeometry.js
@@ -71,12 +71,7 @@ THREE.BufferGeometry.prototype = { if ( ! this.boundingBox ) { - this.boundingBox = { - - min: new THREE.Vector3( Infinity, Infinity, Infinity ), - max: new THREE.Vector3( -Infinity, -Infinity, -Infinity ) - - }; + this.boundingBox = new THREE.Box3(); } @@ -140,7 +135,9 @@ THREE.BufferGeometry.prototype = { computeBoundingSphere: function () { - if ( ! this.boundingSphere ) this.boundingSphere = { radius: 0 }; + if ( ! this.boundingSphere ) { + this.boundingSphere = new THREE.Sphere(); + } var positions = this.attributes[ "position" ].array;
false
Other
mrdoob
three.js
b83d79b7592fd79426cf72b49dc7a69e7d09cd9a.json
remove GC from Ray.distanceToPoint
src/math/Ray.js
@@ -57,10 +57,10 @@ THREE.Ray.prototype = { distanceToPoint: function ( point ) { - // NOTE: this creates a THREE.VEctor3 internally via closestPointToPoint - // that is never returned, can be further GC optimized + var directionDistance = THREE.Ray.__v1.sub( point, this.origin ).dot( this.direction ); + THREE.Ray.__v1.copy( this.direction ).multiplyScalar( directionDistance ).addSelf( this.origin ); - return this.closestPointToPoint( point ).distanceTo( point ); + return THREE.Ray.__v1.distanceTo( point ); },
false
Other
mrdoob
three.js
135a3d35d886cf7cd16369e9644105bfb90e3585.json
add some docs for extras/core
doc/api/extras/core/Curve.rst
@@ -0,0 +1,7 @@ +Curve - Extensible curve object +------------------------ + +.. js:class:: Curve() + + Extensible curve object + \ No newline at end of file
true
Other
mrdoob
three.js
135a3d35d886cf7cd16369e9644105bfb90e3585.json
add some docs for extras/core
doc/api/extras/core/CurvePath.rst
@@ -0,0 +1,7 @@ +CurvePath - Path with connected curves +------------------------ + +.. js:class:: CurvePath() + + A Path made with connected set of curves + \ No newline at end of file
true
Other
mrdoob
three.js
135a3d35d886cf7cd16369e9644105bfb90e3585.json
add some docs for extras/core
doc/api/extras/core/Path.rst
@@ -0,0 +1,7 @@ +Path - A CurvePath with a Drawing API +------------------------ + +.. js:class:: Path() + + A CurvePath with convenience Drawing methods + \ No newline at end of file
true
Other
mrdoob
three.js
135a3d35d886cf7cd16369e9644105bfb90e3585.json
add some docs for extras/core
doc/api/extras/core/Shape.rst
@@ -0,0 +1,7 @@ +Shape - A closed 2d path with holes +------------------------ + +.. js:class:: Shape() + + A closed 2d Path with holes + \ No newline at end of file
true
Other
mrdoob
three.js
135a3d35d886cf7cd16369e9644105bfb90e3585.json
add some docs for extras/core
doc/api/extras/core/TextPath.rst
@@ -0,0 +1,7 @@ +TextPath - Class for turning Text to Shapes +------------------------ + +.. js:class:: TextPath() + + Class for turning Text to Shapes + \ No newline at end of file
true
Other
mrdoob
three.js
135a3d35d886cf7cd16369e9644105bfb90e3585.json
add some docs for extras/core
doc/api/extras/core/index.rst
@@ -0,0 +1,9 @@ +Core Classes +============ + +.. toctree:: + Curve + CurvePath + Path + Shape + TextPath \ No newline at end of file
true
Other
mrdoob
three.js
135a3d35d886cf7cd16369e9644105bfb90e3585.json
add some docs for extras/core
src/extras/core/CurvePath.js
@@ -12,7 +12,8 @@ THREE.CurvePath = function () { this.curves = []; this.bends = []; - + + this.autoClose = false; // Automatically closes the path }; THREE.CurvePath.prototype = new THREE.Curve(); @@ -25,13 +26,22 @@ THREE.CurvePath.prototype.add = function ( curve ) { }; THREE.CurvePath.prototype.checkConnection = function() { - + // TODO + // If the ending of curve is not connected to the starting + // or the next curve, then, this is not a real path }; -// Add a line curve if start and end of lines are not connected - THREE.CurvePath.prototype.closePath = function() { - + // TODO Test + // and verify for vector3 (needs to implement equals) + // Add a line curve if start and end of lines are not connected + var startPoint = this.curves[0].getPoint(0); + var endPoint = this.curves[this.curves.length-1].getPoint(1); + + if (!startPoint.equals(endPoint)) { + this.curves.push( new THREE.LineCurve(endPoint, startPoint) ); + } + }; // To get accurate point with reference to
true
Other
mrdoob
three.js
ff23c44179a82db4e95e3ca139479a43fda94497.json
fix Path.js again
src/extras/core/Path.js
@@ -330,7 +330,6 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) { var deltaAngle = aEndAngle - aStartAngle; var angle; var tdivisions = divisions * 2; - var t; for ( j = 1; j <= tdivisions; j ++ ) { @@ -558,21 +557,20 @@ THREE.Path.prototype.toShapes = function() { if ( subPaths.length == 0 ) return []; + var tmpPath, tmpShape, shapes = []; + var holesFirst = !THREE.Shape.Utils.isClockWise( subPaths[ 0 ].getPoints() ); + // console.log("Holes first", holesFirst); + if ( subPaths.length == 1) { tmpPath = subPaths[0]; tmpShape = new THREE.Shape(); tmpShape.actions = tmpPath.actions; tmpShape.curves = tmpPath.curves; - return tmpShape; + shapes.push( tmpShape ); + return shapes; }; - var tmpPath, tmpShape, shapes = []; - - // console.log("Holes first", holesFirst); - - - if ( holesFirst ) { tmpShape = new THREE.Shape();
false
Other
mrdoob
three.js
228ddebb885247f2ae7755869e63e534370776c9.json
update Spark.js and Tween.js libraries
examples/js/Sparks.js
@@ -17,7 +17,6 @@ var SPARKS = {}; * Creates and Manages Particles *********************************/ - SPARKS.Emitter = function (counter) { this._counter = counter ? counter : new SPARKS.SteadyCounter(10); // provides number of particles to produce @@ -41,6 +40,7 @@ SPARKS.Emitter.prototype = { _timer: null, _lastTime: null, _timerStep: 10, + _velocityVerlet: true, // run its built in timer / stepping start: function() { @@ -66,12 +66,29 @@ SPARKS.Emitter.prototype = { var time = Date.now(); var elapsed = time - emitter._lastTime; - while(elapsed >= emitter._TIMESTEP) { - emitter.update(emitter._TIMESTEP / 1000); - elapsed -= emitter._TIMESTEP; + if (!this._velocityVerlet) { + // if elapsed is way higher than time step, (usually after switching tabs, or excution cached in ff) + // we will drop cycles. perhaps set to a limit of 10 or something? + var maxBlock = emitter._TIMESTEP * 20; + + if (elapsed >= maxBlock) { + //console.log('warning: sparks.js is fast fowarding engine, skipping steps', elapsed / emitter._TIMESTEP); + //emitter.update( (elapsed - maxBlock) / 1000); + elapsed = maxBlock; + } + + while(elapsed >= emitter._TIMESTEP) { + emitter.update(emitter._TIMESTEP / 1000); + elapsed -= emitter._TIMESTEP; + } + emitter._lastTime = time - elapsed; + + } else { + emitter.update(elapsed/1000); + emitter._lastTime = time; } - emitter._lastTime = time - elapsed; + if (emitter._isRunning) setTimeout(emitter.step, emitter._timerStep, emitter); @@ -129,6 +146,8 @@ SPARKS.Emitter.prototype = { } } + this.dispatchEvent("loopUpdated"); + }, createParticle: function() { @@ -154,6 +173,21 @@ SPARKS.Emitter.prototype = { addAction: function (action) { this._actions.push(action); }, + + removeInitializer: function (initializer) { + var index = this._initializers.indexOf(initializer); + if (index > -1) { + this._initializers.splice( index, 1 ); + } + }, + + removeAction: function (action) { + var index = this._actions.indexOf(action); + if (index > -1) { + this._actions.splice( index, 1 ); + } + //console.log('removeAction', index, this._actions); + }, addCallback: function(name, callback) { this.callbacks[name] = callback; @@ -171,18 +205,63 @@ SPARKS.Emitter.prototype = { }; +/* + * Constant Names for + * Events called by emitter.dispatchEvent() + * + */ +SPARKS.EVENT_PARTICLE_CREATED = "created" +SPARKS.EVENT_PARTICLE_UPDATED = "updated" +SPARKS.EVENT_PARTICLE_DEAD = "dead"; +SPARKS.EVENT_LOOP_UPDATED = "loopUpdated"; + + + +/* + * Steady Counter attempts to produces a particle rate steadily + * + */ + // Number of particles per seconds SPARKS.SteadyCounter = function(rate) { this.rate = rate; + // we use a shortfall counter to make up for slow emitters + this.leftover = 0; + }; SPARKS.SteadyCounter.prototype.updateEmitter = function(emitter, time) { - - return Math.floor(time * this.rate); + + var targetRelease = time * this.rate + this.leftover; + var actualRelease = Math.floor(targetRelease); + + this.leftover = targetRelease - actualRelease; + + return actualRelease; }; +/* + * Shot Counter produces specified particles + * on a single impluse or burst + */ + +SPARKS.ShotCounter = function(particles) { + this.particles = particles; + this.used = false; +}; + +SPARKS.ShotCounter.prototype.updateEmitter = function(emitter, time) { + + if (this.used) { + return 0; + } else { + this.used = true; + } + + return this.particles; +}; /******************************** @@ -220,6 +299,7 @@ SPARKS.Particle = function() { this.position = SPARKS.VectorPool.get().set(0,0,0); //new THREE.Vector3( 0, 0, 0 ); this.velocity = SPARKS.VectorPool.get().set(0,0,0); //new THREE.Vector3( 0, 0, 0 ); + this._oldvelocity = SPARKS.VectorPool.get().set(0,0,0); // rotation vec3 // angVelocity vec3 // faceAxis vec3 @@ -276,17 +356,61 @@ SPARKS.Move = function() { }; SPARKS.Move.prototype.update = function(emitter, particle, time) { - + // attempt verlet velocity updating. var p = particle.position; - var v = particle.velocity; + var v = particle.velocity; + var old = particle._oldvelocity; + + if (this._velocityVerlet) { + p.x += (v.x + old.x) * 0.5 * time; + p.y += (v.y + old.y) * 0.5 * time; + p.z += (v.z + old.z) * 0.5 * time; + } else { + p.x += v.x * time; + p.y += v.y * time; + p.z += v.z * time; + } + + // OldVel = Vel; + // Vel = Vel + Accel * dt; + // Pos = Pos + (vel + Vel + Accel * dt) * 0.5 * dt; + + + +}; + +/* Marks particles found in specified zone dead */ +SPARKS.DeathZone = function(zone) { + this.zone = zone; +}; + +SPARKS.DeathZone.prototype.update = function(emitter, particle, time) { - p.x += v.x * time; - p.y += v.y * time; - p.z += v.z * time; + if (this.zone.contains(particle.position)) { + particle.isDead = true; + } }; +/* + * SPARKS.ActionZone applies an action when particle is found in zone + */ +SPARKS.ActionZone = function(action, zone) { + this.action = action; + this.zone = zone; +}; + +SPARKS.ActionZone.prototype.update = function(emitter, particle, time) { + + if (this.zone.contains(particle.position)) { + this.action.update( emitter, particle, time ); + } + +}; +/* + * Accelerate action affects velocity in specified 3d direction + */ SPARKS.Accelerate = function(x,y,z) { if (x instanceof THREE.Vector3) { @@ -303,12 +427,63 @@ SPARKS.Accelerate.prototype.update = function(emitter, particle, time) { var v = particle.velocity; + particle._oldvelocity.set(v.x, v.y, v.z); + v.x += acc.x * time; v.y += acc.y * time; v.z += acc.z * time; }; +/* + * Accelerate Factor accelerate based on a factor of particle's velocity. + */ +SPARKS.AccelerateFactor = function(factor) { + this.factor = factor; +}; + +SPARKS.AccelerateFactor.prototype.update = function(emitter, particle, time) { + var factor = this.factor; + + var v = particle.velocity; + var len = v.length(); + var adjFactor; + if (len>0) { + + adjFactor = factor * time / len; + adjFactor += 1; + + v.multiplyScalar(adjFactor); + // v.x *= adjFactor; + // v.y *= adjFactor; + // v.z *= adjFactor; + } + +}; + +/* +AccelerateNormal + * AccelerateVelocity affects velocity based on its velocity direction + */ +SPARKS.AccelerateVelocity = function(factor) { + + this.factor = factor; + +}; + +SPARKS.AccelerateVelocity.prototype.update = function(emitter, particle, time) { + var factor = this.factor; + + var v = particle.velocity; + + + v.z += - v.x * factor; + v.y += v.z * factor; + v.x += v.y * factor; + +}; + + /* Set the max ammount of x,y,z drift movements in a second */ SPARKS.RandomDrift = function(x,y,z) { if (x instanceof THREE.Vector3) { @@ -373,8 +548,6 @@ SPARKS.LineZone.prototype.getLocation = function() { }; // Basically a RectangleZone - - SPARKS.ParallelogramZone = function(corner, side1, side2) { this.corner = corner; this.side1 = side1; @@ -390,6 +563,65 @@ SPARKS.ParallelogramZone.prototype.getLocation = function() { }; +SPARKS.CubeZone = function(position, x, y, z) { + this.position = position; + this.x = x; + this.y = y; + this.z = z; +}; + +SPARKS.CubeZone.prototype.getLocation = function() { + //TODO use pool? + + var location = this.position.clone(); + location.x += Math.random() * this.x; + location.y += Math.random() * this.y; + location.z += Math.random() * this.z; + + return location; + +}; + + +SPARKS.CubeZone.prototype.contains = function(position) { + + var startX = this.position.x; + var startY = this.position.y; + var startZ = this.position.z; + var x = this.x; // width + var y = this.y; // depth + var z = this.z; // height + + if (x<0) { + startX += x; + x = Math.abs(x); + } + + if (y<0) { + startY += y; + y = Math.abs(y); + } + + if (z<0) { + startZ += z; + z = Math.abs(z); + } + + var diffX = position.x - startX; + var diffY = position.y - startY; + var diffZ = position.z - startZ; + + if ( (diffX > 0) && (diffX < x) && + (diffY > 0) && (diffY < y) && + (diffZ > 0) && (diffZ < z) ) { + return true; + } + + return false; + +}; + + /** * The constructor creates a DiscZone 3D zone. @@ -513,7 +745,7 @@ SPARKS.Target = function(target, callback) { this.callback = callback; }; -SPARKS.Target.prototype.initialize = function( emitter, particle) { +SPARKS.Target.prototype.initialize = function( emitter, particle ) { if (this.callback) { particle.target = this.callback(); @@ -597,4 +829,4 @@ SPARKS.Utils = { } } -}; +}; \ No newline at end of file
true
Other
mrdoob
three.js
228ddebb885247f2ae7755869e63e534370776c9.json
update Spark.js and Tween.js libraries
examples/js/Tween.js
@@ -1,12 +1,13 @@ -// tween.js r2 - http://github.com/sole/tween.js -var TWEEN=TWEEN||function(){var a,e,c,d,f=[];return{start:function(g){c=setInterval(this.update,1E3/(g||60))},stop:function(){clearInterval(c)},add:function(g){f.push(g)},getAll:function(){return f},removeAll:function(){f=[]},remove:function(g){a=f.indexOf(g);a!==-1&&f.splice(a,1)},update:function(){a=0;e=f.length;for(d=(new Date).getTime();a<e;)if(f[a].update(d))a++;else{f.splice(a,1);e--}}}}(); -TWEEN.Tween=function(a){var e={},c={},d={},f=1E3,g=0,j=null,n=TWEEN.Easing.Linear.EaseNone,k=null,l=null,m=null;this.to=function(b,h){if(h!==null)f=h;for(var i in b)if(a[i]!==null)d[i]=b[i];return this};this.start=function(){TWEEN.add(this);j=(new Date).getTime()+g;for(var b in d)if(a[b]!==null){e[b]=a[b];c[b]=d[b]-a[b]}return this};this.stop=function(){TWEEN.remove(this);return this};this.delay=function(b){g=b;return this};this.easing=function(b){n=b;return this};this.chain=function(b){k=b};this.onUpdate= -function(b){l=b;return this};this.onComplete=function(b){m=b;return this};this.update=function(b){var h,i;if(b<j)return true;b=(b-j)/f;b=b>1?1:b;i=n(b);for(h in c)a[h]=e[h]+c[h]*i;l!==null&&l.call(a,i);if(b==1){m!==null&&m.call(a);k!==null&&k.start();return false}return true}};TWEEN.Easing={Linear:{},Quadratic:{},Cubic:{},Quartic:{},Quintic:{},Sinusoidal:{},Exponential:{},Circular:{},Elastic:{},Back:{},Bounce:{}};TWEEN.Easing.Linear.EaseNone=function(a){return a}; +// tween.js r5 - http://github.com/sole/tween.js +var TWEEN=TWEEN||function(){var a,e,c=60,b=false,h=[];return{setFPS:function(f){c=f||60},start:function(f){arguments.length!=0&&this.setFPS(f);e=setInterval(this.update,1E3/c)},stop:function(){clearInterval(e)},setAutostart:function(f){(b=f)&&!e&&this.start()},add:function(f){h.push(f);b&&!e&&this.start()},getAll:function(){return h},removeAll:function(){h=[]},remove:function(f){a=h.indexOf(f);a!==-1&&h.splice(a,1)},update:function(f){a=0;num_tweens=h.length;for(f=f||Date.now();a<num_tweens;)if(h[a].update(f))a++; +else{h.splice(a,1);num_tweens--}num_tweens==0&&b==true&&this.stop()}}}(); +TWEEN.Tween=function(a){var e={},c={},b={},h=1E3,f=0,j=null,n=TWEEN.Easing.Linear.EaseNone,k=null,l=null,m=null;this.to=function(d,g){if(g!==null)h=g;for(var i in d)if(a[i]!==null)b[i]=d[i];return this};this.start=function(d){TWEEN.add(this);j=d?d+f:Date.now()+f;for(var g in b)if(a[g]!==null){e[g]=a[g];c[g]=b[g]-a[g]}return this};this.stop=function(){TWEEN.remove(this);return this};this.delay=function(d){f=d;return this};this.easing=function(d){n=d;return this};this.chain=function(d){k=d};this.onUpdate= +function(d){l=d;return this};this.onComplete=function(d){m=d;return this};this.update=function(d){var g,i;if(d<j)return true;d=(d-j)/h;d=d>1?1:d;i=n(d);for(g in c)a[g]=e[g]+c[g]*i;l!==null&&l.call(a,i);if(d==1){m!==null&&m.call(a);k!==null&&k.start();return false}return true}};TWEEN.Easing={Linear:{},Quadratic:{},Cubic:{},Quartic:{},Quintic:{},Sinusoidal:{},Exponential:{},Circular:{},Elastic:{},Back:{},Bounce:{}};TWEEN.Easing.Linear.EaseNone=function(a){return a}; TWEEN.Easing.Quadratic.EaseIn=function(a){return a*a};TWEEN.Easing.Quadratic.EaseOut=function(a){return-a*(a-2)};TWEEN.Easing.Quadratic.EaseInOut=function(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)};TWEEN.Easing.Cubic.EaseIn=function(a){return a*a*a};TWEEN.Easing.Cubic.EaseOut=function(a){return--a*a*a+1};TWEEN.Easing.Cubic.EaseInOut=function(a){if((a*=2)<1)return 0.5*a*a*a;return 0.5*((a-=2)*a*a+2)};TWEEN.Easing.Quartic.EaseIn=function(a){return a*a*a*a}; TWEEN.Easing.Quartic.EaseOut=function(a){return-(--a*a*a*a-1)};TWEEN.Easing.Quartic.EaseInOut=function(a){if((a*=2)<1)return 0.5*a*a*a*a;return-0.5*((a-=2)*a*a*a-2)};TWEEN.Easing.Quintic.EaseIn=function(a){return a*a*a*a*a};TWEEN.Easing.Quintic.EaseOut=function(a){return(a-=1)*a*a*a*a+1};TWEEN.Easing.Quintic.EaseInOut=function(a){if((a*=2)<1)return 0.5*a*a*a*a*a;return 0.5*((a-=2)*a*a*a*a+2)};TWEEN.Easing.Sinusoidal.EaseIn=function(a){return-Math.cos(a*Math.PI/2)+1}; TWEEN.Easing.Sinusoidal.EaseOut=function(a){return Math.sin(a*Math.PI/2)};TWEEN.Easing.Sinusoidal.EaseInOut=function(a){return-0.5*(Math.cos(Math.PI*a)-1)};TWEEN.Easing.Exponential.EaseIn=function(a){return a==0?0:Math.pow(2,10*(a-1))};TWEEN.Easing.Exponential.EaseOut=function(a){return a==1?1:-Math.pow(2,-10*a)+1};TWEEN.Easing.Exponential.EaseInOut=function(a){if(a==0)return 0;if(a==1)return 1;if((a*=2)<1)return 0.5*Math.pow(2,10*(a-1));return 0.5*(-Math.pow(2,-10*(a-1))+2)}; -TWEEN.Easing.Circular.EaseIn=function(a){return-(Math.sqrt(1-a*a)-1)};TWEEN.Easing.Circular.EaseOut=function(a){return Math.sqrt(1- --a*a)};TWEEN.Easing.Circular.EaseInOut=function(a){if((a/=0.5)<1)return-0.5*(Math.sqrt(1-a*a)-1);return 0.5*(Math.sqrt(1-(a-=2)*a)+1)};TWEEN.Easing.Elastic.EaseIn=function(a){var e,c=0.1,d=0.4;if(a==0)return 0;if(a==1)return 1;d||(d=0.3);if(!c||c<1){c=1;e=d/4}else e=d/(2*Math.PI)*Math.asin(1/c);return-(c*Math.pow(2,10*(a-=1))*Math.sin((a-e)*2*Math.PI/d))}; -TWEEN.Easing.Elastic.EaseOut=function(a){var e,c=0.1,d=0.4;if(a==0)return 0;if(a==1)return 1;d||(d=0.3);if(!c||c<1){c=1;e=d/4}else e=d/(2*Math.PI)*Math.asin(1/c);return c*Math.pow(2,-10*a)*Math.sin((a-e)*2*Math.PI/d)+1}; -TWEEN.Easing.Elastic.EaseInOut=function(a){var e,c=0.1,d=0.4;if(a==0)return 0;if(a==1)return 1;d||(d=0.3);if(!c||c<1){c=1;e=d/4}else e=d/(2*Math.PI)*Math.asin(1/c);if((a*=2)<1)return-0.5*c*Math.pow(2,10*(a-=1))*Math.sin((a-e)*2*Math.PI/d);return c*Math.pow(2,-10*(a-=1))*Math.sin((a-e)*2*Math.PI/d)*0.5+1};TWEEN.Easing.Back.EaseIn=function(a){return a*a*(2.70158*a-1.70158)};TWEEN.Easing.Back.EaseOut=function(a){return(a-=1)*a*(2.70158*a+1.70158)+1}; +TWEEN.Easing.Circular.EaseIn=function(a){return-(Math.sqrt(1-a*a)-1)};TWEEN.Easing.Circular.EaseOut=function(a){return Math.sqrt(1- --a*a)};TWEEN.Easing.Circular.EaseInOut=function(a){if((a/=0.5)<1)return-0.5*(Math.sqrt(1-a*a)-1);return 0.5*(Math.sqrt(1-(a-=2)*a)+1)};TWEEN.Easing.Elastic.EaseIn=function(a){var e,c=0.1,b=0.4;if(a==0)return 0;if(a==1)return 1;b||(b=0.3);if(!c||c<1){c=1;e=b/4}else e=b/(2*Math.PI)*Math.asin(1/c);return-(c*Math.pow(2,10*(a-=1))*Math.sin((a-e)*2*Math.PI/b))}; +TWEEN.Easing.Elastic.EaseOut=function(a){var e,c=0.1,b=0.4;if(a==0)return 0;if(a==1)return 1;b||(b=0.3);if(!c||c<1){c=1;e=b/4}else e=b/(2*Math.PI)*Math.asin(1/c);return c*Math.pow(2,-10*a)*Math.sin((a-e)*2*Math.PI/b)+1}; +TWEEN.Easing.Elastic.EaseInOut=function(a){var e,c=0.1,b=0.4;if(a==0)return 0;if(a==1)return 1;b||(b=0.3);if(!c||c<1){c=1;e=b/4}else e=b/(2*Math.PI)*Math.asin(1/c);if((a*=2)<1)return-0.5*c*Math.pow(2,10*(a-=1))*Math.sin((a-e)*2*Math.PI/b);return c*Math.pow(2,-10*(a-=1))*Math.sin((a-e)*2*Math.PI/b)*0.5+1};TWEEN.Easing.Back.EaseIn=function(a){return a*a*(2.70158*a-1.70158)};TWEEN.Easing.Back.EaseOut=function(a){return(a-=1)*a*(2.70158*a+1.70158)+1}; TWEEN.Easing.Back.EaseInOut=function(a){if((a*=2)<1)return 0.5*a*a*(3.5949095*a-2.5949095);return 0.5*((a-=2)*a*(3.5949095*a+2.5949095)+2)};TWEEN.Easing.Bounce.EaseIn=function(a){return 1-TWEEN.Easing.Bounce.EaseOut(1-a)};TWEEN.Easing.Bounce.EaseOut=function(a){return(a/=1)<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+0.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+0.9375:7.5625*(a-=2.625/2.75)*a+0.984375}; -TWEEN.Easing.Bounce.EaseInOut=function(a){if(a<0.5)return TWEEN.Easing.Bounce.EaseIn(a*2)*0.5;return TWEEN.Easing.Bounce.EaseOut(a*2-1)*0.5+0.5}; +TWEEN.Easing.Bounce.EaseInOut=function(a){if(a<0.5)return TWEEN.Easing.Bounce.EaseIn(a*2)*0.5;return TWEEN.Easing.Bounce.EaseOut(a*2-1)*0.5+0.5}; \ No newline at end of file
true
Other
mrdoob
three.js
8bebe3e184bef7af700ef76a77d1d2dd1e71f85f.json
Fix single subpath bug
src/extras/core/Path.js
@@ -42,7 +42,9 @@ THREE.Path.prototype.fromPoints = function ( vectors ) { this.moveTo( vectors[ 0 ].x, vectors[ 0 ].y ); - for ( var v = 1, vlen = vectors.length; v < vlen; v ++ ) { + var v, vlen = vectors.length; + + for ( v = 1; v < vlen; v++ ) { this.lineTo( vectors[ v ].x, vectors[ v ].y ); @@ -121,9 +123,7 @@ THREE.Path.prototype.splineThru = function( pts /*Array of Vector*/ ) { var x0 = lastargs[ lastargs.length - 2 ]; var y0 = lastargs[ lastargs.length - 1 ]; - - // --- - +//--- var npts = [ new THREE.Vector2( x0, y0 ) ]; Array.prototype.push.apply( npts, pts ); @@ -155,7 +155,7 @@ THREE.Path.prototype.arc = function ( aX, aY, aRadius, THREE.Path.prototype.getSpacedPoints = function ( divisions, closedPath ) { - if ( ! divisions ) divisions = 40; + if ( !divisions ) divisions = 40; var points = []; @@ -332,12 +332,13 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) { var deltaAngle = aEndAngle - aStartAngle; var angle; var tdivisions = divisions * 2; + var t; for ( j = 1; j <= tdivisions; j ++ ) { t = j / tdivisions; - if ( ! aClockwise ) { + if ( !aClockwise ) { t = 1 - t; @@ -506,17 +507,6 @@ THREE.Path.prototype.debug = function( canvas ) { var p, points = this.getPoints(); - //var theta = -90 /180 * Math.PI; - //var p, points = this.transform( 0.866, - 0.866,0, 0.500 , 0.50,-50 ); - - //0.866, - 0.866,0, 0.500 , 0.50,-50 - - // Math.cos(theta),Math.sin(theta),100, - // Math.cos(theta),-Math.sin(theta),-50 - - // translate, scale, rotation - - for ( i = 0, il = points.length; i < il; i ++ ) { p = points[ i ]; @@ -566,15 +556,24 @@ THREE.Path.prototype.toShapes = function() { } - //console.log(subPaths); + // console.log(subPaths); if ( subPaths.length == 0 ) return []; var holesFirst = !THREE.Shape.Utils.isClockWise( subPaths[ 0 ].getPoints() ); + if ( subPaths.length == 1) { + tmpPath = subPaths[0]; + tmpShape = new THREE.Shape(); + tmpShape.actions = tmpPath.actions; + tmpShape.curves = tmpPath.curves; + return tmpShape; + }; var tmpPath, tmpShape, shapes = []; - //console.log("Holes first", holesFirst); + // console.log("Holes first", holesFirst); + + if ( holesFirst ) {
false
Other
mrdoob
three.js
b3f1af8364aa73242c9edc7bf2570dbce2ff5446.json
remove local used in debugging
utils/exporters/obj/convert_obj_three.py
@@ -557,8 +557,7 @@ def parse_obj(fname): if vertex['n'] < 0: vertex['n'] += normlen normal_index.append(vertex['n']) - - d = { + faces.append({ 'vertex':vertex_index, 'uv':uv_index, 'normal':normal_index, @@ -567,8 +566,7 @@ def parse_obj(fname): 'group':group, 'object':object, 'smooth':smooth, - } - faces.append(d) + }) # Group if chunks[0] == "g" and len(chunks) == 2:
false
Other
mrdoob
three.js
f58c4167cdb51cebc6d74e9f41d46b8d6c638bda.json
allow negative vertex indices for obj model format
utils/exporters/obj/convert_obj_three.py
@@ -536,16 +536,29 @@ def parse_obj(fname): uv_index = [] normal_index = [] + + # Precompute vert / normal / uv lists + # for negative index lookup + vertlen = len(vertices) + 1 + normlen = len(normals) + 1 + uvlen = len(uvs) + 1 + for v in chunks[1:]: vertex = parse_vertex(v) if vertex['v']: + if vertex['v'] < 0: + vertex['v'] += vertlen vertex_index.append(vertex['v']) if vertex['t']: + if vertex['t'] < 0: + vertex['t'] += uvlen uv_index.append(vertex['t']) if vertex['n']: + if vertex['n'] < 0: + vertex['n'] += normlen normal_index.append(vertex['n']) - faces.append({ + d = { 'vertex':vertex_index, 'uv':uv_index, 'normal':normal_index, @@ -554,7 +567,8 @@ def parse_obj(fname): 'group':group, 'object':object, 'smooth':smooth, - }) + } + faces.append(d) # Group if chunks[0] == "g" and len(chunks) == 2:
false
Other
mrdoob
three.js
e1ad0a648186dc94280877534ae4925f7cfac382.json
fix broken segments in TubeGeometry
src/extras/geometries/TubeGeometry.js
@@ -42,7 +42,7 @@ THREE.TubeGeometry = function(radius, segments, segmentsRadius, path, debug) { this.grid[i] = new Array(this.segmentsRadius); - u = i / this.segments; + u = i / ( this.segments - 1 ); var pos = this.path.getPointAt(u); tang = this.path.getTangentAt(u); @@ -69,35 +69,35 @@ THREE.TubeGeometry = function(radius, segments, segmentsRadius, path, debug) { oldB = binormal; if (oldB.length()==0) { - - // When binormal is a zero vector, we could brute force another vector ? - // oldB.set( 1, 0, 0 ); - // if (normal.cross(oldB, tang).normalize().length()==0) { - // oldB.set( 0, 1, 0 ); - // if (normal.cross(oldB, tang).normalize().length()==0) { - // oldB.set( 0, 0, 1 ); - // } - // } - - // Method 4 - Sets binormal direction in the smallest tangent xyz component - var smallest = Number.MAX_VALUE; - var x, y, z; - var tx = Math.abs(tang.x); - var ty = Math.abs(tang.y); - var tz = Math.abs(tang.z); - - if (tx <= smallest) { - smallest = tx; - oldB.set(1,0,0); - } - - if (ty <= smallest) { - smallest = ty; - oldB.set(0,1,0); - } - - if (tz <= smallest) { - oldB.set(0,0,1); + // When binormal is a zero vector, we could brute force another vector ? + // oldB.set( 1, 0, 0 ); + // if (normal.cross(oldB, tang).normalize().length()==0) { + // oldB.set( 0, 1, 0 ); + // if (normal.cross(oldB, tang).normalize().length()==0) { + // oldB.set( 0, 0, 1 ); + // } + // } + + // Method 4 - Sets binormal direction in the smallest tangent xyz component + var smallest = Number.MAX_VALUE; + var x, y, z; + var tx = Math.abs(tang.x); + var ty = Math.abs(tang.y); + var tz = Math.abs(tang.z); + + if (tx <= smallest) { + smallest = tx; + oldB.set(1,0,0); + } + + if (ty <= smallest) { + smallest = ty; + oldB.set(0,1,0); + } + + if (tz <= smallest) { + oldB.set(0,0,1); + } } } @@ -131,7 +131,7 @@ THREE.TubeGeometry = function(radius, segments, segmentsRadius, path, debug) { } } - for (var i = 0; i < this.segments; ++i) { // segments -1 for non-closed loops, segment - 0 for closed ? + for (var i = 0; i < this.segments -1; ++i) { for (var j = 0; j < this.segmentsRadius; ++j) {
false
Other
mrdoob
three.js
01d8572207d3a624b747652e717ef4db0431bc3e.json
fix subdivision example
examples/webgl_geometry_subdivison.html
@@ -406,10 +406,6 @@ group.rotation.x = cube.rotation.x += ( targetXRotation - cube.rotation.x ) * 0.05; group.rotation.y = cube.rotation.y += ( targetYRotation - cube.rotation.y ) * 0.05; - cube.updateMatrixWorld(); - group.updateMatrixWorld(); - - renderer.render( scene, camera ); }
false
Other
mrdoob
three.js
ed3cb6613cd63e9c5a5a33235d8e4d5a6e492a9d.json
Update Subdivision model loading
examples/webgl_geometry_subdivison.html
@@ -73,14 +73,7 @@ } - var loader = new THREE.JSONLoader(); - loader.load( 'obj/WaltHeadLo.js', function ( geometry ) { - - THREE.WaltHead = function() { - return geometry; - }; - - } ); + var geometriesParams = [ @@ -96,10 +89,24 @@ font: "helvetiker" }]}, - {type: 'PlaneGeometry', args: [ 200, 200, 4, 4 ] }, - {type: 'WaltHead', args: [ ], scale: 6 } + {type: 'PlaneGeometry', args: [ 200, 200, 4, 4 ] } + ]; + + if (location.protocol !== "file:") { + var loader = new THREE.JSONLoader(); + loader.load( 'obj/WaltHeadLo.js', function ( geometry ) { + + geometriesParams.push({type: 'WaltHead', args: [ ], scale: 6 }); + + THREE.WaltHead = function() { + return geometry; + }; + + } ); + + } var info; @@ -398,7 +405,11 @@ group.rotation.x = cube.rotation.x += ( targetXRotation - cube.rotation.x ) * 0.05; group.rotation.y = cube.rotation.y += ( targetYRotation - cube.rotation.y ) * 0.05; - + + cube.updateMatrixWorld(); + group.updateMatrixWorld(); + + renderer.render( scene, camera ); }
false
Other
mrdoob
three.js
6e6f2453a11ea43c61a7e75207e37288dd816cec.json
change voxelpainter to use THREE.CombinedCamera
examples/webgl_interactive_voxelpainter.html
@@ -31,7 +31,7 @@ if ( ! Detector.webgl ) Detector.addGetWebGLMessage(); var container, stats; - var camera, cameraTarget, cameraPerspective, cameraOrtho, scene, renderer; + var camera, cameraTarget, scene, renderer; var projector, plane, cube; var mouse2D, mouse3D, ray, rollOveredFace, isShiftDown = false, @@ -61,16 +61,9 @@ info.innerHTML = '<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - voxel painter - webgl<br /><strong>click</strong>: add voxel, <strong>control + click</strong>: remove voxel, <strong>shift + click</strong>: rotate, <a href="javascript:save();return false;">save .png</a>'; container.appendChild( info ); - cameraPerspective = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 10000 ); - cameraPerspective.position.y = 800; - - cameraOrtho = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 2000, 10000 ); - cameraOrtho.position.x = 1000; - cameraOrtho.position.y = 707.106; - cameraOrtho.position.z = 1000; - - camera = cameraPerspective; - + camera = new THREE.CombinedCamera( window.innerWidth, window.innerHeight, 45, 1, 10000, -2000, 10000 ); + camera.position.y = 800; + cameraTarget = new THREE.Vector3( 0, 0, 0 ); scene = new THREE.Scene(); @@ -82,7 +75,6 @@ rollOverMesh = new THREE.Mesh( rollOverGeo, rollOverMaterial ); scene.add( rollOverMesh ); - // cubes cubeGeo = new THREE.CubeGeometry( 50, 50, 50 ); @@ -140,10 +132,14 @@ gui.add(voxelConfig, 'orthographicProjection').onChange(function(){ if ( voxelConfig.orthographicProjection ) { - camera = cameraOrtho; + camera.toOrthographic(); + camera.position.x = 1000; + camera.position.y = 707.106; + camera.position.z = 1000; theta = 90; } else { - camera = cameraPerspective; + camera.toPerspective(); + camera.position.y = 800; } });
false
Other
mrdoob
three.js
e645a562b07823b87e1d498f237f81c453803f6a.json
update voxelpainter to use projector pickingRay()
examples/webgl_interactive_voxelpainter.html
@@ -22,13 +22,16 @@ <script src="js/Detector.js"></script> <script src="js/RequestAnimationFrame.js"></script> <script src="js/Stats.js"></script> + + <link href="js/gui/gui.css" media="screen" rel="stylesheet" type="text/css" /> + <script src="js/gui/gui.min.js"></script> <script> if ( ! Detector.webgl ) Detector.addGetWebGLMessage(); var container, stats; - var camera, cameraTarget, scene, renderer; + var camera, cameraTarget, cameraPerspective, cameraOrtho, scene, renderer; var projector, plane, cube; var mouse2D, mouse3D, ray, rollOveredFace, isShiftDown = false, @@ -38,6 +41,10 @@ var cubeGeo, cubeMaterial; var i, intersector; + var gui, voxelConfig = { + orthographicProjection: false + }; + init(); animate(); @@ -54,10 +61,17 @@ info.innerHTML = '<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - voxel painter - webgl<br /><strong>click</strong>: add voxel, <strong>control + click</strong>: remove voxel, <strong>shift + click</strong>: rotate, <a href="javascript:save();return false;">save .png</a>'; container.appendChild( info ); - camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 10000 ); - camera.position.y = 800; + cameraPerspective = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 10000 ); + cameraPerspective.position.y = 800; - cameraTarget = new THREE.Vector3( 0, 200, 0 ); + cameraOrtho = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 2000, 10000 ); + cameraOrtho.position.x = 1000; + cameraOrtho.position.y = 707.106; + cameraOrtho.position.z = 1000; + + camera = cameraPerspective; + + cameraTarget = new THREE.Vector3( 0, 0, 0 ); scene = new THREE.Scene(); @@ -86,7 +100,6 @@ scene.add( plane ); mouse2D = new THREE.Vector3( 0, 10000, 0.5 ); - ray = new THREE.Ray( camera.position, null ); // Lights @@ -121,7 +134,20 @@ document.addEventListener( 'mousedown', onDocumentMouseDown, false ); document.addEventListener( 'keydown', onDocumentKeyDown, false ); document.addEventListener( 'keyup', onDocumentKeyUp, false ); - + + // add GUI + gui = new GUI(); + gui.add(voxelConfig, 'orthographicProjection').onChange(function(){ + + if ( voxelConfig.orthographicProjection ) { + camera = cameraOrtho; + theta = 90; + } else { + camera = cameraPerspective; + } + + }); + } function getRealIntersector( intersects ) { @@ -247,8 +273,7 @@ } - mouse3D = projector.unprojectVector( mouse2D.clone(), camera ); - ray.direction = mouse3D.subSelf( camera.position ).normalize(); + ray = projector.pickingRay( mouse2D.clone(), camera ); var intersects = ray.intersectScene( scene );
false
Other
mrdoob
three.js
bc27e18424abe3e5fe24a0d4701806b5cf4fc9a0.json
add pickingRay method
src/core/Projector.js
@@ -36,39 +36,34 @@ THREE.Projector = function() { this.projectVector = function ( vector, camera ) { - _projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorldInverse ); + _projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorldInverse ); _projScreenMatrix.multiplyVector3( vector ); return vector; }; - this.unprojectVector = function ( vector, camera, ray ) { - var end, dir, t; - - //if ( camera instanceof THREE.OrthographicCamera ) { - - vector.z = -1.0; - end = new THREE.Vector3( vector.x, vector.y, 1.0); - - //} + this.unprojectVector = function ( vector, camera ) { _projScreenMatrix.multiply( camera.matrixWorld, THREE.Matrix4.makeInvert( camera.projectionMatrix ) ); _projScreenMatrix.multiplyVector3( vector ); - // if ( camera instanceof THREE.OrthographicCamera ) { + return vector; + }; + + this.pickingRay = function ( vector, camera ) { + var end, dir, ray, t; - _projScreenMatrix.multiplyVector3( end ); + vector.z = -1.0; + end = new THREE.Vector3( vector.x, vector.y, 1.0 ); - dir = new THREE.Vector3(); - dir.sub( end, vector ); - dir.normalize(); - - ray.origin = vector; - ray.direction = dir; - // } + this.unprojectVector( vector, camera ); + this.unprojectVector( end, camera ); - return vector; + dir = new THREE.Vector3(); + dir.sub( end, vector ); + dir.normalize(); + return new THREE.Ray( vector, dir ); }; this.projectObjects = function ( scene, camera, sort ) {
false
Other
mrdoob
three.js
c1e9cb77ea715138494a9164cd93640ccc75b178.json
Fix CubeGeometry faces inversion.
examples/webgl_geometry_minecraft.html
@@ -127,10 +127,10 @@ h = getY( x, z ); - h2 = getY( x - 1, z ); + h2 = getY( x + 1, z ); px = ( h2 != h && h2 != h + 1 ) || x == 0 ? 1 : 0; - h2 = getY( x + 1, z ); + h2 = getY( x - 1, z ); nx = ( h2 != h && h2 != h + 1 ) || x == worldWidth - 1 ? 1 : 0; h2 = getY( x, z + 1 );
true
Other
mrdoob
three.js
c1e9cb77ea715138494a9164cd93640ccc75b178.json
Fix CubeGeometry faces inversion.
examples/webgl_geometry_minecraft_ao.html
@@ -364,8 +364,8 @@ px = nx = pz = nz = 0; - px = !nleft || x == 0 ? 1 : 0; - nx = !nright || x == worldWidth - 1 ? 1 : 0; + px = !nright || x == 0 ? 1 : 0; + nx = !nleft || x == worldWidth - 1 ? 1 : 0; pz = !nback || z == worldDepth - 1 ? 1 : 0; nz = !nfront || z == 0 ? 1 : 0;
true
Other
mrdoob
three.js
c1e9cb77ea715138494a9164cd93640ccc75b178.json
Fix CubeGeometry faces inversion.
src/extras/geometries/CubeGeometry.js
@@ -53,8 +53,8 @@ THREE.CubeGeometry = function ( width, height, depth, segmentsWidth, segmentsHei } - this.sides.px && buildPlane( 'z', 'y', 1 * flip, - 1, depth, height, - width_half, this.materials[ 0 ] ); // px - this.sides.nx && buildPlane( 'z', 'y', - 1 * flip, - 1, depth, height, width_half, this.materials[ 1 ] ); // nx + this.sides.px && buildPlane( 'z', 'y', - 1 * flip, - 1, depth, height, width_half, this.materials[ 0 ] ); // px + this.sides.nx && buildPlane( 'z', 'y', 1 * flip, - 1, depth, height, - width_half, this.materials[ 1 ] ); // nx this.sides.py && buildPlane( 'x', 'z', 1 * flip, 1, width, depth, height_half, this.materials[ 2 ] ); // py this.sides.ny && buildPlane( 'x', 'z', 1 * flip, - 1, width, depth, - height_half, this.materials[ 3 ] ); // ny this.sides.pz && buildPlane( 'x', 'y', 1 * flip, - 1, width, height, depth_half, this.materials[ 4 ] ); // pz
true
Other
mrdoob
three.js
f66a6f547cee55e053d82892829ecea613b67160.json
remove some old code
src/extras/geometries/TextGeometry.js
@@ -19,7 +19,8 @@ * bevelThickness: <float>, // how deep into text bevel goes * bevelSize: <float>, // how far from text outline is bevel * - * bend: <bool> // bend according to hardcoded curve (for the moment) + * bend: <bool> // bend according to hardcoded curve (generates bendPath) + * bendPath: <curve> // wraps text according to bend Path * } * * It uses techniques used in: @@ -180,363 +181,6 @@ THREE.FontUtils = { }, -/* LEGACY CODE - - extractPoints : function( allPoints, charactersPoints ) { - - // Quick exit - - if ( allPoints.length < 3 ) { - - //throw "not valid polygon"; - - console.log( "not valid polygon" ); - - return { - - points: allPoints, - faces: [] - - }; - - } - - // Try to split shapes and holes. - - var p, point, shape, - all, - ch, singleCharPoints, - isolatedShapes = []; - - // Use a quick hashmap for locating duplicates - - for ( var c = 0; c < charactersPoints.length; c ++ ) { - - singleCharPoints = charactersPoints[ c ]; - - all = []; - - // Use a quick hashmap for locating duplicates - - for ( var p = 0; p < singleCharPoints.length; p ++ ) { - - point = singleCharPoints[ p ]; - all.push( point.x + "," + point.y ); - - } - - var firstIndex, firstPt, endPt, holes; - - // We check the first loop whether its CW or CCW direction to determine - // whether its shapes or holes first - - endPt = all.slice( 1 ).indexOf( all[ 0 ] ); - var shapesFirst = this.Triangulate.area( singleCharPoints.slice( 0, endPt + 1 ) ) < 0; - - //console.log( singleCharPoints.length, "shapesFirst", shapesFirst ); - - holes = []; - endPt = -1; - - while ( endPt < all.length ) { - - firstIndex = endPt + 1; - firstPt = all[ firstIndex ]; - endPt = all.slice( firstIndex + 1 ).indexOf( firstPt ) + firstIndex; - - if ( endPt <= firstIndex ) break; - - var contours = singleCharPoints.slice( firstIndex, endPt + 1 ); - - if ( shapesFirst ) { - - if ( this.Triangulate.area( contours ) < 0 ) { - - // we got new isolated shape - - if ( firstIndex > 0 ) { - - isolatedShapes.push( { shape: shape, holes: holes } ); - - } - - // Save the old shapes, then work on new additional separated shape - - shape = contours; - holes = []; - - } else { - - holes.push( contours ); - - } - - } else { - - if ( this.Triangulate.area( contours ) < 0 ) { - - isolatedShapes.push( { shape: contours, holes: holes } ); - holes = []; - - } else { - - holes.push( contours ); - - } - - } - - endPt++; - - } - - if ( shapesFirst ) { - - isolatedShapes.push( { shape: shape, holes: holes } ); - - } - - } - - //console.log("isolatedShapes", isolatedShapes); - - // For each isolated shape, find the closest points and break to the hole to allow triangulation - - // Find closest points between holes - - // we could optimize with - // http://en.wikipedia.org/wiki/Proximity_problems - // http://en.wikipedia.org/wiki/Closest_pair_of_points - // http://stackoverflow.com/questions/1602164/shortest-distance-between-points-algorithm - - var prevShapeVert, nextShapeVert, - prevHoleVert, nextHoleVert, - holeIndex, shapeIndex, - shapeId, shapeGroup, - h, h2, - hole, shortest, d, - p, pts1, pts2, - tmpShape1, tmpShape2, - tmpHole1, tmpHole2, - verts = []; - - for ( shapeId = 0; shapeId < isolatedShapes.length; shapeId ++ ) { - - shapeGroup = isolatedShapes[ shapeId ]; - - shape = shapeGroup.shape; - holes = shapeGroup.holes; - - for ( h = 0; h < holes.length; h++ ) { - - // we slice to each hole when neccessary - - hole = holes[ h ]; - shortest = Number.POSITIVE_INFINITY; - - for ( h2 = 0; h2 < hole.length; h2++ ) { - - pts1 = hole[ h2 ]; - - for ( p = 0; p < shape.length; p++ ) { - - pts2 = shape[ p ]; - d = pts1.distanceTo( pts2 ); - - if ( d < shortest ) { - - shortest = d; - holeIndex = h2; - shapeIndex = p; - - } - - } - - } - - prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1; - nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0; - - prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1; - nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ; - - var areaapts = []; - areaapts.push( hole[ holeIndex ] ); - areaapts.push( shape[ shapeIndex ] ); - areaapts.push( shape[ prevShapeVert ] ); - - var areaa = this.Triangulate.area( areaapts ); - - var areabpts = []; - areabpts.push( hole[ holeIndex ] ); - areabpts.push( hole[ prevHoleVert ] ); - areabpts.push( shape[ shapeIndex ] ); - - var areab = this.Triangulate.area( areabpts ); - - var shapeOffset =1; - var holeOffset = -1; - - var oldShapeIndex = shapeIndex, oldHoleIndex = holeIndex; - shapeIndex += shapeOffset; - holeIndex += holeOffset; - - if ( shapeIndex < 0 ) { shapeIndex += shape.length; } - shapeIndex %= shape.length; - - if ( holeIndex < 0 ) { holeIndex += hole.length; } - holeIndex %= shape.length; - - prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1; - nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0; - - prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1; - nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ; - - - areaapts = []; - areaapts.push( hole[ holeIndex ] ); - areaapts.push( shape[ shapeIndex ] ); - areaapts.push( shape[ prevShapeVert ] ); - - var areaa2 = this.Triangulate.area( areaapts ); - - areabpts = []; - areabpts.push( hole[ holeIndex ] ); - areabpts.push( hole[ prevHoleVert ] ); - areabpts.push( shape[ shapeIndex ] ); - - var areab2 = this.Triangulate.area( areabpts ); - - if ( ( areaa + areab ) > ( areaa2 + areab2 ) ) { - - shapeIndex = oldShapeIndex; - holeIndex = oldHoleIndex ; - - if ( shapeIndex < 0 ) { shapeIndex += shape.length; } - shapeIndex %= shape.length; - - if ( holeIndex < 0 ) { holeIndex += hole.length; } - holeIndex %= shape.length; - - - prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1; - nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0; - - prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1; - nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ; - - } - - tmpShape1 = shape.slice( 0, shapeIndex ); - tmpShape2 = shape.slice( shapeIndex ); - tmpHole1 = hole.slice( holeIndex ); - tmpHole2 = hole.slice( 0, holeIndex ); - - verts.push( hole[ holeIndex ] ); - verts.push( shape[ shapeIndex ] ); - verts.push( shape[ prevShapeVert ] ); - - verts.push( hole[ holeIndex ] ); - verts.push( hole[ prevHoleVert ] ); - verts.push( shape[ shapeIndex ] ); - - shape = tmpShape1.concat( tmpHole1 ).concat( tmpHole2 ).concat( tmpShape2 ); - - } - - shapeGroup.shape = shape; - - } - - var triangulatedPoints = []; - var triangulatedFaces = []; - var lastTriangles = 0; - - for ( shapeId = 0; shapeId < isolatedShapes.length; shapeId ++ ) { - - shapeGroup = isolatedShapes[ shapeId ]; - - shape = shapeGroup.shape; - triangulatedPoints = triangulatedPoints.concat( shape ); - - var triangles = THREE.FontUtils.Triangulate( shape, true ); - - // We need to offset vertex indices for faces - - for ( var v = 0; v < triangles.length; v++ ) { - - var face = triangles[ v ]; - - face[ 0 ] += lastTriangles; - face[ 1 ] += lastTriangles; - face[ 2 ] += lastTriangles; - - } - - triangulatedFaces = triangulatedFaces.concat( triangles ); - lastTriangles += shape.length; - - } - - - // Now we push the "cut" vertices back to the triangulated indices. - - //console.log("we have verts.length",verts.length,verts); - - var v, j, k, l, found, face; - - for ( v = 0; v < verts.length / 3; v++ ) { - - face = []; - - for ( k = 0; k < 3; k++ ) { - - found = false; - - for ( j = 0; j < triangulatedPoints.length && !found; j++ ) { - - l = v * 3 + k; - - if ( triangulatedPoints[ j ].equals( verts[ l ] ) ) { - - face.push( j ); - found = true; - - } - - } - - // you would not wish to reach this point of code, something went wrong - - if ( !found ) { - - triangulatedPoints.push( verts[ l ] ); - face.push( triangulatedPoints.length - 1 ); - - console.log( "not found" ) - - } - - } - - triangulatedFaces.push( face ); - - } - - - //console.log( "triangles", triangulatedFaces.length, "points", triangulatedPoints ); - - return { - - points: triangulatedPoints, - faces: triangulatedFaces - - }; - - },*/ - drawText : function( text ) { var characterPts = [], allPts = [];
false
Other
mrdoob
three.js
6d6924a621dac2b4780013aa45bcf38aba6f5718.json
Add bend to webgl text example
examples/webgl_geometry_text.html
@@ -33,6 +33,7 @@ <span class="button" id="font">change font</span>, <span class="button" id="weight">change weight</span>, <span class="button" id="bevel">change bevel</span>, + <span class="button" id="bend">bend!</span>, <span class="button" id="postprocessing">change postprocessing</span>, <a id="permalink" href="#">permalink</a> </div> @@ -43,13 +44,9 @@ <script type="text/javascript" src="js/Detector.js"></script> <script type="text/javascript" src="js/RequestAnimationFrame.js"></script> <script type="text/javascript" src="js/Stats.js"></script> - + <!-- load the font file from canvas-text --> - <!-- - - - --> <script type="text/javascript" src="fonts/gentilis_bold.typeface.js"></script> <script type="text/javascript" src="fonts/gentilis_regular.typeface.js"></script> <script type="text/javascript" src="fonts/optimer_bold.typeface.js"></script> @@ -86,6 +83,7 @@ bevelSize = 1.5, bevelSegments = 3, bevelEnabled = true, + bend = true, font = "optimer", // helvetiker, optimer, gentilis, droid sans, droid serif weight = "bold", // normal bold @@ -164,7 +162,7 @@ scene.addLight( dirLight ); var pointLight = new THREE.PointLight( 0xffffff, 1.5 ); - pointLight.position.set( 0, 100, 50 ); + pointLight.position.set( 0, 100, 90 ); scene.addLight( pointLight ); //text = capitalize( font ) + " " + capitalize( weight ); @@ -182,7 +180,8 @@ var weighthash = hash.substring( 7, 8 ); var pphash = hash.substring( 8, 9 ); var bevelhash = hash.substring( 9, 10 ); - var texthash = hash.substring( 11 ); + var bendhash = hash.substring( 10, 11 ); + var texthash = hash.substring( 12 ); hex = colorhash; pointLight.color.setHex( parseInt( colorhash, 16 ) ); @@ -192,6 +191,7 @@ postprocessing.enabled = parseInt( pphash ); bevelEnabled = parseInt( bevelhash ); + bend = parseInt( bendhash ); text = decodeURI( texthash ); @@ -298,6 +298,13 @@ refreshText(); }, false ); + + document.getElementById( "bend" ).addEventListener( 'click', function() { + + bend = !bend; + refreshText(); + + }, false ); document.getElementById( "postprocessing" ).addEventListener( 'click', function() { @@ -321,7 +328,8 @@ function updatePermalink() { - var link = hex + fontMap[ font ] + weightMap[ weight ] + boolToNum( postprocessing.enabled ) + boolToNum( bevelEnabled ) + "#" + encodeURI( text ); + var link = hex + fontMap[ font ] + weightMap[ weight ] + boolToNum( postprocessing.enabled ) + boolToNum( bevelEnabled ) + + boolToNum( bend ) + "#" + encodeURI( text ); permalink.href = "#" + link; window.location.hash = link; @@ -376,7 +384,6 @@ } function createText() { - textGeo = new THREE.TextGeometry( text, { size: size, @@ -389,7 +396,9 @@ bevelThickness: bevelThickness, bevelSize: bevelSize, - bevelEnabled: bevelEnabled + bevelEnabled: bevelEnabled, + + bend: bend });
true
Other
mrdoob
three.js
6d6924a621dac2b4780013aa45bcf38aba6f5718.json
Add bend to webgl text example
src/extras/geometries/Curve.js
@@ -200,13 +200,51 @@ THREE.Curve.prototype.getUtoTmapping = function ( u, distance ) { }; +// In case any sub curves does not implements its normal finding, +// we get 2 points with a small delta, and find a gradient of the 2 pts +// makes an ok approximation + +THREE.Curve.prototype.getNormalVector = function( t ) { + + var pt1 = this.getPoint(t-0.001); + var pt2 = this.getPoint(t+0.001); + + + __vec1.sub(pt2, pt1); + return new THREE.Vector2( -__vec1.y , __vec1.x ).unit(); + +}; + +THREE.Curve.prototype.getTangentUnit = function( t ) { + + var pt1 = this.getPoint(t-0.001); + var pt2 = this.getPoint(t+0.001); + + + __vec1.sub(pt2, pt1); + return new THREE.Vector2( __vec1.x , __vec1.y ).unit(); + +}; + + +var __vec1 = new THREE.Vector2(); // tmp Vector /************************************************************** * Line **************************************************************/ -THREE.LineCurve = function ( x1, y1, x2, y2 ) { + +THREE.LineCurve = function ( v1, v2 ) { + + this.v1 = v1; + this.v2 = v2; + +}; + +THREE.LineCurve.oldConstruct = function ( x1, y1, x2, y2 ) { + //instanceof THREE.Vector2 oldConstruct.apply(this); + this.x1 = x1; this.y1 = y1; @@ -219,18 +257,29 @@ THREE.LineCurve.prototype = new THREE.Curve(); THREE.LineCurve.prototype.constructor = THREE.LineCurve; THREE.LineCurve.prototype.getPoint = function ( t ) { - - var dx = this.x2 - this.x1; - var dy = this.y2 - this.y1; - - var tx = this.x1 + dx * t; - var ty = this.y1 + dy * t; - - return new THREE.Vector2( tx, ty ); + + var tmpVector = new THREE.Vector2(); + tmpVector.sub(this.v2, this.v1); + tmpVector.multiplyScalar(t); + return tmpVector; + + // var dx = this.x2 - this.x1; + // var dy = this.y2 - this.y1; + // + // var tx = this.x1 + dx * t; + // var ty = this.y1 + dy * t; + // + // return new THREE.Vector2( tx, ty ); }; THREE.LineCurve.prototype.getNormalVector = function( t ) { + + //__vec1 = new THREE.Vector2(); + __vec1.sub(this.v2, this.v1); + return new THREE.Vector2( -__vec1.y , __vec1.x ).unit(); + + tx = this.x2 - this.x1; ty = this.y2 - this.y1; @@ -242,7 +291,16 @@ THREE.LineCurve.prototype.getNormalVector = function( t ) { * Quadratic Bezier curve **************************************************************/ -THREE.QuadraticBezierCurve = function ( x0, y0, x1, y1, x2, y2 ) { + +THREE.QuadraticBezierCurve = function ( v0, v1, v2 ) { + + this.v0 = v0; + this.v1 = v1; + this.v2 = v2; + +}; + +THREE.QuadraticBezierCurve.old = function ( x0, y0, x1, y1, x2, y2 ) { this.x0 = x0; this.y0 = y0; @@ -255,30 +313,34 @@ THREE.QuadraticBezierCurve = function ( x0, y0, x1, y1, x2, y2 ) { }; + THREE.QuadraticBezierCurve.prototype = new THREE.Curve(); THREE.QuadraticBezierCurve.prototype.constructor = THREE.QuadraticBezierCurve; THREE.QuadraticBezierCurve.prototype.getPoint = function ( t ) { var tx, ty; + + tx = THREE.Shape.Utils.b2( t, this.v0.x, this.v1.x, this.v2.x ); + ty = THREE.Shape.Utils.b2( t, this.v0.y, this.v1.y, this.v2.y ); - tx = THREE.Shape.Utils.b2( t, this.x0, this.x1, this.x2 ); - ty = THREE.Shape.Utils.b2( t, this.y0, this.y1, this.y2 ); + // tx = THREE.Shape.Utils.b2( t, this.x0, this.x1, this.x2 ); + // ty = THREE.Shape.Utils.b2( t, this.y0, this.y1, this.y2 ); return new THREE.Vector2( tx, ty ); }; -THREE.QuadraticBezierCurve.prototype.getNormalVector = function( t ) { +THREE.QuadraticBezierCurve.prototype.getNormalVector2 = function( t ) { // iterate sub segments // get lengths for sub segments // if segment is bezier // perform subdivisions or perform integrals - var x0, y0, x1, y1, x2, y2; + // var x0, y0, x1, y1, x2, y2; // x0 = this.actions[ 0 ].args[ 0 ]; // y0 = this.actions[ 0 ].args[ 1 ]; @@ -291,8 +353,8 @@ THREE.QuadraticBezierCurve.prototype.getNormalVector = function( t ) { var tx, ty; - tx = THREE.Curve.Utils.tangentQuadraticBezier( t, this.x0, this.x1, this.x2 ); - ty = THREE.Curve.Utils.tangentQuadraticBezier( t, this.y0, this.y1, this.y2 ); + tx = THREE.Curve.Utils.tangentQuadraticBezier( t, this.v0.x, this.v1.x, this.v2.x ); + ty = THREE.Curve.Utils.tangentQuadraticBezier( t, this.v0.y, this.v1.y, this.v2.y ); // return normal unit vector return new THREE.Vector2( -ty , tx ).unit(); @@ -304,7 +366,16 @@ THREE.QuadraticBezierCurve.prototype.getNormalVector = function( t ) { * Cubic Bezier curve **************************************************************/ -THREE.CubicBezierCurve = function ( x0, y0, x1, y1, x2, y2, x3, y3 ) { +THREE.CubicBezierCurve = function ( v0, v1, v2, v3 ) { + + this.v0 = v0; + this.v1 = v1; + this.v2 = v2; + this.v3 = v3; + +}; + +THREE.CubicBezierCurve.old = function ( x0, y0, x1, y1, x2, y2, x3, y3 ) { this.x0 = x0; this.y0 = y0; @@ -326,14 +397,27 @@ THREE.CubicBezierCurve.prototype.constructor = THREE.CubicBezierCurve; THREE.CubicBezierCurve.prototype.getPoint = function ( t ) { var tx, ty; - - tx = THREE.Shape.Utils.b3( t, this.x0, this.x1, this.x2, this.x3 ); - ty = THREE.Shape.Utils.b3( t, this.y0, this.y1, this.y2, this.y3 ); + + tx = THREE.Shape.Utils.b3( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x ); + ty = THREE.Shape.Utils.b3( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y ); return new THREE.Vector2( tx, ty ); }; +THREE.CubicBezierCurve.prototype.getNormalVector = function( t ) { + + var tx, ty; + + tx = THREE.Curve.Utils.tangentCubicBezier( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x ); + ty = THREE.Curve.Utils.tangentCubicBezier( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y ); + + // return normal unit vector + return new THREE.Vector2( -ty , tx ).unit(); + +}; + + /************************************************************** * Spline curve **************************************************************/ @@ -422,6 +506,20 @@ THREE.Curve.Utils = { return 2 * ( 1 - t ) * ( p1 - p0 ) + 2 * t * ( p2 - p1 ); }, + + //derivative + tangentCubicBezier: function (t, p0, p1, p2, p3 ) { + // return -3 * (1 - 2*t + t*t) * p0 - + // 3 * t * (4 - 3*t) * p1 + + // 3 * t * (2 - 3*t) * p2 + + // 3 * t * t * p3; + + return -3 * p0 * (1 - t) * (1 - t) + + 3 * p1 * (1 - t) * (1-t) - 6 *t *p1 * (1-t) + + 6 * t * p2 * (1-t) - 3 * t * t * p2 + + 3 * t * t * p3; + }, + tangentSpline: function ( t, p0, p1, p2, p3 ) { @@ -515,7 +613,7 @@ THREE.LineCurve3 = THREE.Curve.create( THREE.QuadraticBezierCurve3 = THREE.Curve.create( - function ( v0, v1, v2 ) { // Qn should we use 2 Vector3 instead? + function ( v0, v1, v2 ) { this.v0 = v0; this.v1 = v1;
true
Other
mrdoob
three.js
6d6924a621dac2b4780013aa45bcf38aba6f5718.json
Add bend to webgl text example
src/extras/geometries/ExtrudeGeometry.js
@@ -100,7 +100,10 @@ THREE.ExtrudeGeometry.prototype.addShape = function( shape, options ) { var shapesOffset = this.vertices.length; var shapePoints = shape.extractAllPoints( curveSegments ); // use shape.extractAllSpacedPoints( curveSegments ) for points with equal divisions - shapePoints = shape.extractAllPointsWithBend( curveSegments, bendPath ); + + if (bendPath) { + shapePoints = shape.extractAllPointsWithBend( curveSegments, bendPath ); + } var vertices = shapePoints.shape;
true
Other
mrdoob
three.js
6d6924a621dac2b4780013aa45bcf38aba6f5718.json
Add bend to webgl text example
src/extras/geometries/Path.js
@@ -514,31 +514,17 @@ THREE.Path.prototype.createGeometry = function( points ) { // ALL THINGS BELOW TO BE REFACTORED // QN: Transform final pts or transform ACTIONS or add transform filters? -// FUTURE refactor path = an array of lines -> straight, bezier, splines, arc, funcexpr lines // Read http://www.planetclegg.com/projects/WarpingTextToSplines.html - // This returns getPoints() bend/wrapped around the contour of a path. THREE.Path.prototype.transform = function( path, segments ) { var bounds = this.getBoundingBox(); var oldPts = this.getPoints( segments ); // getPoints getSpacedPoints - // path = new THREE.Path(); - // path.moveTo( 0, 0 ); - // path.quadraticCurveTo( 100, 20, 140, 80 ); - - path = new THREE.QuadraticBezierCurve( 0, 0, 150, 100, 400, 0) - //path = new THREE.QuadraticBezierCurve( 0, 0, bounds.maxX/2, 50, bounds.maxX , 0); - - //path = new THREE.LineCurve( 0, 0, 400, 0); - - //console.log( path.cacheArcLengths() ); - //path.getLengths(400); + path.getLengths(400); //segments = 40; - - var i, il, p, oldX, oldY, xNorm; @@ -555,6 +541,7 @@ THREE.Path.prototype.transform = function( path, segments ) { //xNorm = path.getUtoTmapping(xNorm, oldX); // 3 styles. 1) wrap stretched. 2) wrap stretch by arc length 3) warp by actual distance xNorm = path.getUtoTmapping(xNorm, oldX ); + // check for out of bounds? var pathPt = path.getPoint( xNorm ); var normal = path.getNormalVector( xNorm ).multiplyScalar( oldY );
true
Other
mrdoob
three.js
6d6924a621dac2b4780013aa45bcf38aba6f5718.json
Add bend to webgl text example
src/extras/geometries/TextGeometry.js
@@ -50,12 +50,34 @@ THREE.TextGeometry = function ( text, parameters ) { if ( parameters.bevelSize === undefined ) parameters.bevelSize = 8; if ( parameters.bevelEnabled === undefined ) parameters.bevelEnabled = false; + if ( parameters.bend ) { + + var b = textShapes[textShapes.length-1].getBoundingBox(); + var max = b.maxX; + + parameters.bendPath = new THREE.QuadraticBezierCurve( new THREE.Vector2(0, 0), + new THREE.Vector2(max/2, 120), new THREE.Vector2(max, 0)); + + } + + // path = new THREE.CubicBezierCurve( new THREE.Vector2(0, 0), + // new THREE.Vector2(100, 100), new THREE.Vector2(200, 100), new THREE.Vector2(500, 0)); + // + //path = new THREE.QuadraticBezierCurve( 0, 0, bounds.maxX/2, 50, bounds.maxX , 0); + + //path = new THREE.LineCurve( 0, 0, 400, 0); + //path = new THREE.LineCurve( new THREE.Vector2(0, 0), new THREE.Vector2(400, 100)); + + // var bend = new THREE.Path(); + // bend.moveTo(0,0); + // bend.quadraticCurveTo( 500, 100, 1000, 0 ); + // - var bend = new THREE.Path(); - bend.moveTo(0,0); - bend.quadraticCurveTo( 500, 100, 1000, 0 ); + // parameters.bendPath = path; - parameters.bendPath = bend; + + + THREE.ExtrudeGeometry.call( this, textShapes, parameters );
true
Other
mrdoob
three.js
92bb07914581f7ac33f2378eee88ce034dda39a4.json
Add readme for blender plugin
utils/exporters/blender/README.md
@@ -0,0 +1,31 @@ +# Three.js Blender Import/Export + +Imports and exports Three.js' ASCII JSON format. + +Assumes Blender version 2.60. + +## Installation + +Copy the io_mesh_threejs folder to the scripts/addons folder. The full path is OS-dependent (see below). + +Once that is done, you need to activate the plugin. Open Blender preferences, look for +Addons, search for `three`, enable the checkbox next to the `Import-Export: three.js format` entry. + +Goto Usage. + +### Windows + +Should look like this: + + C:\Users\USERNAME\AppData\Roaming\Blender Foundation\Blender\2.60\scripts\addons + +### OSX + +Depends on where blender.app is. Assuming you copied it to your Applications folder: + + /Applications/Blender/blender.app/Contents/MacOS/2.60/scripts/addons + +## Usage + +Use the regular Import and Export menu within Blender, select `Three.js (js)`. +
false
Other
mrdoob
three.js
c8aacd8cdc98c69cf11281fbc86c18a9dd9c7113.json
Add Color methods to prototype object.
src/core/Color.js
@@ -9,16 +9,22 @@ THREE.Color = function ( hex ) { this.hex; this.__styleString = 'rgba(0, 0, 0, 1)'; */ + + this.setHex( hex ); + +} - this.setHex = function ( hex ) { +THREE.Color.prototype = { + + setHex: function ( hex ) { this.hex = hex; this.updateRGBA(); this.updateStyleString(); - }; + }, - this.setRGBA = function ( r, g, b, a ) { + setRGBA: function ( r, g, b, a ) { this.r = r; this.g = g; @@ -28,35 +34,33 @@ THREE.Color = function ( hex ) { this.updateHex(); this.updateStyleString(); - }; + }, - this.updateHex = function () { + updateHex: function () { this.hex = Math.floor( this.a * 255 ) << 24 | Math.floor( this.r * 255 ) << 16 | Math.floor( this.g * 255 ) << 8 | Math.floor( this.b * 255 ); - }; + }, - this.updateRGBA = function () { + updateRGBA: function () { this.a = ( this.hex >> 24 & 255 ) / 255; this.r = ( this.hex >> 16 & 255 ) / 255; this.g = ( this.hex >> 8 & 255 ) / 255; this.b = ( this.hex & 255 ) / 255; - }; + }, - this.updateStyleString = function () { + updateStyleString: function () { this.__styleString = 'rgba(' + Math.floor( this.r * 255 ) + ',' + Math.floor( this.g * 255 ) + ',' + Math.floor( this.b * 255 ) + ',' + this.a + ')'; - }; + }, - this.toString = function () { + toString: function () { return 'THREE.Color ( r: ' + this.r + ', g: ' + this.g + ', b: ' + this.b + ', a: ' + this.a + ', hex: ' + this.hex + ' )'; - }; - - this.setHex( hex ); + } };
false
Other
mrdoob
three.js
f0f3483f91e09ac35763400c62b1ab4ebf86fc5e.json
Remove useless alert.
examples/performance-test.html
@@ -15,8 +15,7 @@ <script type="text/javascript" src="../src/core/Matrix4.old.js"></script> <script type="text/javascript"> function initTest() { - alert("hello"); - var times = 50000; + var times = 5000000; //Vector2 console.time("Vector2 x " + times); for( var i = 0; i < times; ++i) {
false
Other
mrdoob
three.js
578013ac202aa3b28d25c4378018acd077ce5ed8.json
handle case when weights are zero
src/objects/SkinnedMesh.js
@@ -109,7 +109,7 @@ THREE.SkinnedMesh.prototype.normalizeSkinWeights = function () { } else { - // do nothing + sw.set( 1, 0, 0, 0 ); // do something reasonable } @@ -136,7 +136,7 @@ THREE.SkinnedMesh.prototype.normalizeSkinWeights = function () { } else { - // do nothing + vec.set( 1, 0, 0, 0 ); // do something reasonable }
false
Other
mrdoob
three.js
e3d2617108dbf05ab359f91a5b81cfea038c513d.json
Add test for ClosedSplineCurve3
test/unit/extras/curves/ClosedSplineCurve3.js
@@ -0,0 +1,51 @@ +/** + * @author zz85 / http://joshuakoo.com + */ + +module( "ClosedSplineCurve3" ); + +function vectorsAreEqual( check, that ) { + + if ( check.length !== that.length ) return 'Length not equal'; + + for ( var i = 0; i < check.length; i ++ ) { + + if ( ! check[ i ] .equals( that[ i ] ) ) { + + return 'Vector differs at index ' + i; + } + } + + return; +} + +test( "basic check", function() { + + var closedSpline = new THREE.ClosedSplineCurve3( [ + new THREE.Vector3( -60, -100, 60 ), + new THREE.Vector3( -60, 20, 60 ), + new THREE.Vector3( -60, 120, 60 ), + new THREE.Vector3( 60, 20, -60 ), + new THREE.Vector3( 60, -100, -60 ) + ] ); + + var closedSplinePoints = [ + new THREE.Vector3(-60,-100,60), + new THREE.Vector3(-67.5,-46.25,67.5), + new THREE.Vector3(-60,20,60), + new THREE.Vector3(-67.5,83.75,67.5), + new THREE.Vector3(-60,120,60), + new THREE.Vector3(0,83.75,0), + new THREE.Vector3(60,20,-60), + new THREE.Vector3(75,-46.25,-75), + new THREE.Vector3(60,-100,-60), + new THREE.Vector3(0,-115,0), + new THREE.Vector3(-60,-100,60), + ]; + + var getPoints = closedSpline.getPoints(10); + var error = vectorsAreEqual( getPoints , closedSplinePoints ); + ok( getPoints.length == 11, 'getPoints are equal.' + error ); + ok( !error, 'Points are equal.' + error ); + +}); \ No newline at end of file
true
Other
mrdoob
three.js
e3d2617108dbf05ab359f91a5b81cfea038c513d.json
Add test for ClosedSplineCurve3
test/unit/unittests_sources.html
@@ -33,6 +33,10 @@ <script src="../../src/math/Triangle.js"></script> <script src="../../src/math/Interpolant.js"></script> + <script src="../../src/extras/core/Curve.js"></script> + <script src="../../src/extras/CurveUtils.js"></script> + <script src="../../src/extras/curves/ClosedSplineCurve3.js"></script> + <!-- add class-based unit tests below --> <script src="math/Constants.js"></script> @@ -55,5 +59,7 @@ <script src="math/Color.js"></script> <script src="math/Interpolant.js"></script> + <script src="extras/curves/ClosedSplineCurve3.js"></script> + </body> </html>
true
Other
mrdoob
three.js
7aa62714fb08c9956461defdcf225e6dd1a3e381.json
Fix closed curves and clean up
examples/webgl_geometry_shapes.html
@@ -48,7 +48,7 @@ info.style.top = '10px'; info.style.width = '100%'; info.style.textAlign = 'center'; - info.innerHTML = 'Simple procedurally generated 3D shapes<br/>Drag to spin'; + info.innerHTML = 'Simple procedurally-generated shapes<br/>Drag to spin'; container.appendChild( info ); scene = new THREE.Scene(); @@ -64,15 +64,13 @@ group.position.y = 50; scene.add( group ); - var texture = THREE.ImageUtils.loadTexture( "textures/UV_Grid_Sm.jpg" ); + var loader = new THREE.TextureLoader(); + var texture = loader.load( "textures/UV_Grid_Sm.jpg" ); texture.wrapS = texture.wrapT = THREE.RepeatWrapping; texture.repeat.set( 0.008, 0.008 ); function addShape( shape, extrudeSettings, color, x, y, z, rx, ry, rz, s ) { - var points = shape.createPointsGeometry(); - var spacedPoints = shape.createSpacedPointsGeometry( 50 ); - // flat shape with texture // note: default UVs generated by ShapeGemoetry are simply the x- and y-coordinates of the vertices @@ -94,7 +92,7 @@ mesh.scale.set( s, s, s ); group.add( mesh ); - // 3d shape + // extruded shape var geometry = new THREE.ExtrudeGeometry( shape, extrudeSettings ); @@ -104,6 +102,12 @@ mesh.scale.set( s, s, s ); group.add( mesh ); + // lines + + shape.autoClose = true; + var points = shape.createPointsGeometry(); + var spacedPoints = shape.createSpacedPointsGeometry( 50 ); + // solid line var line = new THREE.Line( points, new THREE.LineBasicMaterial( { color: color, linewidth: 3 } ) ); @@ -112,31 +116,29 @@ line.scale.set( s, s, s ); group.add( line ); - // vertices from real points - - var pgeo = points.clone(); - var particles = new THREE.Points( pgeo, new THREE.PointsMaterial( { color: color, size: 4 } ) ); - particles.position.set( x, y, z + 25 ); - particles.rotation.set( rx, ry, rz ); - particles.scale.set( s, s, s ); - group.add( particles ); - // line from equidistance sampled points var line = new THREE.Line( spacedPoints, new THREE.LineBasicMaterial( { color: color, linewidth: 3 } ) ); - line.position.set( x, y, z + 75 ); + line.position.set( x, y, z + 25 ); line.rotation.set( rx, ry, rz ); line.scale.set( s, s, s ); group.add( line ); + // vertices from real points + + var particles = new THREE.Points( points, new THREE.PointsMaterial( { color: color, size: 4 } ) ); + particles.position.set( x, y, z + 75 ); + particles.rotation.set( rx, ry, rz ); + particles.scale.set( s, s, s ); + group.add( particles ); + // equidistance sampled points - var pgeo = spacedPoints.clone(); - var particles2 = new THREE.Points( pgeo, new THREE.PointsMaterial( { color: color, size: 4 } ) ); - particles2.position.set( x, y, z + 125 ); - particles2.rotation.set( rx, ry, rz ); - particles2.scale.set( s, s, s ); - group.add( particles2 ); + var particles = new THREE.Points( spacedPoints, new THREE.PointsMaterial( { color: color, size: 4 } ) ); + particles.position.set( x, y, z + 125 ); + particles.rotation.set( rx, ry, rz ); + particles.scale.set( s, s, s ); + group.add( particles ); }
false
Other
mrdoob
three.js
91b492bd33465ca22fac8064b7ae1ef0b9fa6afe.json
Add raytracing_sandbox_workers to examples index
examples/index.html
@@ -475,7 +475,8 @@ <h1><a href="http://threejs.org">three.js</a> / examples</h1> "canvas_sandbox" ], "raytracing": [ - "raytracing_sandbox" + "raytracing_sandbox", + "raytracing_sandbox_workers" ], "software": [ "software_geometry_earth",
false
Other
mrdoob
three.js
0b8e3281ded386a81d5121d94ef1d8fd75a6a041.json
add removed tests
test/unit/unittests_three.html
@@ -27,6 +27,10 @@ <script src="core/InterleavedBuffer.js"></script> <script src="core/InterleavedBufferAttribute.js"></script> + <script src="core/Raycaster.js"></script> + <script src="core/Face3.js"></script> + <script src="core/Geometry.js"></script> + <script src="core/BufferAttribute.js"></script> <script src="core/BufferGeometry.js"></script> <script src="core/Clock.js"></script>
false
Other
mrdoob
three.js
f2c466b819b5d2c616265106b3b2af6bf4214fa6.json
remove lodash from html
test/unit/unittests_three.html
@@ -7,7 +7,6 @@ </head> <body> <div id="qunit"></div> - <script src="../../node_modules/lodash/index.js"></script> <script src="qunit-1.18.0.js"></script> <script src="qunit-utils.js"></script> <script src="SmartComparer.js"></script>
false