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
8bfe403c00b09093bcf7082888696e371671a789.json
Add dispose method to all controls
examples/js/controls/FlyControls.js
@@ -254,18 +254,38 @@ THREE.FlyControls = function ( object, domElement ) { } - this.domElement.addEventListener( 'contextmenu', function ( event ) { + function contextmenu( event ) { event.preventDefault(); - }, false ); + } + + this.dispose = function() { + + this.domElement.removeEventListener( 'contextmenu', contextmenu, false ); + this.domElement.removeEventListener( 'mousedown', _mousedown, false ); + this.domElement.removeEventListener( 'mousemove', _mousemove, false ); + this.domElement.removeEventListener( 'mouseup', _mouseup, false ); + + window.removeEventListener( 'keydown', _keydown, false ); + window.removeEventListener( 'keyup', _keyup, false ); + + } + + var _mousemove = bind( this, this.mousemove ); + var _mousedown = bind( this, this.mousedown ); + var _mouseup = bind( this, this.mouseup ); + var _keydown = bind( this, this.keydown ); + var _keyup = bind( this, this.keyup ); + + this.domElement.addEventListener( 'contextmenu', contextmenu, false ); - 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 ); + this.domElement.addEventListener( 'mousemove', _mousemove, false ); + this.domElement.addEventListener( 'mousedown', _mousedown, false ); + this.domElement.addEventListener( 'mouseup', _mouseup, false ); - window.addEventListener( 'keydown', bind( this, this.keydown ), false ); - window.addEventListener( 'keyup', bind( this, this.keyup ), false ); + window.addEventListener( 'keydown', _keydown, false ); + window.addEventListener( 'keyup', _keyup, false ); this.updateMovementVector(); this.updateRotationVector();
true
Other
mrdoob
three.js
8bfe403c00b09093bcf7082888696e371671a789.json
Add dispose method to all controls
examples/js/controls/MouseControls.js
@@ -50,6 +50,12 @@ THREE.MouseControls = function ( object ) { }; + this.dispose = function() { + + document.removeEventListener( 'mousemove', onMouseMove, false ); + + } + document.addEventListener( 'mousemove', onMouseMove, false ); };
true
Other
mrdoob
three.js
8bfe403c00b09093bcf7082888696e371671a789.json
Add dispose method to all controls
examples/js/controls/OrbitControls.js
@@ -750,11 +750,31 @@ } - this.domElement.addEventListener( 'contextmenu', function ( event ) { + function contextmenu( event ) { event.preventDefault(); - }, false ); + } + + this.dispose = function() { + + this.domElement.removeEventListener( 'contextmenu', contextmenu, false ); + this.domElement.removeEventListener( 'mousedown', onMouseDown, false ); + this.domElement.removeEventListener( 'mousewheel', onMouseWheel, false ); + this.domElement.removeEventListener( 'DOMMouseScroll', onMouseWheel, false ); // firefox + + this.domElement.removeEventListener( 'touchstart', touchstart, false ); + this.domElement.removeEventListener( 'touchend', touchend, false ); + this.domElement.removeEventListener( 'touchmove', touchmove, false ); + + document.removeEventListener( 'mousemove', onMouseMove, false ); + document.removeEventListener( 'mouseup', onMouseUp, false ); + + window.removeEventListener( 'keydown', onKeyDown, false ); + + } + + this.domElement.addEventListener( 'contextmenu', contextmenu, false ); this.domElement.addEventListener( 'mousedown', onMouseDown, false ); this.domElement.addEventListener( 'mousewheel', onMouseWheel, false );
true
Other
mrdoob
three.js
8bfe403c00b09093bcf7082888696e371671a789.json
Add dispose method to all controls
examples/js/controls/OrthographicTrackballControls.js
@@ -606,14 +606,34 @@ THREE.OrthographicTrackballControls = function ( object, domElement ) { } - this.domElement.addEventListener( 'contextmenu', function ( event ) { + function contextmenu( event ) { event.preventDefault(); - }, false ); + } - this.domElement.addEventListener( 'mousedown', mousedown, false ); + this.dispose = function() { + + this.domElement.removeEventListener( 'contextmenu', contextmenu, false ); + this.domElement.removeEventListener( 'mousedown', mousedown, false ); + this.domElement.removeEventListener( 'mousewheel', mousewheel, false ); + this.domElement.removeEventListener( 'DOMMouseScroll', mousewheel, false ); // firefox + + this.domElement.removeEventListener( 'touchstart', touchstart, false ); + this.domElement.removeEventListener( 'touchend', touchend, false ); + this.domElement.removeEventListener( 'touchmove', touchmove, false ); + + document.removeEventListener( 'mousemove', mousemove, false ); + document.removeEventListener( 'mouseup', mouseup, false ); + window.removeEventListener( 'keydown', keydown, false ); + window.removeEventListener( 'keyup', keyup, false ); + + } + + + this.domElement.addEventListener( 'contextmenu', contextmenu, false ); + this.domElement.addEventListener( 'mousedown', mousedown, false ); this.domElement.addEventListener( 'mousewheel', mousewheel, false ); this.domElement.addEventListener( 'DOMMouseScroll', mousewheel, false ); // firefox
true
Other
mrdoob
three.js
8bfe403c00b09093bcf7082888696e371671a789.json
Add dispose method to all controls
examples/js/controls/PointerLockControls.js
@@ -31,6 +31,12 @@ THREE.PointerLockControls = function ( camera ) { }; + this.dispose = function() { + + document.removeEventListener( 'mousemove', onMouseMove, false ); + + } + document.addEventListener( 'mousemove', onMouseMove, false ); this.enabled = false;
true
Other
mrdoob
three.js
8bfe403c00b09093bcf7082888696e371671a789.json
Add dispose method to all controls
examples/js/controls/TrackballControls.js
@@ -586,14 +586,33 @@ THREE.TrackballControls = function ( object, domElement ) { } - this.domElement.addEventListener( 'contextmenu', function ( event ) { + function contextmenu( event ) { event.preventDefault(); - }, false ); + } - this.domElement.addEventListener( 'mousedown', mousedown, false ); + this.dispose = function() { + + this.domElement.removeEventListener( 'contextmenu', contextmenu, false ); + this.domElement.removeEventListener( 'mousedown', mousedown, false ); + this.domElement.removeEventListener( 'mousewheel', mousewheel, false ); + this.domElement.removeEventListener( 'DOMMouseScroll', mousewheel, false ); // firefox + + this.domElement.removeEventListener( 'touchstart', touchstart, false ); + this.domElement.removeEventListener( 'touchend', touchend, false ); + this.domElement.removeEventListener( 'touchmove', touchmove, false ); + + document.removeEventListener( 'mousemove', mousemove, false ); + document.removeEventListener( 'mouseup', mouseup, false ); + window.removeEventListener( 'keydown', keydown, false ); + window.removeEventListener( 'keyup', keyup, false ); + + } + + this.domElement.addEventListener( 'contextmenu', contextmenu, false ); + this.domElement.addEventListener( 'mousedown', mousedown, false ); this.domElement.addEventListener( 'mousewheel', mousewheel, false ); this.domElement.addEventListener( 'DOMMouseScroll', mousewheel, false ); // firefox
true
Other
mrdoob
three.js
8bfe403c00b09093bcf7082888696e371671a789.json
Add dispose method to all controls
examples/js/controls/VRControls.js
@@ -116,4 +116,10 @@ THREE.VRControls = function ( object, onError ) { }; + this.dispose = function () { + + vrInputs = []; + + }; + };
true
Other
mrdoob
three.js
90ac81fdaa853308a5f4f68c7a258a8f3caa51f2.json
Fix a tiny typo
docs/api/core/BufferAttribute.html
@@ -17,7 +17,7 @@ <h1>[name]</h1> <h2>Constructor</h2> <h3>[name]([page:Array array], [page:Integer itemSize])</h3> <div> - Instantiates this attibute with data from the associated buffer. The array can either be a regular Array or a Typed Array. + Instantiates this attribute with data from the associated buffer. The array can either be a regular Array or a Typed Array. itemSize gives the number of values of the array that should be associated with a particular vertex. </div>
false
Other
mrdoob
three.js
86523359e466eec6cfefa7549a9843c691927c21.json
remove debugging output.
src/animation/AnimationClip.js
@@ -12,7 +12,7 @@ THREE.AnimationClip = function ( name, duration, tracks ) { this.tracks = tracks; this.duration = duration || 1; - // TODO: maybe only do these on demand, as doing them here could potentially slow down loading + // maybe only do these on demand, as doing them here could potentially slow down loading // but leaving these here during development as this ensures a lot of testing of these functions this.trim(); this.optimize(); @@ -32,7 +32,6 @@ THREE.AnimationClip.prototype = { for( var i = 0; i < this.tracks.length; i ++ ) { var track = this.tracks[ i ]; - //console.log( 'track', track ); this.results[ track.name ] = track.getAt( clipTime ); @@ -64,29 +63,10 @@ THREE.AnimationClip.prototype = { }; -/* - "animation" : { - "name" : "Action", - "fps" : 25, - "length" : 2.0, - "hierarchy" : [ - { - "parent" : -1, - "keys" : [ - { - "time":0, - "pos" :[0.532239,5.88733,-0.119685], - "rot" :[-0.451519,0.544179,0.544179,0.451519], - "scl" :[1,1,1] - }, -*/ - THREE.AnimationClip.CreateMorphAnimationFromNames = function( morphTargetNames, duration ) { - //console.log( morphTargetNames, duration ); var tracks = []; var frameStep = duration / morphTargetNames.length; - //console.log( 'frameStep', frameStep ); for( var i = 0; i < morphTargetNames.length; i ++ ) { @@ -113,8 +93,6 @@ THREE.AnimationClip.CreateMorphAnimationFromNames = function( morphTargetNames, } - //console.log( 'keys', keys ); - var morphName = morphTargetNames[i]; var trackName = '.morphTargetInfluences[' + morphName + ']'; var track = new THREE.KeyframeTrack( trackName, keys ); @@ -123,7 +101,6 @@ THREE.AnimationClip.CreateMorphAnimationFromNames = function( morphTargetNames, } var clip = new THREE.AnimationClip( 'morphAnimation', duration, tracks ); - //console.log( 'morphAnimationClip', clip ); return clip; }; @@ -170,8 +147,6 @@ THREE.AnimationClip.FromImplicitMorphTargetAnimations = function( morphTargets, } - //console.log( animations ); - var clips = []; for( var i = 0; i < animationsArray.length; i ++ ) { @@ -190,7 +165,6 @@ THREE.AnimationClip.FromImplicitMorphTargetAnimations = function( morphTargets, THREE.AnimationClip.FromJSONLoaderAnimation = function( animation, bones, nodeName ) { - //var animation = jsonLoader.animation; if( ! animation ) { console.error( " no animation in JSONLoader data" ); return null; @@ -228,7 +202,6 @@ THREE.AnimationClip.FromJSONLoaderAnimation = function( animation, bones, nodeNa var tracks = []; - //var boneList = jsonLoader.bones; var animationTracks = animation.hierarchy; for ( var h = 0; h < animationTracks.length; h ++ ) { @@ -282,7 +255,6 @@ THREE.AnimationClip.FromJSONLoaderAnimation = function( animation, bones, nodeNa else { var boneName = nodeName + '.bones[' + bones[ h ].name + ']'; - //console.log( 'boneName', boneName ); // track contains positions... var positionTrack = convertTrack( boneName + '.position', animationKeys, 'pos', function( animationKey ) { @@ -314,7 +286,6 @@ THREE.AnimationClip.FromJSONLoaderAnimation = function( animation, bones, nodeNa } var clip = new THREE.AnimationClip( clipName, duration, tracks ); - //console.log( 'clipFromJSONLoaderAnimation', clip ); return clip;
true
Other
mrdoob
three.js
86523359e466eec6cfefa7549a9843c691927c21.json
remove debugging output.
src/animation/AnimationMixer.js
@@ -2,7 +2,6 @@ * * Mixes together the AnimationClips scheduled by AnimationActions and applies them to the root and subtree * - * TODO: MUST add support for blending between AnimationActions based on their weights, right now only the last AnimationAction is applied at full weight. * * @author Ben Houston / http://clara.io/ * @author David Sarno / http://lighthaus.us/ @@ -24,7 +23,6 @@ THREE.AnimationMixer.prototype = { constructor: THREE.AnimationMixer, addAction: function( action ) { - //console.log( this.root.name + ".AnimationMixer.addAnimationAction( " + action.name + " )" ); this.actions.push( action ); @@ -67,7 +65,6 @@ THREE.AnimationMixer.prototype = { }, removeAction: function( action ) { - //console.log( this.root.name + ".AnimationMixer.addRemove( " + action.name + " )" ); var index = this.actions.indexOf( action ); @@ -160,14 +157,11 @@ THREE.AnimationMixer.prototype = { var mixerDeltaTime = deltaTime * this.timeScale; this.time += mixerDeltaTime; - //console.log( this.root.name + ".AnimationMixer.update( " + time + " )" ); - for( var i = 0; i < this.actions.length; i ++ ) { var action = this.actions[i]; var weight = action.getWeightAt( this.time ); - //console.log( action.clip.name, weight, this.time ); var actionTimeScale = action.getTimeScaleAt( this.time ); var actionDeltaTime = mixerDeltaTime * actionTimeScale;
true
Other
mrdoob
three.js
86523359e466eec6cfefa7549a9843c691927c21.json
remove debugging output.
src/animation/AnimationUtils.js
@@ -53,15 +53,13 @@ if( exemplarValue.lerp ) { return function( a, b, alpha ) { - //console.log( a, b ); return a.lerp( b, alpha ); } } if( exemplarValue.slerp ) { return function( a, b, alpha ) { - //console.log( a, b ); return a.slerp( b, alpha ); }
true
Other
mrdoob
three.js
86523359e466eec6cfefa7549a9843c691927c21.json
remove debugging output.
src/animation/KeyframeTrack.js
@@ -1,8 +1,6 @@ /** * - * A Track that returns a keyframe interpolated value. - * - * TODO: Add cubic in addition to linear interpolation. + * A Track that returns a keyframe interpolated value, currently linearly interpolated * * @author Ben Houston / http://clara.io/ * @author David Sarno / http://lighthaus.us/ @@ -17,10 +15,8 @@ THREE.KeyframeTrack = function ( name, keys ) { // local cache of value type to avoid allocations during runtime. this.result = THREE.AnimationUtils.clone( this.keys[0].value ); - //console.log( 'constructor result', this.result ) // the index of the last result, used as a starting point for local search. - // TODO: this is okay in the keyframetrack, but it would be better stored in AnimationAction eventually. this.lastIndex = 0; this.sort(); @@ -33,9 +29,6 @@ THREE.KeyframeTrack.prototype = { constructor: THREE.KeyframeTrack, getAt: function( time ) { - //if( /morph/i.test( this.name ) ) { - // console.log( 'KeyframeTrack[' + this.name + '].getAt( ' + time + ' )' ); - //} // this can not go higher than this.keys.length. while( ( this.lastIndex < this.keys.length ) && ( time >= this.keys[this.lastIndex].time ) ) { @@ -47,10 +40,6 @@ THREE.KeyframeTrack.prototype = { this.lastIndex --; } - //if( /morph/i.test( this.name ) ) { - // console.log( "lastIndex: ", this.lastIndex ); - //} - if( this.lastIndex >= this.keys.length ) { this.setResult( this.keys[ this.keys.length - 1 ].value ); @@ -80,19 +69,6 @@ THREE.KeyframeTrack.prototype = { var alpha = ( time - prevKey.time ) / ( currentKey.time - prevKey.time ); this.result = this.lerp( this.result, currentKey.value, alpha ); - //console.log( 'lerp result', this.result ) - /*if( /morph/i.test( this.name ) ) { - console.log( ' interpolated: ', { - index: this.lastIndex, - value: this.result, - alpha: alpha, - time0: this.keys[ this.lastIndex - 1 ].time, - time1: this.keys[ this.lastIndex ].time, - value0: this.keys[ this.lastIndex - 1 ].value, - value1: this.keys[ this.lastIndex ].value - } ); - }*/ - return this.result; }, @@ -143,7 +119,7 @@ THREE.KeyframeTrack.prototype = { }(), // ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable - // TODO: ensure that all key.values in a track are all of the same type (otherwise interpolation makes no sense.) + // One could eventually ensure that all key.values in a track are all of the same type (otherwise interpolation makes no sense.) validate: function() { var prevKey = null; @@ -184,7 +160,6 @@ THREE.KeyframeTrack.prototype = { }, // currently only removes equivalent sequential keys (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0), which are common in morph target animations - // TODO: linear based interpolation optimization with an error threshold. optimize: function() { var newKeys = []; @@ -196,22 +171,21 @@ THREE.KeyframeTrack.prototype = { for( var i = 1; i < this.keys.length - 1; i ++ ) { var currKey = this.keys[i]; var nextKey = this.keys[i+1]; - //console.log( prevKey, currKey, nextKey ); // if prevKey & currKey are the same time, remove currKey. If you want immediate adjacent keys, use an epsilon offset // it is not possible to have two keys at the same time as we sort them. The sort is not stable on keys with the same time. if( ( prevKey.time === currKey.time ) ) { - //console.log( 'removing key at the same time', currKey ); + continue; + } // remove completely unnecessary keyframes that are the same as their prev and next keys if( equalsFunc( prevKey.value, currKey.value ) && equalsFunc( currKey.value, nextKey.value ) ) { - //console.log( 'removing key identical to prev and next', currKey ); + continue; - } - // TODO:add here a check for linear interpolation optimization. + } // determine if interpolation is required prevKey.constantToNext = equalsFunc( prevKey.value, currKey.value ); @@ -221,9 +195,6 @@ THREE.KeyframeTrack.prototype = { } newKeys.push( this.keys[ this.keys.length - 1 ] ); - //if( ( this.keys.length - newKeys.length ) > 0 ) { - //console.log( ' optimizing removed keys:', ( this.keys.length - newKeys.length ), this.name ); - //} this.keys = newKeys; }, @@ -251,9 +222,7 @@ THREE.KeyframeTrack.prototype = { // remove last keys first because it doesn't affect the position of the first keys (the otherway around doesn't work as easily) if( ( firstKeysToRemove + lastKeysToRemove ) > 0 ) { - //console.log( ' triming removed keys: first and last', firstKeysToRemove, lastKeysToRemove, this.keys ); this.keys = this.keys.splice( firstKeysToRemove, this.keys.length - lastKeysToRemove - firstKeysToRemove );; - //console.log( ' result', this.keys ); } }
true
Other
mrdoob
three.js
86523359e466eec6cfefa7549a9843c691927c21.json
remove debugging output.
src/animation/PropertyBinding.js
@@ -15,7 +15,6 @@ THREE.PropertyBinding = function ( rootNode, trackName ) { var parseResults = THREE.PropertyBinding.parseTrackName( trackName ); - //console.log( parseResults ); this.directoryName = parseResults.directoryName; this.nodeName = parseResults.nodeName; this.objectName = parseResults.objectName; @@ -54,15 +53,13 @@ THREE.PropertyBinding.prototype = { this.cumulativeWeight = weight; } - //console.log( this ); } else { var lerpAlpha = weight / ( this.cumulativeWeight + weight ); this.cumulativeValue = this.lerpValue( this.cumulativeValue, value, lerpAlpha ); this.cumulativeWeight += weight; - //console.log( this ); } @@ -83,16 +80,10 @@ THREE.PropertyBinding.prototype = { }, - // creates the member functions: - // - setValue( value ) - // - getValue() - // - triggerDirty() - + // bind to the real property in the scene graph, remember original value, memorize various accessors for speed/inefficiency bind: function() { if( this.isBound ) return; - - //console.log( "PropertyBinding", this ); var targetObject = this.node; @@ -120,15 +111,13 @@ THREE.PropertyBinding.prototype = { console.error( ' can not bind to bones as node does not have a skeleton', this ); return; } - // TODO/OPTIMIZE, skip this if propertyIndex is already an integer, and convert the integer string to a true integer. + // potential future optimization: skip this if propertyIndex is already an integer, and convert the integer string to a true integer. targetObject = targetObject.skeleton.bones; // support resolving morphTarget names into indices. - //console.log( " resolving bone name: ", this.objectIndex ); for( var i = 0; i < targetObject.length; i ++ ) { if( targetObject[i].name === this.objectIndex ) { - //console.log( " resolved to index: ", i ); this.objectIndex = i; break; } @@ -165,10 +154,9 @@ THREE.PropertyBinding.prototype = { if( this.propertyIndex !== undefined ) { if( this.propertyName === "morphTargetInfluences" ) { - // TODO/OPTIMIZE, skip this if propertyIndex is already an integer, and convert the integer string to a true integer. + // potential optimization, skip this if propertyIndex is already an integer, and convert the integer string to a true integer. // support resolving morphTarget names into indices. - //console.log( " resolving morphTargetInfluence name: ", this.propertyIndex ); if( ! targetObject.geometry ) { console.error( ' can not bind to morphTargetInfluences becasuse node does not have a geometry', this ); } @@ -178,14 +166,12 @@ THREE.PropertyBinding.prototype = { for( var i = 0; i < this.node.geometry.morphTargets.length; i ++ ) { if( targetObject.geometry.morphTargets[i].name === this.propertyIndex ) { - //console.log( " resolved to index: ", i ); this.propertyIndex = i; break; } } } - //console.log( ' update property array ' + this.propertyName + '[' + this.propertyIndex + '] via assignment.' ); this.setValue = function( value ) { if( ! this.equalsValue( nodeProperty[ this.propertyIndex ], value ) ) { nodeProperty[ this.propertyIndex ] = value; @@ -202,7 +188,6 @@ THREE.PropertyBinding.prototype = { // must use copy for Object3D.Euler/Quaternion else if( nodeProperty.copy ) { - //console.log( ' update property ' + this.name + '.' + this.propertyName + ' via a set() function.' ); this.setValue = function( value ) { if( ! this.equalsValue( nodeProperty, value ) ) { nodeProperty.copy( value ); @@ -219,7 +204,6 @@ THREE.PropertyBinding.prototype = { // otherwise just set the property directly on the node (do not use nodeProperty as it may not be a reference object) else { - //console.log( ' update property ' + this.name + '.' + this.propertyName + ' via assignment.' ); this.setValue = function( value ) { if( ! this.equalsValue( targetObject[ this.propertyName ], value ) ) { targetObject[ this.propertyName ] = value; @@ -237,15 +221,13 @@ THREE.PropertyBinding.prototype = { // trigger node dirty if( targetObject.needsUpdate !== undefined ) { // material - //console.log( ' triggering material as dirty' ); this.triggerDirty = function() { this.node.needsUpdate = true; } } else if( targetObject.matrixWorldNeedsUpdate !== undefined ) { // node transform - //console.log( ' triggering node as dirty' ); this.triggerDirty = function() { targetObject.matrixWorldNeedsUpdate = true; } @@ -327,8 +309,6 @@ THREE.PropertyBinding.parseTrackName = function( trackName ) { propertyIndex: matches[11] // allowed to be null, specifies that the whole property is set. }; - //console.log( "PropertyBinding.parseTrackName", trackName, results, matches ); - if( results.propertyName === null || results.propertyName.length === 0 ) { throw new Error( "can not parse propertyName from trackName: " + trackName ); } @@ -340,11 +320,8 @@ THREE.PropertyBinding.parseTrackName = function( trackName ) { // TODO: Cache this at some point THREE.PropertyBinding.findNode = function( root, nodeName ) { - //console.log( 'AnimationUtils.findNode( ' + root.name + ', nodeName: ' + nodeName + ')', root ); - if( ! nodeName || nodeName === "" || nodeName === "root" || nodeName === "." || nodeName === -1 || nodeName === root.name || nodeName === root.uuid ) { - //console.log( ' root.' ); return root; } @@ -373,7 +350,6 @@ THREE.PropertyBinding.findNode = function( root, nodeName ) { if( bone ) { - //console.log( ' bone: ' + bone.name + '.' ); return bone; } @@ -408,14 +384,11 @@ THREE.PropertyBinding.findNode = function( root, nodeName ) { if( subTreeNode ) { - //console.log( ' node: ' + subTreeNode.name + '.' ); return subTreeNode; } } - //console.log( " <null>. No node found for name: " + nodeName ); - return null; }
true
Other
mrdoob
three.js
e9cd1a28124456ee10d080ac1e311e047cdb61de.json
memorize the KeyframeTrack.setResult()
src/animation/KeyframeTrack.js
@@ -19,6 +19,8 @@ THREE.KeyframeTrack = function ( name, keys ) { this.result = THREE.AnimationUtils.clone( this.keys[0].value ); //console.log( 'constructor result', this.result ) + // the index of the last result, used as a starting point for local search. + // TODO: this is okay in the keyframetrack, but it would be better stored in AnimationAction eventually. this.lastIndex = 0; this.sort(); @@ -66,8 +68,9 @@ THREE.KeyframeTrack.prototype = { var prevKey = this.keys[ this.lastIndex - 1 ]; this.setResult( prevKey.value ); + // if true, means that prev/current keys are identical, thus no interpolation required. if( prevKey.constantToNext ) { - + return this.result; } @@ -76,6 +79,7 @@ THREE.KeyframeTrack.prototype = { var currentKey = this.keys[ this.lastIndex ]; var alpha = ( time - prevKey.time ) / ( currentKey.time - prevKey.time ); this.result = this.lerp( this.result, currentKey.value, alpha ); + //console.log( 'lerp result', this.result ) /*if( /morph/i.test( this.name ) ) { console.log( ' interpolated: ', { @@ -94,12 +98,24 @@ THREE.KeyframeTrack.prototype = { }, setResult: function( value ) { + if( this.result.copy ) { - this.result.copy( value ); + + setResult = function( value ) { + this.result.copy( value ); + } + } else { - this.result = value; + + setResult = function( value ) { + this.result = value; + } + } + + this.setResult( value ); + }, // memoization of the lerp function for speed.
false
Other
mrdoob
three.js
457f64b976e1403ffcd844159079e6371a4f0c1a.json
fix ObjectLoader for cached images
src/loaders/ImageLoader.js
@@ -20,14 +20,22 @@ THREE.ImageLoader.prototype = { if ( cached !== undefined ) { + scope.manager.itemStart( url ); + if ( onLoad ) { setTimeout( function () { onLoad( cached ); + scope.manager.itemEnd( url ); + }, 0 ); + } else { + + scope.manager.itemEnd( url ); + } return cached;
false
Other
mrdoob
three.js
5e2d24d08cdfc453f44aa232ae7be5236f41dfbc.json
Fix broken link to Canvas 2D Context specification
docs/api/renderers/CanvasRenderer.html
@@ -1,162 +1,162 @@ -<!DOCTYPE html> -<html lang="en"> - <head> +<!DOCTYPE html> +<html lang="en"> + <head> <meta charset="utf-8" /> - <base href="../../" /> - <script src="list.js"></script> - <script src="page.js"></script> - <link type="text/css" rel="stylesheet" href="page.css" /> - </head> - <body> - <h1>[name]</h1> - - <div class="desc"> - The Canvas renderer displays your beautifully crafted scenes <em>not</em> using WebGL, but draws it using the (slower) <a href="http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas/">Canvas 2D Context</a> API.<br /><br /> - This renderer can be a nice fallback from [page:WebGLRenderer] for simple scenes: - - <code> - function webglAvailable() { - try { - var canvas = document.createElement( 'canvas' ); - return !!( window.WebGLRenderingContext && ( - canvas.getContext( 'webgl' ) || - canvas.getContext( 'experimental-webgl' ) ) - ); - } catch ( e ) { - return false; - } - } - - if ( webglAvailable() ) { - renderer = new THREE.WebGLRenderer(); - } else { - renderer = new THREE.CanvasRenderer(); - } - </code> - - Note: both WebGLRenderer and CanvasRenderer are embedded in the web page using an HTML5 &lt;canvas&gt; tag. - The "Canvas" in CanvasRenderer means it uses Canvas 2D instead of WebGL.<br /><br /> - - Don't confuse either CanvasRenderer with the SoftwareRenderer example, which simulates a screen buffer in a Javascript array. - </div> - - <h2>Constructor</h2> - - - <h3>[name]([page:object parameters])</h3> - <div>parameters is an optional object with properties defining the renderer's behaviour. The constructor also accepts no parameters at all. In all cases, it will assume sane defaults when parameters are missing.</div> - - <div> - canvas — A [page:Canvas] where the renderer draws its output. - </div> - - - <h2>Properties</h2> - - <h3>[property:Object info]</h3> - - <div> - An object with a series of statistical information about the graphics board memory and the rendering process. Useful for debugging or just for the sake of curiosity. The object contains the following fields:</div> - <ul> - <li>render: - <ul> - <li>vertices</li> - <li>faces</li> - </ul> - </li> - </ul> - </div> - - <h3>[property:DOMElement domElement]</h3> - - <div> - A [page:Canvas] where the renderer draws its output.<br /> - This is automatically created by the renderer in the constructor (if not provided already); you just need to add it to your page. - </div> - - <h3>[property:Boolean autoClear]</h3> - <div> - Defines whether the renderer should automatically clear its output before rendering. - </div> - - <h3>[property:Boolean sortObjects]</h3> - <div> - Defines whether the renderer should sort objects. Default is true.<br /> - Note: Sorting is used to attempt to properly render objects that have some degree of transparency. By definition, sorting objects may not work in all cases. Depending on the needs of application, it may be neccessary to turn off sorting and use other methods to deal with transparency rendering e.g. manually determining the object rendering order. - </div> - - <h3>[property:boolean sortElements]</h3> - <div> - Defines whether the renderer should sort the face of each object. Default is true. - </div> - - - <h2>Methods</h2> - - <h3>[method:null render]([page:Scene scene], [page:Camera camera])</h3> - <div> - scene -- The scene to render. <br /> - camera -- the camera to view the scene. - </div> - <div> - Render a scene using a camera. - </div> - - <h3>[method:null clear]()</h3> - <div> - Tells the renderer to clear its color drawing buffer with the clearcolor. - </div> - - <h3>[method:null setClearColor]([page:Color color], [page:number alpha])</h3> - <div> - color -- The color to clear the canvas with. <br /> - alpha -- The alpha channel to clear the canvas with. - </div> - <div> - This set the clearColor and the clearAlpha. - </div> - - - <h3>[method:null setSize]([page:Number width], [page:Number height])</h3> - <div> - width -- The width of the drawing canvas. <br /> - height -- The height of the drawing canvas. - </div> - <div> - This set the size of the drawing canvas and if updateStyle is set, then the css of the canvas is updated too. - </div> - - <h3>[method:null setClearColorHex]([page:number hex], [page:number alpha])</h3> - <div> - hex -- The the hexadecimal value of the color to clear the canvas with. <br /> - alpha -- The alpha channel to clear the canvas with. - </div> - <div> - This set the clearColor and the clearAlpha. - </div> - - <h3>[method:number getClearColorHex]()</h3> - <div> - Returns the [page:number hex] color. - </div> - - <h3>[method:number getClearAlpha]()</h3> - <div> - Returns the alpha value. - </div> - - <h2>Empty Methods to Maintain Compatibility with [page:WebglRenderer]</h2> - <div> - [method:null clearColor]()<br/> - [method:null clearDepth]()<br/> - [method:null clearStencil]()<br/> - [method:null setFaceCulling]()<br/> - [method:null supportsVertexTextures]()<br/> - [method:number getMaxAnisotropy]() - returns 1 <br/> - </div> - - <h2>Source</h2> - - [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] - </body> -</html> + <base href="../../" /> + <script src="list.js"></script> + <script src="page.js"></script> + <link type="text/css" rel="stylesheet" href="page.css" /> + </head> + <body> + <h1>[name]</h1> + + <div class="desc"> + The Canvas renderer displays your beautifully crafted scenes <em>not</em> using WebGL, but draws it using the (slower) <a href="http://drafts.htmlwg.org/2dcontext/html5_canvas_CR/Overview.html">Canvas 2D Context</a> API.<br /><br /> + This renderer can be a nice fallback from [page:WebGLRenderer] for simple scenes: + + <code> + function webglAvailable() { + try { + var canvas = document.createElement( 'canvas' ); + return !!( window.WebGLRenderingContext && ( + canvas.getContext( 'webgl' ) || + canvas.getContext( 'experimental-webgl' ) ) + ); + } catch ( e ) { + return false; + } + } + + if ( webglAvailable() ) { + renderer = new THREE.WebGLRenderer(); + } else { + renderer = new THREE.CanvasRenderer(); + } + </code> + + Note: both WebGLRenderer and CanvasRenderer are embedded in the web page using an HTML5 &lt;canvas&gt; tag. + The "Canvas" in CanvasRenderer means it uses Canvas 2D instead of WebGL.<br /><br /> + + Don't confuse either CanvasRenderer with the SoftwareRenderer example, which simulates a screen buffer in a Javascript array. + </div> + + <h2>Constructor</h2> + + + <h3>[name]([page:object parameters])</h3> + <div>parameters is an optional object with properties defining the renderer's behaviour. The constructor also accepts no parameters at all. In all cases, it will assume sane defaults when parameters are missing.</div> + + <div> + canvas — A [page:Canvas] where the renderer draws its output. + </div> + + + <h2>Properties</h2> + + <h3>[property:Object info]</h3> + + <div> + An object with a series of statistical information about the graphics board memory and the rendering process. Useful for debugging or just for the sake of curiosity. The object contains the following fields:</div> + <ul> + <li>render: + <ul> + <li>vertices</li> + <li>faces</li> + </ul> + </li> + </ul> + </div> + + <h3>[property:DOMElement domElement]</h3> + + <div> + A [page:Canvas] where the renderer draws its output.<br /> + This is automatically created by the renderer in the constructor (if not provided already); you just need to add it to your page. + </div> + + <h3>[property:Boolean autoClear]</h3> + <div> + Defines whether the renderer should automatically clear its output before rendering. + </div> + + <h3>[property:Boolean sortObjects]</h3> + <div> + Defines whether the renderer should sort objects. Default is true.<br /> + Note: Sorting is used to attempt to properly render objects that have some degree of transparency. By definition, sorting objects may not work in all cases. Depending on the needs of application, it may be neccessary to turn off sorting and use other methods to deal with transparency rendering e.g. manually determining the object rendering order. + </div> + + <h3>[property:boolean sortElements]</h3> + <div> + Defines whether the renderer should sort the face of each object. Default is true. + </div> + + + <h2>Methods</h2> + + <h3>[method:null render]([page:Scene scene], [page:Camera camera])</h3> + <div> + scene -- The scene to render. <br /> + camera -- the camera to view the scene. + </div> + <div> + Render a scene using a camera. + </div> + + <h3>[method:null clear]()</h3> + <div> + Tells the renderer to clear its color drawing buffer with the clearcolor. + </div> + + <h3>[method:null setClearColor]([page:Color color], [page:number alpha])</h3> + <div> + color -- The color to clear the canvas with. <br /> + alpha -- The alpha channel to clear the canvas with. + </div> + <div> + This set the clearColor and the clearAlpha. + </div> + + + <h3>[method:null setSize]([page:Number width], [page:Number height])</h3> + <div> + width -- The width of the drawing canvas. <br /> + height -- The height of the drawing canvas. + </div> + <div> + This set the size of the drawing canvas and if updateStyle is set, then the css of the canvas is updated too. + </div> + + <h3>[method:null setClearColorHex]([page:number hex], [page:number alpha])</h3> + <div> + hex -- The the hexadecimal value of the color to clear the canvas with. <br /> + alpha -- The alpha channel to clear the canvas with. + </div> + <div> + This set the clearColor and the clearAlpha. + </div> + + <h3>[method:number getClearColorHex]()</h3> + <div> + Returns the [page:number hex] color. + </div> + + <h3>[method:number getClearAlpha]()</h3> + <div> + Returns the alpha value. + </div> + + <h2>Empty Methods to Maintain Compatibility with [page:WebglRenderer]</h2> + <div> + [method:null clearColor]()<br/> + [method:null clearDepth]()<br/> + [method:null clearStencil]()<br/> + [method:null setFaceCulling]()<br/> + [method:null supportsVertexTextures]()<br/> + [method:number getMaxAnisotropy]() - returns 1 <br/> + </div> + + <h2>Source</h2> + + [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + </body> +</html>
false
Other
mrdoob
three.js
91dfdffddd7e2875ea12d21816bd0c333ecdd972.json
Implement normals loading
examples/js/loaders/AMFLoader.js
@@ -275,6 +275,7 @@ THREE.AMFLoader.prototype = { function loadMeshVertices( node ) { var vertArray = []; + var normalArray = []; var currVerticesNode = node.firstElementChild; while ( currVerticesNode ) { @@ -303,7 +304,18 @@ THREE.AMFLoader.prototype = { } + } else if ( vNode.nodeName === "normal" ) { + + var nx = vNode.getElementsByTagName("nx")[0].textContent; + var ny = vNode.getElementsByTagName("ny")[0].textContent; + var nz = vNode.getElementsByTagName("nz")[0].textContent; + + normalArray.push(nx); + normalArray.push(ny); + normalArray.push(nz); + } + vNode = vNode.nextElementSibling; } @@ -313,7 +325,7 @@ THREE.AMFLoader.prototype = { } - return vertArray; + return { "vertices": vertArray, "normals": normalArray }; } @@ -345,13 +357,16 @@ THREE.AMFLoader.prototype = { } else if ( currObjNode.nodeName === "mesh" ) { var currMeshNode = currObjNode.firstElementChild; - var mesh = { "vertices": [], "volumes": [], "color": currColor }; + var mesh = { "vertices": [], "normals": [], "volumes": [], "color": currColor }; while ( currMeshNode ) { if ( currMeshNode.nodeName === "vertices" ) { - mesh.vertices = mesh.vertices.concat( loadMeshVertices( currMeshNode ) ); + var loadedVertices = loadMeshVertices( currMeshNode ); + + mesh.normals = mesh.normals.concat( loadedVertices.normals ); + mesh.vertices = mesh.vertices.concat( loadedVertices.vertices ); } else if ( currMeshNode.nodeName === "volume" ) { @@ -433,10 +448,19 @@ THREE.AMFLoader.prototype = { for ( var i = 0; i < meshes.length; i ++ ) { + var objDefaultMaterial = defaultMaterial; var mesh = meshes[ i ]; var meshVertices = Float32Array.from( mesh.vertices ); var vertices = new THREE.BufferAttribute( Float32Array.from( meshVertices ), 3 ); - var objDefaultMaterial = defaultMaterial; + var meshNormals = null; + var normals = null; + + if ( mesh.normals.length ) { + + meshNormals = Float32Array.from( mesh.normals ); + normals = new THREE.BufferAttribute( Float32Array.from( meshNormals ), 3 ); + + } if ( mesh.color ) { @@ -461,12 +485,17 @@ THREE.AMFLoader.prototype = { var volume = volumes[ j ]; var newGeometry = new THREE.BufferGeometry(); var indexes = Uint32Array.from( volume.triangles ); - var normals = new Uint32Array( vertices.array.length ); var material = objDefaultMaterial; newGeometry.setIndex( new THREE.BufferAttribute( indexes, 1 ) ); newGeometry.addAttribute( 'position', vertices.clone() ); + if( normals ) { + + newGeometry.addAttribute( 'normal', normals.clone() ); + + } + if ( amfMaterials[ volume.materialid ] !== undefined ) { material = amfMaterials[ volume.materialid ];
false
Other
mrdoob
three.js
262fb39e67cdd95208ceed82277a258ce408a7c6.json
Implement normals loading
examples/js/loaders/AMFLoader.js
@@ -267,7 +267,7 @@ THREE.AMFLoader.prototype = { function loadMeshVertices( node ) { var vertArray = []; - + var normalArray = []; var currVerticesNode = node.firstElementChild; while ( currVerticesNode ) { @@ -288,7 +288,18 @@ THREE.AMFLoader.prototype = { vertArray.push(y); vertArray.push(z); + } else if ( vNode.nodeName === "normal" ) { + + var nx = vNode.getElementsByTagName("nx")[0].textContent; + var ny = vNode.getElementsByTagName("ny")[0].textContent; + var nz = vNode.getElementsByTagName("nz")[0].textContent; + + normalArray.push(nx); + normalArray.push(ny); + normalArray.push(nz); + } + vNode = vNode.nextElementSibling; } @@ -298,7 +309,7 @@ THREE.AMFLoader.prototype = { } - return vertArray; + return { "vertices": vertArray, "normals": normalArray }; } @@ -330,13 +341,16 @@ THREE.AMFLoader.prototype = { } else if ( currObjNode.nodeName === "mesh" ) { var currMeshNode = currObjNode.firstElementChild; - var mesh = { "vertices": [], "volumes": [], "color": currColor }; + var mesh = { "vertices": [], "normals": [], "volumes": [], "color": currColor }; while ( currMeshNode ) { if ( currMeshNode.nodeName === "vertices" ) { - mesh.vertices = mesh.vertices.concat( loadMeshVertices( currMeshNode ) ); + var loadedVertices = loadMeshVertices( currMeshNode ); + + mesh.normals = mesh.normals.concat( loadedVertices.normals ); + mesh.vertices = mesh.vertices.concat( loadedVertices.vertices ); } else if ( currMeshNode.nodeName === "volume" ) { @@ -418,10 +432,19 @@ THREE.AMFLoader.prototype = { for ( var i = 0; i < meshes.length; i ++ ) { + var objDefaultMaterial = defaultMaterial; var mesh = meshes[ i ]; var meshVertices = Float32Array.from( mesh.vertices ); var vertices = new THREE.BufferAttribute( Float32Array.from( meshVertices ), 3 ); - var objDefaultMaterial = defaultMaterial; + var meshNormals = null; + var normals = null; + + if ( mesh.normals.length ) { + + meshNormals = Float32Array.from( mesh.normals ); + normals = new THREE.BufferAttribute( Float32Array.from( meshNormals ), 3 ); + + } if ( mesh.color ) { @@ -446,12 +469,17 @@ THREE.AMFLoader.prototype = { var volume = volumes[ j ]; var newGeometry = new THREE.BufferGeometry(); var indexes = Uint32Array.from( volume.triangles ); - var normals = new Uint32Array( vertices.array.length ); var material = objDefaultMaterial; newGeometry.setIndex( new THREE.BufferAttribute( indexes, 1 ) ); newGeometry.addAttribute( 'position', vertices.clone() ); + if( normals ) { + + newGeometry.addAttribute( 'normal', normals.clone() ); + + } + if ( amfMaterials[ volume.materialid ] !== undefined ) { material = amfMaterials[ volume.materialid ];
false
Other
mrdoob
three.js
fcd853dad665ffa76218d1233468782f9992a997.json
Enforce order of x, y, z and v1, v2, v3 elements
examples/js/loaders/AMFLoader.js
@@ -246,21 +246,13 @@ THREE.AMFLoader.prototype = { } else if ( currVolumeNode.nodeName === "triangle" ) { - var triangleNode = currVolumeNode.firstElementChild; + var v1 = currVolumeNode.getElementsByTagName("v1")[0].textContent; + var v2 = currVolumeNode.getElementsByTagName("v2")[0].textContent; + var v3 = currVolumeNode.getElementsByTagName("v3")[0].textContent; - while ( triangleNode ) { - - if ( triangleNode.nodeName === "v1" || - triangleNode.nodeName === "v2" || - triangleNode.nodeName === "v3" ) { - - volume.triangles.push( triangleNode.textContent ); - - } - - triangleNode = triangleNode.nextElementSibling; - - } + volume.triangles.push( v1 ); + volume.triangles.push( v2 ); + volume.triangles.push( v3 ); } @@ -275,6 +267,7 @@ THREE.AMFLoader.prototype = { function loadMeshVertices( node ) { var vertArray = []; + var currVerticesNode = node.firstElementChild; while ( currVerticesNode ) { @@ -287,21 +280,13 @@ THREE.AMFLoader.prototype = { if ( vNode.nodeName === "coordinates" ) { - var coordNode = vNode.firstElementChild; - - while ( coordNode ) { - - if ( coordNode.nodeName === "x" || - coordNode.nodeName === "y" || - coordNode.nodeName === "z" ) { - - vertArray.push( coordNode.textContent ); - - } - - coordNode = coordNode.nextElementSibling; + var x = vNode.getElementsByTagName("x")[0].textContent; + var y = vNode.getElementsByTagName("y")[0].textContent; + var z = vNode.getElementsByTagName("z")[0].textContent; - } + vertArray.push(x); + vertArray.push(y); + vertArray.push(z); } vNode = vNode.nextElementSibling;
false
Other
mrdoob
three.js
914c4bdcccd265d8c5f31df7f3f50dcba2e133da.json
remove useless foreground
examples/webgl_read_float_buffer.html
@@ -89,7 +89,7 @@ var container, stats; - var cameraRTT, camera, sceneRTT, sceneScreen, scene, renderer, zmesh1, zmesh2; + var cameraRTT, sceneRTT, sceneScreen, renderer, zmesh1, zmesh2; var mouseX = 0, mouseY = 0; @@ -108,15 +108,11 @@ container = document.getElementById( 'container' ); - camera = new THREE.PerspectiveCamera( 30, window.innerWidth / window.innerHeight, 1, 10000 ); - camera.position.z = 100; - cameraRTT = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 10000, 10000 ); cameraRTT.position.z = 100; // - scene = new THREE.Scene(); sceneRTT = new THREE.Scene(); sceneScreen = new THREE.Scene(); @@ -173,28 +169,6 @@ quad.position.z = - 100; sceneScreen.add( quad ); - var n = 5, - geometry = new THREE.SphereGeometry( 10, 64, 32 ), - material2 = new THREE.MeshBasicMaterial( { color: 0xffffff, map: rtTexture } ); - - for ( var j = 0; j < n; j ++ ) { - - for ( var i = 0; i < n; i ++ ) { - - mesh = new THREE.Mesh( geometry, material2 ); - - mesh.position.x = ( i - ( n - 1 ) / 2 ) * 20; - mesh.position.y = ( j - ( n - 1 ) / 2 ) * 20; - mesh.position.z = 0; - - mesh.rotation.y = - Math.PI / 2; - - scene.add( mesh ); - - } - - } - renderer = new THREE.WebGLRenderer(); renderer.setPixelRatio( window.devicePixelRatio ); renderer.setSize( window.innerWidth, window.innerHeight ); @@ -245,11 +219,6 @@ var time = Date.now() * 0.0015; - camera.position.x += ( mouseX - camera.position.x ) * .05; - camera.position.y += ( - mouseY - camera.position.y ) * .05; - - camera.lookAt( scene.position ); - if ( zmesh1 && zmesh2 ) { zmesh1.rotation.y = - time; @@ -275,12 +244,6 @@ renderer.render( sceneScreen, cameraRTT ); - // Render second scene to screen - // (using first scene as regular texture) - - renderer.render( scene, camera ); - - var read = new Float32Array( 4 ); renderer.readRenderTargetPixels( rtTexture, windowHalfX + mouseX, windowHalfY - mouseY, 1, 1, read );
false
Other
mrdoob
three.js
4985ed03dbfa59fb722af18fa66f4c347d034ae9.json
update morphanimmesh to work with the new mixer.
examples/js/MD2Character.js
@@ -52,7 +52,7 @@ THREE.MD2Character = function () { scope.root.add( mesh ); scope.meshBody = mesh; - scope.activeAnimationClipName = geo.firstAnimationClip.name; + scope.activeAnimationClipName = mesh.firstAnimationClip.name; checkLoadingComplete();
true
Other
mrdoob
three.js
4985ed03dbfa59fb722af18fa66f4c347d034ae9.json
update morphanimmesh to work with the new mixer.
src/animation/PropertyBinding.js
@@ -23,8 +23,8 @@ THREE.PropertyBinding = function ( rootNode, trackName ) { this.propertyName = parseResults.propertyName; this.propertyIndex = parseResults.propertyIndex; - this.node = THREE.PropertyBinding.findNode( rootNode, this.nodeName ); - + this.node = THREE.PropertyBinding.findNode( rootNode, this.nodeName ) || rootNode; + this.cumulativeValue = null; this.cumulativeWeight = 0; }; @@ -340,7 +340,7 @@ THREE.PropertyBinding.parseTrackName = function( trackName ) { // TODO: Cache this at some point THREE.PropertyBinding.findNode = function( root, nodeName ) { - //console.log( 'AnimationUtils.findNode( ' + root.name + ', nodeName: ' + nodeName + ')'); + //console.log( 'AnimationUtils.findNode( ' + root.name + ', nodeName: ' + nodeName + ')', root ); if( ! nodeName || nodeName === "" || nodeName === "root" || nodeName === "." || nodeName === -1 || nodeName === root.name || nodeName === root.uuid ) {
true
Other
mrdoob
three.js
4985ed03dbfa59fb722af18fa66f4c347d034ae9.json
update morphanimmesh to work with the new mixer.
src/objects/MorphAnimMesh.js
@@ -36,7 +36,7 @@ THREE.MorphAnimMesh.prototype.parseAnimations = function () { }; -THREE.MorphAnimMesh.prototype.playAnimation = function ( label ) { +THREE.MorphAnimMesh.prototype.playAnimation = function ( label, fps ) { this.mixer.removeAllActions(); @@ -50,7 +50,9 @@ THREE.MorphAnimMesh.prototype.playAnimation = function ( label ) { if ( clip ) { - this.mixer.addAction( new THREE.AnimationAction( clip, 0, 1, 1, true ) ); + var action = new THREE.AnimationAction( clip, 0, 1, 1, true ); + action.timeScale = ( clip.tracks.length * fps ) / clip.duration; + this.mixer.addAction( action ); } else {
true
Other
mrdoob
three.js
9583d29532fa647c261579e1b9b40190f971d03a.json
fix skeleton in example, better comments.
examples/webgl_animation_skinning_morph.html
@@ -285,6 +285,7 @@ if( mixer ) { mixer.update( delta ); + helper.update(); } renderer.render( scene, camera );
true
Other
mrdoob
three.js
9583d29532fa647c261579e1b9b40190f971d03a.json
fix skeleton in example, better comments.
src/animation/AnimationUtils.js
@@ -41,7 +41,6 @@ }, - // TODO/OPTIMIZATION: Accumulator should be writable and it will get rid of the *.clone() calls that are likely slow. getLerpFunc: function( exemplarValue, interTrack ) { if( exemplarValue === undefined || exemplarValue === null ) throw new Error( "examplarValue is null" );
true
Other
mrdoob
three.js
9583d29532fa647c261579e1b9b40190f971d03a.json
fix skeleton in example, better comments.
src/animation/KeyframeTrack.js
@@ -30,8 +30,6 @@ THREE.KeyframeTrack.prototype = { constructor: THREE.KeyframeTrack, - // TODO: this is a straight forward linear search for the key that corresponds to this time, this - // should be optimized. getAt: function( time ) { //if( /morph/i.test( this.name ) ) { // console.log( 'KeyframeTrack[' + this.name + '].getAt( ' + time + ' )' );
true
Other
mrdoob
three.js
e3b2c7593c1a415db6a8892a1b7a8806f361c9b8.json
introduce time awareness in AnimationAction.
src/animation/AnimationAction.js
@@ -14,6 +14,8 @@ THREE.AnimationAction = function ( clip, startTime, timeScale, weight, loop ) { this.weight = weight || 1; this.loop = loop || clip.loop || false; this.enabled = true; // allow for easy disabling of the action. + + this.time = 0; }; THREE.AnimationAction.prototype = { @@ -24,7 +26,7 @@ THREE.AnimationAction.prototype = { //console.log( 'AnimationAction[' + this.clip.name + '].toAnimationClipTime( ' + time + ' )' ); - var clipTime = ( time - this.startTime ) * this.timeScale; + var clipTime = ( time - this.startTime ) * this.getTimeScaleAt( time ); //console.log( ' clipTime: ' + clipTime ); var duration = this.clip.duration; @@ -48,11 +50,19 @@ THREE.AnimationAction.prototype = { } }, - getAt: function( time ) { + init: function( time ) { + + this.time = time; + + }, + + update: function( deltaTime ) { //console.log( 'AnimationAction[' + this.clip.name + '].getAt( ' + time + ' )' ); - var clipTime = this.toAnimationClipTime( time ); + this.time += deltaTime; + + var clipTime = this.toAnimationClipTime( this.time ); var clipResults = this.clip.getAt( clipTime ); @@ -62,6 +72,18 @@ THREE.AnimationAction.prototype = { }, + getTimeScaleAt: function( time ) { + + if( this.timeScale.getAt ) { + // pass in time, not clip time, allows for fadein/fadeout across multiple loops of the clip + return this.timeScale.getAt( time ); + + } + + return this.timeScale; + + }, + getWeightAt: function( time ) { if( this.weight.getAt ) {
true
Other
mrdoob
three.js
e3b2c7593c1a415db6a8892a1b7a8806f361c9b8.json
introduce time awareness in AnimationAction.
src/animation/AnimationMixer.js
@@ -142,7 +142,7 @@ THREE.AnimationMixer.prototype = { var endStartRatio = 1.0 / startEndRatio; this.wrap( fadeOutAction, 1.0, startEndRatio, duration ); - this.wrap( fadeInAction, endStartRatio, 1.0, duration ); + this.wrap( action, endStartRatio, 1.0, duration ); }
true
Other
mrdoob
three.js
0ffea7b8f2a80eff8e8c4d90880b8c75e01a40f5.json
fix MorphBlendMesh setAnimationFps() bugfix for: When setAnimationFPS then animation.duration is NaN.
src/extras/objects/MorphBlendMesh.js
@@ -33,8 +33,8 @@ THREE.MorphBlendMesh.prototype.createAnimation = function ( name, start, end, fp var animation = { - startFrame: start, - endFrame: end, + start: start, + end: end, length: end - start + 1, @@ -280,7 +280,7 @@ THREE.MorphBlendMesh.prototype.update = function ( delta ) { } - var keyframe = animation.startFrame + THREE.Math.clamp( Math.floor( animation.time / frameTime ), 0, animation.length - 1 ); + var keyframe = animation.start + THREE.Math.clamp( Math.floor( animation.time / frameTime ), 0, animation.length - 1 ); var weight = animation.weight; if ( keyframe !== animation.currentFrame ) {
false
Other
mrdoob
three.js
c35c65b4778f39c0896712fdc7bde380c4577629.json
fix wrong constructor
src/renderers/WebGLRenderer.js
@@ -213,7 +213,7 @@ THREE.WebGLRenderer = function ( parameters ) { var state = new THREE.WebGLState( _gl, extensions, paramThreeToGL ); var properties = new THREE.WebGLProperties(); var objects = new THREE.WebGLObjects( _gl, properties, this.info ); - var programCache = new THREE.WebGLPrograms( this, _gl, extensions ); + var programCache = new THREE.WebGLPrograms( this, capabilities ); var bufferRenderer = new THREE.WebGLBufferRenderer( _gl, extensions, _infoRender ); var indexedBufferRenderer = new THREE.WebGLIndexedBufferRenderer( _gl, extensions, _infoRender );
false
Other
mrdoob
three.js
aa7aac30757a13c075e557cfa28ae72e7b6c3f7c.json
use tab instead of whitespace
test/unit/cameras/Camera.js
@@ -5,8 +5,8 @@ module( "Camera" ); test( "lookAt", function() { - var obj = new THREE.Camera(); - obj.lookAt(new THREE.Vector3(0, 1, -1)); + var obj = new THREE.Camera(); + obj.lookAt(new THREE.Vector3(0, 1, -1)); ok( obj.rotation.x * (180 / Math.PI) === 45 , "x is equal" ); });
true
Other
mrdoob
three.js
aa7aac30757a13c075e557cfa28ae72e7b6c3f7c.json
use tab instead of whitespace
test/unit/core/Object3D.js
@@ -7,96 +7,96 @@ module( "Object3D" ); var RadToDeg = 180 / Math.PI; test( "rotateX", function() { - var obj = new THREE.Object3D(); + var obj = new THREE.Object3D(); - var angleInRad = 1.562; - obj.rotateX(angleInRad); + var angleInRad = 1.562; + obj.rotateX(angleInRad); - // should calculate the correct rotation on x - checkIfFloatsAreEqual(obj.rotation.x, angleInRad); + // should calculate the correct rotation on x + checkIfFloatsAreEqual(obj.rotation.x, angleInRad); }); test( "rotateY", function() { - var obj = new THREE.Object3D(); + var obj = new THREE.Object3D(); - var angleInRad = -0.346; - obj.rotateY(angleInRad); + var angleInRad = -0.346; + obj.rotateY(angleInRad); - // should calculate the correct rotation on y - checkIfFloatsAreEqual(obj.rotation.y, angleInRad); + // should calculate the correct rotation on y + checkIfFloatsAreEqual(obj.rotation.y, angleInRad); }); test( "rotateZ", function() { - var obj = new THREE.Object3D(); + var obj = new THREE.Object3D(); - var angleInRad = 1; - obj.rotateZ(angleInRad); + var angleInRad = 1; + obj.rotateZ(angleInRad); - // should calculate the correct rotation on y - checkIfFloatsAreEqual(obj.rotation.z, angleInRad); + // should calculate the correct rotation on y + checkIfFloatsAreEqual(obj.rotation.z, angleInRad); }); test( "translateOnAxis", function() { - var obj = new THREE.Object3D(); + var obj = new THREE.Object3D(); - // get a reference object for comparing + // get a reference object for comparing var reference = {x: 1, y: 1.23, z: -4.56}; - obj.translateOnAxis(new THREE.Vector3(1, 0, 0), 1); - obj.translateOnAxis(new THREE.Vector3(0, 1, 0), 1.23); - obj.translateOnAxis(new THREE.Vector3(0, 0, 1), -4.56); + obj.translateOnAxis(new THREE.Vector3(1, 0, 0), 1); + obj.translateOnAxis(new THREE.Vector3(0, 1, 0), 1.23); + obj.translateOnAxis(new THREE.Vector3(0, 0, 1), -4.56); - checkIfPropsAreEqual(reference, obj.position); + checkIfPropsAreEqual(reference, obj.position); }); test( "translateX", function() { - var obj = new THREE.Object3D(); - obj.translateX(1.234); + var obj = new THREE.Object3D(); + obj.translateX(1.234); - ok( obj.position.x === 1.234 , "x is equal" ); + ok( obj.position.x === 1.234 , "x is equal" ); }); test( "translateY", function() { - var obj = new THREE.Object3D(); - obj.translateY(1.234); + var obj = new THREE.Object3D(); + obj.translateY(1.234); - ok( obj.position.y === 1.234 , "y is equal" ); + ok( obj.position.y === 1.234 , "y is equal" ); }); test( "translateZ", function() { - var obj = new THREE.Object3D(); - obj.translateZ(1.234); + var obj = new THREE.Object3D(); + obj.translateZ(1.234); - ok( obj.position.z === 1.234 , "z is equal" ); + ok( obj.position.z === 1.234 , "z is equal" ); }); test( "lookAt", function() { - var obj = new THREE.Object3D(); - obj.lookAt(new THREE.Vector3(0, -1, 1)); + var obj = new THREE.Object3D(); + obj.lookAt(new THREE.Vector3(0, -1, 1)); - ok( obj.rotation.x * RadToDeg === 45 , "x is equal" ); + ok( obj.rotation.x * RadToDeg === 45 , "x is equal" ); }); test( "getWorldQuaternion", function() { - var obj = new THREE.Object3D(); + var obj = new THREE.Object3D(); - obj.lookAt(new THREE.Vector3(0, -1, 1)); - ok( obj.getWorldRotation().x * RadToDeg === 45 , "x is equal" ); + obj.lookAt(new THREE.Vector3(0, -1, 1)); + ok( obj.getWorldRotation().x * RadToDeg === 45 , "x is equal" ); - obj.lookAt(new THREE.Vector3(1, 0, 0)); - ok( obj.getWorldRotation().y * RadToDeg === 90 , "y is equal" ); + obj.lookAt(new THREE.Vector3(1, 0, 0)); + ok( obj.getWorldRotation().y * RadToDeg === 90 , "y is equal" ); }); function checkIfPropsAreEqual(reference, obj) { - ok( obj.x === reference.x , "x is equal" ); - ok( obj.y === reference.y , "y is equal!" ); - ok( obj.z === reference.z , "z is equal!" ); + ok( obj.x === reference.x , "x is equal" ); + ok( obj.y === reference.y , "y is equal!" ); + ok( obj.z === reference.z , "z is equal!" ); } // since float equal checking is a mess in js, one solution is to cut off // decimal places function checkIfFloatsAreEqual(f1, f2) { - var f1Rounded = ((f1 * 1000) | 0) / 1000; - var f2Rounded = ((f2 * 1000) | 0) / 1000; + var f1Rounded = ((f1 * 1000) | 0) / 1000; + var f2Rounded = ((f2 * 1000) | 0) / 1000; - ok( f1Rounded === f2Rounded, "passed" ); + ok( f1Rounded === f2Rounded, "passed" ); }
true
Other
mrdoob
three.js
e9d593b78ac841a6eb10d04cf92283fbfb532ce4.json
fix two broken examples.
examples/webgl_loader_scene.html
@@ -92,6 +92,7 @@ </div> <script src="../build/three.min.js"></script> + <script src="js/MorphAnimMesh.js"></script> <script src="js/loaders/collada/Animation.js"></script> <script src="js/loaders/collada/AnimationHandler.js"></script> <script src="js/loaders/collada/KeyFrameAnimation.js"></script>
true
Other
mrdoob
three.js
e9d593b78ac841a6eb10d04cf92283fbfb532ce4.json
fix two broken examples.
examples/webgl_shadowmap_performance.html
@@ -237,7 +237,7 @@ scene.add( mesh ); - mixer = new THREE.AnimationMixer( scene ); + //mixer = new THREE.AnimationMixer( scene ); // MORPHS @@ -254,8 +254,10 @@ var mesh = new THREE.Mesh( geometry, material ); mesh.speed = speed; + var mixer = new THREE.AnimationMixer( this.mesh ); mixer.addAction( new THREE.AnimationAction( geometry.clips[0], Math.random() ).warpToDuration( duration ).setLocalRoot( mesh ) ); + mesh.mixer = mixer; mesh.position.set( x, y, z ); mesh.rotation.y = Math.PI/2; @@ -366,13 +368,13 @@ var delta = clock.getDelta(); - if( mixer ) mixer.update( delta ); + //if( mixer ) mixer.update( delta ); for ( var i = 0; i < morphs.length; i ++ ) { morph = morphs[ i ]; - // morph.mixer.update( delta ); + morph.mixer.update( delta ); morph.position.x += morph.speed * delta;
true
Other
mrdoob
three.js
a73bd4341d144c68aa14be04b492f09635ae4475.json
Convert canvas horse morph to Mixer.
examples/canvas_morphtargets_horse.html
@@ -26,7 +26,7 @@ var container, stats; var camera, scene, projector, renderer; - var mesh, animation; + var mesh, mixer; init(); animate(); @@ -69,8 +69,10 @@ mesh.scale.set( 1.5, 1.5, 1.5 ); scene.add( mesh ); - animation = new THREE.MorphAnimation( mesh ); - animation.play(); + mixer = new THREE.AnimationMixer( mesh ); + + var clip = THREE.AnimationClip.CreateFromMorphTargetSequence( 'gallop', geometry.morphTargets, 30 ); + mixer.addAction( new THREE.AnimationAction( clip ).warpToDuration( 1.5 ) ); } ); @@ -129,11 +131,11 @@ camera.lookAt( camera.target ); - if ( animation ) { + if ( mixer ) { var time = Date.now(); - animation.update( time - prevTime ); + mixer.update( ( time - prevTime ) * 0.001 ); prevTime = time;
false
Other
mrdoob
three.js
a1fb6c3134d6dd68035aecab72bfaf58ff3a3c20.json
fix bug, not calling AnimationAction.init.
src/animation/AnimationMixer.js
@@ -26,6 +26,7 @@ THREE.AnimationMixer.prototype = { // TODO: check for duplicate action names? Or provide each action with a UUID? this.actions.push( action ); + action.init( this.time ); action.mixer = this; var tracks = action.clip.tracks;
false
Other
mrdoob
three.js
3a24fca91de0b174b09292dd888625561e13ed64.json
use a single mixer for shadow map performance.
examples/webgl_shadowmap_performance.html
@@ -57,7 +57,7 @@ var NEAR = 5, FAR = 3000; - var morph, morphs = []; + var morph, morphs = [], mixer; var light; @@ -237,6 +237,8 @@ scene.add( mesh ); + mixer = new THREE.AnimationMixer( scene ); + // MORPHS function addMorph( geometry, speed, duration, x, y, z, fudgeColor ) { @@ -252,11 +254,8 @@ var mesh = new THREE.Mesh( geometry, material ); mesh.speed = speed; - var mixer = new THREE.AnimationMixer( mesh ); - mixer.addAction( new THREE.AnimationAction( geometry.clips[0] ).warpToDuration( duration ) ); - mixer.update( 600 * Math.random() ); - mesh.mixer = mixer; - + mixer.addAction( new THREE.AnimationAction( geometry.clips[0], Math.random() ).warpToDuration( duration ).setLocalRoot( mesh ) ); + mesh.position.set( x, y, z ); mesh.rotation.y = Math.PI/2; @@ -367,11 +366,13 @@ var delta = clock.getDelta(); + if( mixer ) mixer.update( delta ); + for ( var i = 0; i < morphs.length; i ++ ) { morph = morphs[ i ]; - morph.mixer.update( delta ); + // morph.mixer.update( delta ); morph.position.x += morph.speed * delta;
false
Other
mrdoob
three.js
e29f28d6486eb2d49f62122d9cc7d7f92e05fac1.json
Extract updateAttribute from updateObject
src/renderers/webgl/WebGLObjects.js
@@ -168,60 +168,67 @@ THREE.WebGLObjects = function ( gl, properties, info ) { for ( var name in attributes ) { var attribute = attributes[ name ]; + updateAttribute( attribute, name ); - var bufferType = ( name === 'index' ) ? gl.ELEMENT_ARRAY_BUFFER : gl.ARRAY_BUFFER; + } - var data = ( attribute instanceof THREE.InterleavedBufferAttribute ) ? attribute.data : attribute; + } - var attributeProperties = properties.get( data ); + function updateAttribute ( attribute, name ) { - if ( attributeProperties.__webglBuffer === undefined ) { + var bufferType = ( name === 'index' ) ? gl.ELEMENT_ARRAY_BUFFER : gl.ARRAY_BUFFER; - attributeProperties.__webglBuffer = gl.createBuffer(); - gl.bindBuffer( bufferType, attributeProperties.__webglBuffer ); + var data = ( attribute instanceof THREE.InterleavedBufferAttribute ) ? attribute.data : attribute; - var usage = gl.STATIC_DRAW; + var attributeProperties = properties.get( data ); - if ( data instanceof THREE.DynamicBufferAttribute - || ( data instanceof THREE.InstancedBufferAttribute && data.dynamic === true ) - || ( data instanceof THREE.InterleavedBuffer && data.dynamic === true ) ) { + if ( attributeProperties.__webglBuffer === undefined ) { - usage = gl.DYNAMIC_DRAW; + attributeProperties.__webglBuffer = gl.createBuffer(); + gl.bindBuffer( bufferType, attributeProperties.__webglBuffer ); - } + var usage = gl.STATIC_DRAW; - gl.bufferData( bufferType, data.array, usage ); + if ( data instanceof THREE.DynamicBufferAttribute + || ( data instanceof THREE.InstancedBufferAttribute && data.dynamic === true ) + || ( data instanceof THREE.InterleavedBuffer && data.dynamic === true ) ) { - data.needsUpdate = false; + usage = gl.DYNAMIC_DRAW; - } else if ( data.needsUpdate === true ) { + } - gl.bindBuffer( bufferType, attributeProperties.__webglBuffer ); + gl.bufferData( bufferType, data.array, usage ); - if ( data.updateRange === undefined || data.updateRange.count === -1 ) { // Not using update ranges + data.needsUpdate = false; - gl.bufferSubData( bufferType, 0, data.array ); + } else if ( data.needsUpdate === true ) { - } else if ( data.updateRange.count === 0 ) { + gl.bindBuffer( bufferType, attributeProperties.__webglBuffer ); - console.error( 'THREE.WebGLRenderer.updateObject: using updateRange for THREE.DynamicBufferAttribute and marked as needsUpdate but count is 0, ensure you are using set methods or updating manually.' ); + if ( data.updateRange === undefined || data.updateRange.count === -1 ) { // Not using update ranges - } else { + gl.bufferSubData( bufferType, 0, data.array ); - gl.bufferSubData( bufferType, data.updateRange.offset * data.array.BYTES_PER_ELEMENT, - data.array.subarray( data.updateRange.offset, data.updateRange.offset + data.updateRange.count ) ); + } else if ( data.updateRange.count === 0 ) { - data.updateRange.count = 0; // reset range + console.error( 'THREE.WebGLRenderer.updateObject: using updateRange for THREE.DynamicBufferAttribute and marked as needsUpdate but count is 0, ensure you are using set methods or updating manually.' ); - } + } else { - data.needsUpdate = false; + gl.bufferSubData( bufferType, data.updateRange.offset * data.array.BYTES_PER_ELEMENT, + data.array.subarray( data.updateRange.offset, data.updateRange.offset + data.updateRange.count ) ); + + data.updateRange.count = 0; // reset range } + data.needsUpdate = false; + } - }; + } + + // returns the webgl buffer for a specified attribute this.getAttributeBuffer = function ( attribute ) {
false
Other
mrdoob
three.js
48a4d9de1bb57bfd58626bd4ccb0b6e249afec39.json
Verify all faces of cubemap with DDSCAPS2_CUBEMAP
examples/js/loaders/DDSLoader.js
@@ -16,7 +16,7 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) { var dds = { mipmaps: [], width: 0, height: 0, format: null, mipmapCount: 1 }; // Adapted from @toji's DDS utils - // https://github.com/toji/webgl-texture-utils/blob/master/texture-util/dds.js + // https://github.com/toji/webgl-texture-utils/blob/master/texture-util/dds.js // All values and structures referenced from: // http://msdn.microsoft.com/en-us/library/bb943991.aspx/ @@ -175,9 +175,9 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) { default: - if ( header[ off_RGBBitCount ] == 32 + if ( header[ off_RGBBitCount ] === 32 && header[ off_RBitMask ] & 0xff0000 - && header[ off_GBitMask ] & 0xff00 + && header[ off_GBitMask ] & 0xff00 && header[ off_BBitMask ] & 0xff && header[ off_ABitMask ] & 0xff000000 ) { @@ -201,9 +201,21 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) { } - //TODO: Verify that all faces of the cubemap are present with DDSCAPS2_CUBEMAP_POSITIVEX, etc. + var caps2 = header[ off_caps2 ]; + dds.isCubemap = caps2 & DDSCAPS2_CUBEMAP ? true : false; + if ( dds.isCubemap && ( + ! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEX ) || + ! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEX ) || + ! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEY ) || + ! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEY ) || + ! ( caps2 & DDSCAPS2_CUBEMAP_POSITIVEZ ) || + ! ( caps2 & DDSCAPS2_CUBEMAP_NEGATIVEZ ) + ) ) { + + console.error( 'THREE.DDSLoader.parse: Incomplete cubemap faces' ); + return dds; - dds.isCubemap = header[ off_caps2 ] & DDSCAPS2_CUBEMAP ? true : false; + } dds.width = header[ off_width ]; dds.height = header[ off_height ]; @@ -212,13 +224,13 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) { // Extract mipmaps buffers - var width = dds.width; - var height = dds.height; - var faces = dds.isCubemap ? 6 : 1; for ( var face = 0; face < faces; face ++ ) { + var width = dds.width; + var height = dds.height; + for ( var i = 0; i < dds.mipmapCount; i ++ ) { if ( isRGBAUncompressed ) { @@ -232,23 +244,19 @@ THREE.DDSLoader.parse = function ( buffer, loadMipmaps ) { var byteArray = new Uint8Array( buffer, dataOffset, dataLength ); } - + var mipmap = { "data": byteArray, "width": width, "height": height }; dds.mipmaps.push( mipmap ); dataOffset += dataLength; - width = Math.max( width * 0.5, 1 ); - height = Math.max( height * 0.5, 1 ); + width = Math.max( width >> 1, 1 ); + height = Math.max( height >> 1, 1 ); } - width = dds.width; - height = dds.height; - } return dds; }; -
false
Other
mrdoob
three.js
eeb750bdd3ac9d120913d51678610a24f1e63b09.json
remove dat GUI, not needed.
examples/webgl_animation_scene.html
@@ -44,7 +44,6 @@ <script src="js/Detector.js"></script> <script src="js/libs/stats.min.js"></script> - <script src="js/libs/dat.gui.min.js"></script> <script> @@ -136,12 +135,6 @@ } ); - // GUI - - initGUI(); - - // - window.addEventListener( 'resize', onWindowResize, false ); } @@ -158,20 +151,6 @@ } - function initGUI() { - - var API = { - 'show model' : true, - 'show skeleton' : false - }; - - var gui = new dat.GUI(); - - gui.add( API, 'show model' ).onChange( function() { mesh.visible = API[ 'show model' ]; } ); - - gui.add( API, 'show skeleton' ).onChange( function() { helper.visible = API[ 'show skeleton' ]; } ); - - } function onDocumentMouseMove( event ) {
false
Other
mrdoob
three.js
4cc67551a7d0a1fc8874d36271e9a3cd676a075a.json
add more authors.
utils/exporters/blender/addons/io_three/__init__.py
@@ -38,7 +38,7 @@ bl_info = { 'name': "Three.js Format", - 'author': "repsac, mrdoob, yomotsu, mpk, jpweeks, rkusa, tschw", + 'author': "repsac, mrdoob, yomotsu, mpk, jpweeks, rkusa, tschw, jackcaron, bhouston", 'version': (1, 5, 0), 'blender': (2, 74, 0), 'location': "File > Export",
false
Other
mrdoob
three.js
d4f5a1f4456da6efef4e106f0e9ea305a491f4f8.json
remove supports in WebGLCapabilities
src/renderers/webgl/WebGLCapabilities.js
@@ -47,7 +47,7 @@ THREE.WebGLCapabilities = function( gl, extensions, parameters ) { this.vertexTextures = this.maxVertexTextures > 0; this.floatFragmentTextures = !! extensions.get( 'OES_texture_float' ); - this.floatVertexTextures = this.supportsVertexTextures && this.supportsFloatFragmentTextures; + this.floatVertexTextures = this.vertexTextures && this.floatFragmentTextures; var _maxPrecision = this.getMaxPrecision( this.precision );
false
Other
mrdoob
three.js
42520325677e0ae51c157e87ffd0c065ff8770c6.json
remove getMaxPrecision from webglstate
src/renderers/webgl/WebGLState.js
@@ -142,36 +142,6 @@ THREE.WebGLState = function ( gl, extensions, paramThreeToGL ) { }; - this.getMaxPrecision = function ( precision ) { - - if ( precision === 'highp' ) { - - if ( gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.HIGH_FLOAT ).precision > 0 && - gl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ).precision > 0 ) { - - return 'highp'; - - } - - precision = 'mediump'; - - } - - if ( precision === 'mediump' ) { - - if ( gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.MEDIUM_FLOAT ).precision > 0 && - gl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ).precision > 0 ) { - - return 'mediump'; - - } - - } - - return 'lowp'; - - }; - this.setBlending = function ( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha ) { if ( blending !== currentBlending ) {
false
Other
mrdoob
three.js
5af00a5efc88f431deed5d4dcba292c973d336fb.json
Use parameter setup Done similar to what CircleGeometry does.
examples/js/geometries/TeapotGeometry.js
@@ -395,18 +395,28 @@ THREE.TeapotGeometry = function ( size, segments, bottom, lid, body, fitLid, bli this.type = 'TeapotGeometry'; - this.size = size || 50; + this.parameters = { + size: size, + segments: segments, + bottom: bottom, + lid: lid, + body: body, + fitLid: fitLid, + blinn: blinn + }; + + size = size || 50; // number of segments per patch - this.segments = Math.max( 2, Math.floor( segments ) || 10 ); + segments = segments !== undefined ? Math.max( 2, Math.floor( segments ) || 10 ) : 10; // which parts should be visible - this.bottom = bottom === undefined ? true : bottom; - this.lid = lid === undefined ? true : lid; - this.body = body === undefined ? true : body; + bottom = bottom === undefined ? true : bottom; + lid = lid === undefined ? true : lid; + body = body === undefined ? true : body; // Should the lid be snug? It's not traditional, so off by default - this.fitLid = fitLid === undefined ? false : fitLid; + fitLid = fitLid === undefined ? false : fitLid; // Jim Blinn scaled the teapot down in size by about 1.3 for // some rendering tests. He liked the new proportions that he kept @@ -416,13 +426,13 @@ THREE.TeapotGeometry = function ( size, segments, bottom, lid, body, fitLid, bli // real teapot is more like 1.25, but since 1.3 is the traditional // value given, we use it here. var blinnScale = 1.3; - this.blinn = blinn === undefined ? true : blinn; + blinn = blinn === undefined ? true : blinn; // scale the size to be the real scaling factor - var maxHeight = 3.15 * ( this.blinn ? 1 : blinnScale ); + var maxHeight = 3.15 * ( blinn ? 1 : blinnScale ); var maxHeight2 = maxHeight / 2; - var trueSize = this.size / maxHeight2; + var trueSize = size / maxHeight2; var normals = [], uvs = []; // Bezier form @@ -483,10 +493,10 @@ THREE.TeapotGeometry = function ( size, segments, bottom, lid, body, fitLid, bli } - var minPatches = this.body ? 0 : 20; - var maxPatches = this.bottom ? 32 : 28; + var minPatches = body ? 0 : 20; + var maxPatches = bottom ? 32 : 28; - vertPerRow = this.segments + 1; + vertPerRow = segments + 1; eps = 0.0000001; @@ -496,7 +506,7 @@ THREE.TeapotGeometry = function ( size, segments, bottom, lid, body, fitLid, bli // lid is in the middle of the data, patches 20-27, // so ignore it for this part of the loop if the lid is not desired - if ( this.lid || ( surf < 20 || surf >= 28 ) ) { + if ( lid || ( surf < 20 || surf >= 28 ) ) { // get M * G * M matrix for x,y,z for ( i = 0 ; i < 3 ; i ++ ) { @@ -511,7 +521,7 @@ THREE.TeapotGeometry = function ( size, segments, bottom, lid, body, fitLid, bli // is the lid to be made larger, and is this a point on the lid // that is X or Y? - if ( this.fitLid && ( surf >= 20 && surf < 28 ) && ( i !== 2 ) ) { + if ( fitLid && ( surf >= 20 && surf < 28 ) && ( i !== 2 ) ) { // increase XY size by 7.7%, found empirically. I don't // increase Z so that the teapot will continue to fit in the @@ -522,7 +532,7 @@ THREE.TeapotGeometry = function ( size, segments, bottom, lid, body, fitLid, bli // Blinn "fixed" the teapot by dividing Z by blinnScale, and that's the // data we now use. The original teapot is taller. Fix it: - if ( ! this.blinn && ( i === 2 ) ) { + if ( ! blinn && ( i === 2 ) ) { g[ c * 4 + r ] *= blinnScale; @@ -542,13 +552,13 @@ THREE.TeapotGeometry = function ( size, segments, bottom, lid, body, fitLid, bli } // step along, get points, and output - for ( sstep = 0 ; sstep <= this.segments ; sstep ++ ) { + for ( sstep = 0 ; sstep <= segments ; sstep ++ ) { - s = sstep / this.segments; + s = sstep / segments; - for ( tstep = 0 ; tstep <= this.segments ; tstep ++ ) { + for ( tstep = 0 ; tstep <= segments ; tstep ++ ) { - t = tstep / this.segments; + t = tstep / segments; // point from basis // get power vectors and their derivatives @@ -631,9 +641,9 @@ THREE.TeapotGeometry = function ( size, segments, bottom, lid, body, fitLid, bli } // save the faces - for ( sstep = 0 ; sstep < this.segments ; sstep ++ ) { + for ( sstep = 0 ; sstep < segments ; sstep ++ ) { - for ( tstep = 0 ; tstep < this.segments ; tstep ++ ) { + for ( tstep = 0 ; tstep < segments ; tstep ++ ) { v1 = surfCount * vertPerRow * vertPerRow + sstep * vertPerRow + tstep; v2 = v1 + 1; @@ -673,3 +683,19 @@ THREE.TeapotGeometry = function ( size, segments, bottom, lid, body, fitLid, bli THREE.TeapotGeometry.prototype = Object.create( THREE.Geometry.prototype ); THREE.TeapotGeometry.prototype.constructor = THREE.TeapotGeometry; + +THREE.TeapotGeometry.prototype.clone = function () { + + var geometry = new THREE.TeapotGeometry( + this.parameters.size, + this.parameters.segments, + this.parameters.bottom, + this.parameters.lid, + this.parameters.body, + this.parameters.fitLid, + this.parameters.blinn + ); + + return geometry; + +}; \ No newline at end of file
false
Other
mrdoob
three.js
f017384f1d7541cfebd270c3a9ae05560ee589e9.json
fix issue with parameterName
src/renderers/webgl/WebGLProgramCache.js
@@ -15,7 +15,7 @@ THREE.WebGLProgramCache = function ( renderer1, gl, extensions ) { PointCloudMaterial: 'particle_basic' }; - var parameterNames = [ " precision", "supportsVertexTextures", "map", "envMap", "envMapMode", "lightMap", "aoMap", "emissiveMap", "bumpMap", "normalMap", "specularMap", "alphaMap", "combine", + var parameterNames = [ "precision", "supportsVertexTextures", "map", "envMap", "envMapMode", "lightMap", "aoMap", "emissiveMap", "bumpMap", "normalMap", "specularMap", "alphaMap", "combine", "vertexColors", "fog", "useFog", "fogExp", "flatShading", "sizeAttenuation", "logarithmicDepthBuffer", "skinning", "maxBones", "useVertexTexture", "morphTargets", "morphNormals", "maxMorphTargets", "maxMorphNormals", "maxDirLights", "maxPointLights", "maxSpotLights", "maxHemiLights", "maxShadows", "shadowMapEnabled", "shadowMapType", "shadowMapDebug", "alphaTest", "metal", "doubleSided", "flipSided" ];
false
Other
mrdoob
three.js
47ef34ec9dd5d2684348a25c35263ed8a18ccb0e.json
Fix broken ellipses
src/extras/core/Path.js
@@ -168,7 +168,13 @@ THREE.Path.prototype.ellipse = function ( aX, aY, xRadius, yRadius, THREE.Path.prototype.absellipse = function ( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) { - var args = Array.prototype.slice.call( arguments ); + var args = [ + aX, aY, + xRadius, yRadius, + aStartAngle, aEndAngle, + aClockwise, + aRotation || 0 // aRotation is optional. + ]; var curve = new THREE.EllipseCurve( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ); this.curves.push( curve ); @@ -387,7 +393,7 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) { yRadius = args[ 3 ], aStartAngle = args[ 4 ], aEndAngle = args[ 5 ], aClockwise = !! args[ 6 ], - aRotation = args[ 7 ] || 0; + aRotation = args[ 7 ]; var deltaAngle = aEndAngle - aStartAngle; @@ -419,9 +425,11 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) { if ( aRotation !== 0 ) { + var x = tx, y = ty; + // Rotate the point about the center of the ellipse. - tx = ( tx - aX ) * cos - ( ty - aY ) * sin + aX; - ty = ( tx - aX ) * sin + ( ty - aY ) * cos + aY; + tx = ( x - aX ) * cos - ( y - aY ) * sin + aX; + ty = ( x - aX ) * sin + ( y - aY ) * cos + aY; }
true
Other
mrdoob
three.js
47ef34ec9dd5d2684348a25c35263ed8a18ccb0e.json
Fix broken ellipses
src/extras/curves/EllipseCurve.js
@@ -49,9 +49,11 @@ THREE.EllipseCurve.prototype.getPoint = function ( t ) { var cos = Math.cos( this.aRotation ); var sin = Math.sin( this.aRotation ); + var tx = x, ty = y; + // Rotate the point about the center of the ellipse. - x = ( x - this.aX ) * cos - ( y - this.aY ) * sin + this.aX; - y = ( x - this.aX ) * sin + ( y - this.aY ) * cos + this.aY; + x = ( tx - this.aX ) * cos - ( ty - this.aY ) * sin + this.aX; + y = ( tx - this.aX ) * sin + ( ty - this.aY ) * cos + this.aY; }
true
Other
mrdoob
three.js
1a4762f0c535fd8fcd4a4dfdc7925bdf0098f412.json
fix slidertime start position
utils/exporters/max/ThreeJSAnimationExporter.ms
@@ -1526,6 +1526,7 @@ rollout ThreeJSExporter "ThreeJSExporter" function ExportScene = ( + slidertime = animationrange.start -- Extract meshes
false
Other
mrdoob
three.js
a15ffe8dd987fba876da6c14e37ee0506f01b771.json
fix bug in ObjectLoader.
src/loaders/ObjectLoader.js
@@ -621,7 +621,7 @@ THREE.ObjectLoader.prototype = { for ( var child in data.children ) { - object.add( this.parseObject( data.children[ child ], geometries, materials ) ); + object.add( this.parseObject( data.children[ child ], geometries, materials, tracks ) ); } @@ -633,19 +633,19 @@ THREE.ObjectLoader.prototype = { if( dataTracks.position ) { - tracks.add( THREE.VectorKeyframeTrack.parse( object.uuid + '.position', dataTracks.position ) ); + tracks.push( THREE.VectorKeyframeTrack.parse( object.uuid + '.position', dataTracks.position ) ); } if( dataTracks.quaternion ) { - tracks.add( THREE.QuaternionKeyframeTrack.parse( object.uuid + '.quaternion', dataTracks.quaternion ) ); + tracks.push( THREE.QuaternionKeyframeTrack.parse( object.uuid + '.quaternion', dataTracks.quaternion ) ); } if( dataTracks.scale ) { - tracks.add( THREE.VectorKeyframeTrack.parse( object.uuid + '.scale', dataTracks.scale ) ); + tracks.push( THREE.VectorKeyframeTrack.parse( object.uuid + '.scale', dataTracks.scale ) ); } }
false
Other
mrdoob
three.js
62f3060ace5b53cb0bf8174ad8d83c06cfa1ea40.json
Add Utah teapot as a geometry object; doc cleanup Add the Utah teapot geometry object, along with a demo showing its options. Also fix Matrix* documentation: match current constructor code, and clean up style.
docs/api/math/Matrix3.html
@@ -16,26 +16,9 @@ <h1>[name]</h1> <h2>Constructor</h2> - <h3>[name]([page:Float n11], [page:Float n12], [page:Float n13], [page:Float n21], [page:Float n22], [page:Float n23], [page:Float n31], [page:Float n32], [page:Float n33])</h3> + <h3>[name]()</h3> <div> - n11 -- [page:Float] <br /> - n12 -- [page:Float] <br /> - n13 -- [page:Float] <br /> - n21 -- [page:Float] <br /> - n22 -- [page:Float] <br /> - n23 -- [page:Float] <br /> - n31 -- [page:Float] <br /> - n32 -- [page:Float] <br /> - n33 -- [page:Float] - </div> - <div> - Initialize the 3x3 matrix with a row-major sequence of values.<br/><br/> - - n11, n12, n13,<br/> - n21, n22, n23,<br/> - n31, n32, n33<br/><br/> - - If no values are sent the matrix will be initialized as an identity matrix. + Creates and initializes the 3x3 matrix to the identity matrix. </div> @@ -44,7 +27,7 @@ <h2>Properties</h2> <h3>[property:Float32Array elements]</h3> <div> - Float32Array with column-major matrix values. + A column-major list of matrix values. </div> @@ -60,13 +43,13 @@ <h3>[method:Matrix3 transposeIntoArray]( [page:Array array] )</h3> array -- [page:Array] <br /> </div> <div> - Transposes this matrix into the supplied array, and returns itself. + Transposes this matrix into the supplied array, and returns itself unchanged. </div> <h3>[method:Float determinant]()</h3> <div> - Returns the matrix's determinant. + Computes and returns the determinant of this matrix. </div> <h3>[method:Matrix3 set]([page:Float n11], [page:Float n12], [page:Float n13], [page:Float n21], [page:Float n22], [page:Float n23], [page:Float n31], [page:Float n32], [page:Float n33]) [page:Matrix3 this]</h3> @@ -82,58 +65,58 @@ <h3>[method:Matrix3 set]([page:Float n11], [page:Float n12], [page:Float n13], [ n33 -- [page:Float] </div> <div> - Set the 3x3 matrix values to the given row-major sequence of values. + Sets the 3x3 matrix values to the given row-major sequence of values. </div> - <h3>[method:Matrix3 multiplyScalar]([page:Float scalar]) [page:Matrix3 this]</h3> + <h3>[method:Matrix3 multiplyScalar]([page:Float s]) [page:Matrix3 this]</h3> <div> scalar -- [page:Float] </div> <div> - Multiply every component of the matrix by a scalar value. + Multiplies every component of the matrix by the scalar value *s*. </div> <h3>[method:Array applyToVector3Array]([page:Array array])</h3> <div> array -- An array in the form [vector1x, vector1y, vector1z, vector2x, vector2y, vector2z, ...] </div> <div> - Multiply (apply) this matrix to every vector3 in the array. + Multiplies (applies) this matrix to every vector3 in the array. </div> - <h3>[method:Matrix3 getNormalMatrix]([page:Matrix4 matrix4]) [page:Matrix3 this]</h3> + <h3>[method:Matrix3 getNormalMatrix]([page:Matrix4 m]) [page:Matrix3 this]</h3> <div> - matrix4 -- [page:Matrix4] + m -- [page:Matrix4] </div> <div> - Set this matrix as the normal matrix of the passed [page:Matrix4 matrix4]. The normal matrix is the inverse transpose of the matrix. + Sets this matrix as the normal matrix (upper left 3x3)of the passed [page:Matrix4 matrix4]. The normal matrix is the inverse transpose of the matrix *m*. </div> - <h3>[method:Matrix3 getInverse]([page:Matrix4 matrix4], [page:Boolean throwOnInvertible]) [page:Matrix3 this]</h3> + <h3>[method:Matrix3 getInverse]([page:Matrix4 m], [page:Boolean throwOnInvertible]) [page:Matrix3 this]</h3> <div> - matrix4 -- [page:Matrix4] <br /> + m -- [page:Matrix4]<br /> throwOnInvertible -- [Page:Boolean] If true, throw an error if the matrix is invertible. </div> <div> Set this matrix to the inverse of the passed matrix. </div> - <h3>[method:Matrix3 copy]([page:Matrix3 matrix]) [page:Matrix3 this]</h3> + <h3>[method:Matrix3 copy]([page:Matrix3 m]) [page:Matrix3 this]</h3> <div> - matrix -- [page:Matrix3] + m -- [page:Matrix4] </div> <div> - Copy the values of the passed matrix. + Copies the values of matrix *m* into this matrix. </div> <h3>[method:Matrix3 clone]()</h3> <div> - Create a copy of the matrix. + Creates a copy of this matrix. </div> <h3>[method:Matrix3 identity]() [page:Matrix3 this]</h3> <div> - Set as an identity matrix.<br/><br/> + Resets this matrix to identity.<br/><br/> 1, 0, 0<br/> 0, 1, 0<br/>
true
Other
mrdoob
three.js
62f3060ace5b53cb0bf8174ad8d83c06cfa1ea40.json
Add Utah teapot as a geometry object; doc cleanup Add the Utah teapot geometry object, along with a demo showing its options. Also fix Matrix* documentation: match current constructor code, and clean up style.
docs/api/math/Matrix4.html
@@ -39,10 +39,10 @@ <h2>Example</h2> <h2>Constructor</h2> - <h3>[name]( [page:Float n11], [page:Float n12], [page:Float n13], [page:Float n14], [page:Float n21], [page:Float n22], [page:Float n23], [page:Float n24], [page:Float n31], [page:Float n32], [page:Float n33], [page:Float n34], [page:Float n41], [page:Float n42], [page:Float n43], [page:Float n44] )</h3> + <h3>[name]()</h3> <div> - Initialises the matrix with the supplied row-major values n11..n44, or just creates an identity matrix if no values are passed. + Creates and initializes the matrix to the identity matrix. </div> <h2>Properties</h2> @@ -64,20 +64,20 @@ <h3>[method:Matrix4 identity]() [page:Matrix4 this]</h3> <h3>[method:Matrix4 copy]( [page:Matrix4 m] ) [page:Matrix4 this]</h3> <div> - Copies a matrix *m* into this matrix. + Copies the values of matrix *m* into this matrix. </div> <h3>[method:Matrix4 copyPosition]( [page:Matrix4 m] ) [page:Matrix4 this]</h3> <div> Copies the translation component of the supplied matrix *m* into this matrix translation component. </div> - <h3>[method:Matrix4 makeBasis]( [page:Vector3 xAxis], [page:Vector3 yAxis], [page:Vector3 zAxis] ) [page:Matrix4 this]</h3> + <h3>[method:Matrix4 makeBasis]( [page:Vector3 xAxis], [page:Vector3 zAxis], [page:Vector3 zAxis] ) [page:Matrix4 this]</h3> <div> Creates the basis matrix consisting of the three provided axis vectors. Returns the current matrix. </div> - <h3>[method:Matrix4 extractBasis]( [page:Vector3 xAxis], [page:Vector3 yAxis], [page:Vector3 zAxis] ) [page:Matrix4 this]</h3> + <h3>[method:Matrix4 extractBasis]( [page:Vector3 xAxis], [page:Vector3 zAxis], [page:Vector3 zAxis] ) [page:Matrix4 this]</h3> <div> Extracts basis of into the three axis vectors provided. Returns the current matrix. </div> @@ -110,12 +110,12 @@ <h3>[method:Matrix4 multiplyToArray]( [page:Matrix4 a], [page:Matrix4 b], [page: <h3>[method:Matrix4 multiplyScalar]( [page:Float s] ) [page:Matrix4 this]</h3> <div> - Multiplies this matrix by *s*. + Multiplies every component of the matrix by a scalar value *s*. </div> <h3>[method:Float determinant]()</h3> <div> - Computes determinant of this matrix.<br /> + Computes and returns the determinant of this matrix.<br /> Based on [link:http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm] </div> @@ -142,7 +142,7 @@ <h3>[method:Matrix4 getInverse]( [page:Matrix4 m] ) [page:Matrix4 this]</h3> <h3>[method:Matrix4 makeRotationFromEuler]( [page:Euler euler] ) [page:Matrix4 this]</h3> <div> - euler — Rotation vector followed by order of rotations. Eg. "XYZ". + euler — Rotation vector followed by order of rotations, e.g., "XYZ". </div> <div> Sets the rotation submatrix of this matrix to the rotation specified by Euler angles, the rest of the matrix is identity.<br /> @@ -230,20 +230,20 @@ <h3>[method:Matrix4 makeOrthographic]( [page:Float left], [page:Float right], [p <h3>[method:Matrix4 clone]()</h3> <div> - Clones this matrix. + Creates a copy of this matrix. </div> <h3>[method:Array applyToVector3Array]([page:Array a])</h3> <div> array -- An array in the form [vector1x, vector1y, vector1z, vector2x, vector2y, vector2z, ...] </div> <div> - Multiply (apply) this matrix to every vector3 in the array. + Multiplies (applies) this matrix to every vector3 in the array. </div> <h3>[method:Float getMaxScaleOnAxis]()</h3> <div> - Gets the max scale value of the 3 axes. + Gets the maximum scale value of the 3 axes. </div> <h2>Source</h2>
true
Other
mrdoob
three.js
62f3060ace5b53cb0bf8174ad8d83c06cfa1ea40.json
Add Utah teapot as a geometry object; doc cleanup Add the Utah teapot geometry object, along with a demo showing its options. Also fix Matrix* documentation: match current constructor code, and clean up style.
examples/index.html
@@ -219,6 +219,7 @@ <h1><a href="http://threejs.org">three.js</a> / examples</h1> "webgl_geometry_nurbs", "webgl_geometry_shapes", "webgl_geometry_spline_editor", + "webgl_geometry_teapot", "webgl_geometry_terrain", "webgl_geometry_terrain_fog", "webgl_geometry_terrain_raycast",
true
Other
mrdoob
three.js
62f3060ace5b53cb0bf8174ad8d83c06cfa1ea40.json
Add Utah teapot as a geometry object; doc cleanup Add the Utah teapot geometry object, along with a demo showing its options. Also fix Matrix* documentation: match current constructor code, and clean up style.
examples/js/geometries/TeapotGeometry.js
@@ -0,0 +1,634 @@ +/** + * @author Eric Haines / http://erichaines.com/ + * + * Tessellates the famous Utah teapot database by Martin Newell into triangles. + * + * THREE.TeapotGeometry = function ( size, segments, bottom, lid, body, fitLid, blinn ) + * + * defaults: size = 50, segments = 10, bottom = true, lid = true, body = true, + * fitLid = false, blinn = true + * + * size is a relative scale: I've scaled the teapot to fit vertically between -1 and 1. + * Think of it as a "radius". + * segments - number of line segments to subdivide each patch edge; + * 1 is possible but gives degenerates, so two is the real minimum. + * bottom - boolean, if true (default) then the bottom patches are added. Some consider + * adding the bottom heresy, so set this to "false" to adhere to the One True Way. + * lid - to remove the lid and look inside, set to true. + * body - to remove the body and leave the lid, set this and "bottom" to false. + * fitLid - the lid is a tad small in the original. This stretches it a bit so you can't + * see the teapot's insides through the gap. + * blinn - Jim Blinn scaled the original data vertically by dividing by about 1.3 to look + * nicer. If you want to see the original teapot, similar to the real-world model, set + * this to false. True by default. + * See http://en.wikipedia.org/wiki/File:Original_Utah_Teapot.jpg for the original + * real-world teapot (from http://en.wikipedia.org/wiki/Utah_teapot). + * + * Note that the bottom (the last four patches) is not flat - blame Frank Crow, not me. + * + * The teapot should normally be rendered as a double sided object, since for some + * patches both sides can be seen, e.g., the gap around the lid and inside the spout. + * + * Segments 'n' determines the number of triangles output. + * Total triangles = 32*2*n*n - 8*n [degenerates at the top and bottom cusps are deleted] + * + * size_factor # triangles + * 1 56 + * 2 240 + * 3 552 + * 4 992 + * + * 10 6320 + * 20 25440 + * 30 57360 + * + * Code converted from my ancient SPD software, http://tog.acm.org/resources/SPD/ + * Created for the Udacity course "Interactive Rendering", http://bit.ly/ericity + * Lesson: https://www.udacity.com/course/viewer#!/c-cs291/l-68866048/m-106482448 + * YouTube video on teapot history: https://www.youtube.com/watch?v=DxMfblPzFNc + * + * See https://en.wikipedia.org/wiki/Utah_teapot for the history of the teapot + * + */ +/*global THREE */ + +THREE.TeapotGeometry = function ( size, segments, bottom, lid, body, fitLid, blinn ) { + "use strict"; + + // 32 * 4 * 4 Bezier spline patches + var teapotPatches = [ +/*rim*/ +0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, +3,16,17,18,7,19,20,21,11,22,23,24,15,25,26,27, +18,28,29,30,21,31,32,33,24,34,35,36,27,37,38,39, +30,40,41,0,33,42,43,4,36,44,45,8,39,46,47,12, +/*body*/ +12,13,14,15,48,49,50,51,52,53,54,55,56,57,58,59, +15,25,26,27,51,60,61,62,55,63,64,65,59,66,67,68, +27,37,38,39,62,69,70,71,65,72,73,74,68,75,76,77, +39,46,47,12,71,78,79,48,74,80,81,52,77,82,83,56, +56,57,58,59,84,85,86,87,88,89,90,91,92,93,94,95, +59,66,67,68,87,96,97,98,91,99,100,101,95,102,103,104, +68,75,76,77,98,105,106,107,101,108,109,110,104,111,112,113, +77,82,83,56,107,114,115,84,110,116,117,88,113,118,119,92, +/*handle*/ +120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135, +123,136,137,120,127,138,139,124,131,140,141,128,135,142,143,132, +132,133,134,135,144,145,146,147,148,149,150,151,68,152,153,154, +135,142,143,132,147,155,156,144,151,157,158,148,154,159,160,68, +/*spout*/ +161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176, +164,177,178,161,168,179,180,165,172,181,182,169,176,183,184,173, +173,174,175,176,185,186,187,188,189,190,191,192,193,194,195,196, +176,183,184,173,188,197,198,185,192,199,200,189,196,201,202,193, +/*lid*/ +203,203,203,203,204,205,206,207,208,208,208,208,209,210,211,212, +203,203,203,203,207,213,214,215,208,208,208,208,212,216,217,218, +203,203,203,203,215,219,220,221,208,208,208,208,218,222,223,224, +203,203,203,203,221,225,226,204,208,208,208,208,224,227,228,209, +209,210,211,212,229,230,231,232,233,234,235,236,237,238,239,240, +212,216,217,218,232,241,242,243,236,244,245,246,240,247,248,249, +218,222,223,224,243,250,251,252,246,253,254,255,249,256,257,258, +224,227,228,209,252,259,260,229,255,261,262,233,258,263,264,237, +/*bottom*/ +265,265,265,265,266,267,268,269,270,271,272,273,92,119,118,113, +265,265,265,265,269,274,275,276,273,277,278,279,113,112,111,104, +265,265,265,265,276,280,281,282,279,283,284,285,104,103,102,95, +265,265,265,265,282,286,287,266,285,288,289,270,95,94,93,92 + ] ; + + var teapotVertices = [ +1.4,0,2.4, +1.4,-0.784,2.4, +0.784,-1.4,2.4, +0,-1.4,2.4, +1.3375,0,2.53125, +1.3375,-0.749,2.53125, +0.749,-1.3375,2.53125, +0,-1.3375,2.53125, +1.4375,0,2.53125, +1.4375,-0.805,2.53125, +0.805,-1.4375,2.53125, +0,-1.4375,2.53125, +1.5,0,2.4, +1.5,-0.84,2.4, +0.84,-1.5,2.4, +0,-1.5,2.4, +-0.784,-1.4,2.4, +-1.4,-0.784,2.4, +-1.4,0,2.4, +-0.749,-1.3375,2.53125, +-1.3375,-0.749,2.53125, +-1.3375,0,2.53125, +-0.805,-1.4375,2.53125, +-1.4375,-0.805,2.53125, +-1.4375,0,2.53125, +-0.84,-1.5,2.4, +-1.5,-0.84,2.4, +-1.5,0,2.4, +-1.4,0.784,2.4, +-0.784,1.4,2.4, +0,1.4,2.4, +-1.3375,0.749,2.53125, +-0.749,1.3375,2.53125, +0,1.3375,2.53125, +-1.4375,0.805,2.53125, +-0.805,1.4375,2.53125, +0,1.4375,2.53125, +-1.5,0.84,2.4, +-0.84,1.5,2.4, +0,1.5,2.4, +0.784,1.4,2.4, +1.4,0.784,2.4, +0.749,1.3375,2.53125, +1.3375,0.749,2.53125, +0.805,1.4375,2.53125, +1.4375,0.805,2.53125, +0.84,1.5,2.4, +1.5,0.84,2.4, +1.75,0,1.875, +1.75,-0.98,1.875, +0.98,-1.75,1.875, +0,-1.75,1.875, +2,0,1.35, +2,-1.12,1.35, +1.12,-2,1.35, +0,-2,1.35, +2,0,0.9, +2,-1.12,0.9, +1.12,-2,0.9, +0,-2,0.9, +-0.98,-1.75,1.875, +-1.75,-0.98,1.875, +-1.75,0,1.875, +-1.12,-2,1.35, +-2,-1.12,1.35, +-2,0,1.35, +-1.12,-2,0.9, +-2,-1.12,0.9, +-2,0,0.9, +-1.75,0.98,1.875, +-0.98,1.75,1.875, +0,1.75,1.875, +-2,1.12,1.35, +-1.12,2,1.35, +0,2,1.35, +-2,1.12,0.9, +-1.12,2,0.9, +0,2,0.9, +0.98,1.75,1.875, +1.75,0.98,1.875, +1.12,2,1.35, +2,1.12,1.35, +1.12,2,0.9, +2,1.12,0.9, +2,0,0.45, +2,-1.12,0.45, +1.12,-2,0.45, +0,-2,0.45, +1.5,0,0.225, +1.5,-0.84,0.225, +0.84,-1.5,0.225, +0,-1.5,0.225, +1.5,0,0.15, +1.5,-0.84,0.15, +0.84,-1.5,0.15, +0,-1.5,0.15, +-1.12,-2,0.45, +-2,-1.12,0.45, +-2,0,0.45, +-0.84,-1.5,0.225, +-1.5,-0.84,0.225, +-1.5,0,0.225, +-0.84,-1.5,0.15, +-1.5,-0.84,0.15, +-1.5,0,0.15, +-2,1.12,0.45, +-1.12,2,0.45, +0,2,0.45, +-1.5,0.84,0.225, +-0.84,1.5,0.225, +0,1.5,0.225, +-1.5,0.84,0.15, +-0.84,1.5,0.15, +0,1.5,0.15, +1.12,2,0.45, +2,1.12,0.45, +0.84,1.5,0.225, +1.5,0.84,0.225, +0.84,1.5,0.15, +1.5,0.84,0.15, +-1.6,0,2.025, +-1.6,-0.3,2.025, +-1.5,-0.3,2.25, +-1.5,0,2.25, +-2.3,0,2.025, +-2.3,-0.3,2.025, +-2.5,-0.3,2.25, +-2.5,0,2.25, +-2.7,0,2.025, +-2.7,-0.3,2.025, +-3,-0.3,2.25, +-3,0,2.25, +-2.7,0,1.8, +-2.7,-0.3,1.8, +-3,-0.3,1.8, +-3,0,1.8, +-1.5,0.3,2.25, +-1.6,0.3,2.025, +-2.5,0.3,2.25, +-2.3,0.3,2.025, +-3,0.3,2.25, +-2.7,0.3,2.025, +-3,0.3,1.8, +-2.7,0.3,1.8, +-2.7,0,1.575, +-2.7,-0.3,1.575, +-3,-0.3,1.35, +-3,0,1.35, +-2.5,0,1.125, +-2.5,-0.3,1.125, +-2.65,-0.3,0.9375, +-2.65,0,0.9375, +-2,-0.3,0.9, +-1.9,-0.3,0.6, +-1.9,0,0.6, +-3,0.3,1.35, +-2.7,0.3,1.575, +-2.65,0.3,0.9375, +-2.5,0.3,1.125, +-1.9,0.3,0.6, +-2,0.3,0.9, +1.7,0,1.425, +1.7,-0.66,1.425, +1.7,-0.66,0.6, +1.7,0,0.6, +2.6,0,1.425, +2.6,-0.66,1.425, +3.1,-0.66,0.825, +3.1,0,0.825, +2.3,0,2.1, +2.3,-0.25,2.1, +2.4,-0.25,2.025, +2.4,0,2.025, +2.7,0,2.4, +2.7,-0.25,2.4, +3.3,-0.25,2.4, +3.3,0,2.4, +1.7,0.66,0.6, +1.7,0.66,1.425, +3.1,0.66,0.825, +2.6,0.66,1.425, +2.4,0.25,2.025, +2.3,0.25,2.1, +3.3,0.25,2.4, +2.7,0.25,2.4, +2.8,0,2.475, +2.8,-0.25,2.475, +3.525,-0.25,2.49375, +3.525,0,2.49375, +2.9,0,2.475, +2.9,-0.15,2.475, +3.45,-0.15,2.5125, +3.45,0,2.5125, +2.8,0,2.4, +2.8,-0.15,2.4, +3.2,-0.15,2.4, +3.2,0,2.4, +3.525,0.25,2.49375, +2.8,0.25,2.475, +3.45,0.15,2.5125, +2.9,0.15,2.475, +3.2,0.15,2.4, +2.8,0.15,2.4, +0,0,3.15, +0.8,0,3.15, +0.8,-0.45,3.15, +0.45,-0.8,3.15, +0,-0.8,3.15, +0,0,2.85, +0.2,0,2.7, +0.2,-0.112,2.7, +0.112,-0.2,2.7, +0,-0.2,2.7, +-0.45,-0.8,3.15, +-0.8,-0.45,3.15, +-0.8,0,3.15, +-0.112,-0.2,2.7, +-0.2,-0.112,2.7, +-0.2,0,2.7, +-0.8,0.45,3.15, +-0.45,0.8,3.15, +0,0.8,3.15, +-0.2,0.112,2.7, +-0.112,0.2,2.7, +0,0.2,2.7, +0.45,0.8,3.15, +0.8,0.45,3.15, +0.112,0.2,2.7, +0.2,0.112,2.7, +0.4,0,2.55, +0.4,-0.224,2.55, +0.224,-0.4,2.55, +0,-0.4,2.55, +1.3,0,2.55, +1.3,-0.728,2.55, +0.728,-1.3,2.55, +0,-1.3,2.55, +1.3,0,2.4, +1.3,-0.728,2.4, +0.728,-1.3,2.4, +0,-1.3,2.4, +-0.224,-0.4,2.55, +-0.4,-0.224,2.55, +-0.4,0,2.55, +-0.728,-1.3,2.55, +-1.3,-0.728,2.55, +-1.3,0,2.55, +-0.728,-1.3,2.4, +-1.3,-0.728,2.4, +-1.3,0,2.4, +-0.4,0.224,2.55, +-0.224,0.4,2.55, +0,0.4,2.55, +-1.3,0.728,2.55, +-0.728,1.3,2.55, +0,1.3,2.55, +-1.3,0.728,2.4, +-0.728,1.3,2.4, +0,1.3,2.4, +0.224,0.4,2.55, +0.4,0.224,2.55, +0.728,1.3,2.55, +1.3,0.728,2.55, +0.728,1.3,2.4, +1.3,0.728,2.4, +0,0,0, +1.425,0,0, +1.425,0.798,0, +0.798,1.425,0, +0,1.425,0, +1.5,0,0.075, +1.5,0.84,0.075, +0.84,1.5,0.075, +0,1.5,0.075, +-0.798,1.425,0, +-1.425,0.798,0, +-1.425,0,0, +-0.84,1.5,0.075, +-1.5,0.84,0.075, +-1.5,0,0.075, +-1.425,-0.798,0, +-0.798,-1.425,0, +0,-1.425,0, +-1.5,-0.84,0.075, +-0.84,-1.5,0.075, +0,-1.5,0.075, +0.798,-1.425,0, +1.425,-0.798,0, +0.84,-1.5,0.075, +1.5,-0.84,0.075 + ] ; + + THREE.Geometry.call( this ); + + this.type = 'TeapotGeometry'; + + this.size = size || 50; + + // number of segments per patch + this.segments = Math.max( 2, Math.floor( segments ) || 10 ); + + // which parts should be visible + this.bottom = bottom === undefined ? true : bottom; + this.lid = lid === undefined ? true : lid; + this.body = body === undefined ? true : body; + + // Should the lid be snug? It's not traditional, so off by default + this.fitLid = fitLid === undefined ? false : fitLid; + + // Jim Blinn scaled the teapot down in size by about 1.3 for + // some rendering tests. He liked the new proportions that he kept + // the data in this form. The model was distributed with these new + // proportions and became the norm. Trivia: comparing images of the + // real teapot and the computer model, the ratio for the bowl of the + // real teapot is more like 1.25, but since 1.3 is the traditional + // value given, we use it here. + var blinnScale = 1.3; + this.blinn = blinn === undefined ? true : blinn; + + // scale the size to be the real scaling factor + var maxHeight = 3.15 * (this.blinn ? 1 : blinnScale); + + var maxHeight2 = maxHeight / 2; + var trueSize = this.size / maxHeight2; + + var normals = [], uvs = []; + // Bezier form + var ms = new THREE.Matrix4(); + ms.set( -1.0, 3.0, -3.0, 1.0, + 3.0, -6.0, 3.0, 0.0, + -3.0, 3.0, 0.0, 0.0, + 1.0, 0.0, 0.0, 0.0 ) ; + + var g = []; + var i, r, c; + + var sp = []; + var tp = []; + var dsp = []; + var dtp = []; + + // M * G * M matrix, sort of see + // http://www.cs.helsinki.fi/group/goa/mallinnus/curves/surfaces.html + var mgm = []; + + var vert = []; + var sdir = []; + var tdir = []; + + var norm = new THREE.Vector3(); + + var tcoord; + + var sstep, tstep; + var gmx, tmtx; + + var vertPerRow, eps; + + var s, t, sval, tval, p, dsval, dtval; + + var vsp, vtp, vdsp, vdtp; + var vsdir, vtdir, normOut, vertOut; + var v1, v2, v3, v4; + + var mst = ms.clone(); + mst.transpose(); + + // internal function: test if triangle has any matching vertices; + // if so, don't save triangle, since it won't display anything. + var notDegenerate = function ( vtx1, vtx2, vtx3 ) { + if ( vtx1.equals( vtx2 ) ) { return false; } + if ( vtx1.equals( vtx3 ) ) { return false; } + if ( vtx2.equals( vtx3 ) ) { return false; } + return true; + }; + + + for ( i = 0; i < 3; i++ ) + { + mgm[i] = new THREE.Matrix4(); + } + + var minPatches = this.body ? 0 : 20; + var maxPatches = this.bottom ? 32 : 28; + + vertPerRow = (this.segments+1); + + eps = 0.0000001; + + var surfCount = 0; + + for ( var surf = minPatches ; surf < maxPatches ; surf++ ) { + // lid is in the middle of the data, patches 20-27, + // so ignore it for this part of the loop if the lid is not desired + if ( this.lid || (surf < 20 || surf >= 28) ) { + + // get M * G * M matrix for x,y,z + for ( i = 0 ; i < 3 ; i++ ) { + // get control patches + for ( r = 0 ; r < 4 ; r++ ) { + for ( c = 0 ; c < 4 ; c++ ) { + // transposed + g[c*4+r] = teapotVertices[teapotPatches[surf*16 + r*4 + c]*3 + i] ; + + // is the lid to be made larger, and is this a point on the lid + // that is X or Y? + if ( this.fitLid && (surf >= 20 && surf < 28) && (i !== 2) ) { + // increase XY size by 7.7%, found empirically. I don't + // increase Z so that the teapot will continue to fit in the + // space -1 to 1 for Y (Y is up for the final model). + g[c*4+r] *= 1.077; + } + + // Blinn "fixed" the teapot by dividing Z by blinnScale, and that's the + // data we now use. The original teapot is taller. Fix it: + if ( !this.blinn && (i === 2) ) { + g[c*4+r] *= blinnScale; + } + } + } + + gmx = new THREE.Matrix4(); + gmx.set( g[0], g[1], g[2], g[3], g[4], g[5], g[6], g[7], g[8], g[9], g[10], g[11], g[12], g[13], g[14], g[15] ); + + tmtx = new THREE.Matrix4(); + tmtx.multiplyMatrices( gmx, ms ); + mgm[i].multiplyMatrices( mst, tmtx ); + } + + // step along, get points, and output + for ( sstep = 0 ; sstep <= this.segments ; sstep++ ) { + s = sstep / this.segments; + + for ( tstep = 0 ; tstep <= this.segments ; tstep++ ) { + t = tstep / this.segments; + + // point from basis + // get power vectors and their derivatives + for ( p = 4, sval = tval = 1.0 ; p-- ; ) { + sp[p] = sval ; + tp[p] = tval ; + sval *= s ; + tval *= t ; + + if ( p === 3 ) { + dsp[p] = dtp[p] = 0.0 ; + dsval = dtval = 1.0 ; + } else { + dsp[p] = dsval * (3-p) ; + dtp[p] = dtval * (3-p) ; + dsval *= s ; + dtval *= t ; + } + } + + vsp = new THREE.Vector4( sp[0], sp[1], sp[2], sp[3] ); + vtp = new THREE.Vector4( tp[0], tp[1], tp[2], tp[3] ); + vdsp = new THREE.Vector4( dsp[0], dsp[1], dsp[2], dsp[3] ); + vdtp = new THREE.Vector4( dtp[0], dtp[1], dtp[2], dtp[3] ); + + // do for x,y,z + for ( i = 0 ; i < 3 ; i++ ) { + // multiply power vectors times matrix to get value + tcoord = vsp.clone(); + tcoord.applyMatrix4( mgm[i] ); + vert[i] = tcoord.dot( vtp ); + + // get s and t tangent vectors + tcoord = vdsp.clone(); + tcoord.applyMatrix4( mgm[i] ); + sdir[i] = tcoord.dot( vtp ) ; + + tcoord = vsp.clone(); + tcoord.applyMatrix4( mgm[i] ); + tdir[i] = tcoord.dot( vdtp ) ; + } + + // find normal + vsdir = new THREE.Vector3( sdir[0], sdir[1], sdir[2] ); + vtdir = new THREE.Vector3( tdir[0], tdir[1], tdir[2] ); + norm.crossVectors( vtdir, vsdir ); + norm.normalize(); + + // rotate on X axis + normOut = new THREE.Vector3( norm.x, norm.z, -norm.y ); + + // if X and Z length is 0, at the cusp, so point the normal up or down, depending on patch number + if ( vert[0] === 0 && vert[1] === 0 ) + { + // if above the middle of the teapot, normal points up, else down + normOut.set( 0, vert[2] > maxHeight2 ? 1 : -1, 0 ); + } + normals.push( normOut ); + + uvs.push( new THREE.Vector2( 1-t, 1-s ) ); + + // three.js uses Y up, the code makes Z up, so time for a trick: + // rotate on X axis, and offset down on Y axis so object ranges from -1 to 1 in Y + vertOut = new THREE.Vector3( trueSize*vert[0], trueSize*(vert[2] - maxHeight2), -trueSize*vert[1] ); + + this.vertices.push( vertOut ); + + } + } + + // save the faces + for ( sstep = 0 ; sstep < this.segments ; sstep++ ) { + for ( tstep = 0 ; tstep < this.segments ; tstep++ ) { + v1 = surfCount * vertPerRow * vertPerRow + sstep * vertPerRow + tstep; + v2 = v1 + 1; + v3 = v2 + vertPerRow; + v4 = v1 + vertPerRow; + + if ( notDegenerate ( this.vertices[v1], this.vertices[v2], this.vertices[v3] ) ) { + this.faces.push( new THREE.Face3( v1, v2, v3, [ normals[v1], normals[v2], normals[v3] ] ) ); + this.faceVertexUvs[ 0 ].push( [ uvs[v1], uvs[v2], uvs[v3] ] ); + } + if ( notDegenerate ( this.vertices[v1], this.vertices[v3], this.vertices[v4] ) ) { + this.faces.push( new THREE.Face3( v1, v3, v4, [ normals[v1], normals[v3], normals[v4] ] ) ); + this.faceVertexUvs[ 0 ].push( [ uvs[v1], uvs[v3], uvs[v4] ] ); + } + } + } + // increment only if a surface was used + surfCount++; + } + } + + this.computeFaceNormals(); +}; + + +THREE.TeapotGeometry.prototype = Object.create( THREE.Geometry.prototype ); +THREE.TeapotGeometry.prototype.constructor = THREE.TeapotGeometry;
true
Other
mrdoob
three.js
62f3060ace5b53cb0bf8174ad8d83c06cfa1ea40.json
Add Utah teapot as a geometry object; doc cleanup Add the Utah teapot geometry object, along with a demo showing its options. Also fix Matrix* documentation: match current constructor code, and clean up style.
examples/webgl_geometry_teapot.html
@@ -0,0 +1,383 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <title>three.js webgl - teapot geometry</title> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> + <style> + body { + color: #fff; + font-family: Monospace; + font-size: 13px; + text-align: center; + font-weight: bold; + + background-color: #000; + margin: 0px; + overflow: hidden; + } + + #info { + position: relative; + margin: 0 auto -2.1em; + top: 0px; + width: 550px; + padding: 5px; + z-index:100; + } + + a { color: blue; } + + #stats #fps { background: transparent !important } + #stats #fps #fpsText { color: #444 !important } + #stats #fps #fpsGraph { display: none } + </style> + </head> + <body> + <div id="info"> + <a href="http://threejs.org" target="_blank">three.js</a> - the Utah Teapot from the <a href="https://www.udacity.com/course/interactive-3d-graphics--cs291">Udacity Interactive 3D Graphics course</a> + </div> + + <script src="../build/three.min.js"></script> + + <script src="js/controls/OrbitControls.js"></script> + + <script src="js/Detector.js"></script> + <script src="js/libs/stats.min.js"></script> + + <script src='js/libs/dat.gui.min.js'></script> + + <script src='js/geometries/TeapotGeometry.js'></script> + + <script> + + //////////////////////////////////////////////////////////////////////////////// + // Utah/Newell Teapot demo + //////////////////////////////////////////////////////////////////////////////// + /*global THREE, requestAnimationFrame, Detector, container, Stats, dat, window */ + + if ( ! Detector.webgl ) Detector.addGetWebGLMessage(); + + var camera, scene, sceneCube, renderer, stats; + var cameraControls; + var effectController; + var clock = new THREE.Clock(); + var teapotSize = 400; + var ambientLight, light; + var skybox; + + var tess = -1; // force initialization + var bBottom ; + var bLid; + var bBody; + var bFitLid; + var bNonBlinn; + var shading; + var wireMaterial, flatGouraudMaterial, gouraudMaterial, phongMaterial, texturedMaterial, reflectiveMaterial; + + init(); + animate(); + + function init() { + container = document.createElement( 'div' ); + document.body.appendChild( container ); + + var canvasWidth = window.innerWidth; + var canvasHeight = window.innerHeight; + + // CAMERA + camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 80000 ); + camera.position.set( -600, 550, 1300 ); + + // LIGHTS + ambientLight = new THREE.AmbientLight( 0x333333 ); // 0.2 + + light = new THREE.DirectionalLight( 0xFFFFFF, 1.0 ); + // direction is set in GUI + + // RENDERER + renderer = new THREE.WebGLRenderer( { antialias: true } ); + renderer.setSize( canvasWidth, canvasHeight ); + renderer.setClearColor( 0xAAAAAA ); + renderer.gammaInput = true; + renderer.gammaOutput = true; + container.appendChild( renderer.domElement ); + + // STATS + stats = new Stats(); + stats.domElement.style.position = 'absolute'; + stats.domElement.style.top = '0px'; + container.appendChild( stats.domElement ); + + // EVENTS + window.addEventListener( 'resize', onWindowResize, false ); + + // CONTROLS + cameraControls = new THREE.OrbitControls( camera, renderer.domElement ); + cameraControls.target.set(0, 0, 0); + + // TEXTURE MAP + var textureMap = THREE.ImageUtils.loadTexture( 'textures/UV_Grid_Sm.jpg' ); + textureMap.wrapS = textureMap.wrapT = THREE.RepeatWrapping; + textureMap.anisotropy = 16; + + // REFLECTION MAP + var path = "textures/cube/skybox/"; + var urls = [path + "px.jpg", path + "nx.jpg", + path + "py.jpg", path + "ny.jpg", + path + "pz.jpg", path + "nz.jpg" ]; + + var textureCube = THREE.ImageUtils.loadTextureCube( urls ); + + // MATERIALS + var materialColor = new THREE.Color(); + materialColor.setRGB( 1.0, 1.0, 1.0 ); + + wireMaterial = new THREE.MeshBasicMaterial( { color: 0xFFFFFF, wireframe: true } ) ; + + flatGouraudMaterial = new THREE.MeshLambertMaterial( { color: materialColor, shading: THREE.FlatShading, side: THREE.DoubleSide } ); + + gouraudMaterial = new THREE.MeshLambertMaterial( { color: materialColor, shading: THREE.SmoothShading, side: THREE.DoubleSide } ); + + phongMaterial = new THREE.MeshPhongMaterial( { color: materialColor, shading: THREE.SmoothShading, side: THREE.DoubleSide } ); + + texturedMaterial = new THREE.MeshPhongMaterial( { color: materialColor, map: textureMap, shading: THREE.SmoothShading, side: THREE.DoubleSide } ); + + reflectiveMaterial = new THREE.MeshPhongMaterial( { color: materialColor, envMap: textureCube, shading: THREE.SmoothShading, side: THREE.DoubleSide } ); + + // SKYBOX + var shader = THREE.ShaderLib[ "cube" ]; + shader.uniforms[ "tCube" ].value = textureCube; + + var skyboxMaterial = new THREE.ShaderMaterial( { + + fragmentShader: shader.fragmentShader, + vertexShader: shader.vertexShader, + uniforms: shader.uniforms, + depthWrite: false, + side: THREE.BackSide + + } ); + + skybox = new THREE.Mesh( new THREE.BoxGeometry( 5000, 5000, 5000 ), skyboxMaterial ); + + // skybox scene - keep camera centered here + sceneCube = new THREE.Scene(); + sceneCube.add( skybox ); + + // GUI + setupGui(); + + } + + // EVENT HANDLERS + + function onWindowResize() { + + var canvasWidth = window.innerWidth; + var canvasHeight = window.innerHeight; + + renderer.setSize( canvasWidth, canvasHeight ); + + camera.aspect = canvasWidth/ canvasHeight; + camera.updateProjectionMatrix(); + } + + function setupGui() { + + effectController = { + + shininess: 40.0, + ka: 0.17, + kd: 0.51, + ks: 0.2, + metallic: true, + + hue: 0.121, + saturation: 0.73, + lightness: 0.66, + + lhue: 0.04, + lsaturation: 0.01, // non-zero so that fractions will be shown + llightness: 1.0, + + // bizarrely, if you initialize these with negative numbers, the sliders + // will not show any decimal places. + lx: 0.32, + ly: 0.39, + lz: 0.7, + newTess: 15, + bottom: true, + lid: true, + body: true, + fitLid: false, + nonblinn: false, + newShading: "glossy" + }; + + var h; + + var gui = new dat.GUI(); + + // material (attributes) + + h = gui.addFolder( "Material control" ); + + h.add( effectController, "shininess", 1.0, 400.0, 1.0 ).name("Shininess"); + h.add( effectController, "ka", 0.0, 1.0, 0.025 ).name("Ka"); + h.add( effectController, "kd", 0.0, 1.0, 0.025 ).name("Kd"); + h.add( effectController, "ks", 0.0, 1.0, 0.025 ).name("Ks"); + h.add( effectController, "metallic" ); + + // material (color) + + h = gui.addFolder( "Material color" ); + + h.add( effectController, "hue", 0.0, 1.0, 0.025 ).name("Hue"); + h.add( effectController, "saturation", 0.0, 1.0, 0.025 ).name("Saturation"); + h.add( effectController, "lightness", 0.0, 1.0, 0.025 ).name("Lightness"); + + // light (point) + + h = gui.addFolder( "Light color" ); + + h.add( effectController, "lhue", 0.0, 1.0, 0.025 ).name("Hue"); + h.add( effectController, "lsaturation", 0.0, 1.0, 0.025 ).name("Saturation"); + h.add( effectController, "llightness", 0.0, 1.0, 0.025 ).name("Lightness"); + + // light (directional) + + h = gui.addFolder( "Light direction" ); + + h.add( effectController, "lx", -1.0, 1.0, 0.025 ).name("x"); + h.add( effectController, "ly", -1.0, 1.0, 0.025 ).name("y"); + h.add( effectController, "lz", -1.0, 1.0, 0.025 ).name("z"); + + h = gui.addFolder( "Tessellation control" ); + h.add(effectController, "newTess", [2,3,4,5,6,8,10,15,20,30,40,50] ).name("Tessellation Level"); + h.add(effectController, "lid").name("display lid"); + h.add(effectController, "body").name("display body"); + h.add(effectController, "bottom").name("display bottom"); + h.add(effectController, "fitLid").name("snug lid"); + h.add(effectController, "nonblinn").name("original scale"); + + // shading + h = gui.add(effectController, "newShading", ["wireframe","flat","smooth","glossy","textured","reflective"] ).name("Shading"); + } + + + // + + function animate() { + + requestAnimationFrame( animate ); + render(); + stats.update(); + + } + + function render() { + + var delta = clock.getDelta(); + + cameraControls.update( delta ); + + if ( effectController.newTess !== tess || + effectController.bottom !== bBottom || + effectController.lid !== bLid || + effectController.body !== bBody || + effectController.fitLid !== bFitLid || + effectController.nonblinn !== bNonBlinn || + effectController.newShading !== shading) + { + tess = effectController.newTess; + bBottom = effectController.bottom; + bLid = effectController.lid; + bBody = effectController.body; + bFitLid = effectController.fitLid; + bNonBlinn = effectController.nonblinn; + shading = effectController.newShading; + + fillScene(); + } + + phongMaterial.shininess = effectController.shininess; + texturedMaterial.shininess = effectController.shininess; + + var diffuseColor = new THREE.Color(); + diffuseColor.setHSL( effectController.hue, effectController.saturation, effectController.lightness ); + var specularColor = new THREE.Color(); + if ( effectController.metallic ) + { + // make colors match to give a more metallic look + specularColor.copy( diffuseColor ); + } + else + { + // more of a plastic look + specularColor.setRGB(1,1,1); + } + + diffuseColor.multiplyScalar(effectController.kd); + flatGouraudMaterial.color.copy( diffuseColor ); + gouraudMaterial.color.copy( diffuseColor ); + phongMaterial.color.copy( diffuseColor ); + texturedMaterial.color.copy( diffuseColor ); + + specularColor.multiplyScalar(effectController.ks); + phongMaterial.specular.copy( specularColor ); + texturedMaterial.specular.copy( specularColor ); + + // Ambient's actually controlled by the light for this demo + ambientLight.color.setHSL( effectController.hue, effectController.saturation, effectController.lightness * effectController.ka ); + + light.position.set( effectController.lx, effectController.ly, effectController.lz ); + light.color.setHSL( effectController.lhue, effectController.lsaturation, effectController.llightness ); + + // skybox is rendered separately, so that it is always behind the teapot. + if ( shading === "reflective" ) + { + // clear to skybox + renderer.autoClear = false; + skybox.position.copy( camera.position ); + renderer.render( sceneCube, camera ); + } + else + { + // clear to regular background color + renderer.autoClear = true; + } + + renderer.render( scene, camera ); + } + + function fillScene() { + scene = new THREE.Scene(); + //scene.fog = new THREE.Fog( 0x808080, 2000, 4000 ); + + // LIGHTS + + scene.add( ambientLight ); + scene.add( light ); + + var teapot = new THREE.Mesh( + new THREE.TeapotGeometry( teapotSize, + tess, + effectController.bottom, + effectController.lid, + effectController.body, + effectController.fitLid, + !effectController.nonblinn ), + shading === "wireframe" ? wireMaterial : ( + shading === "flat" ? flatGouraudMaterial : ( + shading === "smooth" ? gouraudMaterial : ( + shading === "glossy" ? phongMaterial : ( + shading === "textured" ? texturedMaterial : reflectiveMaterial ))))); // if no match, pick Phong + + scene.add( teapot ); + } + + </script> + + </body> +</html>
true
Other
mrdoob
three.js
13febe3f3d9fd9c9a3762baaa02e5069303837f8.json
Add reference to materials to OBJ Loader
examples/js/loaders/OBJLoader.js
@@ -5,6 +5,8 @@ THREE.OBJLoader = function ( manager ) { this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + + this.materials = null; }; @@ -31,6 +33,12 @@ THREE.OBJLoader.prototype = { this.crossOrigin = value; }, + + setMaterials: function ( materials ) { + + this.materials = materials; + + }, parse: function ( text ) { @@ -362,6 +370,21 @@ THREE.OBJLoader.prototype = { buffergeometry.addAttribute( 'uv', new THREE.BufferAttribute( new Float32Array( geometry.uvs ), 2 ) ); } + + var material; + + if ( this.materials !== null ) { + + material = this.materials.create( object.material.name ); + + } + + if ( !material ) { + + material = new THREE.MeshPhongMaterial(); + material.name = object.material.name; + + } material = new THREE.MeshLambertMaterial(); material.name = object.material.name;
false
Other
mrdoob
three.js
194cbacaf7d34ff5568a34e6a1612385bc096c8f.json
add unit tests for event dispatcher
test/unit/core/EventDispatcher.js
@@ -0,0 +1,88 @@ +/** + * @author simonThiele / https://github.com/simonThiele + */ + +module( "EventDispatcher" ); + +test( "apply", function() { + var innocentObject = {}; + var eventDispatcher = new THREE.EventDispatcher(); + + eventDispatcher.apply( innocentObject ); + + ok( innocentObject.addEventListener !== undefined && + innocentObject.hasEventListener !== undefined && + innocentObject.removeEventListener !== undefined && + innocentObject.dispatchEvent !== undefined, "events where added to object" ); +}); + +test( "addEventListener", function() { + var eventDispatcher = new THREE.EventDispatcher(); + + var listener = {}; + eventDispatcher.addEventListener( 'anyType', listener ); + + ok( eventDispatcher._listeners.anyType.length === 1, "listener with unknown type was added" ); + ok( eventDispatcher._listeners.anyType[0] === listener, "listener with unknown type was added" ); + + eventDispatcher.addEventListener( 'anyType', listener ); + + ok( eventDispatcher._listeners.anyType.length === 1, "can't add one listener twice to same type" ); + ok( eventDispatcher._listeners.anyType[0] === listener, "listener is still there" ); +}); + +test( "hasEventListener", function() { + var eventDispatcher = new THREE.EventDispatcher(); + + var listener = {}; + eventDispatcher.addEventListener( 'anyType', listener ); + + ok( eventDispatcher.hasEventListener( 'anyType', listener ), "listener was found" ); + ok( !eventDispatcher.hasEventListener( 'anotherType', listener ), "listener was not found which is good" ); +}); + +test( "removeEventListener", function() { + var eventDispatcher = new THREE.EventDispatcher(); + + var listener = {}; + + ok ( eventDispatcher._listeners === undefined, "there are no listeners by default" ); + + eventDispatcher.addEventListener( 'anyType', listener ); + ok ( Object.keys( eventDispatcher._listeners ).length === 1 && + eventDispatcher._listeners.anyType.length === 1, "if a listener was added, there is a new key" ); + + eventDispatcher.removeEventListener( 'anyType', listener ); + ok ( eventDispatcher._listeners.anyType.length === 0, "listener was deleted" ); + + eventDispatcher.removeEventListener( 'unknownType', listener ); + ok ( eventDispatcher._listeners.unknownType === undefined, "unknown types will be ignored" ); + + eventDispatcher.removeEventListener( 'anyType', undefined ); + ok ( eventDispatcher._listeners.anyType.length === 0, "undefined listeners are ignored" ); +}); + +test( "dispatchEvent", function() { + var eventDispatcher = new THREE.EventDispatcher(); + + var callCount = 0; + var listener = function() { callCount++; }; + + eventDispatcher.addEventListener( 'anyType', listener ); + ok( callCount === 0, "no event, no call" ); + + eventDispatcher.dispatchEvent( { type: 'anyType' } ); + ok( callCount === 1, "one event, one call" ); + + eventDispatcher.dispatchEvent( { type: 'anyType' } ); + ok( callCount === 2, "two events, two calls" ); +}); + + + + + + + + +//
true
Other
mrdoob
three.js
194cbacaf7d34ff5568a34e6a1612385bc096c8f.json
add unit tests for event dispatcher
test/unit/unittests_three.html
@@ -25,6 +25,7 @@ <script src="core/BufferAttribute.js"></script> <script src="core/BufferGeometry.js"></script> <script src="core/Clock.js"></script> + <script src="core/EventDispatcher.js"></script> <script src="core/Object3D.js"></script> <script src="math/Constants.js"></script>
true
Other
mrdoob
three.js
7cb97cf7e3eba3da8ec668faa5841f311e83c8d4.json
change whitespace to tab
test/unit/core/Clock.js
@@ -5,48 +5,48 @@ module( "Clock" ); function mockPerformance() { - self.performance = { - deltaTime: 0, + self.performance = { + deltaTime: 0, - next: function( delta ) { - this.deltaTime += delta; - }, + next: function( delta ) { + this.deltaTime += delta; + }, - now: function() { - return this.deltaTime; - } - }; + now: function() { + return this.deltaTime; + } + }; } test( "clock with performance", function() { - mockPerformance(); + mockPerformance(); - var clock = new THREE.Clock(); + var clock = new THREE.Clock(); - clock.start(); + clock.start(); - self.performance.next(123); - ok( clock.getElapsedTime() === 0.123 , "okay"); + self.performance.next(123); + ok( clock.getElapsedTime() === 0.123 , "okay"); - self.performance.next(100); - ok( clock.getElapsedTime() === 0.223 , "okay"); + self.performance.next(100); + ok( clock.getElapsedTime() === 0.223 , "okay"); - clock.stop(); + clock.stop(); - self.performance.next(1000); - ok( clock.getElapsedTime() === 0.223 , "don't update time if the clock was stopped"); + self.performance.next(1000); + ok( clock.getElapsedTime() === 0.223 , "don't update time if the clock was stopped"); }); test( "clock with date", function() { - // remove the performance object so that clock takes Date() - self.performance = undefined; + // remove the performance object so that clock takes Date() + self.performance = undefined; - var clock = new THREE.Clock(); + var clock = new THREE.Clock(); - clock.start(); + clock.start(); - // if a value was calculated, the clock took the alternative Date() object - ok( clock.getElapsedTime() >= 0 , "okay"); + // if a value was calculated, the clock took the alternative Date() object + ok( clock.getElapsedTime() >= 0 , "okay"); - clock.stop(); + clock.stop(); });
false
Other
mrdoob
three.js
d73576afd43d4c571ac70c4087c7c11afd230a91.json
add unit tests for clock
test/unit/core/Clock.js
@@ -0,0 +1,52 @@ +/** + * @author simonThiele / https://github.com/simonThiele + */ + +module( "Clock" ); + +function mockPerformance() { + self.performance = { + deltaTime: 0, + + next: function( delta ) { + this.deltaTime += delta; + }, + + now: function() { + return this.deltaTime; + } + }; +} + +test( "clock with performance", function() { + mockPerformance(); + + var clock = new THREE.Clock(); + + clock.start(); + + self.performance.next(123); + ok( clock.getElapsedTime() === 0.123 , "okay"); + + self.performance.next(100); + ok( clock.getElapsedTime() === 0.223 , "okay"); + + clock.stop(); + + self.performance.next(1000); + ok( clock.getElapsedTime() === 0.223 , "don't update time if the clock was stopped"); +}); + +test( "clock with date", function() { + // remove the performance object so that clock takes Date() + self.performance = undefined; + + var clock = new THREE.Clock(); + + clock.start(); + + // if a value was calculated, the clock took the alternative Date() object + ok( clock.getElapsedTime() >= 0 , "okay"); + + clock.stop(); +});
true
Other
mrdoob
three.js
d73576afd43d4c571ac70c4087c7c11afd230a91.json
add unit tests for clock
test/unit/unittests_three.html
@@ -24,6 +24,7 @@ <script src="core/BufferAttribute.js"></script> <script src="core/BufferGeometry.js"></script> + <script src="core/Clock.js"></script> <script src="core/Object3D.js"></script> <script src="math/Constants.js"></script>
true
Other
mrdoob
three.js
43bedce7868cc5786641e8b32333af2e0249a046.json
Remove reference to `diffuse` parameter `kD` is set to the `color` parameter directly.
examples/js/loaders/MTLLoader.js
@@ -319,7 +319,7 @@ THREE.MTLLoader.MaterialCreator.prototype = { // Diffuse color (color under white light) using RGB values - params[ 'diffuse' ] = new THREE.Color().fromArray( value ); + params[ 'color' ] = new THREE.Color().fromArray( value ); break; @@ -390,12 +390,6 @@ THREE.MTLLoader.MaterialCreator.prototype = { } - if ( params[ 'diffuse' ] ) { - - params[ 'color' ] = params[ 'diffuse' ]; - - } - this.materials[ materialName ] = new THREE.MeshPhongMaterial( params ); return this.materials[ materialName ];
false
Other
mrdoob
three.js
94d8f1ad06934e21220c6eaf7ed35566c0c82f98.json
remove some left over console.log statements.
examples/webgl_animation_scene.html
@@ -125,7 +125,6 @@ loader.load( "models/json/scene-animation.json", function ( loadedScene ) { sceneAnimationClip = loadedScene.animations[0]; - console.log('sceneAnimationClip', sceneAnimationClip); scene = loadedScene; scene.add( camera ); scene.fog = new THREE.Fog( 0xffffff, 2000, 10000 );
true
Other
mrdoob
three.js
94d8f1ad06934e21220c6eaf7ed35566c0c82f98.json
remove some left over console.log statements.
src/loaders/ObjectLoader.js
@@ -61,9 +61,8 @@ THREE.ObjectLoader.prototype = { var object = this.parseObject( json.object, geometries, materials ); if( json.animations ) { - console.log( json.animations ); + object.animations = this.parseAnimations( json.animations ); - console.log( object.animations ); }
true
Other
mrdoob
three.js
8ee9c980007eca2ff0cd8bdd6c06a59236ad3f64.json
write animations at the root
utils/exporters/blender/addons/io_three/exporter/api/mesh.py
@@ -458,7 +458,7 @@ def blend_shapes(mesh, options): return manifest @_mesh -def animated_blend_shapes(mesh, options): +def animated_blend_shapes(mesh, name, options): """ :param mesh: @@ -473,7 +473,7 @@ def animated_blend_shapes(mesh, options): animCurves = animCurves.action.fcurves for key in shp.key_blocks.keys()[1:]: # skip "Basis" - key_name = ".morphTargetInfluences["+key+"]" + key_name = name+".morphTargetInfluences["+key+"]" found_animation = False data_path = 'key_blocks["'+key+'"].value' values = [] @@ -492,12 +492,7 @@ def animated_blend_shapes(mesh, options): constants.KEYS: values }); - animation = [{ - constants.KEYFRAMES: tracks, - constants.FPS: context.scene.render.fps, - constants.NAME: "default" - }] - return animation + return tracks @_mesh def materials(mesh, options):
true
Other
mrdoob
three.js
8ee9c980007eca2ff0cd8bdd6c06a59236ad3f64.json
write animations at the root
utils/exporters/blender/addons/io_three/exporter/api/object.py
@@ -180,6 +180,8 @@ def animated_xform(obj, options): return [] fcurves = fcurves.action.fcurves + objName = obj.name + tracks = [] i = 0 nb_curves = len(fcurves) @@ -202,7 +204,7 @@ def animated_xform(obj, options): track = [] track_loc.append(track) tracks.append({ - constants.NAME: field_info[0], + constants.NAME: objName+field_info[0], constants.TYPE: field_info[2], constants.KEYS: track }) @@ -228,12 +230,7 @@ def animated_xform(obj, options): context.scene.frame_set(original_frame, 0.0) # restore to original frame # TODO: remove duplicated key frames - - return [{ - constants.KEYFRAMES: tracks, - constants.FPS: context.scene.render.fps, - constants.NAME: obj.name - }] + return tracks @_object def mesh(obj, options):
true
Other
mrdoob
three.js
8ee9c980007eca2ff0cd8bdd6c06a59236ad3f64.json
write animations at the root
utils/exporters/blender/addons/io_three/exporter/geometry.py
@@ -568,9 +568,12 @@ def _parse_geometry(self): logger.info("Parsing %s", constants.BLEND_SHAPES) mt = api.mesh.blend_shapes(self.node, self.options) or [] self[constants.MORPH_TARGETS] = mt - if len(mt) > 0: # there's blend shapes, let check for animation - self[constants.CLIPS] = api.mesh.animated_blend_shapes(self.node, self.options) or [] - + if len(mt) > 0 and self._scene: # there's blend shapes, let check for animation + #self[constants.CLIPS] = api.mesh.animated_blend_shapes(self.node, self.options) or [] + tracks = api.mesh.animated_blend_shapes(self.node, self[constants.NAME], self.options) or [] + merge = self._scene[constants.ANIMATION][0][constants.KEYFRAMES] + for track in tracks: + merge.append(track) # In the moment there is no way to add extra data to a Geomtry in # Three.js. In case there is some day, here is the code:
true
Other
mrdoob
three.js
8ee9c980007eca2ff0cd8bdd6c06a59236ad3f64.json
write animations at the root
utils/exporters/blender/addons/io_three/exporter/object.py
@@ -124,7 +124,12 @@ def _node_setup(self): no_anim = (None, False, constants.OFF) if self.options.get(constants.KEYFRAMES) not in no_anim: logger.info("Export Transform Animation for %s", self.node) - self[constants.CLIPS] = api.object.animated_xform(self.node, self.options) + if self._scene: + # only when exporting scene + tracks = api.object.animated_xform(self.node, self.options) + merge = self._scene[constants.ANIMATION][0][constants.KEYFRAMES] + for track in tracks: + merge.append(track) if self.options.get(constants.HIERARCHY, False): for child in api.object.children(self.node, self.scene.valid_types):
true
Other
mrdoob
three.js
8ee9c980007eca2ff0cd8bdd6c06a59236ad3f64.json
write animations at the root
utils/exporters/blender/addons/io_three/exporter/scene.py
@@ -10,7 +10,7 @@ io, api ) - +from bpy import context class Scene(base_classes.BaseScene): """Class that handles the contruction of a Three scene""" @@ -22,13 +22,23 @@ def __init__(self, filepath, options=None): constants.GEOMETRIES: [], constants.MATERIALS: [], constants.IMAGES: [], - constants.TEXTURES: [] + constants.TEXTURES: [], + constants.ANIMATION: [] } base_classes.BaseScene.__init__(self, filepath, options or {}) source_file = api.scene_name() if source_file: self[constants.METADATA][constants.SOURCE_FILE] = source_file + self.__init_animation() + + def __init_animation(self): + self[constants.ANIMATION].append({ + constants.NAME: "default", + constants.FPS : context.scene.render.fps, + constants.KEYFRAMES: [] + }); + pass @property def valid_types(self):
true
Other
mrdoob
three.js
a99f5f8f686fd1de274fbe9007e6158eef20dc3a.json
add tests for bufferGeometry
test/unit/core/BufferGeometry.js
@@ -0,0 +1,319 @@ +/** + * @author simonThiele / https://github.com/simonThiele + */ + +module( "BufferGeometry" ); + +var DegToRad = Math.PI / 180; + +test( "add / delete Attribute", function() { + var geometry = new THREE.BufferGeometry(); + var attributeName = "position"; + + ok ( geometry.attributes[attributeName] === undefined , 'no attribute defined' ); + + geometry.addAttribute( attributeName, new THREE.BufferAttribute( new Float32Array( [1, 2, 3], 1 ) ) ); + + ok ( geometry.attributes[attributeName] !== undefined , 'attribute is defined' ); + + geometry.removeAttribute( attributeName ); + + ok ( geometry.attributes[attributeName] === undefined , 'no attribute defined' ); +}); + +test( "applyMatrix", function() { + var geometry = new THREE.BufferGeometry(); + geometry.addAttribute( "position", new THREE.BufferAttribute( new Float32Array(6), 3 ) ); + + var matrix = new THREE.Matrix4().set( + 1, 0, 0, 1.5, + 0, 1, 0, -2, + 0, 0, 1, 3, + 0, 0, 0, 1 + ); + geometry.applyMatrix(matrix); + + var position = geometry.attributes.position.array; + var m = matrix.elements; + ok( position[0] === m[12] && position[1] === m[13] && position[2] === m[14], "position was extracted from matrix" ); + ok( position[3] === m[12] && position[4] === m[13] && position[5] === m[14], "position was extracted from matrix twice" ); + ok( geometry.attributes.position.version === 1, "version was increased during update" ); +}); + +test( "rotateX/Y/Z", function() { + var geometry = new THREE.BufferGeometry(); + geometry.addAttribute( "position", new THREE.BufferAttribute( new Float32Array([1, 2, 3, 4, 5, 6]), 3 ) ); + + var pos = geometry.attributes.position.array; + + geometry.rotateX( 180 * DegToRad ); + + // object was rotated around x so all items should be flipped but the x ones + ok( pos[0] === 1 && pos[1] === -2 && pos[2] === -3 && + pos[3] === 4 && pos[4] === -5 && pos[5] === -6, "vertices were rotated around x by 180 degrees" ); + + + geometry.rotateY( 180 * DegToRad ); + + // vertices were rotated around y so all items should be flipped again but the y ones + ok( pos[0] === -1 && pos[1] === -2 && pos[2] === 3 && + pos[3] === -4 && pos[4] === -5 && pos[5] === 6, "vertices were rotated around y by 180 degrees" ); + + + geometry.rotateZ( 180 * DegToRad ); + + // vertices were rotated around z so all items should be flipped again but the z ones + ok( pos[0] === 1 && pos[1] === 2 && pos[2] === 3 && + pos[3] === 4 && pos[4] === 5 && pos[5] === 6, "vertices were rotated around z by 180 degrees" ); +}); + + +test( "translate", function() { + var geometry = new THREE.BufferGeometry(); + geometry.addAttribute( "position", new THREE.BufferAttribute( new Float32Array([1, 2, 3, 4, 5, 6]), 3 ) ); + + var pos = geometry.attributes.position.array; + + geometry.translate( 10, 20, 30 ); + + ok( pos[0] === 11 && pos[1] === 22 && pos[2] === 33 && + pos[3] === 14 && pos[4] === 25 && pos[5] === 36, "vertices were translated" ); +}); + +test( "scale", function() { + var geometry = new THREE.BufferGeometry(); + geometry.addAttribute( "position", new THREE.BufferAttribute( new Float32Array([-1, -1, -1, 2, 2, 2]), 3 ) ); + + var pos = geometry.attributes.position.array; + + geometry.scale( 1, 2, 3 ); + + ok( pos[0] === -1 && pos[1] === -2 && pos[2] === -3 && + pos[3] === 2 && pos[4] === 4 && pos[5] === 6, "vertices were scaled" ); +}); + +test( "center", function() { + var geometry = new THREE.BufferGeometry(); + geometry.addAttribute( "position", new THREE.BufferAttribute( new Float32Array([ + -1, -1, -1, + 1, 1, 1, + 4, 4, 4 + ]), 3 ) ); + + geometry.center(); + + var pos = geometry.attributes.position.array; + var bb = geometry.boundingBox; + + // the boundingBox should go from (-1, -1, -1) to (4, 4, 4) so it has a size of (5, 5, 5) + // after centering it the vertices should be placed between (-2.5, -2.5, -2.5) and (2.5, 2.5, 2.5) + ok( pos[0] === -2.5 && pos[1] === -2.5 && pos[2] === -2.5 && + pos[3] === -0.5 && pos[4] === -0.5 && pos[5] === -0.5 && + pos[6] === 2.5 && pos[7] === 2.5 && pos[8] === 2.5, "vertices were replaced by boundingBox dimensions" ); +}); + +test( "setFromObject", function() { + var lineGeo = new THREE.Geometry(); + lineGeo.vertices.push( + new THREE.Vector3( -10, 0, 0 ), + new THREE.Vector3( 0, 10, 0 ), + new THREE.Vector3( 10, 0, 0 ) + ); + + lineGeo.colors.push( + new THREE.Color(1, 0, 0 ), + new THREE.Color(0, 1, 0 ), + new THREE.Color(0, 0, 1 ) + ); + + var line = new THREE.Line( lineGeo, null ); + var geometry = new THREE.BufferGeometry().setFromObject( line ); + + var pos = geometry.attributes.position.array; + var col = geometry.attributes.color.array; + var v = lineGeo.vertices; + var c = lineGeo.colors; + + ok( + // position exists + pos !== undefined && + + // vertex arrays have the same size + v.length * 3 === pos.length && + + // there are three complete vertices (each vertex contains three values) + geometry.attributes.position.count === 3 && + + // check if both arrays contains the same data + pos[0] === v[0].x && pos[1] === v[0].y && pos[2] === v[0].z && + pos[3] === v[1].x && pos[4] === v[1].y && pos[5] === v[1].z && + pos[6] === v[2].x && pos[7] === v[2].y && pos[8] === v[2].z + , "positions are equal" ); + + ok( + // color exists + col !== undefined && + + // color arrays have the same size + c.length * 3 === col.length && + + // there are three complete colors (each color contains three values) + geometry.attributes.color.count === 3 && + + // check if both arrays contains the same data + col[0] === c[0].r && col[1] === c[0].g && col[2] === c[0].b && + col[3] === c[1].r && col[4] === c[1].g && col[5] === c[1].b && + col[6] === c[2].r && col[7] === c[2].g && col[8] === c[2].b + , "colors are equal" ); +}); + +test( "computeBoundingBox", function() { + var bb = getBBForVertices( [-1, -2, -3, 13, -2, -3.5, -1, -20, 0, -4, 5, 6] ); + + ok( bb.min.x === -4 && bb.min.y === -20 && bb.min.z === -3.5, "min values are set correctly" ); + ok( bb.max.x === 13 && bb.max.y === 5 && bb.max.z === 6, "max values are set correctly" ); + + + bb = getBBForVertices( [] ); + + ok( bb.min.x === 0 && bb.min.y === 0 && bb.min.z === 0, "since there are no values given, the bb has size = 0" ); + ok( bb.max.x === 0 && bb.max.y === 0 && bb.max.z === 0, "since there are no values given, the bb has size = 0" ); + + + bb = getBBForVertices( [-1, -1, -1] ); + + ok( bb.min.x === bb.max.x && bb.min.y === bb.max.y && bb.min.z === bb.max.z, "since there is only one vertex, max and min are equal" ); + ok( bb.min.x === -1 && bb.min.y === -1 && bb.min.z === -1, "since there is only one vertex, min and max are this vertex" ); + + bb = getBBForVertices( [-1] ); +}); + +test( "computeBoundingSphere", function() { + var bs = getBSForVertices( [-10, 0, 0, 10, 0, 0] ); + + ok( bs.radius === (10 + 10) / 2, "radius is equal to deltaMinMax / 2" ) + ok( bs.center.x === 0 && bs.center.y === 0 && bs.center.y === 0, "bounding sphere is at ( 0, 0, 0 )" ) + + + var bs = getBSForVertices( [-5, 11, -3, 5, -11, 3] ); + var radius = new THREE.Vector3(5, 11, 3).length(); + + ok( bs.radius === radius, "radius is equal to directionLength" ) + ok( bs.center.x === 0 && bs.center.y === 0 && bs.center.y === 0, "bounding sphere is at ( 0, 0, 0 )" ) +}); + +function getBBForVertices(vertices) { + var geometry = new THREE.BufferGeometry(); + + geometry.addAttribute( "position", new THREE.BufferAttribute( new Float32Array(vertices), 3 ) ); + geometry.computeBoundingBox(); + + return geometry.boundingBox; +} + +function getBSForVertices(vertices) { + var geometry = new THREE.BufferGeometry(); + + geometry.addAttribute( "position", new THREE.BufferAttribute( new Float32Array(vertices), 3 ) ); + geometry.computeBoundingSphere(); + + return geometry.boundingSphere; +} + +test( "computeVertexNormals", function() { + // get normals for a counter clockwise created triangle + var normals = getNormalsForVertices([-1, 0, 0, 1, 0, 0, 0, 1, 0]); + + ok( normals[0] === 0 && normals[1] === 0 && normals[2] === 1, + "first normal is pointing to screen since the the triangle was created counter clockwise" ); + + ok( normals[3] === 0 && normals[4] === 0 && normals[5] === 1, + "second normal is pointing to screen since the the triangle was created counter clockwise" ); + + ok( normals[6] === 0 && normals[7] === 0 && normals[8] === 1, + "third normal is pointing to screen since the the triangle was created counter clockwise" ); + + + // get normals for a clockwise created triangle + var normals = getNormalsForVertices([1, 0, 0, -1, 0, 0, 0, 1, 0]); + + ok( normals[0] === 0 && normals[1] === 0 && normals[2] === -1, + "first normal is pointing to screen since the the triangle was created clockwise" ); + + ok( normals[3] === 0 && normals[4] === 0 && normals[5] === -1, + "second normal is pointing to screen since the the triangle was created clockwise" ); + + ok( normals[6] === 0 && normals[7] === 0 && normals[8] === -1, + "third normal is pointing to screen since the the triangle was created clockwise" ); + + + var normals = getNormalsForVertices([0, 0, 1, 0, 0, -1, 1, 1, 0]); + + // the triangle is rotated by 45 degrees to the right so the normals of the three vertices + // should point to (1, -1, 0).normalized(). The simplest solution is to check against a normalized + // vector (1, -1, 0) but you will get calculation errors because of floating calculations so another + // valid technique is to create a vector which stands in 90 degrees to the normals and calculate the + // dot product which is the cos of the angle between them. This should be < floating calculation error + // which can be taken from Number.EPSILON + var direction = new THREE.Vector3(1, 1, 0).normalize(); // a vector which should have 90 degrees difference to normals + var difference = direction.dot( new THREE.Vector3( normals[0], normals[1], normals[2] ) ); + ok( difference < Number.EPSILON, "normal is equal to reference vector"); + + + // get normals for a line should be NAN because you need min a triangle to calculate normals + var normals = getNormalsForVertices([1, 0, 0, -1, 0, 0]); + for (var i = 0; i < normals.length; i++) { + ok ( !normals[i], "normals can't be calculated which is good"); + } +}); + +function getNormalsForVertices(vertices) { + var geometry = new THREE.BufferGeometry(); + + geometry.addAttribute( "position", new THREE.BufferAttribute( new Float32Array(vertices), 3 ) ); + + geometry.computeVertexNormals(); + + ok( geometry.attributes.normal !== undefined, "normal attribute was created" ); + + return geometry.attributes.normal.array; +} + +test( "merge", function() { + var geometry1 = new THREE.BufferGeometry(); + geometry1.addAttribute( "attrName", new THREE.BufferAttribute( new Float32Array([1, 2, 3, 0, 0, 0]), 3 ) ); + + var geometry2 = new THREE.BufferGeometry(); + geometry2.addAttribute( "attrName", new THREE.BufferAttribute( new Float32Array([4, 5, 6]), 3 ) ); + + var attr = geometry1.attributes.attrName.array; + + geometry1.merge(geometry2, 1); + + // merged array should be 1, 2, 3, 4, 5, 6 + for (var i = 0; i < attr.length; i++) { + ok( attr[i] === i + 1, ""); + } + + geometry1.merge(geometry2); + ok( attr[0] === 4 && attr[1] === 5 && attr[2] === 6, "copied the 3 attributes without offset" ); +}); + +test( "copy", function() { + var geometry = new THREE.BufferGeometry(); + geometry.addAttribute( "attrName", new THREE.BufferAttribute( new Float32Array([1, 2, 3, 4, 5, 6]), 3 ) ); + geometry.addAttribute( "attrName2", new THREE.BufferAttribute( new Float32Array([0, 1, 3, 5, 6]), 1 ) ); + + var copy = new THREE.BufferGeometry().copy(geometry); + + ok( copy !== geometry && geometry.id !== copy.id, "new object was created" ); + + Object.keys(geometry.attributes).forEach(function(key) { + var attribute = geometry.attributes[key]; + ok( attribute !== undefined, "all attributes where copied"); + + for (var i = 0; i < attribute.array.length; i++) { + ok( attribute.array[i] === copy.attributes[key].array[i], "values of the attribute are equal" ); + } + }); +});
true
Other
mrdoob
three.js
a99f5f8f686fd1de274fbe9007e6158eef20dc3a.json
add tests for bufferGeometry
test/unit/unittests_three.html
@@ -23,6 +23,7 @@ <script src="cameras/PerspectiveCamera.js"></script> <script src="core/BufferAttribute.js"></script> + <script src="core/BufferGeometry.js"></script> <script src="core/Object3D.js"></script> <script src="math/Constants.js"></script>
true
Other
mrdoob
three.js
a8021bedfdff485e7d8bedad510a44563bdd6583.json
add tests for BufferAttribute
test/unit/core/BufferAttribute.js
@@ -0,0 +1,117 @@ +/** + * @author simonThiele / https://github.com/simonThiele + */ + +module( "BufferAttribute" ); + +test( "count", function() { + ok( + new THREE.BufferAttribute( new Float32Array( [1, 2, 3, 4, 5, 6] ), 3 ).count === 2, + 'count is equal to the number of chunks' + ); +}); + +test( "copy", function() { + var attr = new THREE.BufferAttribute( new Float32Array( [1, 2, 3, 4, 5, 6] ), 3 ); + attr.setDynamic( true ); + attr.needsUpdate = true; + + var attrCopy = new THREE.BufferAttribute().copy( attr ); + + ok( attr.count === attrCopy.count, 'count is equal' ); + ok( attr.itemSize === attrCopy.itemSize, 'itemSize is equal' ); + ok( attr.dynamic === attrCopy.dynamic, 'dynamic is equal' ); + ok( attr.array.length === attrCopy.array.length, 'array length is equal' ); + ok( attr.version === 1 && attrCopy.version === 0, 'version is not copied which is good' ); +}); + +test( "copyAt", function() { + var attr = new THREE.BufferAttribute( new Float32Array( [1, 2, 3, 4, 5, 6, 7, 8, 9] ), 3 ); + var attr2 = new THREE.BufferAttribute( [], 3 ); + + attr2.copyAt( 1, attr, 2 ); + attr2.copyAt( 0, attr, 1 ); + attr2.copyAt( 2, attr, 0 ); + + var i = attr.array; + var i2 = attr2.array; // should be [4, 5, 6, 7, 8, 9, 1, 2, 3] + + ok( i2[0] === i[3] && i2[1] === i[4] && i2[2] === i[5], 'chunck copied to correct place' ); + ok( i2[3] === i[6] && i2[4] === i[7] && i2[5] === i[8], 'chunck copied to correct place' ); + ok( i2[6] === i[0] && i2[7] === i[1] && i2[8] === i[2], 'chunck copied to correct place' ); +}); + +test( "copyColorsArray", function() { + var attr = new THREE.BufferAttribute( [], 3 ); + + attr.copyColorsArray( [ + new THREE.Color( 0, 0.5, 1 ), + new THREE.Color( 0.25, 1, 0 ) + ]); + + var i = attr.array; + ok( i[0] === 0 && i[1] === 0.5 && i[2] === 1, 'first color was copied correctly' ); + ok( i[3] === 0.25 && i[4] === 1 && i[5] === 0, 'second color was copied correctly' ); +}); + +test( "copyIndicesArray", function() { + var attr = new THREE.BufferAttribute( [], 3 ); + + attr.copyIndicesArray( [ + {a: 1, b: 2, c: 3}, + {a: 4, b: 5, c: 6} + ]); + + var i = attr.array; + ok( i[0] === 1 && i[1] === 2 && i[2] === 3, 'first indices were copied correctly' ); + ok( i[3] === 4 && i[4] === 5 && i[5] === 6, 'second indices were copied correctly' ); +}); + +test( "copyVector2sArray", function() { + var attr = new THREE.BufferAttribute( [], 2 ); + + attr.copyVector2sArray( [ + new THREE.Vector2(1, 2), + new THREE.Vector2(4, 5) + ]); + + var i = attr.array; + ok( i[0] === 1 && i[1] === 2, 'first vector was copied correctly' ); + ok( i[2] === 4 && i[3] === 5, 'second vector was copied correctly' ); +}); + +test( "copyVector3sArray", function() { + var attr = new THREE.BufferAttribute( [], 2 ); + + attr.copyVector3sArray( [ + new THREE.Vector3(1, 2, 3), + new THREE.Vector3(10, 20, 30) + ]); + + var i = attr.array; + ok( i[0] === 1 && i[1] === 2 && i[2] === 3, 'first vector was copied correctly' ); + ok( i[3] === 10 && i[4] === 20 && i[5] === 30, 'second vector was copied correctly' ); +}); + +test( "copyVector4sArray", function() { + var attr = new THREE.BufferAttribute( [], 2 ); + + attr.copyVector4sArray( [ + new THREE.Vector4(1, 2, 3, 4), + new THREE.Vector4(10, 20, 30, 40) + ]); + + var i = attr.array; + ok( i[0] === 1 && i[1] === 2 && i[2] === 3 && i[3] === 4, 'first vector was copied correctly' ); + ok( i[4] === 10 && i[5] === 20 && i[6] === 30 && i[7] === 40, 'second vector was copied correctly' ); +}); + +test( "clone", function() { + var attr = new THREE.BufferAttribute( new Float32Array([1, 2, 3, 4, 0.12, -12]), 2 ); + var attrCopy = attr.clone(); + + ok( attr.array.length === attrCopy.array.length, 'attribute was cloned' ); + for ( var i = 0; i < attr.array.length; i++ ) { + ok( attr.array[i] === attrCopy.array[i], 'array item is equal' ); + } +});
true
Other
mrdoob
three.js
a8021bedfdff485e7d8bedad510a44563bdd6583.json
add tests for BufferAttribute
test/unit/unittests_three.html
@@ -22,6 +22,7 @@ <script src="cameras/OrthographicCamera.js"></script> <script src="cameras/PerspectiveCamera.js"></script> + <script src="core/BufferAttribute.js"></script> <script src="core/Object3D.js"></script> <script src="math/Constants.js"></script>
true
Other
mrdoob
three.js
1d12f6167fea809fff93df45429c57d0d4d3db2b.json
add tests for perspective camera
test/unit/cameras/PerspectiveCamera.js
@@ -0,0 +1,56 @@ +/** + * @author simonThiele / https://github.com/simonThiele + */ + +module( "PerspectiveCamera" ); + +test( "updateProjectionMatrix", function() { + var near = 1, + far = 3, + bottom = -1, + top = 1, + aspect = 16 / 9, + left = -top * aspect, + right = -bottom * aspect, + fov = 90; + + var cam = new THREE.PerspectiveCamera( fov, aspect, near, far ); + + // updateProjectionMatrix is called in contructor + var m = cam.projectionMatrix.elements; + + // perspective projection is given my the 4x4 Matrix + // 2n/r-l 0 l+r/r-l 0 + // 0 2n/t-b t+b/t-b 0 + // 0 0 -(f+n/f-n) -(2fn/f-n) + // 0 0 0 1 + + ok( m[0] === ( 2 * near ) / ( right - left ), "m[0,0] === 2n/r-l" ); + ok( m[5] === ( 2 * near ) / ( top - bottom ), "m[1,1] === 2n/r-l" ); + ok( m[8] === ( right + left ) / ( right - left ), "m[2,0] === 2n/r-l" ); + ok( m[9] === ( top + bottom ) / ( top - bottom ), "m[2,1] === 2n/r-l" ); + ok( m[10] === - ( far + near ) / ( far - near ), "m[2,2] === 2n/r-l" ); + ok( m[14] === - ( 2 * near * far ) / ( far - near ), "m[3,2] === 2n/r-l" ); +}); + +test( "clone", function() { + var near = 1, + far = 3, + bottom = -1, + top = 1, + aspect = 16 / 9, + left = -top * aspect, + right = -bottom * aspect, + fov = 90; + + var cam = new THREE.PerspectiveCamera( fov, aspect, near, far ); + + var clonedCam = cam.clone(); + + ok( cam.fov === clonedCam.fov , "fov is equal" ); + ok( cam.aspect === clonedCam.aspect , "aspect is equal" ); + ok( cam.near === clonedCam.near , "near is equal" ); + ok( cam.far === clonedCam.far , "far is equal" ); + ok( cam.zoom === clonedCam.zoom , "zoom is equal" ); + ok( cam.projectionMatrix.equals(clonedCam.projectionMatrix) , "projectionMatrix is equal" ); +});
true
Other
mrdoob
three.js
1d12f6167fea809fff93df45429c57d0d4d3db2b.json
add tests for perspective camera
test/unit/unittests_three.html
@@ -20,6 +20,7 @@ <script src="cameras/Camera.js"></script> <script src="cameras/OrthographicCamera.js"></script> + <script src="cameras/PerspectiveCamera.js"></script> <script src="core/Object3D.js"></script>
true
Other
mrdoob
three.js
aaa0df093590184adf246e9d8d424db7126d70f6.json
add tests for orthographic camera
test/unit/cameras/OrthographicCamera.js
@@ -0,0 +1,41 @@ +/** + * @author simonThiele / https://github.com/simonThiele + */ + +module( "OrthographicCamera" ); + +test( "updateProjectionMatrix", function() { + var left = -1, right = 1, top = 1, bottom = -1, near = 1, far = 3; + cam = new THREE.OrthographicCamera(left, right, top, bottom, near, far); + + // updateProjectionMatrix is called in contructor + var pMatrix = cam.projectionMatrix.elements; + + // orthographic projection is given my the 4x4 Matrix + // 2/r-l 0 0 -(l+r/r-l) + // 0 2/t-b 0 -(t+b/t-b) + // 0 0 -2/f-n -(f+n/f-n) + // 0 0 0 1 + + ok( pMatrix[0] === 2 / ( right - left ), "m[0,0] === 2 / (r - l)" ); + ok( pMatrix[5] === 2 / ( top - bottom ), "m[1,1] === 2 / (t - b)" ); + ok( pMatrix[10] === -2 / ( far - near ), "m[2,2] === -2 / (f - n)" ); + ok( pMatrix[12] === - ( ( right + left ) / ( right - left ) ), "m[3,0] === -(r+l/r-l)" ); + ok( pMatrix[13] === - ( ( top + bottom ) / ( top - bottom ) ), "m[3,1] === -(t+b/b-t)" ); + ok( pMatrix[14] === - ( ( far + near ) / ( far - near ) ), "m[3,2] === -(f+n/f-n)" ); +}); + +test( "clone", function() { + var left = -1.5, right = 1.5, top = 1, bottom = -1, near = 0.1, far = 42; + var cam = new THREE.OrthographicCamera(left, right, top, bottom, near, far); + + var clonedCam = cam.clone(); + + ok( cam.left === clonedCam.left , "left is equal" ); + ok( cam.right === clonedCam.right , "right is equal" ); + ok( cam.top === clonedCam.top , "top is equal" ); + ok( cam.bottom === clonedCam.bottom , "bottom is equal" ); + ok( cam.near === clonedCam.near , "near is equal" ); + ok( cam.far === clonedCam.far , "far is equal" ); + ok( cam.zoom === clonedCam.zoom , "zoom is equal" ); +});
true
Other
mrdoob
three.js
aaa0df093590184adf246e9d8d424db7126d70f6.json
add tests for orthographic camera
test/unit/unittests_three.html
@@ -18,9 +18,10 @@ <!-- add class-based unit tests below --> - <script src="core/Object3D.js"></script> + <script src="cameras/Camera.js"></script> + <script src="cameras/OrthographicCamera.js"></script> - <script src="Cameras/Camera.js"></script> + <script src="core/Object3D.js"></script> <script src="math/Constants.js"></script> <script src="math/Box2.js"></script>
true
Other
mrdoob
three.js
760252a56043ef0031f08d4e56b6582c9224b6a2.json
add space after comma
examples/js/Cloth.js
@@ -35,7 +35,7 @@ var pins = []; var wind = true; var windStrength = 2; -var windForce = new THREE.Vector3( 0,0,0 ); +var windForce = new THREE.Vector3( 0, 0, 0 ); var ballPosition = new THREE.Vector3( 0, - 45, 0 ); var ballSize = 60; //40 @@ -239,7 +239,7 @@ function simulate( time ) { particles = cloth.particles; - for ( i = 0,il = faces.length; i < il; i ++ ) { + for ( i = 0, il = faces.length; i < il; i ++ ) { face = faces[ i ]; normal = face.normal;
true
Other
mrdoob
three.js
760252a56043ef0031f08d4e56b6582c9224b6a2.json
add space after comma
examples/js/Sparks.js
@@ -487,7 +487,7 @@ SPARKS.ActionZone.prototype.update = function( emitter, particle, time ) { /* * Accelerate action affects velocity in specified 3d direction */ -SPARKS.Accelerate = function( x,y,z ) { +SPARKS.Accelerate = function( x, y, z ) { if ( x instanceof THREE.Vector3 ) { @@ -496,7 +496,7 @@ SPARKS.Accelerate = function( x,y,z ) { } - this.acceleration = new THREE.Vector3( x,y,z ); + this.acceleration = new THREE.Vector3( x, y, z ); }; @@ -569,7 +569,7 @@ SPARKS.AccelerateVelocity.prototype.update = function( emitter, particle, time ) /* Set the max ammount of x,y,z drift movements in a second */ -SPARKS.RandomDrift = function( x,y,z ) { +SPARKS.RandomDrift = function( x, y, z ) { if ( x instanceof THREE.Vector3 ) { @@ -578,7 +578,7 @@ SPARKS.RandomDrift = function( x,y,z ) { } - this.drift = new THREE.Vector3( x,y,z ); + this.drift = new THREE.Vector3( x, y, z ); };
true
Other
mrdoob
three.js
760252a56043ef0031f08d4e56b6582c9224b6a2.json
add space after comma
examples/js/controls/TransformControls.js
@@ -382,23 +382,23 @@ this.handleGizmos = { X: [ - [ new THREE.Line( new CircleGeometry( 1,'x',0.5 ), new GizmoLineMaterial( { color: 0xff0000 } ) ) ] + [ new THREE.Line( new CircleGeometry( 1, 'x', 0.5 ), new GizmoLineMaterial( { color: 0xff0000 } ) ) ] ], Y: [ - [ new THREE.Line( new CircleGeometry( 1,'y',0.5 ), new GizmoLineMaterial( { color: 0x00ff00 } ) ) ] + [ new THREE.Line( new CircleGeometry( 1, 'y', 0.5 ), new GizmoLineMaterial( { color: 0x00ff00 } ) ) ] ], Z: [ - [ new THREE.Line( new CircleGeometry( 1,'z',0.5 ), new GizmoLineMaterial( { color: 0x0000ff } ) ) ] + [ new THREE.Line( new CircleGeometry( 1, 'z', 0.5 ), new GizmoLineMaterial( { color: 0x0000ff } ) ) ] ], E: [ - [ new THREE.Line( new CircleGeometry( 1.25,'z',1 ), new GizmoLineMaterial( { color: 0xcccc00 } ) ) ] + [ new THREE.Line( new CircleGeometry( 1.25, 'z', 1 ), new GizmoLineMaterial( { color: 0xcccc00 } ) ) ] ], XYZE: [ - [ new THREE.Line( new CircleGeometry( 1,'z',1 ), new GizmoLineMaterial( { color: 0x787878 } ) ) ] + [ new THREE.Line( new CircleGeometry( 1, 'z', 1 ), new GizmoLineMaterial( { color: 0x787878 } ) ) ] ] };
true
Other
mrdoob
three.js
760252a56043ef0031f08d4e56b6582c9224b6a2.json
add space after comma
examples/js/loaders/AssimpJSONLoader.js
@@ -123,7 +123,7 @@ THREE.AssimpJSONLoader.prototype = { for ( in_data = json.faces, i = 0, e = in_data.length; i < e; ++ i ) { src = in_data[ i ]; - face = new THREE.Face3( src[ 0 ],src[ 1 ],src[ 2 ] ); + face = new THREE.Face3( src[ 0 ], src[ 1 ], src[ 2 ] ); geometry.faces.push( face ); }
true
Other
mrdoob
three.js
760252a56043ef0031f08d4e56b6582c9224b6a2.json
add space after comma
examples/js/loaders/ColladaLoader.js
@@ -4398,8 +4398,8 @@ // TODO - this might be a good place to choose greatest 4 weights for ( var i = 0; i < weights.length; i ++ ) { - var indicies = new THREE.Vector4( weights[ i ][ 0 ] ? weights[ i ][ 0 ].joint : 0,weights[ i ][ 1 ] ? weights[ i ][ 1 ].joint : 0,weights[ i ][ 2 ] ? weights[ i ][ 2 ].joint : 0,weights[ i ][ 3 ] ? weights[ i ][ 3 ].joint : 0 ); - var weight = new THREE.Vector4( weights[ i ][ 0 ] ? weights[ i ][ 0 ].weight : 0,weights[ i ][ 1 ] ? weights[ i ][ 1 ].weight : 0,weights[ i ][ 2 ] ? weights[ i ][ 2 ].weight : 0,weights[ i ][ 3 ] ? weights[ i ][ 3 ].weight : 0 ); + var indicies = new THREE.Vector4( weights[ i ][ 0 ] ? weights[ i ][ 0 ].joint : 0, weights[ i ][ 1 ] ? weights[ i ][ 1 ].joint : 0, weights[ i ][ 2 ] ? weights[ i ][ 2 ].joint : 0, weights[ i ][ 3 ] ? weights[ i ][ 3 ].joint : 0 ); + var weight = new THREE.Vector4( weights[ i ][ 0 ] ? weights[ i ][ 0 ].weight : 0, weights[ i ][ 1 ] ? weights[ i ][ 1 ].weight : 0, weights[ i ][ 2 ] ? weights[ i ][ 2 ].weight : 0, weights[ i ][ 3 ] ? weights[ i ][ 3 ].weight : 0 ); skinIndices.push( indicies ); skinWeights.push( weight ); @@ -4413,7 +4413,7 @@ //create an animation for the animated bones //NOTE: this has no effect when using morphtargets - var animationdata = { "name": animationBounds.ID,"fps": 30,"length": animationBounds.frames / 30,"hierarchy": [] }; + var animationdata = { "name": animationBounds.ID, "fps": 30, "length": animationBounds.frames / 30, "hierarchy": [] }; for ( var j = 0; j < sortedbones.length; j ++ ) { @@ -4451,12 +4451,12 @@ if ( frame === 0 ) bones[ i ].matrix = key.matrix; - var data = [ new THREE.Vector3(),new THREE.Quaternion(),new THREE.Vector3() ]; + var data = [ new THREE.Vector3(), new THREE.Quaternion(), new THREE.Vector3() ]; key.matrix.decompose( data[ 0 ], data[ 1 ], data[ 2 ] ); - key.pos = [ data[ 0 ].x,data[ 0 ].y,data[ 0 ].z ]; + key.pos = [ data[ 0 ].x, data[ 0 ].y, data[ 0 ].z ]; - key.scl = [ data[ 2 ].x,data[ 2 ].y,data[ 2 ].z ]; + key.scl = [ data[ 2 ].x, data[ 2 ].y, data[ 2 ].z ]; key.rot = data[ 1 ]; animationdata.hierarchy[ j ].keys.push( key ); @@ -4497,7 +4497,7 @@ } - return { start: start, end: end, frames: frames,ID: ID }; + return { start: start, end: end, frames: frames, ID: ID }; }; @@ -5028,13 +5028,13 @@ bone.name = node.sid; bone.parent = parentid; bone.matrix = node.matrix; - var data = [ new THREE.Vector3(),new THREE.Quaternion(),new THREE.Vector3() ]; + var data = [ new THREE.Vector3(), new THREE.Quaternion(), new THREE.Vector3() ]; bone.matrix.decompose( data[ 0 ], data[ 1 ], data[ 2 ] ); - bone.pos = [ data[ 0 ].x,data[ 0 ].y,data[ 0 ].z ]; + bone.pos = [ data[ 0 ].x, data[ 0 ].y, data[ 0 ].z ]; - bone.scl = [ data[ 2 ].x,data[ 2 ].y,data[ 2 ].z ]; - bone.rotq = [ data[ 1 ].x,data[ 1 ].y,data[ 1 ].z,data[ 1 ].w ]; + bone.scl = [ data[ 2 ].x, data[ 2 ].y, data[ 2 ].z ]; + bone.rotq = [ data[ 1 ].x, data[ 1 ].y, data[ 1 ].z, data[ 1 ].w ]; list.push( bone ); for ( var i in node.nodes ) { @@ -5532,7 +5532,7 @@ }; //Move the vertices into the pose that is proper for the start of the animation - function skinToBindPose ( geometry,skeleton,skinController ) { + function skinToBindPose ( geometry, skeleton, skinController ) { var bones = []; setupSkeleton( skeleton, bones, - 1 );
true
Other
mrdoob
three.js
760252a56043ef0031f08d4e56b6582c9224b6a2.json
add space after comma
examples/js/loaders/PDBLoader.js
@@ -81,8 +81,8 @@ THREE.PDBLoader.prototype = { } - var CPK = { "h": [ 255,255,255 ],"he": [ 217,255,255 ],"li": [ 204,128,255 ],"be": [ 194,255,0 ],"b": [ 255,181,181 ],"c": [ 144,144,144 ],"n": [ 48,80,248 ],"o": [ 255,13,13 ],"f": [ 144,224,80 ],"ne": [ 179,227,245 ],"na": [ 171,92,242 ],"mg": [ 138,255,0 ],"al": [ 191,166,166 ],"si": [ 240,200,160 ],"p": [ 255,128,0 ],"s": [ 255,255,48 ],"cl": [ 31,240,31 ],"ar": [ 128,209,227 ],"k": [ 143,64,212 ],"ca": [ 61,255,0 ],"sc": [ 230,230,230 ],"ti": [ 191,194,199 ],"v": [ 166,166,171 ],"cr": [ 138,153,199 ],"mn": [ 156,122,199 ],"fe": [ 224,102,51 ],"co": [ 240,144,160 ],"ni": [ 80,208,80 ],"cu": [ 200,128,51 ],"zn": [ 125,128,176 ],"ga": [ 194,143,143 ],"ge": [ 102,143,143 ],"as": [ 189,128,227 ],"se": [ 255,161,0 ],"br": [ 166,41,41 ],"kr": [ 92,184,209 ],"rb": [ 112,46,176 ],"sr": [ 0,255,0 ],"y": [ 148,255,255 ],"zr": [ 148,224,224 ],"nb": [ 115,194,201 ],"mo": [ 84,181,181 ],"tc": [ 59,158,158 ],"ru": [ 36,143,143 ],"rh": [ 10,125,140 ],"pd": [ 0,105,133 ],"ag": [ 192,192,192 ],"cd": [ 255,217,143 ],"in": [ 166,117,115 ],"sn": [ 102,128,128 ],"sb": [ 158,99,181 ],"te": [ 212,122,0 ],"i": [ 148,0,148 ],"xe": [ 66,158,176 ],"cs": [ 87,23,143 ],"ba": [ 0,201,0 ],"la": [ 112,212,255 ],"ce": [ 255,255,199 ],"pr": [ 217,255,199 ],"nd": [ 199,255,199 ],"pm": [ 163,255,199 ],"sm": [ 143,255,199 ],"eu": [ 97,255,199 ],"gd": [ 69,255,199 ],"tb": [ 48,255,199 ],"dy": [ 31,255,199 ],"ho": [ 0,255,156 ],"er": [ 0,230,117 ],"tm": [ 0,212,82 ],"yb": [ 0,191,56 ],"lu": [ 0,171,36 ],"hf": [ 77,194,255 ],"ta": [ 77,166,255 ],"w": [ 33,148,214 ],"re": [ 38,125,171 ],"os": [ 38,102,150 ],"ir": [ 23,84,135 ],"pt": [ 208,208,224 ],"au": [ 255,209,35 ],"hg": [ 184,184,208 ],"tl": [ 166,84,77 ],"pb": [ 87,89,97 ],"bi": [ 158,79,181 ],"po": [ 171,92,0 ],"at": [ 117,79,69 ],"rn": [ 66,130,150 ],"fr": [ 66,0,102 ],"ra": [ 0,125,0 ],"ac": [ 112,171,250 ],"th": [ 0,186,255 ],"pa": [ 0,161,255 ],"u": [ 0,143,255 ],"np": [ 0,128,255 ],"pu": [ 0,107,255 ],"am": [ 84,92,242 ],"cm": [ 120,92,227 ],"bk": [ 138,79,227 ],"cf": [ 161,54,212 ],"es": [ 179,31,212 ],"fm": [ 179,31,186 ],"md": [ 179,13,166 ],"no": [ 189,13,135 ],"lr": [ 199,0,102 ],"rf": [ 204,0,89 ],"db": [ 209,0,79 ],"sg": [ 217,0,69 ],"bh": [ 224,0,56 ],"hs": [ 230,0,46 ],"mt": [ 235,0,38 ], - "ds": [ 235,0,38 ],"rg": [ 235,0,38 ],"cn": [ 235,0,38 ],"uut": [ 235,0,38 ],"uuq": [ 235,0,38 ],"uup": [ 235,0,38 ],"uuh": [ 235,0,38 ],"uus": [ 235,0,38 ],"uuo": [ 235,0,38 ] }; + var CPK = { "h": [ 255, 255, 255 ], "he": [ 217, 255, 255 ], "li": [ 204, 128, 255 ], "be": [ 194, 255, 0 ], "b": [ 255, 181, 181 ], "c": [ 144, 144, 144 ], "n": [ 48, 80, 248 ], "o": [ 255, 13, 13 ], "f": [ 144, 224, 80 ], "ne": [ 179, 227, 245 ], "na": [ 171, 92, 242 ], "mg": [ 138, 255, 0 ], "al": [ 191, 166, 166 ], "si": [ 240, 200, 160 ], "p": [ 255, 128, 0 ], "s": [ 255, 255, 48 ], "cl": [ 31, 240, 31 ], "ar": [ 128, 209, 227 ], "k": [ 143, 64, 212 ], "ca": [ 61, 255, 0 ], "sc": [ 230, 230, 230 ], "ti": [ 191, 194, 199 ], "v": [ 166, 166, 171 ], "cr": [ 138, 153, 199 ], "mn": [ 156, 122, 199 ], "fe": [ 224, 102, 51 ], "co": [ 240, 144, 160 ], "ni": [ 80, 208, 80 ], "cu": [ 200, 128, 51 ], "zn": [ 125, 128, 176 ], "ga": [ 194, 143, 143 ], "ge": [ 102, 143, 143 ], "as": [ 189, 128, 227 ], "se": [ 255, 161, 0 ], "br": [ 166, 41, 41 ], "kr": [ 92, 184, 209 ], "rb": [ 112, 46, 176 ], "sr": [ 0, 255, 0 ], "y": [ 148, 255, 255 ], "zr": [ 148, 224, 224 ], "nb": [ 115, 194, 201 ], "mo": [ 84, 181, 181 ], "tc": [ 59, 158, 158 ], "ru": [ 36, 143, 143 ], "rh": [ 10, 125, 140 ], "pd": [ 0, 105, 133 ], "ag": [ 192, 192, 192 ], "cd": [ 255, 217, 143 ], "in": [ 166, 117, 115 ], "sn": [ 102, 128, 128 ], "sb": [ 158, 99, 181 ], "te": [ 212, 122, 0 ], "i": [ 148, 0, 148 ], "xe": [ 66, 158, 176 ], "cs": [ 87, 23, 143 ], "ba": [ 0, 201, 0 ], "la": [ 112, 212, 255 ], "ce": [ 255, 255, 199 ], "pr": [ 217, 255, 199 ], "nd": [ 199, 255, 199 ], "pm": [ 163, 255, 199 ], "sm": [ 143, 255, 199 ], "eu": [ 97, 255, 199 ], "gd": [ 69, 255, 199 ], "tb": [ 48, 255, 199 ], "dy": [ 31, 255, 199 ], "ho": [ 0, 255, 156 ], "er": [ 0, 230, 117 ], "tm": [ 0, 212, 82 ], "yb": [ 0, 191, 56 ], "lu": [ 0, 171, 36 ], "hf": [ 77, 194, 255 ], "ta": [ 77, 166, 255 ], "w": [ 33, 148, 214 ], "re": [ 38, 125, 171 ], "os": [ 38, 102, 150 ], "ir": [ 23, 84, 135 ], "pt": [ 208, 208, 224 ], "au": [ 255, 209, 35 ], "hg": [ 184, 184, 208 ], "tl": [ 166, 84, 77 ], "pb": [ 87, 89, 97 ], "bi": [ 158, 79, 181 ], "po": [ 171, 92, 0 ], "at": [ 117, 79, 69 ], "rn": [ 66, 130, 150 ], "fr": [ 66, 0, 102 ], "ra": [ 0, 125, 0 ], "ac": [ 112, 171, 250 ], "th": [ 0, 186, 255 ], "pa": [ 0, 161, 255 ], "u": [ 0, 143, 255 ], "np": [ 0, 128, 255 ], "pu": [ 0, 107, 255 ], "am": [ 84, 92, 242 ], "cm": [ 120, 92, 227 ], "bk": [ 138, 79, 227 ], "cf": [ 161, 54, 212 ], "es": [ 179, 31, 212 ], "fm": [ 179, 31, 186 ], "md": [ 179, 13, 166 ], "no": [ 189, 13, 135 ], "lr": [ 199, 0, 102 ], "rf": [ 204, 0, 89 ], "db": [ 209, 0, 79 ], "sg": [ 217, 0, 69 ], "bh": [ 224, 0, 56 ], "hs": [ 230, 0, 46 ], "mt": [ 235, 0, 38 ], + "ds": [ 235, 0, 38 ], "rg": [ 235, 0, 38 ], "cn": [ 235, 0, 38 ], "uut": [ 235, 0, 38 ], "uuq": [ 235, 0, 38 ], "uup": [ 235, 0, 38 ], "uuh": [ 235, 0, 38 ], "uus": [ 235, 0, 38 ], "uuo": [ 235, 0, 38 ] }; var atoms = []; @@ -106,7 +106,7 @@ THREE.PDBLoader.prototype = { e = trim( lines[ i ].substr( 76, 2 ) ).toLowerCase(); if ( e == "" ) e = trim( lines[ i ].substr( 12, 2 ) ).toLowerCase(); - atoms.push( [ x,y,z, CPK[ e ], capitalize( e ) ] ); + atoms.push( [ x, y, z, CPK[ e ], capitalize( e ) ] ); if ( histogram[ e ] == undefined ) histogram[ e ] = 1; else histogram[ e ] += 1;
true
Other
mrdoob
three.js
760252a56043ef0031f08d4e56b6582c9224b6a2.json
add space after comma
examples/js/loaders/RGBELoader.js
@@ -327,7 +327,7 @@ THREE.RGBELoader.prototype._parser = function( buffer ) { var w = rgbe_header_info.width, h = rgbe_header_info.height - ,image_rgba_data = RGBE_ReadPixels_RLE( byteArray.subarray( byteArray.pos ), w, h ) + , image_rgba_data = RGBE_ReadPixels_RLE( byteArray.subarray( byteArray.pos ), w, h ) ; if ( RGBE_RETURN_FAILURE !== image_rgba_data ) {
true
Other
mrdoob
three.js
760252a56043ef0031f08d4e56b6582c9224b6a2.json
add space after comma
examples/js/loaders/STLLoader.js
@@ -302,7 +302,7 @@ if ( typeof DataView === 'undefined' ) { DataView.prototype = { - _getCharCodes: function( buffer,start,length ) { + _getCharCodes: function( buffer, start, length ) { start = start || 0; length = length || buffer.length;
true
Other
mrdoob
three.js
760252a56043ef0031f08d4e56b6582c9224b6a2.json
add space after comma
examples/js/loaders/VRMLLoader.js
@@ -509,7 +509,7 @@ THREE.VRMLLoader.prototype = { // first subpattern should match the Node name - var block = { 'nodeType' : matches[ 1 ], 'string': line, 'parent': current, 'children': [],'comment' : comment }; + var block = { 'nodeType' : matches[ 1 ], 'string': line, 'parent': current, 'children': [], 'comment' : comment }; current.children.push( block ); current = block;
true
Other
mrdoob
three.js
760252a56043ef0031f08d4e56b6582c9224b6a2.json
add space after comma
src/extras/geometries/OctahedronGeometry.js
@@ -5,7 +5,7 @@ THREE.OctahedronGeometry = function ( radius, detail ) { var vertices = [ - 1, 0, 0, - 1, 0, 0, 0, 1, 0, 0,- 1, 0, 0, 0, 1, 0, 0,- 1 + 1, 0, 0, - 1, 0, 0, 0, 1, 0, 0, - 1, 0, 0, 0, 1, 0, 0, - 1 ]; var indices = [
true
Other
mrdoob
three.js
760252a56043ef0031f08d4e56b6582c9224b6a2.json
add space after comma
src/math/Quaternion.js
@@ -18,7 +18,7 @@ THREE.Quaternion.prototype = { constructor: THREE.Quaternion, - _x: 0,_y: 0, _z: 0, _w: 0, + _x: 0, _y: 0, _z: 0, _w: 0, get x () {
true
Other
mrdoob
three.js
760252a56043ef0031f08d4e56b6582c9224b6a2.json
add space after comma
src/math/Ray.js
@@ -356,7 +356,7 @@ THREE.Ray.prototype = { // http://www.scratchapixel.com/lessons/3d-basic-lessons/lesson-7-intersecting-simple-shapes/ray-box-intersection/ - var tmin,tmax,tymin,tymax,tzmin,tzmax; + var tmin, tmax, tymin, tymax, tzmin, tzmax; var invdirx = 1 / this.direction.x, invdiry = 1 / this.direction.y,
true
Other
mrdoob
three.js
760252a56043ef0031f08d4e56b6582c9224b6a2.json
add space after comma
utils/codestyle/config.json
@@ -1,6 +1,7 @@ { "preset": "mdcs", "disallowNewlineBeforeBlockStatements": true, + "requireSpaceAfterBinaryOperators": [","], "excludeFiles": [ "../../.c9/", "../../.c9version/",
true
Other
mrdoob
three.js
fb210eb85e9a4baaefc20109a9b41e134c0568df.json
add new rule disallowNewlineBeforeBlockStatements
examples/js/Octree.js
@@ -1929,8 +1929,7 @@ tmin; // ray would intersect in reverse direction, i.e. this is behind ray - if ( tmax < 0 ) - { + if ( tmax < 0 ) { return false;
true
Other
mrdoob
three.js
fb210eb85e9a4baaefc20109a9b41e134c0568df.json
add new rule disallowNewlineBeforeBlockStatements
examples/js/SimplexNoise.js
@@ -168,8 +168,7 @@ SimplexNoise.prototype.noise3d = function( xin, yin, zin ) { var i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords if ( x0 >= y0 ) { - if ( y0 >= z0 ) - { + if ( y0 >= z0 ) { i1 = 1; j1 = 0; k1 = 0; i2 = 1; j2 = 1; k2 = 0;
true
Other
mrdoob
three.js
fb210eb85e9a4baaefc20109a9b41e134c0568df.json
add new rule disallowNewlineBeforeBlockStatements
examples/js/Sparks.js
@@ -125,8 +125,7 @@ SPARKS.Emitter.prototype = { // Update activities len = this._activities.length; - for ( i = 0; i < len; i ++ ) - { + for ( i = 0; i < len; i ++ ) { this._activities[ i ].update( this, time ); @@ -139,12 +138,10 @@ SPARKS.Emitter.prototype = { var action; var len2 = this._particles.length; - for ( j = 0; j < len; j ++ ) - { + for ( j = 0; j < len; j ++ ) { action = this._actions[ j ]; - for ( i = 0; i < len2; ++ i ) - { + for ( i = 0; i < len2; ++ i ) { particle = this._particles[ i ]; action.update( this, particle, time ); @@ -155,12 +152,10 @@ SPARKS.Emitter.prototype = { // remove dead particles - for ( i = len2; i --; ) - { + for ( i = len2; i --; ) { particle = this._particles[ i ]; - if ( particle.isDead ) - { + if ( particle.isDead ) { //particle = this._particles.splice( i, 1 ); @@ -389,15 +384,13 @@ SPARKS.Age = function( easing ) { SPARKS.Age.prototype.update = function ( emitter, particle, time ) { particle.age += time; - if ( particle.age >= particle.lifetime ) - { + if ( particle.age >= particle.lifetime ) { particle.energy = 0; particle.isDead = true; } - else - { + else { var t = this._easing( particle.age / particle.lifetime ); particle.energy = - 1 * t + 1; @@ -971,17 +964,14 @@ SPARKS.Utils = { }, - getPerpendicular: function( v ) - { + getPerpendicular: function( v ) { - if ( v.x == 0 ) - { + if ( v.x == 0 ) { return new THREE.Vector3D( 1, 0, 0 ); } - else - { + else { var temp = new THREE.Vector3( v.y, - v.x, 0 ); return temp.normalize();
true
Other
mrdoob
three.js
fb210eb85e9a4baaefc20109a9b41e134c0568df.json
add new rule disallowNewlineBeforeBlockStatements
examples/js/WaterShader.js
@@ -141,8 +141,7 @@ THREE.Water = function ( renderer, camera, scene, options ) { if ( camera instanceof THREE.PerspectiveCamera ) this.camera = camera; - else - { + else { this.camera = new THREE.PerspectiveCamera(); console.log( this.name + ': camera is not a Perspective Camera!' ) @@ -178,8 +177,7 @@ THREE.Water = function ( renderer, camera, scene, options ) { this.material.uniforms.eye.value = this.eye; - if ( ! THREE.Math.isPowerOfTwo( width ) || ! THREE.Math.isPowerOfTwo( height ) ) - { + if ( ! THREE.Math.isPowerOfTwo( width ) || ! THREE.Math.isPowerOfTwo( height ) ) { this.texture.generateMipmaps = false; this.texture.minFilter = THREE.LinearFilter;
true
Other
mrdoob
three.js
fb210eb85e9a4baaefc20109a9b41e134c0568df.json
add new rule disallowNewlineBeforeBlockStatements
examples/js/crossfade/scenes.js
@@ -38,17 +38,15 @@ function generateGeometry( objectType, numObjects ) { scale.x = Math.random() * 200 + 100; - if ( objectType == "cube" ) - { + if ( objectType == "cube" ) { geom = new THREE.BoxGeometry( 1, 1, 1 ); scale.y = Math.random() * 200 + 100; scale.z = Math.random() * 200 + 100; color.setRGB( 0, 0, Math.random() + 0.1 ); } - else if ( objectType == "sphere" ) - { + else if ( objectType == "sphere" ) { geom = new THREE.IcosahedronGeometry( 1, 1 ); scale.y = scale.z = scale.x;
true
Other
mrdoob
three.js
fb210eb85e9a4baaefc20109a9b41e134c0568df.json
add new rule disallowNewlineBeforeBlockStatements
examples/js/crossfade/transition.js
@@ -120,18 +120,15 @@ function Transition ( sceneA, sceneB ) { this.render = function( delta ) { // Transition animation - if ( transitionParams.animateTransition ) - { + if ( transitionParams.animateTransition ) { var t = ( 1 + Math.sin( transitionParams.transitionSpeed * clock.getElapsedTime() / Math.PI ) ) / 2; transitionParams.transition = THREE.Math.smoothstep( t, 0.3, 0.7 ); // Change the current alpha texture after each transition - if ( transitionParams.loopTexture && ( transitionParams.transition == 0 || transitionParams.transition == 1 ) ) - { + if ( transitionParams.loopTexture && ( transitionParams.transition == 0 || transitionParams.transition == 1 ) ) { - if ( this.needChange ) - { + if ( this.needChange ) { transitionParams.texture = ( transitionParams.texture + 1 ) % this.textures.length; this.quadmaterial.uniforms.tMixTexture.value = this.textures[ transitionParams.texture ];
true
Other
mrdoob
three.js
fb210eb85e9a4baaefc20109a9b41e134c0568df.json
add new rule disallowNewlineBeforeBlockStatements
examples/js/loaders/AWDLoader.js
@@ -55,15 +55,13 @@ AWDProperties = function() {} AWDProperties.prototype = { - set : function( key, value ) - { + set : function( key, value ) { this[ key ] = value; }, - get : function( key, fallback ) - { + get : function( key, fallback ) { if ( this.hasOwnProperty( key ) ) return this[ key ]; @@ -548,8 +546,7 @@ mtx_data = this.parseMatrix4(); - } else - { + } else { mtx_data = new THREE.Matrix4();
true
Other
mrdoob
three.js
fb210eb85e9a4baaefc20109a9b41e134c0568df.json
add new rule disallowNewlineBeforeBlockStatements
examples/js/loaders/AssimpJSONLoader.js
@@ -37,8 +37,7 @@ THREE.AssimpJSONLoader.prototype = { // This header is used to disambiguate between // different JSON-based file formats. metadata = json.__metadata__; - if ( typeof metadata !== 'undefined' ) - { + if ( typeof metadata !== 'undefined' ) { // Check if assimp2json at all if ( metadata.format !== 'assimp2json' ) {
true
Other
mrdoob
three.js
fb210eb85e9a4baaefc20109a9b41e134c0568df.json
add new rule disallowNewlineBeforeBlockStatements
examples/js/postprocessing/GlitchPass.js
@@ -42,15 +42,13 @@ THREE.GlitchPass = function ( dt_size ) { THREE.GlitchPass.prototype = { - render: function ( renderer, writeBuffer, readBuffer, delta ) - { + render: function ( renderer, writeBuffer, readBuffer, delta ) { this.uniforms[ "tDiffuse" ].value = readBuffer; this.uniforms[ 'seed' ].value = Math.random();//default seeding this.uniforms[ 'byp' ].value = 0; - if ( this.curF % this.randX == 0 || this.goWild == true ) - { + if ( this.curF % this.randX == 0 || this.goWild == true ) { this.uniforms[ 'amount' ].value = Math.random() / 30; this.uniforms[ 'angle' ].value = THREE.Math.randFloat( - Math.PI, Math.PI ); @@ -62,8 +60,7 @@ THREE.GlitchPass.prototype = { this.generateTrigger(); } - else if ( this.curF % this.randX < this.randX / 5 ) - { + else if ( this.curF % this.randX < this.randX / 5 ) { this.uniforms[ 'amount' ].value = Math.random() / 90; this.uniforms[ 'angle' ].value = THREE.Math.randFloat( - Math.PI, Math.PI ); @@ -73,44 +70,38 @@ THREE.GlitchPass.prototype = { this.uniforms[ 'seed_y' ].value = THREE.Math.randFloat( - 0.3, 0.3 ); } - else if ( this.goWild == false ) - { + else if ( this.goWild == false ) { this.uniforms[ 'byp' ].value = 1; } this.curF ++; this.quad.material = this.material; - if ( this.renderToScreen ) - { + if ( this.renderToScreen ) { renderer.render( this.scene, this.camera ); } - else - { + else { renderer.render( this.scene, this.camera, writeBuffer, false ); } }, - generateTrigger: function() - { + generateTrigger: function() { this.randX = THREE.Math.randInt( 120, 240 ); }, - generateHeightmap: function( dt_size ) - { + generateHeightmap: function( dt_size ) { var data_arr = new Float32Array( dt_size * dt_size * 3 ); console.log( dt_size ); var length = dt_size * dt_size; - for ( var i = 0; i < length; i ++ ) - { + for ( var i = 0; i < length; i ++ ) { var val = THREE.Math.randFloat( 0, 1 ); data_arr[ i * 3 + 0 ] = val;
true
Other
mrdoob
three.js
740d0ea5fad17f6e543a177b1ea9ddb053b5e176.json
set config for codestyle
utils/codestyle/codestyle.sh
@@ -1,5 +1,2 @@ - -jscs "../../src" --fix --preset=mdcs -jscs "../../examples/js" --fix --preset=mdcs - +jscs "../.." --fix --config=./config.json --max-errors=1000000
true
Other
mrdoob
three.js
740d0ea5fad17f6e543a177b1ea9ddb053b5e176.json
set config for codestyle
utils/codestyle/config.json
@@ -1,13 +1,26 @@ { "preset": "mdcs", "excludeFiles": [ - "build/**", - "docs/**", - "editor/**", - "examples/**", - "node_modules/**", - "test/**", - "utils/**" + "../../.c9/", + "../../.c9version/", + "../../.git/", + "../../build/", + "../../docs/", + "../../editor/", + "../../node_modules/", + "../../test/", + "../../utils/", + "../../examples/files/", + "../../examples/fonts/", + "../../examples/models/", + "../../examples/obj/", + "../../examples/scenes/", + "../../examples/sounds/", + "../../examples/textures/", + "../../examples/js/libs/", + "../../examples/js/loaders/ctm/", + "../../examples/js/loaders/gltf/", + "../../examples/js/loaders/sea3d/" ] } \ No newline at end of file
true