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 | 516dce8f38107e8585e438dc335e8fb4bdc04b09.json | place holders for test animations. | src/animation/AnimationClip.js | @@ -155,3 +155,27 @@ THREE.AnimationClip.prototype = {
};
+THREE.AnimationClip.CreateMorphAnimation = function( morphTargetNames, duration ) {
+ // TODO
+ // - should create three keys per morphTarget track.
+ // - one track per morphTarget name.
+};
+
+THREE.AnimationClip.CreateRotationAnimation = function( node, period ) {
+ // TODO
+ // - create a single track representing the rotation
+ // - create a few quaternion keys representing the rotation path
+};
+
+THREE.AnimationClip.CreateShakeAnimation = function( node, duration, shakeScale ) {
+ // TODO
+ // - create a single track representing the shake
+ // - multiple random vector by shake scalar/vector
+};
+
+
+THREE.AnimationClip.CreatePulsationAnimation = function( node, duration, pulseScale ) {
+ // TODO
+ // - create a single track representing the shake
+ // - multiple random vector by pulse scalar/vector
+};
\ No newline at end of file | true |
Other | mrdoob | three.js | 516dce8f38107e8585e438dc335e8fb4bdc04b09.json | place holders for test animations. | src/animation/KeyframeTrack.js | @@ -20,7 +20,7 @@ THREE.KeyframeTrack = function ( name, keys ) {
THREE.KeyframeTrack.prototype = {
- constructor: THREE.Track,
+ constructor: THREE.KeyframeTrack,
getAt: function( time ) {
console.log( 'KeyframeTrack[' + this.name + '].getAt( ' + time + ' )' ); | true |
Other | mrdoob | three.js | 9c8e33510e34d43dcc7c3776f1298ec85bf633ac.json | add css: pointer-events | editor/css/light.css | @@ -39,6 +39,7 @@ input.Number {
#viewport #info {
text-shadow: 1px 1px 0px rgba(0,0,0,0.25);
+ pointer-events: none;
}
#script { | false |
Other | mrdoob | three.js | 360f932f22299d14c32afa5ea8305cba35d03470.json | add css: pointer-events | editor/css/dark.css | @@ -46,6 +46,7 @@ input.Number {
#viewport #info {
text-shadow: 1px 1px 0px rgba(0,0,0,0.25);
+ pointer-events: none;
}
#script { | false |
Other | mrdoob | three.js | cd2e24938f95f2364dd3c117ca80d2bc8310dc6c.json | Fix error in BoxHelper with non-geometric object | src/extras/helpers/BoxHelper.js | @@ -28,6 +28,8 @@ THREE.BoxHelper.prototype.update = ( function () {
box.setFromObject( object );
+ if ( box.empty() ) return;
+
var min = box.min;
var max = box.max;
| false |
Other | mrdoob | three.js | 6a2a28fe34e3ff1ab6b183325ebbc810da2a4195.json | Extract OrbitConstraint from OrbitControls
OrbitControls takes care of the DOM, input binding and event handling.
OrbitConstraint is responsible for keeping the camera on an orbit, maintaining its orientation towards the target and updating the camera and target position.
There is only one insignificant API change. Before, dolly / rotate functions could be called without parameters to engage autoRotate / autoSpeed. OrbitConstraint does not support that. Now, OrbitControls must provide these parameter explicitly to OrbitConstraint. As far as I can tell, those methods were only used internally and should not be part of the control API.
OrbitControls extends OrbitConstraint. In my ideal implementation, OrbitConstraint should be a property of the OrbitControls, but using inheritence help preserve the existing interface.
OrbitConstraint is not included in the `THREE` namespace. It is defined in a closure and private to this file. It could also the placed in `extras\constraints`, along with other contraints that could be extracted from the current controls, and maybe other type of constraints on the object position/displacement (constrain movement to plane, to path, collision).
These constraints should not necessarily be limited to cameras; they could apply to any objects. It's not clear to me how all this will shape up, but this is a nice place to pause and ask for feedback before going forward. | examples/js/controls/OrbitControls.js | @@ -7,700 +7,740 @@
*/
/*global THREE, console */
-// This set of controls performs orbiting, dollying (zooming), and panning. It maintains
-// the "up" direction as +Y, unlike the TrackballControls. Touch on tablet and phones is
-// supported.
-//
-// Orbit - left mouse / touch: one finger move
-// Zoom - middle mouse, or mousewheel / touch: two finger spread or squish
-// Pan - right mouse, or arrow keys / touch: three finter swipe
+(function () {
-THREE.OrbitControls = function ( object, domElement ) {
+ function OrbitConstraint ( object ) {
- this.object = object;
- this.domElement = ( domElement !== undefined ) ? domElement : document;
+ this.object = object;
- // API
+ // "target" sets the location of focus, where the object orbits around
+ // and where it pans with respect to.
+ this.target = new THREE.Vector3();
- // Set to false to disable this control
- this.enabled = true;
+ // Limits to how far you can dolly in and out ( PerspectiveCamera only )
+ this.minDistance = 0;
+ this.maxDistance = Infinity;
- // "target" sets the location of focus, where the control orbits around
- // and where it pans with respect to.
- this.target = new THREE.Vector3();
+ // Limits to how far you can zoom in and out ( OrthographicCamera only )
+ this.minZoom = 0;
+ this.maxZoom = Infinity;
- // center is old, deprecated; use "target" instead
- this.center = this.target;
+ // How far you can orbit vertically, upper and lower limits.
+ // Range is 0 to Math.PI radians.
+ this.minPolarAngle = 0; // radians
+ this.maxPolarAngle = Math.PI; // radians
- // This option actually enables dollying in and out; left as "zoom" for
- // backwards compatibility
- this.noZoom = false;
- this.zoomSpeed = 1.0;
+ // How far you can orbit horizontally, upper and lower limits.
+ // If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ].
+ this.minAzimuthAngle = - Infinity; // radians
+ this.maxAzimuthAngle = Infinity; // radians
- // Limits to how far you can dolly in and out ( PerspectiveCamera only )
- this.minDistance = 0;
- this.maxDistance = Infinity;
+ ////////////
+ // internals
- // Limits to how far you can zoom in and out ( OrthographicCamera only )
- this.minZoom = 0;
- this.maxZoom = Infinity;
+ var scope = this;
- // Set to true to disable this control
- this.noRotate = false;
- this.rotateSpeed = 1.0;
+ var EPS = 0.000001;
- // Set to true to disable this control
- this.noPan = false;
- this.keyPanSpeed = 7.0; // pixels moved per arrow key push
+ // Current position in spherical coordinate system.
+ var theta;
+ var phi;
- // Set to true to automatically rotate around the target
- this.autoRotate = false;
- this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60
+ // Pending changes
+ var phiDelta = 0;
+ var thetaDelta = 0;
+ var scale = 1;
+ var panOffset = new THREE.Vector3();
- // How far you can orbit vertically, upper and lower limits.
- // Range is 0 to Math.PI radians.
- this.minPolarAngle = 0; // radians
- this.maxPolarAngle = Math.PI; // radians
+ // events
+ var changeEvent = { type: 'change' };
- // How far you can orbit horizontally, upper and lower limits.
- // If set, must be a sub-interval of the interval [ - Math.PI, Math.PI ].
- this.minAzimuthAngle = - Infinity; // radians
- this.maxAzimuthAngle = Infinity; // radians
+ this.getPolarAngle = function () {
- // Set to true to disable use of the keys
- this.noKeys = false;
+ return phi;
- // The four arrow keys
- this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };
+ };
- // Mouse buttons
- this.mouseButtons = { ORBIT: THREE.MOUSE.LEFT, ZOOM: THREE.MOUSE.MIDDLE, PAN: THREE.MOUSE.RIGHT };
+ this.getAzimuthalAngle = function () {
- ////////////
- // internals
+ return theta;
- var scope = this;
+ };
- var EPS = 0.000001;
+ this.rotateLeft = function ( angle ) {
- var rotateStart = new THREE.Vector2();
- var rotateEnd = new THREE.Vector2();
- var rotateDelta = new THREE.Vector2();
+ thetaDelta -= angle;
- var panStart = new THREE.Vector2();
- var panEnd = new THREE.Vector2();
- var panDelta = new THREE.Vector2();
- var panOffset = new THREE.Vector3();
+ };
- var offset = new THREE.Vector3();
+ this.rotateUp = function ( angle ) {
- var dollyStart = new THREE.Vector2();
- var dollyEnd = new THREE.Vector2();
- var dollyDelta = new THREE.Vector2();
+ phiDelta -= angle;
- var theta;
- var phi;
- var phiDelta = 0;
- var thetaDelta = 0;
- var scale = 1;
- var pan = new THREE.Vector3();
+ };
- var lastPosition = new THREE.Vector3();
- var lastQuaternion = new THREE.Quaternion();
+ // pass in distance in world space to move left
+ this.panLeft = function() {
- var STATE = { NONE : -1, ROTATE : 0, DOLLY : 1, PAN : 2, TOUCH_ROTATE : 3, TOUCH_DOLLY : 4, TOUCH_PAN : 5 };
+ var v = new THREE.Vector3();
- var state = STATE.NONE;
+ return function panLeft ( distance ) {
- // for reset
+ var te = this.object.matrix.elements;
- this.target0 = this.target.clone();
- this.position0 = this.object.position.clone();
- this.zoom0 = this.object.zoom;
+ // get X column of matrix
+ v.set( te[ 0 ], te[ 1 ], te[ 2 ] );
+ v.multiplyScalar( - distance );
- // so camera.up is the orbit axis
+ panOffset.add( v );
- var quat = new THREE.Quaternion().setFromUnitVectors( object.up, new THREE.Vector3( 0, 1, 0 ) );
- var quatInverse = quat.clone().inverse();
+ };
- // events
+ }();
- var changeEvent = { type: 'change' };
- var startEvent = { type: 'start' };
- var endEvent = { type: 'end' };
+ // pass in distance in world space to move up
+ this.panUp = function() {
- this.rotateLeft = function ( angle ) {
+ var v = new THREE.Vector3();
- if ( angle === undefined ) {
+ return function panUp ( distance ) {
- angle = getAutoRotationAngle();
+ var te = this.object.matrix.elements;
- }
+ // get Y column of matrix
+ v.set( te[ 4 ], te[ 5 ], te[ 6 ] );
+ v.multiplyScalar( distance );
- thetaDelta -= angle;
+ panOffset.add( v );
- };
+ };
- this.rotateUp = function ( angle ) {
+ }();
- if ( angle === undefined ) {
+ // pass in x,y of change desired in pixel space,
+ // right and down are positive
+ this.pan = function ( deltaX, deltaY, screenWidth, screenHeight ) {
- angle = getAutoRotationAngle();
+ if ( scope.object instanceof THREE.PerspectiveCamera ) {
- }
+ // perspective
+ var position = scope.object.position;
+ var offset = position.clone().sub( scope.target );
+ var targetDistance = offset.length();
- phiDelta -= angle;
+ // half of the fov is center to top of screen
+ targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 );
- };
+ // we actually don't use screenWidth, since perspective camera is fixed to screen height
+ scope.panLeft( 2 * deltaX * targetDistance / screenHeight );
+ scope.panUp( 2 * deltaY * targetDistance / screenHeight );
- // pass in distance in world space to move left
- this.panLeft = function ( distance ) {
+ } else if ( scope.object instanceof THREE.OrthographicCamera ) {
- var te = this.object.matrix.elements;
+ // orthographic
+ scope.panLeft( deltaX * ( scope.object.right - scope.object.left ) / screenWidth );
+ scope.panUp( deltaY * ( scope.object.top - scope.object.bottom ) / screenHeight );
- // get X column of matrix
- panOffset.set( te[ 0 ], te[ 1 ], te[ 2 ] );
- panOffset.multiplyScalar( - distance );
+ } else {
- pan.add( panOffset );
+ // camera neither orthographic or perspective
+ console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' );
- };
+ }
- // pass in distance in world space to move up
- this.panUp = function ( distance ) {
+ };
- var te = this.object.matrix.elements;
+ this.dollyIn = function ( dollyScale ) {
- // get Y column of matrix
- panOffset.set( te[ 4 ], te[ 5 ], te[ 6 ] );
- panOffset.multiplyScalar( distance );
+ if ( scope.object instanceof THREE.PerspectiveCamera ) {
- pan.add( panOffset );
+ scale /= dollyScale;
- };
+ } else if ( scope.object instanceof THREE.OrthographicCamera ) {
- // pass in x,y of change desired in pixel space,
- // right and down are positive
- this.pan = function ( deltaX, deltaY ) {
+ scope.object.zoom = Math.max( this.minZoom, Math.min( this.maxZoom, this.object.zoom * dollyScale ) );
+ scope.object.updateProjectionMatrix();
+ scope.dispatchEvent( changeEvent );
- var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
+ } else {
- if ( scope.object instanceof THREE.PerspectiveCamera ) {
+ console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
- // perspective
- var position = scope.object.position;
- var offset = position.clone().sub( scope.target );
- var targetDistance = offset.length();
+ }
- // half of the fov is center to top of screen
- targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 );
+ };
- // we actually don't use screenWidth, since perspective camera is fixed to screen height
- scope.panLeft( 2 * deltaX * targetDistance / element.clientHeight );
- scope.panUp( 2 * deltaY * targetDistance / element.clientHeight );
+ this.dollyOut = function ( dollyScale ) {
- } else if ( scope.object instanceof THREE.OrthographicCamera ) {
+ if ( scope.object instanceof THREE.PerspectiveCamera ) {
- // orthographic
- scope.panLeft( deltaX * (scope.object.right - scope.object.left) / element.clientWidth );
- scope.panUp( deltaY * (scope.object.top - scope.object.bottom) / element.clientHeight );
+ scale *= dollyScale;
- } else {
+ } else if ( scope.object instanceof THREE.OrthographicCamera ) {
- // camera neither orthographic or perspective
- console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' );
+ scope.object.zoom = Math.max( this.minZoom, Math.min( this.maxZoom, this.object.zoom / dollyScale ) );
+ scope.object.updateProjectionMatrix();
+ scope.dispatchEvent( changeEvent );
- }
+ } else {
- };
+ console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
- this.dollyIn = function ( dollyScale ) {
+ }
- if ( dollyScale === undefined ) {
+ };
- dollyScale = getZoomScale();
+ this.update = function() {
- }
+ var offset = new THREE.Vector3();
- if ( scope.object instanceof THREE.PerspectiveCamera ) {
+ // so camera.up is the orbit axis
+ var quat = new THREE.Quaternion().setFromUnitVectors( object.up, new THREE.Vector3( 0, 1, 0 ) );
+ var quatInverse = quat.clone().inverse();
- scale /= dollyScale;
+ var lastPosition = new THREE.Vector3();
+ var lastQuaternion = new THREE.Quaternion();
- } else if ( scope.object instanceof THREE.OrthographicCamera ) {
+ return function () {
- scope.object.zoom = Math.max( this.minZoom, Math.min( this.maxZoom, this.object.zoom * dollyScale ) );
- scope.object.updateProjectionMatrix();
- scope.dispatchEvent( changeEvent );
+ var position = this.object.position;
- } else {
+ offset.copy( position ).sub( this.target );
- console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
+ // rotate offset to "y-axis-is-up" space
+ offset.applyQuaternion( quat );
- }
+ // angle from z-axis around y-axis
- };
+ theta = Math.atan2( offset.x, offset.z );
- this.dollyOut = function ( dollyScale ) {
+ // angle from y-axis
- if ( dollyScale === undefined ) {
+ phi = Math.atan2( Math.sqrt( offset.x * offset.x + offset.z * offset.z ), offset.y );
- dollyScale = getZoomScale();
+ theta += thetaDelta;
+ phi += phiDelta;
- }
+ // restrict theta to be between desired limits
+ theta = Math.max( this.minAzimuthAngle, Math.min( this.maxAzimuthAngle, theta ) );
- if ( scope.object instanceof THREE.PerspectiveCamera ) {
+ // restrict phi to be between desired limits
+ phi = Math.max( this.minPolarAngle, Math.min( this.maxPolarAngle, phi ) );
- scale *= dollyScale;
+ // restrict phi to be betwee EPS and PI-EPS
+ phi = Math.max( EPS, Math.min( Math.PI - EPS, phi ) );
- } else if ( scope.object instanceof THREE.OrthographicCamera ) {
+ var radius = offset.length() * scale;
- scope.object.zoom = Math.max( this.minZoom, Math.min( this.maxZoom, this.object.zoom / dollyScale ) );
- scope.object.updateProjectionMatrix();
- scope.dispatchEvent( changeEvent );
+ // restrict radius to be between desired limits
+ radius = Math.max( this.minDistance, Math.min( this.maxDistance, radius ) );
- } else {
+ // move target to panned location
+ this.target.add( panOffset );
- console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.' );
+ offset.x = radius * Math.sin( phi ) * Math.sin( theta );
+ offset.y = radius * Math.cos( phi );
+ offset.z = radius * Math.sin( phi ) * Math.cos( theta );
- }
+ // rotate offset back to "camera-up-vector-is-up" space
+ offset.applyQuaternion( quatInverse );
- };
+ position.copy( this.target ).add( offset );
- this.update = function () {
+ this.object.lookAt( this.target );
- var position = this.object.position;
+ thetaDelta = 0;
+ phiDelta = 0;
+ scale = 1;
+ panOffset.set( 0, 0, 0 );
- offset.copy( position ).sub( this.target );
+ // update condition is:
+ // min(camera displacement, camera rotation in radians)^2 > EPS
+ // using small-angle approximation cos(x/2) = 1 - x^2 / 8
- // rotate offset to "y-axis-is-up" space
- offset.applyQuaternion( quat );
+ if ( lastPosition.distanceToSquared( this.object.position ) > EPS ||
+ 8 * ( 1 - lastQuaternion.dot( this.object.quaternion) ) > EPS ) {
- // angle from z-axis around y-axis
+ lastPosition.copy( this.object.position );
+ lastQuaternion.copy( this.object.quaternion );
- theta = Math.atan2( offset.x, offset.z );
+ return true;
- // angle from y-axis
+ }
- phi = Math.atan2( Math.sqrt( offset.x * offset.x + offset.z * offset.z ), offset.y );
+ return false;
- if ( this.autoRotate && state === STATE.NONE ) {
+ };
- this.rotateLeft( getAutoRotationAngle() );
+ }();
- }
+ };
- theta += thetaDelta;
- phi += phiDelta;
+ OrbitConstraint.prototype = Object.create( THREE.EventDispatcher.prototype );
+ OrbitConstraint.prototype.constructor = OrbitConstraint;
- // restrict theta to be between desired limits
- theta = Math.max( this.minAzimuthAngle, Math.min( this.maxAzimuthAngle, theta ) );
- // restrict phi to be between desired limits
- phi = Math.max( this.minPolarAngle, Math.min( this.maxPolarAngle, phi ) );
- // restrict phi to be betwee EPS and PI-EPS
- phi = Math.max( EPS, Math.min( Math.PI - EPS, phi ) );
+ // This set of controls performs orbiting, dollying (zooming), and panning. It maintains
+ // the "up" direction as +Y, unlike the TrackballControls. Touch on tablet and phones is
+ // supported.
+ //
+ // Orbit - left mouse / touch: one finger move
+ // Zoom - middle mouse, or mousewheel / touch: two finger spread or squish
+ // Pan - right mouse, or arrow keys / touch: three finter swipe
- var radius = offset.length() * scale;
+ THREE.OrbitControls = function ( object, domElement ) {
- // restrict radius to be between desired limits
- radius = Math.max( this.minDistance, Math.min( this.maxDistance, radius ) );
+ OrbitConstraint.call( this, object );
- // move target to panned location
- this.target.add( pan );
+ this.domElement = ( domElement !== undefined ) ? domElement : document;
- offset.x = radius * Math.sin( phi ) * Math.sin( theta );
- offset.y = radius * Math.cos( phi );
- offset.z = radius * Math.sin( phi ) * Math.cos( theta );
+ // API
- // rotate offset back to "camera-up-vector-is-up" space
- offset.applyQuaternion( quatInverse );
+ // Set to false to disable this control
+ this.enabled = true;
- position.copy( this.target ).add( offset );
+ // center is old, deprecated; use "target" instead
+ this.center = this.target;
- this.object.lookAt( this.target );
+ // This option actually enables dollying in and out; left as "zoom" for
+ // backwards compatibility
+ this.noZoom = false;
+ this.zoomSpeed = 1.0;
- thetaDelta = 0;
- phiDelta = 0;
- scale = 1;
- pan.set( 0, 0, 0 );
+ // Set to true to disable this control
+ this.noRotate = false;
+ this.rotateSpeed = 1.0;
- // update condition is:
- // min(camera displacement, camera rotation in radians)^2 > EPS
- // using small-angle approximation cos(x/2) = 1 - x^2 / 8
+ // Set to true to disable this control
+ this.noPan = false;
+ this.keyPanSpeed = 7.0; // pixels moved per arrow key push
- if ( lastPosition.distanceToSquared( this.object.position ) > EPS
- || 8 * (1 - lastQuaternion.dot(this.object.quaternion)) > EPS ) {
+ // Set to true to automatically rotate around the target
+ this.autoRotate = false;
+ this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60
- this.dispatchEvent( changeEvent );
+ // Set to true to disable use of the keys
+ this.noKeys = false;
- lastPosition.copy( this.object.position );
- lastQuaternion.copy (this.object.quaternion );
+ // The four arrow keys
+ this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };
- }
+ // Mouse buttons
+ this.mouseButtons = { ORBIT: THREE.MOUSE.LEFT, ZOOM: THREE.MOUSE.MIDDLE, PAN: THREE.MOUSE.RIGHT };
- };
+ ////////////
+ // internals
+ var scope = this;
- this.reset = function () {
+ var rotateStart = new THREE.Vector2();
+ var rotateEnd = new THREE.Vector2();
+ var rotateDelta = new THREE.Vector2();
- state = STATE.NONE;
+ var panStart = new THREE.Vector2();
+ var panEnd = new THREE.Vector2();
+ var panDelta = new THREE.Vector2();
- this.target.copy( this.target0 );
- this.object.position.copy( this.position0 );
- this.object.zoom = this.zoom0;
+ var dollyStart = new THREE.Vector2();
+ var dollyEnd = new THREE.Vector2();
+ var dollyDelta = new THREE.Vector2();
- this.object.updateProjectionMatrix();
- this.dispatchEvent( changeEvent );
+ var STATE = { NONE : -1, ROTATE : 0, DOLLY : 1, PAN : 2, TOUCH_ROTATE : 3, TOUCH_DOLLY : 4, TOUCH_PAN : 5 };
- this.update();
+ var state = STATE.NONE;
- };
+ // for reset
- this.getPolarAngle = function () {
+ this.target0 = this.target.clone();
+ this.position0 = this.object.position.clone();
+ this.zoom0 = this.object.zoom;
- return phi;
+ // events
- };
+ var changeEvent = { type: 'change' };
+ var startEvent = { type: 'start' };
+ var endEvent = { type: 'end' };
- this.getAzimuthalAngle = function () {
+ // pass in x,y of change desired in pixel space,
+ // right and down are positive
+ var _pan = this.pan;
+ this.pan = function ( deltaX, deltaY ) {
- return theta
+ var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
- };
+ _pan.call( this, deltaX, deltaY, element.clientWidth, element.clientHeight );
- function getAutoRotationAngle() {
+ };
- return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
+ var _update = this.update;
+ this.update = function() {
- }
+ if ( this.autoRotate && state === STATE.NONE ) {
- function getZoomScale() {
+ this.rotateLeft( getAutoRotationAngle() );
- return Math.pow( 0.95, scope.zoomSpeed );
+ }
- }
+ if ( _update.call( this ) === true ) {
- function onMouseDown( event ) {
+ this.dispatchEvent( changeEvent );
- if ( scope.enabled === false ) return;
- event.preventDefault();
+ }
- if ( event.button === scope.mouseButtons.ORBIT ) {
- if ( scope.noRotate === true ) return;
+ };
- state = STATE.ROTATE;
+ this.reset = function () {
- rotateStart.set( event.clientX, event.clientY );
+ state = STATE.NONE;
- } else if ( event.button === scope.mouseButtons.ZOOM ) {
- if ( scope.noZoom === true ) return;
+ this.target.copy( this.target0 );
+ this.object.position.copy( this.position0 );
+ this.object.zoom = this.zoom0;
- state = STATE.DOLLY;
+ this.object.updateProjectionMatrix();
+ this.dispatchEvent( changeEvent );
- dollyStart.set( event.clientX, event.clientY );
+ this.update();
- } else if ( event.button === scope.mouseButtons.PAN ) {
- if ( scope.noPan === true ) return;
+ };
- state = STATE.PAN;
+ function getAutoRotationAngle() {
- panStart.set( event.clientX, event.clientY );
+ return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
}
- if ( state !== STATE.NONE ) {
- document.addEventListener( 'mousemove', onMouseMove, false );
- document.addEventListener( 'mouseup', onMouseUp, false );
- scope.dispatchEvent( startEvent );
+ function getZoomScale() {
+
+ return Math.pow( 0.95, scope.zoomSpeed );
+
}
- }
+ function onMouseDown( event ) {
- function onMouseMove( event ) {
+ if ( scope.enabled === false ) return;
+ event.preventDefault();
- if ( scope.enabled === false ) return;
+ if ( event.button === scope.mouseButtons.ORBIT ) {
+ if ( scope.noRotate === true ) return;
- event.preventDefault();
+ state = STATE.ROTATE;
- var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
+ rotateStart.set( event.clientX, event.clientY );
- if ( state === STATE.ROTATE ) {
+ } else if ( event.button === scope.mouseButtons.ZOOM ) {
+ if ( scope.noZoom === true ) return;
- if ( scope.noRotate === true ) return;
+ state = STATE.DOLLY;
- rotateEnd.set( event.clientX, event.clientY );
- rotateDelta.subVectors( rotateEnd, rotateStart );
+ dollyStart.set( event.clientX, event.clientY );
- // rotating across whole screen goes 360 degrees around
- scope.rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
+ } else if ( event.button === scope.mouseButtons.PAN ) {
+ if ( scope.noPan === true ) return;
- // rotating up and down along whole screen attempts to go 360, but limited to 180
- scope.rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );
+ state = STATE.PAN;
- rotateStart.copy( rotateEnd );
+ panStart.set( event.clientX, event.clientY );
- } else if ( state === STATE.DOLLY ) {
+ }
- if ( scope.noZoom === true ) return;
+ if ( state !== STATE.NONE ) {
- dollyEnd.set( event.clientX, event.clientY );
- dollyDelta.subVectors( dollyEnd, dollyStart );
+ document.addEventListener( 'mousemove', onMouseMove, false );
+ document.addEventListener( 'mouseup', onMouseUp, false );
+ scope.dispatchEvent( startEvent );
- if ( dollyDelta.y > 0 ) {
+ }
- scope.dollyIn();
+ }
- } else if ( dollyDelta.y < 0 ) {
+ function onMouseMove( event ) {
- scope.dollyOut();
+ if ( scope.enabled === false ) return;
- }
+ event.preventDefault();
- dollyStart.copy( dollyEnd );
+ var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
- } else if ( state === STATE.PAN ) {
+ if ( state === STATE.ROTATE ) {
- if ( scope.noPan === true ) return;
+ if ( scope.noRotate === true ) return;
- panEnd.set( event.clientX, event.clientY );
- panDelta.subVectors( panEnd, panStart );
+ rotateEnd.set( event.clientX, event.clientY );
+ rotateDelta.subVectors( rotateEnd, rotateStart );
- scope.pan( panDelta.x, panDelta.y );
+ // rotating across whole screen goes 360 degrees around
+ scope.rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
- panStart.copy( panEnd );
+ // rotating up and down along whole screen attempts to go 360, but limited to 180
+ scope.rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );
- }
+ rotateStart.copy( rotateEnd );
- if ( state !== STATE.NONE ) scope.update();
+ } else if ( state === STATE.DOLLY ) {
- }
+ if ( scope.noZoom === true ) return;
- function onMouseUp( /* event */ ) {
+ dollyEnd.set( event.clientX, event.clientY );
+ dollyDelta.subVectors( dollyEnd, dollyStart );
- if ( scope.enabled === false ) return;
+ if ( dollyDelta.y > 0 ) {
- document.removeEventListener( 'mousemove', onMouseMove, false );
- document.removeEventListener( 'mouseup', onMouseUp, false );
- scope.dispatchEvent( endEvent );
- state = STATE.NONE;
+ scope.dollyIn( getZoomScale() );
- }
+ } else if ( dollyDelta.y < 0 ) {
- function onMouseWheel( event ) {
+ scope.dollyOut( getZoomScale() );
- if ( scope.enabled === false || scope.noZoom === true || state !== STATE.NONE ) return;
+ }
- event.preventDefault();
- event.stopPropagation();
+ dollyStart.copy( dollyEnd );
- var delta = 0;
+ } else if ( state === STATE.PAN ) {
- if ( event.wheelDelta !== undefined ) { // WebKit / Opera / Explorer 9
+ if ( scope.noPan === true ) return;
- delta = event.wheelDelta;
+ panEnd.set( event.clientX, event.clientY );
+ panDelta.subVectors( panEnd, panStart );
- } else if ( event.detail !== undefined ) { // Firefox
+ scope.pan( panDelta.x, panDelta.y );
- delta = - event.detail;
+ panStart.copy( panEnd );
- }
+ }
+
+ if ( state !== STATE.NONE ) scope.update();
- if ( delta > 0 ) {
+ }
- scope.dollyOut();
+ function onMouseUp( /* event */ ) {
- } else if ( delta < 0 ) {
+ if ( scope.enabled === false ) return;
- scope.dollyIn();
+ document.removeEventListener( 'mousemove', onMouseMove, false );
+ document.removeEventListener( 'mouseup', onMouseUp, false );
+ scope.dispatchEvent( endEvent );
+ state = STATE.NONE;
}
- scope.update();
- scope.dispatchEvent( startEvent );
- scope.dispatchEvent( endEvent );
+ function onMouseWheel( event ) {
- }
+ if ( scope.enabled === false || scope.noZoom === true || state !== STATE.NONE ) return;
- function onKeyDown( event ) {
+ event.preventDefault();
+ event.stopPropagation();
- if ( scope.enabled === false || scope.noKeys === true || scope.noPan === true ) return;
+ var delta = 0;
- switch ( event.keyCode ) {
+ if ( event.wheelDelta !== undefined ) { // WebKit / Opera / Explorer 9
- case scope.keys.UP:
- scope.pan( 0, scope.keyPanSpeed );
- scope.update();
- break;
+ delta = event.wheelDelta;
- case scope.keys.BOTTOM:
- scope.pan( 0, - scope.keyPanSpeed );
- scope.update();
- break;
+ } else if ( event.detail !== undefined ) { // Firefox
- case scope.keys.LEFT:
- scope.pan( scope.keyPanSpeed, 0 );
- scope.update();
- break;
+ delta = - event.detail;
- case scope.keys.RIGHT:
- scope.pan( - scope.keyPanSpeed, 0 );
- scope.update();
- break;
+ }
+
+ if ( delta > 0 ) {
+
+ scope.dollyOut( getZoomScale() );
+
+ } else if ( delta < 0 ) {
+
+ scope.dollyIn( getZoomScale() );
+
+ }
+
+ scope.update();
+ scope.dispatchEvent( startEvent );
+ scope.dispatchEvent( endEvent );
}
- }
+ function onKeyDown( event ) {
- function touchstart( event ) {
+ if ( scope.enabled === false || scope.noKeys === true || scope.noPan === true ) return;
- if ( scope.enabled === false ) return;
+ switch ( event.keyCode ) {
- switch ( event.touches.length ) {
+ case scope.keys.UP:
+ scope.pan( 0, scope.keyPanSpeed );
+ scope.update();
+ break;
- case 1: // one-fingered touch: rotate
+ case scope.keys.BOTTOM:
+ scope.pan( 0, - scope.keyPanSpeed );
+ scope.update();
+ break;
- if ( scope.noRotate === true ) return;
+ case scope.keys.LEFT:
+ scope.pan( scope.keyPanSpeed, 0 );
+ scope.update();
+ break;
- state = STATE.TOUCH_ROTATE;
+ case scope.keys.RIGHT:
+ scope.pan( - scope.keyPanSpeed, 0 );
+ scope.update();
+ break;
- rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
- break;
+ }
- case 2: // two-fingered touch: dolly
+ }
- if ( scope.noZoom === true ) return;
+ function touchstart( event ) {
- state = STATE.TOUCH_DOLLY;
+ if ( scope.enabled === false ) return;
- var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
- var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
- var distance = Math.sqrt( dx * dx + dy * dy );
- dollyStart.set( 0, distance );
- break;
+ switch ( event.touches.length ) {
- case 3: // three-fingered touch: pan
+ case 1: // one-fingered touch: rotate
- if ( scope.noPan === true ) return;
+ if ( scope.noRotate === true ) return;
- state = STATE.TOUCH_PAN;
+ state = STATE.TOUCH_ROTATE;
- panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
- break;
+ rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
+ break;
- default:
+ case 2: // two-fingered touch: dolly
- state = STATE.NONE;
+ if ( scope.noZoom === true ) return;
- }
+ state = STATE.TOUCH_DOLLY;
- if ( state !== STATE.NONE ) scope.dispatchEvent( startEvent );
+ var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
+ var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
+ var distance = Math.sqrt( dx * dx + dy * dy );
+ dollyStart.set( 0, distance );
+ break;
- }
+ case 3: // three-fingered touch: pan
- function touchmove( event ) {
+ if ( scope.noPan === true ) return;
- if ( scope.enabled === false ) return;
+ state = STATE.TOUCH_PAN;
- event.preventDefault();
- event.stopPropagation();
+ panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
+ break;
- var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
+ default:
- switch ( event.touches.length ) {
+ state = STATE.NONE;
- case 1: // one-fingered touch: rotate
+ }
- if ( scope.noRotate === true ) return;
- if ( state !== STATE.TOUCH_ROTATE ) return;
+ if ( state !== STATE.NONE ) scope.dispatchEvent( startEvent );
- rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
- rotateDelta.subVectors( rotateEnd, rotateStart );
+ }
- // rotating across whole screen goes 360 degrees around
- scope.rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
- // rotating up and down along whole screen attempts to go 360, but limited to 180
- scope.rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );
+ function touchmove( event ) {
- rotateStart.copy( rotateEnd );
+ if ( scope.enabled === false ) return;
- scope.update();
- break;
+ event.preventDefault();
+ event.stopPropagation();
- case 2: // two-fingered touch: dolly
+ var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
- if ( scope.noZoom === true ) return;
- if ( state !== STATE.TOUCH_DOLLY ) return;
+ switch ( event.touches.length ) {
- var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
- var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
- var distance = Math.sqrt( dx * dx + dy * dy );
+ case 1: // one-fingered touch: rotate
- dollyEnd.set( 0, distance );
- dollyDelta.subVectors( dollyEnd, dollyStart );
+ if ( scope.noRotate === true ) return;
+ if ( state !== STATE.TOUCH_ROTATE ) return;
- if ( dollyDelta.y > 0 ) {
+ rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
+ rotateDelta.subVectors( rotateEnd, rotateStart );
- scope.dollyOut();
+ // rotating across whole screen goes 360 degrees around
+ scope.rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
+ // rotating up and down along whole screen attempts to go 360, but limited to 180
+ scope.rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );
- } else if ( dollyDelta.y < 0 ) {
+ rotateStart.copy( rotateEnd );
- scope.dollyIn();
+ scope.update();
+ break;
- }
+ case 2: // two-fingered touch: dolly
- dollyStart.copy( dollyEnd );
+ if ( scope.noZoom === true ) return;
+ if ( state !== STATE.TOUCH_DOLLY ) return;
- scope.update();
- break;
+ var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
+ var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
+ var distance = Math.sqrt( dx * dx + dy * dy );
- case 3: // three-fingered touch: pan
+ dollyEnd.set( 0, distance );
+ dollyDelta.subVectors( dollyEnd, dollyStart );
- if ( scope.noPan === true ) return;
- if ( state !== STATE.TOUCH_PAN ) return;
+ if ( dollyDelta.y > 0 ) {
- panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
- panDelta.subVectors( panEnd, panStart );
+ scope.dollyOut( getZoomScale() );
- scope.pan( panDelta.x, panDelta.y );
+ } else if ( dollyDelta.y < 0 ) {
- panStart.copy( panEnd );
+ scope.dollyIn( getZoomScale() );
- scope.update();
- break;
+ }
- default:
+ dollyStart.copy( dollyEnd );
- state = STATE.NONE;
+ scope.update();
+ break;
+
+ case 3: // three-fingered touch: pan
+
+ if ( scope.noPan === true ) return;
+ if ( state !== STATE.TOUCH_PAN ) return;
+
+ panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
+ panDelta.subVectors( panEnd, panStart );
+
+ scope.pan( panDelta.x, panDelta.y );
+
+ panStart.copy( panEnd );
+
+ scope.update();
+ break;
+
+ default:
+
+ state = STATE.NONE;
+
+ }
}
- }
+ function touchend( /* event */ ) {
- function touchend( /* event */ ) {
+ if ( scope.enabled === false ) return;
- if ( scope.enabled === false ) return;
+ scope.dispatchEvent( endEvent );
+ state = STATE.NONE;
- scope.dispatchEvent( endEvent );
- state = STATE.NONE;
+ }
- }
+ this.domElement.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
+ this.domElement.addEventListener( 'mousedown', onMouseDown, false );
+ this.domElement.addEventListener( 'mousewheel', onMouseWheel, false );
+ this.domElement.addEventListener( 'DOMMouseScroll', onMouseWheel, false ); // firefox
- this.domElement.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
- this.domElement.addEventListener( 'mousedown', onMouseDown, false );
- this.domElement.addEventListener( 'mousewheel', onMouseWheel, false );
- this.domElement.addEventListener( 'DOMMouseScroll', onMouseWheel, false ); // firefox
+ this.domElement.addEventListener( 'touchstart', touchstart, false );
+ this.domElement.addEventListener( 'touchend', touchend, false );
+ this.domElement.addEventListener( 'touchmove', touchmove, false );
- this.domElement.addEventListener( 'touchstart', touchstart, false );
- this.domElement.addEventListener( 'touchend', touchend, false );
- this.domElement.addEventListener( 'touchmove', touchmove, false );
+ window.addEventListener( 'keydown', onKeyDown, false );
- window.addEventListener( 'keydown', onKeyDown, false );
+ // force an update at start
+ this.update();
- // force an update at start
- this.update();
+ };
-};
+ THREE.OrbitControls.prototype = Object.create( OrbitConstraint.prototype );
+ THREE.OrbitControls.prototype.constructor = THREE.OrbitControls;
-THREE.OrbitControls.prototype = Object.create( THREE.EventDispatcher.prototype );
-THREE.OrbitControls.prototype.constructor = THREE.OrbitControls;
+}()); | false |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/cameras/OrthographicCamera.js | @@ -40,7 +40,7 @@ THREE.OrthographicCamera.prototype.clone = function () {
var camera = new THREE.OrthographicCamera();
- THREE.Camera.prototype.copy.call( camera, this );
+ camera.copy( this );
camera.zoom = this.zoom;
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/cameras/PerspectiveCamera.js | @@ -126,7 +126,7 @@ THREE.PerspectiveCamera.prototype.clone = function () {
var camera = new THREE.PerspectiveCamera();
- THREE.Camera.prototype.copy.call( camera, this );
+ camera.copy( this );
camera.zoom = this.zoom;
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/extras/geometries/CircleBufferGeometry.js | @@ -77,7 +77,7 @@ THREE.CircleBufferGeometry.prototype.clone = function () {
this.parameters.thetaLength
);
- THREE.BufferGeometry.prototype.copy.call( geometry, this );
+ geometry.copy( this );
return geometry;
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/extras/geometries/DodecahedronGeometry.js | @@ -64,7 +64,7 @@ THREE.DodecahedronGeometry.prototype.clone = function () {
this.parameters.detail
);
- THREE.PolyhedronGeometry.prototype.copy.call( geometry, this );
+ geometry.copy( this );
return geometry;
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/extras/geometries/IcosahedronGeometry.js | @@ -39,7 +39,7 @@ THREE.IcosahedronGeometry.prototype.clone = function () {
this.parameters.detail
);
- THREE.PolyhedronGeometry.prototype.copy.call( geometry, this );
+ geometry.copy( this );
return geometry;
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/extras/geometries/OctahedronGeometry.js | @@ -32,7 +32,7 @@ THREE.OctahedronGeometry.prototype.clone = function () {
this.parameters.detail
);
- THREE.PolyhedronGeometry.prototype.copy.call( geometry, this );
+ geometry.copy( this );
return geometry;
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/extras/geometries/PlaneBufferGeometry.js | @@ -104,7 +104,7 @@ THREE.PlaneBufferGeometry.prototype.clone = function () {
this.parameters.heightSegments
);
- THREE.BufferGeometry.prototype.copy.call( geometry, this );
+ geometry.copy( this );
return geometry;
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/extras/geometries/SphereBufferGeometry.js | @@ -112,7 +112,7 @@ THREE.SphereBufferGeometry.prototype.clone = function () {
this.parameters.thetaLength
);
- THREE.BufferGeometry.prototype.copy.call( geometry, this );
+ geometry.copy( this );
return geometry;
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/extras/geometries/TetrahedronGeometry.js | @@ -33,7 +33,7 @@ THREE.TetrahedronGeometry.prototype.clone = function () {
this.parameters.detail
);
- THREE.PolyhedronGeometry.prototype.copy.call( geometry, this );
+ geometry.copy( this );
return geometry;
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/lights/AmbientLight.js | @@ -17,7 +17,7 @@ THREE.AmbientLight.prototype.clone = function () {
var light = new THREE.AmbientLight();
- THREE.Light.prototype.copy.call( light, this );
+ light.copy( this );
return light;
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/lights/AreaLight.js | @@ -31,7 +31,7 @@ THREE.AreaLight.prototype.clone = function () {
var light = new THREE.AreaLight();
- THREE.Light.prototype.copy.call( light, this );
+ light.copy( this );
light.normal.copy(this.normal);
light.right.copy(this.right); | true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/lights/DirectionalLight.js | @@ -67,7 +67,7 @@ THREE.DirectionalLight.prototype.clone = function () {
var light = new THREE.DirectionalLight();
- THREE.Light.prototype.copy.call( light, this );
+ light.copy( this );
light.target = this.target.clone();
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/lights/HemisphereLight.js | @@ -22,7 +22,7 @@ THREE.HemisphereLight.prototype.clone = function () {
var light = new THREE.HemisphereLight();
- THREE.Light.prototype.copy.call( light, this );
+ light.copy( this );
light.groundColor.copy( this.groundColor );
light.intensity = this.intensity; | true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/lights/PointLight.js | @@ -21,7 +21,7 @@ THREE.PointLight.prototype.clone = function () {
var light = new THREE.PointLight();
- THREE.Light.prototype.copy.call( light, this );
+ light.copy( this );
light.intensity = this.intensity;
light.distance = this.distance; | true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/lights/SpotLight.js | @@ -50,7 +50,7 @@ THREE.SpotLight.prototype.clone = function () {
var light = new THREE.SpotLight();
- THREE.Light.prototype.copy.call( light, this );
+ light.copy( this );
light.target = this.target.clone();
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/materials/LineBasicMaterial.js | @@ -47,7 +47,7 @@ THREE.LineBasicMaterial.prototype.clone = function () {
var material = new THREE.LineBasicMaterial();
- THREE.Material.prototype.copy.call( material, this );
+ material.copy( this );
material.color.copy( this.color );
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/materials/LineDashedMaterial.js | @@ -50,7 +50,7 @@ THREE.LineDashedMaterial.prototype.clone = function () {
var material = new THREE.LineDashedMaterial();
- THREE.Material.prototype.copy.call( material, this );
+ material.copy( this );
material.color.copy( this.color );
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/materials/MeshBasicMaterial.js | @@ -83,7 +83,7 @@ THREE.MeshBasicMaterial.prototype.clone = function () {
var material = new THREE.MeshBasicMaterial();
- THREE.Material.prototype.copy.call( material, this );
+ material.copy( this );
material.color.copy( this.color );
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/materials/MeshDepthMaterial.js | @@ -35,7 +35,7 @@ THREE.MeshDepthMaterial.prototype.clone = function () {
var material = new THREE.MeshDepthMaterial();
- THREE.Material.prototype.copy.call( material, this );
+ material.copy( this );
material.wireframe = this.wireframe;
material.wireframeLinewidth = this.wireframeLinewidth; | true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/materials/MeshLambertMaterial.js | @@ -82,7 +82,7 @@ THREE.MeshLambertMaterial.prototype.clone = function () {
var material = new THREE.MeshLambertMaterial();
- THREE.Material.prototype.copy.call( material, this );
+ material.copy( this );
material.color.copy( this.color );
material.emissive.copy( this.emissive ); | true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/materials/MeshNormalMaterial.js | @@ -36,7 +36,7 @@ THREE.MeshNormalMaterial.prototype.clone = function () {
var material = new THREE.MeshNormalMaterial();
- THREE.Material.prototype.copy.call( material, this );
+ material.copy( this );
material.wireframe = this.wireframe;
material.wireframeLinewidth = this.wireframeLinewidth; | true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/materials/MeshPhongMaterial.js | @@ -116,7 +116,7 @@ THREE.MeshPhongMaterial.prototype.clone = function () {
var material = new THREE.MeshPhongMaterial();
- THREE.Material.prototype.copy.call( material, this );
+ material.copy( this );
material.color.copy( this.color );
material.emissive.copy( this.emissive ); | true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/materials/PointCloudMaterial.js | @@ -48,7 +48,7 @@ THREE.PointCloudMaterial.prototype.clone = function () {
var material = new THREE.PointCloudMaterial();
- THREE.Material.prototype.copy.call( material, this );
+ material.copy( this );
material.color.copy( this.color );
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/materials/RawShaderMaterial.js | @@ -17,7 +17,7 @@ THREE.RawShaderMaterial.prototype.clone = function () {
var material = new THREE.RawShaderMaterial();
- THREE.ShaderMaterial.prototype.copy.call( material, this );
+ material.copy( this );
return material;
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/materials/SpriteMaterial.js | @@ -43,7 +43,7 @@ THREE.SpriteMaterial.prototype.clone = function () {
var material = new THREE.SpriteMaterial();
- THREE.Material.prototype.copy.call( material, this );
+ material.copy( this );
material.color.copy( this.color );
material.map = this.map; | true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/objects/LineSegments.js | @@ -17,7 +17,7 @@ THREE.LineSegments.prototype.clone = function () {
var line = new THREE.LineSegments( this.geometry, this.material );
- THREE.Line.prototype.copy.call( line, this );
+ line.copy( this );
return line;
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/textures/CompressedTexture.js | @@ -28,7 +28,7 @@ THREE.CompressedTexture.prototype.clone = function () {
var texture = new THREE.CompressedTexture();
- THREE.Texture.prototype.copy.call( texture, this );
+ texture.copy( this );
return texture;
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/textures/CubeTexture.js | @@ -20,7 +20,7 @@ THREE.CubeTexture.clone = function () {
var texture = new THREE.CubeTexture();
- THREE.Texture.prototype.copy.call( texture, this );
+ texture.copy( this );
texture.images = this.images;
| true |
Other | mrdoob | three.js | 309ef4a72900fae5175d72b605394f0c6972a93b.json | Simplify copy invocation | src/textures/DataTexture.js | @@ -17,7 +17,7 @@ THREE.DataTexture.prototype.clone = function () {
var texture = new THREE.DataTexture();
- THREE.Texture.prototype.copy.call( texture, this );
+ texture.copy( this );
return texture;
| true |
Other | mrdoob | three.js | 2326db968f885471939cb6c1cc0bdbab64074daa.json | Fix typo in webgl_materials_bumpmap_skin | examples/webgl_materials_bumpmap_skin.html | @@ -216,7 +216,7 @@
effectCopy.renderToScreen = true;
- var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBufer: false };
+ var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false };
var rtwidth = 512, rtheight = 512;
composerBeckmann = new THREE.EffectComposer( renderer, new THREE.WebGLRenderTarget( rtwidth, rtheight, pars ) ); | false |
Other | mrdoob | three.js | b4575e143d7438d0c0d00be65a1a76ce0a87db83.json | fix index -> start | src/renderers/WebGLRenderer.js | @@ -1212,13 +1212,13 @@ THREE.WebGLRenderer = function ( parameters ) {
} else {
- _gl.drawArrays( mode, offsets[i].index, offsets[i].count );
+ _gl.drawArrays( mode, offsets[ i ].start, offsets[i].count );
}
_this.info.render.calls++;
- _this.info.render.vertices += offsets[i].count - offsets[i].index;
- _this.info.render.faces += ( offsets[i].count - offsets[i].index ) / 3;
+ _this.info.render.vertices += offsets[ i ].count - offsets[ i ].start;
+ _this.info.render.faces += ( offsets[ i ].count - offsets[ i ].start ) / 3;
}
} | false |
Other | mrdoob | three.js | 3c67a38348ff0d9d5c9c6ea939006206e91a6e4b.json | remove unnessary worlk | src/renderers/WebGLRenderer.js | @@ -1195,19 +1195,13 @@ THREE.WebGLRenderer = function ( parameters ) {
// must set attribute pointers to use new offsets for each chunk
// even if geometry and materials didn't change
- updateBuffers = true;
-
- for ( var i = 0, il = offsets.length; i < il; i++ ) {
-
- var startIndex = offsets[i].index;
-
- if ( updateBuffers ) {
+ if ( updateBuffers ) {
- setupVertexAttributes( material, program, geometry, startIndex );
+ setupVertexAttributes( material, program, geometry, 0 );
- }
+ }
- var position = geometry.attributes['position'];
+ for ( var i = 0, il = offsets.length; i < il; i++ ) {
// render non-indexed triangles
| false |
Other | mrdoob | three.js | c2d8c3d5b7400bf5582bff77266321d1e652d236.json | Add draw calls to non-indexed buffers | src/renderers/WebGLRenderer.js | @@ -1068,7 +1068,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( extension === null ) {
- THREE.error( 'THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
+ THREE.error( 'THREE.WebGLRenderer.renderMesh: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
return;
}
@@ -1111,7 +1111,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( extension === null ) {
- THREE.error( 'THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
+ THREE.error( 'THREE.WebGLRenderer.renderMesh: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
return;
}
@@ -1135,56 +1135,99 @@ THREE.WebGLRenderer = function ( parameters ) {
} else {
// non-indexed triangles
+
+ var offsets = geometry.offsets;
- if ( updateBuffers ) {
+ if ( offsets.length === 0 ) {
- setupVertexAttributes( material, program, geometry, 0 );
+ if ( updateBuffers ) {
- }
+ setupVertexAttributes( material, program, geometry, 0 );
- var position = geometry.attributes[ 'position' ];
+ }
- // render non-indexed triangles
+ var position = geometry.attributes['position'];
- if ( geometry instanceof THREE.InstancedBufferGeometry && geometry.maxInstancedCount > 0 ) {
+ // render non-indexed triangles
- var extension = extensions.get( 'ANGLE_instanced_arrays' );
+ if ( geometry instanceof THREE.InstancedBufferGeometry && geometry.maxInstancedCount > 0 ) {
- if ( extension === null ) {
+ var extension = extensions.get( 'ANGLE_instanced_arrays' );
- THREE.error( 'THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
- return;
+ if ( extension === null ) {
- }
+ THREE.error( 'THREE.WebGLRenderer.renderMesh: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );
+ return;
- if ( position instanceof THREE.InterleavedBufferAttribute ) {
+ }
+
+ if ( position instanceof THREE.InterleavedBufferAttribute ) {
+
+ extension.drawArraysInstancedANGLE( mode, 0, position.data.array.length / position.data.stride, geometry.maxInstancedCount ); // Draw the instanced meshes
+
+ } else {
+
+ extension.drawArraysInstancedANGLE( mode, 0, position.array.length / position.itemSize, geometry.maxInstancedCount ); // Draw the instanced meshes
- extension.drawArraysInstancedANGLE( mode, 0, position.data.array.length / position.data.stride, geometry.maxInstancedCount ); // Draw the instanced meshes
+ }
} else {
- extension.drawArraysInstancedANGLE( mode, 0, position.array.length / position.itemSize, geometry.maxInstancedCount ); // Draw the instanced meshes
+ if ( position instanceof THREE.InterleavedBufferAttribute ) {
+
+ _gl.drawArrays( mode, 0, position.data.array.length / position.data.stride );
+
+ } else {
+
+ _gl.drawArrays( mode, 0, position.array.length / position.itemSize );
+
+ }
}
+ _this.info.render.calls++;
+ _this.info.render.vertices += position.array.length / position.itemSize;
+ _this.info.render.faces += position.array.length / ( 3 * position.itemSize );
+
} else {
- if ( position instanceof THREE.InterleavedBufferAttribute ) {
+ // if there is more than 1 chunk
+ // must set attribute pointers to use new offsets for each chunk
+ // even if geometry and materials didn't change
- _gl.drawArrays( mode, 0, position.data.array.length / position.data.stride );
+ updateBuffers = true;
- } else {
+ for ( var i = 0, il = offsets.length; i < il; i++ ) {
- _gl.drawArrays( mode, 0, position.array.length / position.itemSize );
+ var startIndex = offsets[i].index;
- }
+ if ( updateBuffers ) {
- }
+ setupVertexAttributes( material, program, geometry, startIndex );
+
+ }
- _this.info.render.calls ++;
- _this.info.render.vertices += position.array.length / position.itemSize;
- _this.info.render.faces += position.array.length / ( 3 * position.itemSize );
+ var position = geometry.attributes['position'];
+ // render non-indexed triangles
+
+ if ( geometry instanceof THREE.InstancedBufferGeometry ) {
+
+ THREE.error( 'THREE.WebGLRenderer.renderMesh: cannot use drawCalls with THREE.InstancedBufferGeometry.' );
+ return;
+
+ } else {
+
+ _gl.drawArrays( mode, offsets[i].index, offsets[i].count );
+
+ }
+
+ _this.info.render.calls++;
+ _this.info.render.vertices += offsets[i].count - offsets[i].index;
+ _this.info.render.faces += ( offsets[i].count - offsets[i].index ) / 3;
+
+ }
+ }
}
} | false |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/core/BufferGeometry.js | @@ -316,7 +316,7 @@ THREE.BufferGeometry.prototype = {
var hasFaceVertexUv = faceVertexUvs[ 0 ] && faceVertexUvs[ 0 ].length > 0;
var hasFaceVertexUv2 = faceVertexUvs[ 1 ] && faceVertexUvs[ 1 ].length > 0;
- var hasFaceVertexNormals = faces[ 0 ] && faces[ 0 ].vertexNormals.length == 3;
+ var hasFaceVertexNormals = faces[ 0 ] && faces[ 0 ].vertexNormals.length === 3;
var positions = new Float32Array( faces.length * 3 * 3 );
this.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
@@ -977,7 +977,7 @@ THREE.BufferGeometry.prototype = {
for ( var vo = 0; vo < 3; vo ++ ) {
var vid = indices[ findex * 3 + vo ];
- if ( vertexMap[ vid ] == - 1 ) {
+ if ( vertexMap[ vid ] === - 1 ) {
//Unmapped vertice
faceVertices[ vo * 2 ] = vid;
faceVertices[ vo * 2 + 1 ] = - 1;
@@ -1111,7 +1111,7 @@ THREE.BufferGeometry.prototype = {
/* Create a copy of all attributes for reordering. */
var sortedAttributes = {};
for ( var attr in this.attributes ) {
- if ( attr == 'index' )
+ if ( attr === 'index' )
continue;
var sourceArray = this.attributes[ attr ].array;
sortedAttributes[ attr ] = new sourceArray.constructor( this.attributes[ attr ].itemSize * vertexCount );
@@ -1121,7 +1121,7 @@ THREE.BufferGeometry.prototype = {
for ( var new_vid = 0; new_vid < vertexCount; new_vid ++ ) {
var vid = indexMap[ new_vid ];
for ( var attr in this.attributes ) {
- if ( attr == 'index' )
+ if ( attr === 'index' )
continue;
var attrArray = this.attributes[ attr ].array;
var attrSize = this.attributes[ attr ].itemSize;
@@ -1134,7 +1134,7 @@ THREE.BufferGeometry.prototype = {
/* Carry the new sorted buffers locally */
this.attributes[ 'index' ].array = indexBuffer;
for ( var attr in this.attributes ) {
- if ( attr == 'index' )
+ if ( attr === 'index' )
continue;
this.attributes[ attr ].array = sortedAttributes[ attr ];
this.attributes[ attr ].numItems = this.attributes[ attr ].itemSize * vertexCount; | true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/core/Geometry.js | @@ -757,7 +757,7 @@ THREE.Geometry.prototype = {
// if any duplicate vertices are found in a Face3
// we have to remove the face as nothing can be saved
for ( var n = 0; n < 3; n ++ ) {
- if ( indices[ n ] == indices[ ( n + 1 ) % 3 ] ) {
+ if ( indices[ n ] === indices[ ( n + 1 ) % 3 ] ) {
dupIndex = n;
faceIndicesToRemove.push( i ); | true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/extras/animation/MorphAnimation.js | @@ -52,7 +52,7 @@ THREE.MorphAnimation.prototype = {
var influences = this.mesh.morphTargetInfluences;
- if ( frame != this.currentFrame ) {
+ if ( frame !== this.currentFrame ) {
influences[ this.lastFrame ] = 0;
influences[ this.currentFrame ] = 1; | true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/extras/core/Curve.js | @@ -110,7 +110,7 @@ THREE.Curve.prototype.getLengths = function ( divisions ) {
if ( ! divisions ) divisions = (this.__arcLengthDivisions) ? (this.__arcLengthDivisions) : 200;
if ( this.cacheArcLengths
- && ( this.cacheArcLengths.length == divisions + 1 )
+ && ( this.cacheArcLengths.length === divisions + 1 )
&& ! this.needsUpdate) {
//THREE.log( "cached", this.cacheArcLengths );
@@ -202,7 +202,7 @@ THREE.Curve.prototype.getUtoTmapping = function ( u, distance ) {
//THREE.log('b' , i, low, high, Date.now()- time);
- if ( arcLengths[ i ] == targetArcLength ) {
+ if ( arcLengths[ i ] === targetArcLength ) {
var t = i / ( il - 1 );
return t; | true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/extras/core/CurvePath.js | @@ -12,7 +12,7 @@ THREE.CurvePath = function () {
this.curves = [];
this.bends = [];
-
+
this.autoClose = false; // Automatically closes the path
};
@@ -37,11 +37,11 @@ THREE.CurvePath.prototype.closePath = function() {
// Add a line curve if start and end of lines are not connected
var startPoint = this.curves[0].getPoint(0);
var endPoint = this.curves[this.curves.length - 1].getPoint(1);
-
+
if (! startPoint.equals(endPoint)) {
this.curves.push( new THREE.LineCurve(endPoint, startPoint) );
}
-
+
};
// To get accurate point with reference to
@@ -107,7 +107,7 @@ THREE.CurvePath.prototype.getCurveLengths = function() {
// We use cache values if curves and cache array are same length
- if ( this.cacheLengths && this.cacheLengths.length == this.curves.length ) {
+ if ( this.cacheLengths && this.cacheLengths.length === this.curves.length ) {
return this.cacheLengths;
@@ -322,4 +322,3 @@ THREE.CurvePath.prototype.getWrapPoints = function ( oldPts, path ) {
return oldPts;
};
- | true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/extras/core/Path.js | @@ -376,7 +376,7 @@ THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
//THREE.log(points);
break;
-
+
case THREE.PathActions.ELLIPSE:
var aX = args[ 0 ], aY = args[ 1 ],
@@ -464,9 +464,9 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
args = item.args;
action = item.action;
- if ( action == THREE.PathActions.MOVE_TO ) {
+ if ( action === THREE.PathActions.MOVE_TO ) {
- if ( lastPath.actions.length != 0 ) {
+ if ( lastPath.actions.length !== 0 ) {
subPaths.push( lastPath );
lastPath = new THREE.Path();
@@ -479,7 +479,7 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
}
- if ( lastPath.actions.length != 0 ) {
+ if ( lastPath.actions.length !== 0 ) {
subPaths.push( lastPath );
@@ -534,17 +534,17 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
}
if ( ( inPt.y < edgeLowPt.y ) || ( inPt.y > edgeHighPt.y ) ) continue;
- if ( inPt.y == edgeLowPt.y ) {
- if ( inPt.x == edgeLowPt.x ) return true; // inPt is on contour ?
+ if ( inPt.y === edgeLowPt.y ) {
+ if ( inPt.x === edgeLowPt.x ) return true; // inPt is on contour ?
// continue; // no intersection or edgeLowPt => doesn't count !!!
} else {
var perpEdge = edgeDy * (inPt.x - edgeLowPt.x) - edgeDx * (inPt.y - edgeLowPt.y);
- if ( perpEdge == 0 ) return true; // inPt is on contour ?
+ if ( perpEdge === 0 ) return true; // inPt is on contour ?
if ( perpEdge < 0 ) continue;
inside = ! inside; // true intersection left of inPt
}
} else { // parallel or colinear
- if ( inPt.y != edgeLowPt.y ) continue; // parallel
+ if ( inPt.y !== edgeLowPt.y ) continue; // parallel
// egde lies on the same horizontal line as inPt
if ( ( ( edgeHighPt.x <= inPt.x ) && ( inPt.x <= edgeLowPt.x ) ) ||
( ( edgeLowPt.x <= inPt.x ) && ( inPt.x <= edgeHighPt.x ) ) ) return true; // inPt: Point on contour !
@@ -557,14 +557,14 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
var subPaths = extractSubpaths( this.actions );
- if ( subPaths.length == 0 ) return [];
+ if ( subPaths.length === 0 ) return [];
if ( noHoles === true ) return toShapesNoHoles( subPaths );
var solid, tmpPath, tmpShape, shapes = [];
- if ( subPaths.length == 1) {
+ if ( subPaths.length === 1) {
tmpPath = subPaths[0];
tmpShape = new THREE.Shape();
@@ -579,7 +579,7 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
holesFirst = isCCW ? ! holesFirst : holesFirst;
// THREE.log("Holes first", holesFirst);
-
+
var betterShapeHoles = [];
var newShapes = [];
var newShapeHoles = [];
@@ -605,7 +605,7 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
newShapes[mainIdx] = { s: new THREE.Shape(), p: tmpPoints };
newShapes[mainIdx].s.actions = tmpPath.actions;
newShapes[mainIdx].s.curves = tmpPath.curves;
-
+
if ( holesFirst ) mainIdx ++;
newShapeHoles[mainIdx] = [];
@@ -639,7 +639,7 @@ THREE.Path.prototype.toShapes = function( isCCW, noHoles ) {
var hole_unassigned = true;
for (var s2Idx = 0; s2Idx < newShapes.length; s2Idx ++ ) {
if ( isPointInsidePolygon( ho.p, newShapes[s2Idx].p ) ) {
- if ( sIdx != s2Idx ) toChange.push( { froms: sIdx, tos: s2Idx, hole: hIdx } );
+ if ( sIdx !== s2Idx ) toChange.push( { froms: sIdx, tos: s2Idx, hole: hIdx } );
if ( hole_unassigned ) {
hole_unassigned = false;
betterShapeHoles[s2Idx].push( ho ); | true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/extras/core/Shape.js | @@ -128,7 +128,7 @@ THREE.Shape.Utils = {
function point_in_segment_2D_colin( inSegPt1, inSegPt2, inOtherPt ) {
// inOtherPt needs to be colinear to the inSegment
- if ( inSegPt1.x != inSegPt2.x ) {
+ if ( inSegPt1.x !== inSegPt2.x ) {
if ( inSegPt1.x < inSegPt2.x ) {
return ( ( inSegPt1.x <= inOtherPt.x ) && ( inOtherPt.x <= inSegPt2.x ) );
} else {
@@ -170,37 +170,37 @@ THREE.Shape.Utils = {
// i.e. to reduce rounding errors
// intersection at endpoint of segment#1?
- if ( perpSeg2 == 0 ) {
+ if ( perpSeg2 === 0 ) {
if ( ( inExcludeAdjacentSegs ) &&
- ( ( perpSeg1 == 0 ) || ( perpSeg1 == limit ) ) ) return [];
+ ( ( perpSeg1 === 0 ) || ( perpSeg1 === limit ) ) ) return [];
return [ inSeg1Pt1 ];
}
- if ( perpSeg2 == limit ) {
+ if ( perpSeg2 === limit ) {
if ( ( inExcludeAdjacentSegs ) &&
- ( ( perpSeg1 == 0 ) || ( perpSeg1 == limit ) ) ) return [];
+ ( ( perpSeg1 === 0 ) || ( perpSeg1 === limit ) ) ) return [];
return [ inSeg1Pt2 ];
}
// intersection at endpoint of segment#2?
- if ( perpSeg1 == 0 ) return [ inSeg2Pt1 ];
- if ( perpSeg1 == limit ) return [ inSeg2Pt2 ];
+ if ( perpSeg1 === 0 ) return [ inSeg2Pt1 ];
+ if ( perpSeg1 === limit ) return [ inSeg2Pt2 ];
// return real intersection point
var factorSeg1 = perpSeg2 / limit;
return [ { x: inSeg1Pt1.x + factorSeg1 * seg1dx,
y: inSeg1Pt1.y + factorSeg1 * seg1dy } ];
} else { // parallel or colinear
- if ( ( perpSeg1 != 0 ) ||
- ( seg2dy * seg1seg2dx != seg2dx * seg1seg2dy ) ) return [];
+ if ( ( perpSeg1 !== 0 ) ||
+ ( seg2dy * seg1seg2dx !== seg2dx * seg1seg2dy ) ) return [];
// they are collinear or degenerate
- var seg1Pt = ( (seg1dx == 0) && (seg1dy == 0) ); // segment1 ist just a point?
- var seg2Pt = ( (seg2dx == 0) && (seg2dy == 0) ); // segment2 ist just a point?
+ var seg1Pt = ( (seg1dx === 0) && (seg1dy === 0) ); // segment1 ist just a point?
+ var seg2Pt = ( (seg2dx === 0) && (seg2dy === 0) ); // segment2 ist just a point?
// both segments are points
if ( seg1Pt && seg2Pt ) {
- if ( (inSeg1Pt1.x != inSeg2Pt1.x) ||
- (inSeg1Pt1.y != inSeg2Pt1.y) ) return []; // they are distinct points
- return [ inSeg1Pt1 ]; // they are the same point
+ if ( (inSeg1Pt1.x !== inSeg2Pt1.x) ||
+ (inSeg1Pt1.y !== inSeg2Pt1.y) ) return []; // they are distinct points
+ return [ inSeg1Pt1 ]; // they are the same point
}
// segment#1 is a single point
if ( seg1Pt ) {
@@ -216,7 +216,7 @@ THREE.Shape.Utils = {
// they are collinear segments, which might overlap
var seg1min, seg1max, seg1minVal, seg1maxVal;
var seg2min, seg2max, seg2minVal, seg2maxVal;
- if (seg1dx != 0) { // the segments are NOT on a vertical line
+ if (seg1dx !== 0) { // the segments are NOT on a vertical line
if ( inSeg1Pt1.x < inSeg1Pt2.x ) {
seg1min = inSeg1Pt1; seg1minVal = inSeg1Pt1.x;
seg1max = inSeg1Pt2; seg1maxVal = inSeg1Pt2.x;
@@ -249,15 +249,15 @@ THREE.Shape.Utils = {
}
if ( seg1minVal <= seg2minVal ) {
if ( seg1maxVal < seg2minVal ) return [];
- if ( seg1maxVal == seg2minVal ) {
+ if ( seg1maxVal === seg2minVal ) {
if ( inExcludeAdjacentSegs ) return [];
return [ seg2min ];
}
if ( seg1maxVal <= seg2maxVal ) return [ seg2min, seg1max ];
return [ seg2min, seg2max ];
} else {
if ( seg1minVal > seg2maxVal ) return [];
- if ( seg1minVal == seg2maxVal ) {
+ if ( seg1minVal === seg2maxVal ) {
if ( inExcludeAdjacentSegs ) return [];
return [ seg1min ];
}
@@ -574,4 +574,3 @@ THREE.Shape.Utils = {
}
};
- | true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/extras/curves/CatmullRomCurve3.js | @@ -100,7 +100,7 @@ THREE.CatmullRomCurve3 = ( function() {
intPoint = Math.floor( point );
weight = point - intPoint;
- if ( weight == 0 && intPoint == l - 1 ) {
+ if ( weight === 0 && intPoint === l - 1 ) {
intPoint = l - 2;
weight = 1;
@@ -109,7 +109,7 @@ THREE.CatmullRomCurve3 = ( function() {
var p0, p1, p2, p3;
- if ( intPoint == 0 ) {
+ if ( intPoint === 0 ) {
// extrapolate first point
tmp.subVectors( points[ 0 ], points[ 1 ] ).add( points[ 0 ] ); | true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/extras/curves/SplineCurve.js | @@ -19,7 +19,7 @@ THREE.SplineCurve.prototype.getPoint = function ( t ) {
var intPoint = Math.floor( point );
var weight = point - intPoint;
- var point0 = points[ intPoint == 0 ? intPoint : intPoint - 1 ];
+ var point0 = points[ intPoint === 0 ? intPoint : intPoint - 1 ];
var point1 = points[ intPoint ];
var point2 = points[ intPoint > points.length - 2 ? points.length - 1 : intPoint + 1 ];
var point3 = points[ intPoint > points.length - 3 ? points.length - 1 : intPoint + 2 ]; | true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/extras/geometries/ExtrudeGeometry.js | @@ -250,7 +250,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
if ( v_prev_x < - EPSILON ) {
if ( v_next_x < - EPSILON ) { direction_eq = true; }
} else {
- if ( Math.sign(v_prev_y) == Math.sign(v_next_y) ) { direction_eq = true; }
+ if ( Math.sign(v_prev_y) === Math.sign(v_next_y) ) { direction_eq = true; }
}
}
| true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/extras/geometries/PolyhedronGeometry.js | @@ -153,7 +153,7 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) {
for ( var j = 0; j <= rows; j ++) {
- if ( j == 0 && i == cols ) {
+ if ( j === 0 && i === cols ) {
v[ i ][ j ] = aj;
@@ -175,7 +175,7 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) {
var k = Math.floor( j / 2 );
- if ( j % 2 == 0 ) {
+ if ( j % 2 === 0 ) {
make(
v[ i ][ k + 1], | true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/loaders/CompressedTextureLoader.js | @@ -49,7 +49,7 @@ THREE.CompressedTextureLoader.prototype = {
if ( loaded === 6 ) {
- if (texDatas.mipmapCount == 1)
+ if (texDatas.mipmapCount === 1)
texture.minFilter = THREE.LinearFilter;
texture.format = texDatas.format; | true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/materials/Material.js | @@ -91,7 +91,7 @@ THREE.Material.prototype = {
currentValue.copy( newValue );
- } else if ( key == 'overdraw' ) {
+ } else if ( key === 'overdraw' ) {
// ensure overdraw is backwards-compatable with legacy boolean type
this[ key ] = Number( newValue ); | true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/math/Math.js | @@ -17,11 +17,11 @@ THREE.Math = {
for ( var i = 0; i < 36; i ++ ) {
- if ( i == 8 || i == 13 || i == 18 || i == 23 ) {
+ if ( i === 8 || i === 13 || i === 18 || i === 23 ) {
uuid[ i ] = '-';
- } else if ( i == 14 ) {
+ } else if ( i === 14 ) {
uuid[ i ] = '4';
@@ -30,7 +30,7 @@ THREE.Math = {
if ( rnd <= 0x02 ) rnd = 0x2000000 + ( Math.random() * 0x1000000 ) | 0;
r = rnd & 0xf;
rnd = rnd >> 4;
- uuid[ i ] = chars[ ( i == 19 ) ? ( r & 0x3 ) | 0x8 : r ];
+ uuid[ i ] = chars[ ( i === 19 ) ? ( r & 0x3 ) | 0x8 : r ];
}
} | true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/math/Matrix4.js | @@ -685,7 +685,7 @@ THREE.Matrix4.prototype = {
var det = n11 * te[ 0 ] + n21 * te[ 4 ] + n31 * te[ 8 ] + n41 * te[ 12 ];
- if ( det == 0 ) {
+ if ( det === 0 ) {
var msg = "THREE.Matrix4.getInverse(): can't invert matrix, determinant is 0";
| true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/math/Plane.js | @@ -140,10 +140,10 @@ THREE.Plane.prototype = {
var denominator = this.normal.dot( direction );
- if ( denominator == 0 ) {
+ if ( denominator === 0 ) {
// line is coplanar, return origin
- if ( this.distanceToPoint( line.start ) == 0 ) {
+ if ( this.distanceToPoint( line.start ) === 0 ) {
return result.copy( line.start );
@@ -210,7 +210,7 @@ THREE.Plane.prototype = {
equals: function ( plane ) {
- return plane.normal.equals( this.normal ) && ( plane.constant == this.constant );
+ return plane.normal.equals( this.normal ) && ( plane.constant === this.constant );
},
| true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/math/Ray.js | @@ -261,7 +261,7 @@ THREE.Ray.prototype = {
// in order to always return an intersect point that is in front of the ray.
if ( t0 < 0 ) return this.at( t1, optionalTarget );
- // else t0 is in front of the ray, so return the first collision point scaled by t0
+ // else t0 is in front of the ray, so return the first collision point scaled by t0
return this.at( t0, optionalTarget );
}
@@ -297,10 +297,10 @@ THREE.Ray.prototype = {
distanceToPlane: function ( plane ) {
var denominator = plane.normal.dot( this.direction );
- if ( denominator == 0 ) {
+ if ( denominator === 0 ) {
// line is coplanar, return origin
- if ( plane.distanceToPoint( this.origin ) == 0 ) {
+ if ( plane.distanceToPoint( this.origin ) === 0 ) {
return 0;
| true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/math/Spline.js | @@ -104,7 +104,7 @@ THREE.Spline = function ( points ) {
point = ( this.points.length - 1 ) * index;
intPoint = Math.floor( point );
- if ( intPoint != oldIntPoint ) {
+ if ( intPoint !== oldIntPoint ) {
chunkLengths[ intPoint ] = totalLength;
oldIntPoint = intPoint; | true |
Other | mrdoob | three.js | dad328077dfc50ab44bdc9a70634787374d45253.json | use strict (in)equalities | src/math/Triangle.js | @@ -61,7 +61,7 @@ THREE.Triangle.barycoordFromPoint = function () {
var result = optionalTarget || new THREE.Vector3();
// colinear or singular triangle
- if ( denom == 0 ) {
+ if ( denom === 0 ) {
// arbitrary location outside of triangle?
// not sure if this is the best idea, maybe should be returning undefined
return result.set( - 2, - 1, - 1 ); | true |
Other | mrdoob | three.js | 669eb6dd6191978e2f6b280bc50f976453f3d654.json | Simplify tracking of EdgesGeometry coordinates | src/extras/geometries/EdgesGeometry.js | @@ -33,7 +33,6 @@ THREE.EdgesGeometry = function ( geometry, thresholdAngle ) {
var vertices = geometry2.vertices;
var faces = geometry2.faces;
- var numEdges = 0;
for ( var i = 0, l = faces.length; i < l; i ++ ) {
@@ -50,7 +49,6 @@ THREE.EdgesGeometry = function ( geometry, thresholdAngle ) {
if ( hash[ key ] === undefined ) {
hash[ key ] = { vert1: edge[ 0 ], vert2: edge[ 1 ], face1: i, face2: undefined };
- numEdges ++;
} else {
@@ -62,9 +60,7 @@ THREE.EdgesGeometry = function ( geometry, thresholdAngle ) {
}
- var coords = new Float32Array( numEdges * 2 * 3 );
-
- var index = 0;
+ var coords = [];
for ( var key in hash ) {
@@ -73,22 +69,20 @@ THREE.EdgesGeometry = function ( geometry, thresholdAngle ) {
if ( h.face2 === undefined || faces[ h.face1 ].normal.dot( faces[ h.face2 ].normal ) <= thresholdDot ) {
var vertex = vertices[ h.vert1 ];
- coords[ index ++ ] = vertex.x;
- coords[ index ++ ] = vertex.y;
- coords[ index ++ ] = vertex.z;
+ coords.push( vertex.x );
+ coords.push( vertex.y );
+ coords.push( vertex.z );
vertex = vertices[ h.vert2 ];
- coords[ index ++ ] = vertex.x;
- coords[ index ++ ] = vertex.y;
- coords[ index ++ ] = vertex.z;
+ coords.push( vertex.x );
+ coords.push( vertex.y );
+ coords.push( vertex.z );
}
}
- coords = coords.subarray( 0, index );
-
- this.addAttribute( 'position', new THREE.BufferAttribute( coords, 3 ) );
+ this.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( coords ), 3 ) );
};
| false |
Other | mrdoob | three.js | cfa8e9aa0c7c9cb9aec7e3415bc5d3bd549c4da8.json | Add unit tests | test/unit/geometry/EdgesGeometry.js | @@ -0,0 +1,273 @@
+module( "EdgesGeometry" );
+
+var DEBUG = false;
+
+var vertList = [
+ new THREE.Vector3(0, 0, 0),
+ new THREE.Vector3(1, 0, 0),
+ new THREE.Vector3(1, 1, 0),
+ new THREE.Vector3(0, 1, 0),
+ new THREE.Vector3(1, 1, 1),
+];
+
+test( "singularity", function() {
+
+ testEdges( vertList, [1, 1, 1], 0 );
+
+});
+
+test( "needle", function() {
+
+ testEdges( vertList, [0, 0, 1], 0 );
+
+});
+
+test( "single triangle", function() {
+
+ testEdges( vertList, [0, 1, 2], 3 );
+
+});
+
+test( "two isolated triangles", function() {
+
+ var vertList = [
+ new THREE.Vector3(0, 0, 0),
+ new THREE.Vector3(1, 0, 0),
+ new THREE.Vector3(1, 1, 0),
+ new THREE.Vector3(0, 0, 1),
+ new THREE.Vector3(1, 0, 1),
+ new THREE.Vector3(1, 1, 1),
+ ];
+
+ testEdges( vertList, [0, 1, 2, 3, 4, 5], 6 );
+
+});
+
+test( "two flat triangles", function() {
+
+ testEdges( vertList, [0, 1, 2, 0, 2, 3], 4 );
+
+});
+
+test( "two flat triangles, inverted", function() {
+
+ testEdges( vertList, [0, 1, 2, 0, 3, 2], 5 );
+
+});
+
+test( "two non-coplanar triangles", function() {
+
+ testEdges( vertList, [0, 1, 2, 0, 4, 2], 5 );
+
+});
+
+test( "three triangles, coplanar first", function() {
+
+ testEdges( vertList, [0, 1, 2, 0, 2, 3, 0, 4, 2], 7 );
+
+});
+
+test( "three triangles, coplanar last", function() {
+
+ testEdges( vertList, [0, 1, 2, 0, 4, 2, 0, 2, 3], 7 );
+
+});
+
+test( "tetrahedron", function() {
+
+ testEdges( vertList, [0, 1, 2, 0, 1, 4, 0, 4, 2, 1, 2, 4], 6 );
+
+});
+
+
+
+//
+// HELPERS
+//
+
+function testEdges( vertList, idxList, numAfter ) {
+
+ var geoms = createGeometries ( vertList, idxList );
+
+ for ( var i = 0 ; i < geoms.length ; i ++ ) {
+
+ var geom = geoms[i];
+ console.log(geom);
+ var numBefore = idxList.length;
+ equal( countEdges (geom), numBefore, "Edges before!" );
+
+ var egeom = new THREE.EdgesGeometry ( geom );;
+
+ equal( countEdges (egeom), numAfter, "Edges after!" );
+ output( geom, egeom );
+
+ }
+
+}
+
+function createGeometries ( vertList, idxList ) {
+
+ var geomIB = createIndexedBufferGeometry ( vertList, idxList );
+ var geom = new THREE.Geometry().fromBufferGeometry( geomIB );
+ var geomB = new THREE.BufferGeometry().fromGeometry( geom );
+ var geomDC = addDrawCalls( geomIB.clone() );
+ return [ geom, geomB, geomIB, geomDC ];
+
+}
+
+function createIndexedBufferGeometry ( vertList, idxList ) {
+
+ var geom = new THREE.BufferGeometry();
+
+ var indexTable = [];
+ var numTris = idxList.length / 3;
+ var numVerts = 0;
+
+ var indices = new Uint32Array( numTris * 3 );
+ var vertices = new Float32Array( vertList.length * 3 );
+
+ for ( var i = 0; i < numTris; i ++ ) {
+
+ for ( var j = 0; j < 3; j ++ ) {
+
+ var idx = idxList[ 3 * i + j ];
+ if ( indexTable[ idx ] === undefined ) {
+
+ var v = vertList[ idx ];
+ vertices[ 3 * numVerts ] = v.x;
+ vertices[ 3 * numVerts + 1 ] = v.y;
+ vertices[ 3 * numVerts + 2 ] = v.z;
+
+ indexTable[ idx ] = numVerts;
+
+ numVerts ++;
+
+ }
+
+ indices[ 3 * i + j ] = indexTable[ idx ] ;
+
+ }
+
+ }
+
+ vertices = vertices.subarray( 0, 3 * numVerts );
+
+ geom.addAttribute( 'index', new THREE.BufferAttribute( indices, 1 ) );
+ geom.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
+
+ geom.computeFaceNormals();
+
+ return geom;
+
+}
+
+function addDrawCalls ( geometry ) {
+
+ var numTris = geometry.getAttribute( 'index' ).length / 3;
+
+ var offset = 0;
+ for ( var i = 0 ; i < numTris; i ++ ) {
+
+ var start = i * 3;
+ var count = 3;
+
+ geometry.addDrawCall ( start, count, offset );
+
+ }
+
+ return geometry;
+
+}
+
+function countEdges ( geom ) {
+
+ if ( geom instanceof THREE.EdgesGeometry ) {
+
+ return geom.getAttribute( 'position' ).length / ( 3 * 2 );
+
+ }
+
+ if ( geom.faces !== undefined ) {
+
+ return geom.faces.length * 3;
+
+ }
+
+ var indices = geom.getAttribute( 'index' );
+ if ( indices !== undefined ) {
+
+ return indices.length;
+
+ }
+
+ return geom.getAttribute( 'position' ).length / 3;
+
+}
+
+//
+// DEBUGGING
+//
+
+var renderer;
+var camera;
+var scene = new THREE.Scene();
+var xoffset = 0;
+
+function output (geom, egeom) {
+
+ if ( DEBUG !== true ) return;
+
+ if ( !renderer ) initDebug( DEBUG );
+
+ var mesh = new THREE.Mesh( geom, undefined );
+ var edges = new THREE.Line( egeom, new THREE.LineBasicMaterial( { color: 'black' }), THREE.LinePieces );
+
+ mesh.position.setX( xoffset );
+ edges.position.setX( xoffset ++ );
+ scene.add(mesh);
+ scene.add(edges);
+
+ if (scene.children.length % 8 === 0) {
+ xoffset += 2;
+ }
+
+}
+
+function initDebug( debug ) {
+
+ if ( renderer || !debug ) return;
+
+ renderer = new THREE.WebGLRenderer({
+ antialias: true
+ });
+
+ var width = 600;
+ var height = 480;
+
+ renderer.setSize(width, height);
+ renderer.setClearColor( 0xCCCCCC );
+
+ camera = new THREE.PerspectiveCamera(45, width / height, 1, 100);
+ camera.position.x = 30;
+ camera.position.z = 40;
+ camera.lookAt(new THREE.Vector3(30, 0, 0));
+
+ document.body.appendChild(renderer.domElement);
+
+ var controls = new THREE.OrbitControls( camera, renderer.domElement );
+ controls.target = new THREE.Vector3(30, 0, 0);
+
+ animate();
+
+ function animate() {
+
+ requestAnimationFrame( animate );
+
+ controls.update();
+
+ renderer.render( scene, camera );
+
+ }
+
+}
+ | true |
Other | mrdoob | three.js | cfa8e9aa0c7c9cb9aec7e3415bc5d3bd549c4da8.json | Add unit tests | test/unit/unittests_three.html | @@ -32,5 +32,10 @@
<script src="math/Matrix3.js"></script>
<script src="math/Matrix4.js"></script>
<script src="math/Frustum.js"></script>
+
+ <script src="geometry/EdgesGeometry.js"></script>
+
+ <!-- for debug output -->
+ <script src="../../examples/js/controls/OrbitControls.js"></script>
</body>
</html> | true |
Other | mrdoob | three.js | 688cde2f6cbed70b2ce0ca74e13d585a22cca15f.json | add blender logging handlers only once | utils/exporters/blender/addons/io_three/logger.py | @@ -32,20 +32,21 @@ def init(filename, level=constants.DEBUG):
LOGGER = logging.getLogger('Three.Export')
LOGGER.setLevel(LEVELS[level])
- stream = logging.StreamHandler()
- stream.setLevel(LEVELS[level])
+ if not LOGGER.handlers:
+ stream = logging.StreamHandler()
+ stream.setLevel(LEVELS[level])
- format_ = '%(asctime)s - %(name)s - %(levelname)s: %(message)s'
- formatter = logging.Formatter(format_)
+ format_ = '%(asctime)s - %(name)s - %(levelname)s: %(message)s'
+ formatter = logging.Formatter(format_)
- stream.setFormatter(formatter)
+ stream.setFormatter(formatter)
- file_handler = logging.FileHandler(LOG_FILE)
- file_handler.setLevel(LEVELS[level])
- file_handler.setFormatter(formatter)
+ file_handler = logging.FileHandler(LOG_FILE)
+ file_handler.setLevel(LEVELS[level])
+ file_handler.setFormatter(formatter)
- LOGGER.addHandler(stream)
- LOGGER.addHandler(file_handler)
+ LOGGER.addHandler(stream)
+ LOGGER.addHandler(file_handler)
def info(*args): | false |
Other | mrdoob | three.js | 65e6cdd6903cefc2c96970adf97f61da411353f2.json | Do lookup directly in sort function | src/renderers/WebGLRenderer.js | @@ -3233,9 +3233,9 @@ THREE.WebGLRenderer = function ( parameters ) {
function painterSortStable ( a, b ) {
- if ( a.renderOrder !== b.renderOrder ) {
+ if ( a.object.renderOrder !== b.object.renderOrder ) {
- return a.renderOrder - b.renderOrder;
+ return a.object.renderOrder - b.object.renderOrder;
} else if ( a.material.id !== b.material.id ) {
@@ -3255,9 +3255,9 @@ THREE.WebGLRenderer = function ( parameters ) {
function reversePainterSortStable ( a, b ) {
- if ( a.renderOrder !== b.renderOrder ) {
+ if ( a.object.renderOrder !== b.object.renderOrder ) {
- return a.renderOrder - b.renderOrder;
+ return a.object.renderOrder - b.object.renderOrder;
} if ( a.z !== b.z ) {
@@ -3467,7 +3467,6 @@ THREE.WebGLRenderer = function ( parameters ) {
_vector3.applyProjection( _projScreenMatrix );
webglObject.z = _vector3.z;
- webglObject.renderOrder = object.renderOrder;
}
@@ -3888,8 +3887,7 @@ THREE.WebGLRenderer = function ( parameters ) {
buffer: buffer,
object: object,
material: null,
- z: 0,
- renderOrder: 0
+ z: 0
}
);
@@ -3903,8 +3901,7 @@ THREE.WebGLRenderer = function ( parameters ) {
object: object,
opaque: null,
transparent: null,
- z: 0,
- renderOrder: 0
+ z: 0
}
);
| false |
Other | mrdoob | three.js | 26a2dcb516d8687b2e0b4c1056be95e0b2e517c2.json | Change renderfinish event to complete | examples/js/renderers/RaytracingRenderer.js | @@ -460,7 +460,7 @@ THREE.RaytracingRenderer = function ( parameters ) {
if ( blockY >= canvasHeight ) {
- dispatch( { type: "renderfinish" } );
+ dispatch( { type: "complete" } );
return;
| false |
Other | mrdoob | three.js | 940a60884a0bd76bc085293ee4a3ac616a465124.json | Fix OBJExporter exported file format.
OBJExporter produced invalid OBJ file in case of missing texture coordinates or vertex normals. Now I fixed it, and write dummy texture coordinates if there aren't any, and write face normals if vertex normals are not exist. In addition I created an example to test the code. | examples/js/exporters/OBJExporter.js | @@ -13,7 +13,7 @@ THREE.OBJExporter.prototype = {
var output = '';
var indexVertex = 0;
- var indexVertexUvs = 0
+ var indexVertexUvs = 0;
var indexNormals = 0;
var parseObject = function ( child ) {
@@ -41,21 +41,34 @@ THREE.OBJExporter.prototype = {
// uvs
- for ( var i = 0, l = geometry.faceVertexUvs[ 0 ].length; i < l; i ++ ) {
+ if (geometry.faceVertexUvs[ 0 ].length == geometry.faces.length) {
+
+ for ( var i = 0, l = geometry.faceVertexUvs[ 0 ].length; i < l; i ++ ) {
- var vertexUvs = geometry.faceVertexUvs[ 0 ][ i ];
+ var vertexUvs = geometry.faceVertexUvs[ 0 ][ i ];
- for ( var j = 0; j < vertexUvs.length; j ++ ) {
+ for ( var j = 0; j < vertexUvs.length; j ++ ) {
- var uv = vertexUvs[ j ];
- vertex.applyMatrix4( child.matrixWorld );
+ var uv = vertexUvs[ j ];
+ vertex.applyMatrix4( child.matrixWorld );
- output += 'vt ' + uv.x + ' ' + uv.y + '\n';
+ output += 'vt ' + uv.x + ' ' + uv.y + '\n';
- nbVertexUvs ++;
+ nbVertexUvs ++;
+
+ }
}
+
+ } else {
+
+ for ( var i = 0, l = geometry.faces.length * 3; i < l; i ++ ) {
+ output += 'vt 0 0\n';
+ nbVertexUvs ++;
+
+ }
+
}
// normals
@@ -64,13 +77,29 @@ THREE.OBJExporter.prototype = {
var normals = geometry.faces[ i ].vertexNormals;
- for ( var j = 0; j < normals.length; j ++ ) {
+ if (normals.length == 3) {
+
+ for ( var j = 0; j < normals.length; j ++ ) {
+
+ var normal = normals[ j ];
+ output += 'vn ' + normal.x + ' ' + normal.y + ' ' + normal.z + '\n';
+
+ nbNormals ++;
+
+ }
+
+ } else {
+
+ var normal = geometry.faces[ i ].normal;
+
+ for ( var j = 0; j < 3; j ++ ) {
- var normal = normals[ j ];
- output += 'vn ' + normal.x + ' ' + normal.y + ' ' + normal.z + '\n';
+ output += 'vn ' + normal.x + ' ' + normal.y + ' ' + normal.z + '\n';
- nbNormals ++;
+ nbNormals ++;
+ }
+
}
} | true |
Other | mrdoob | three.js | 940a60884a0bd76bc085293ee4a3ac616a465124.json | Fix OBJExporter exported file format.
OBJExporter produced invalid OBJ file in case of missing texture coordinates or vertex normals. Now I fixed it, and write dummy texture coordinates if there aren't any, and write face normals if vertex normals are not exist. In addition I created an example to test the code. | examples/webgl_exporter_obj.html | @@ -0,0 +1,223 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <title>three.js webgl - exporter - obj</title>
+ <meta charset="utf-8">
+ <style>
+ body {
+ font-family: Monospace;
+ background-color: #000000;
+ margin: 0px;
+ overflow: hidden;
+ }
+
+ #info {
+ color: #fff;
+ position: absolute;
+ top: 10px;
+ width: 100%;
+ text-align: center;
+ z-index: 100;
+ display: block;
+ }
+
+ div.floating {
+ color : #ffffff;
+ background : #000000;
+ opacity : 0.8;
+ width : 80%;
+ height : 80%;
+ position : absolute;
+ left : 10%;
+ top : 10%;
+ border : 1px solid #555555;
+ padding : 10px;
+ display : none;
+ overflow : auto;
+ z-index: 100;
+ }
+
+ span.link {
+ color: skyblue;
+ cursor: pointer;
+ text-decoration : underline;
+ }
+
+ a {
+ color: skyblue
+ }
+ </style>
+ </head>
+ <body>
+ <div id="info">
+ <a href="http://threejs.org" target="_blank">three.js</a>
+ - geometries:
+ <span class="link" id="triangle">triangle</span>,
+ <span class="link" id="cube">cube</span>,
+ <span class="link" id="cylinder">cylinder</span>,
+ <span class="link" id="both">both</span>
+ - <span class="link" id="export">export to obj</span>
+ </div>
+
+ <script src="../build/three.min.js"></script>
+ <script src="js/exporters/OBJExporter.js"></script>
+
+ <script>
+
+ var camera, scene, light, renderer;
+ var exportButton, floatingDiv;
+ var mouseX = 0, mouseY = 0;
+
+ function exportToObj ()
+ {
+ var exporter = new THREE.OBJExporter ();
+ var result = exporter.parse (scene);
+ floatingDiv.style.display = 'block';
+ floatingDiv.innerHTML = result.split ('\n').join ('<br />');
+ }
+
+ function addGeometry (type)
+ {
+ for (var i = 0; i < scene.children.length; i++) {
+ var current = scene.children[i];
+ if (current instanceof THREE.Mesh) {
+ scene.remove (current);
+ i--;
+ }
+ }
+
+ if (type == 1) {
+ var material = new THREE.MeshLambertMaterial ( { color : 0x00cc00 } );
+ var geometry = new THREE.Geometry ();
+ geometry.vertices.push (new THREE.Vector3 (-50, -50, 0));
+ geometry.vertices.push (new THREE.Vector3 (50, -50, 0));
+ geometry.vertices.push (new THREE.Vector3 (50, 50, 0));
+ var face = new THREE.Face3 (0, 1, 2);
+ geometry.faces.push (face);
+ geometry.computeFaceNormals ();
+ scene.add( new THREE.Mesh( geometry, material ) );
+ } else if (type == 2) {
+ var material = new THREE.MeshLambertMaterial ( { color : 0x00cc00 } );
+ var geometry = new THREE.BoxGeometry( 100, 100, 100 );
+ scene.add( new THREE.Mesh( geometry, material ) );
+ } else if (type == 3) {
+ var material = new THREE.MeshLambertMaterial ( { color : 0x00cc00 } );
+ var geometry = new THREE.CylinderGeometry( 50, 50, 100, 30, 1 );
+ scene.add( new THREE.Mesh( geometry, material ) );
+ } else if (type == 4) {
+ var material = new THREE.MeshLambertMaterial ( { color : 0x00cc00 } );
+
+ var geometry = new THREE.Geometry ();
+ geometry.vertices.push (new THREE.Vector3 (-50, -50, 0));
+ geometry.vertices.push (new THREE.Vector3 (50, -50, 0));
+ geometry.vertices.push (new THREE.Vector3 (50, 50, 0));
+ geometry.faces.push (new THREE.Face3 (0, 1, 2));
+ geometry.computeFaceNormals ();
+ var mesh = new THREE.Mesh( geometry, material );
+ mesh.position.x = -200;
+ scene.add( mesh );
+
+ var geometry2 = new THREE.BoxGeometry( 100, 100, 100 );
+ var mesh2 = new THREE.Mesh( geometry2, material );
+ scene.add( mesh2 );
+
+ var geometry3 = new THREE.CylinderGeometry( 50, 50, 100, 30, 1 );
+ var mesh3 = new THREE.Mesh( geometry3, material );
+ mesh3.position.x = 200;
+
+ scene.add( mesh3 );
+ }
+ }
+
+ function init() {
+
+ renderer = new THREE.WebGLRenderer();
+ renderer.setPixelRatio( window.devicePixelRatio );
+ renderer.setSize( window.innerWidth, window.innerHeight );
+ document.body.appendChild( renderer.domElement );
+
+ camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000 );
+ camera.position.set (0, 0, 400);
+
+ scene = new THREE.Scene();
+
+ light = new THREE.DirectionalLight( 0xffffff );
+ scene.add( light );
+
+ addGeometry (1);
+
+ window.addEventListener( 'click', onWindowClick, false );
+ window.addEventListener( 'resize', onWindowResize, false );
+ document.addEventListener( 'mousemove', onDocumentMouseMove, false );
+ document.addEventListener( 'mouseover', onDocumentMouseMove, false );
+
+ document.getElementById( 'triangle' ).addEventListener( 'click', function() { addGeometry (1); });
+ document.getElementById( 'cube' ).addEventListener( 'click', function() { addGeometry (2); });
+ document.getElementById( 'cylinder' ).addEventListener( 'click', function() { addGeometry (3); });
+ document.getElementById( 'both' ).addEventListener( 'click', function() { addGeometry (4); });
+
+ exportButton = document.getElementById( 'export' );
+ exportButton.addEventListener( 'click', function() { exportToObj (); });
+
+ floatingDiv = document.createElement ('div');
+ floatingDiv.className = 'floating';
+ document.body.appendChild (floatingDiv);
+ }
+
+ function onWindowClick(event) {
+
+ var needToClose = true;
+ var target = event.target;
+ while (target !== null) {
+ if (target === floatingDiv || target == exportButton) {
+ needToClose = false;
+ break;
+ }
+ target = target.parentElement;
+ }
+
+ if (needToClose) {
+ floatingDiv.style.display = 'none';
+ }
+
+ }
+
+ function onWindowResize() {
+
+ camera.aspect = window.innerWidth / window.innerHeight;
+ camera.updateProjectionMatrix();
+
+ renderer.setSize( window.innerWidth, window.innerHeight );
+
+ }
+
+ function onDocumentMouseMove( event ) {
+
+ var windowHalfX = window.innerWidth / 2;
+ var windowHalfY = window.innerHeight / 2;
+ mouseX = ( event.clientX - windowHalfX ) / 2;
+ mouseY = ( event.clientY - windowHalfY ) / 2;
+
+ }
+
+ function animate() {
+
+ requestAnimationFrame( animate );
+
+ camera.position.x += ( mouseX - camera.position.x ) * .05;
+ camera.position.y += ( -mouseY - camera.position.y ) * .05;
+ camera.lookAt( new THREE.Vector3 (0.0, 0.0, 0.0) );
+
+ light.position.set( camera.position.x, camera.position.y, camera.position.z ).normalize ();
+ renderer.render( scene, camera );
+
+ }
+
+ init();
+ animate();
+
+
+ </script>
+
+ </body>
+</html> | true |
Other | mrdoob | three.js | 504bdabe074d89e2c8dbd2dbcc2e020d17af7084.json | Avoid obscure error on certain non-image textures. | utils/exporters/blender/addons/io_three/exporter/api/texture.py | @@ -174,5 +174,6 @@ def textures():
if mat.users == 0:
continue
for slot in mat.texture_slots:
- if slot and slot.use and slot.texture.type == IMAGE:
+ if (slot and slot.use and
+ slot.texture and slot.texture.type == IMAGE):
yield slot.texture.name | false |
Other | mrdoob | three.js | 9e7bf038a500cf78e48985545e3d5ef01dea6ada.json | Read texture info numeric or symbolic (compatible) | src/loaders/ObjectLoader.js | @@ -293,6 +293,12 @@ THREE.ObjectLoader.prototype = {
},
+ parseConstant: function ( json ) {
+
+ return typeof( json ) === 'number' ? json : THREE[json];
+
+ },
+
parseImages: function ( json, onLoad ) {
var scope = this;
@@ -358,15 +364,15 @@ THREE.ObjectLoader.prototype = {
texture.uuid = data.uuid;
if ( data.name !== undefined ) texture.name = data.name;
- if ( data.mapping !== undefined ) texture.mapping = data.mapping;
+ if ( data.mapping !== undefined ) texture.mapping = this.parseConstant( data.mapping );
if ( data.repeat !== undefined ) texture.repeat = new THREE.Vector2( data.repeat[ 0 ], data.repeat[ 1 ] );
- if ( data.minFilter !== undefined ) texture.minFilter = THREE[ data.minFilter ];
- if ( data.magFilter !== undefined ) texture.magFilter = THREE[ data.magFilter ];
+ if ( data.minFilter !== undefined ) texture.minFilter = this.parseConstant( data.minFilter );
+ if ( data.magFilter !== undefined ) texture.magFilter = this.parseConstant( data.magFilter );
if ( data.anisotropy !== undefined ) texture.anisotropy = data.anisotropy;
if ( data.wrap instanceof Array ) {
- texture.wrapS = THREE[ data.wrap[ 0 ] ];
- texture.wrapT = THREE[ data.wrap[ 1 ] ];
+ texture.wrapS = this.parseConstant( data.wrap[ 0 ] );
+ texture.wrapT = this.parseConstant( data.wrap[ 1 ] );
}
| false |
Other | mrdoob | three.js | 612aa17d75ab4a11f8ea0fe130983edfa4e191f3.json | Serialize complete texture info (numeric). | src/textures/Texture.js | @@ -109,8 +109,19 @@ THREE.Texture.prototype = {
type: 'Texture',
generator: 'Texture.toJSON'
},
+
uuid: this.uuid,
- mapping: this.mapping
+ name: this.name,
+
+ mapping: this.mapping,
+
+ repeat: [ this.repeat.x, this.repeat.y ],
+ offset: [ this.offset.x, this.offset.y ],
+ wrap: [ this.wrapS, this.wrapT ],
+
+ minFilter: this.minFilter,
+ magFilter: this.magFilter,
+ anisotropy: this.anisotropy
};
if ( this.image !== undefined ) { | false |
Other | mrdoob | three.js | 1ce8842c75806521a811a3f2eafcc59ad0453fb2.json | Avoid obscure error on certain non-image textures. | utils/exporters/blender/addons/io_three/exporter/api/material.py | @@ -384,7 +384,10 @@ def _valid_textures(material, strict_use=True):
in_use = texture.use
else:
in_use = True
- if texture.texture.type != IMAGE or not in_use:
+ if not in_use:
+ continue
+ if not texture.texture or texture.texture.type != IMAGE:
+ logger.warning("Unable to export non-image texture %s", texture)
continue
logger.debug("Valid texture found %s", texture)
yield texture | false |
Other | mrdoob | three.js | f7c695f0d374fcefbec47dd8fff09bf669aee650.json | Fix typo in webgl_animation_cloth | examples/webgl_animation_cloth.html | @@ -187,7 +187,7 @@
clothTexture.wrapS = clothTexture.wrapT = THREE.RepeatWrapping;
clothTexture.anisotropy = 16;
- var clothMaterial = new THREE.MeshPhongMaterial( { alphaTest: 0.5, color: 0xffffff, specular: 0x030303, emissive: 0x111111, shiness: 10, map: clothTexture, side: THREE.DoubleSide } );
+ var clothMaterial = new THREE.MeshPhongMaterial( { alphaTest: 0.5, color: 0xffffff, specular: 0x030303, emissive: 0x111111, shininess: 10, map: clothTexture, side: THREE.DoubleSide } );
// cloth geometry
clothGeometry = new THREE.ParametricGeometry( clothFunction, cloth.w, cloth.h );
@@ -241,7 +241,7 @@
// poles
var poleGeo = new THREE.BoxGeometry( 5, 375, 5 );
- var poleMat = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x111111, shiness: 100 } );
+ var poleMat = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0x111111, shininess: 100 } );
var mesh = new THREE.Mesh( poleGeo, poleMat );
mesh.position.x = -125; | false |
Other | mrdoob | three.js | 1b4c469ea3f66030f05fa81092fa3ad2e26f7fdb.json | Solve the spaces vs tabs indentation issues. | examples/js/renderers/SoftwareRenderer.js | @@ -38,10 +38,10 @@ THREE.SoftwareRenderer = function ( parameters ) {
var blockShift = 3; // Normally, it should be 3. At line mode, it has to be 0
var blockSize = 1 << blockShift;
var maxZVal = (1 << 24); // Note: You want to size this so you don't get overflows.
- var lineMode = false;
- var lookVector = new THREE.Vector3( 0, 0, 1 );
- var crossVector = new THREE.Vector3();
-
+ var lineMode = false;
+ var lookVector = new THREE.Vector3( 0, 0, 1 );
+ var crossVector = new THREE.Vector3();
+
var rectx1 = Infinity, recty1 = Infinity;
var rectx2 = 0, recty2 = 0;
@@ -75,7 +75,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
this.setSize = function ( width, height ) {
- setSize( width, height );
+ setSize( width, height );
};
this.setSize( canvas.width, canvas.height );
@@ -254,9 +254,9 @@ THREE.SoftwareRenderer = function ( parameters ) {
};
- function setSize( width, height ) {
+ function setSize( width, height ) {
- canvasWBlocks = Math.floor( width / blockSize );
+ canvasWBlocks = Math.floor( width / blockSize );
canvasHBlocks = Math.floor( height / blockSize );
canvasWidth = canvasWBlocks * blockSize;
canvasHeight = canvasHBlocks * blockSize;
@@ -299,7 +299,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
}
cleanColorBuffer();
- }
+ }
function cleanColorBuffer() {
@@ -475,9 +475,9 @@ THREE.SoftwareRenderer = function ( parameters ) {
if ( shaders[ id ] === undefined ) {
if ( material instanceof THREE.MeshBasicMaterial ||
- material instanceof THREE.MeshLambertMaterial ||
- material instanceof THREE.MeshPhongMaterial ||
- material instanceof THREE.SpriteMaterial ) {
+ material instanceof THREE.MeshLambertMaterial ||
+ material instanceof THREE.MeshPhongMaterial ||
+ material instanceof THREE.SpriteMaterial ) {
if ( material instanceof THREE.MeshLambertMaterial ) {
// Generate color palette
@@ -540,7 +540,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
} else if ( material instanceof THREE.LineBasicMaterial ) {
- var string = [
+ var string = [
'var colorOffset = offset * 4;',
'buffer[ colorOffset ] = material.color.r * (color1.r+color2.r) * 0.5 * 255;',
'buffer[ colorOffset + 1 ] = material.color.g * (color1.g+color2.g) * 0.5 * 255;',
@@ -551,7 +551,7 @@ THREE.SoftwareRenderer = function ( parameters ) {
shader = new Function( 'buffer, depthBuf, offset, depth, color1, color2, material', string );
- } else {
+ } else {
var string = [
'var colorOffset = offset * 4;',
@@ -1066,38 +1066,38 @@ THREE.SoftwareRenderer = function ( parameters ) {
}
- // When drawing line, the blockShiftShift has to be zero. In order to clean pixel
- // Using color1 and color2 to interpolation pixel color
- // LineWidth is according to material.linewidth
- function drawLine( v1, v2, color1, color2, shader, material ) {
+ // When drawing line, the blockShiftShift has to be zero. In order to clean pixel
+ // Using color1 and color2 to interpolation pixel color
+ // LineWidth is according to material.linewidth
+ function drawLine( v1, v2, color1, color2, shader, material ) {
- // While the line mode is enable, blockSize has to be changed to 0.
- if ( !lineMode ) {
- lineMode = true;
- blockShift = 0;
- blockSize = 1 << blockShift;
-
- setSize( canvas.width, canvas.height );
- }
+ // While the line mode is enable, blockSize has to be changed to 0.
+ if ( !lineMode ) {
+ lineMode = true;
+ blockShift = 0;
+ blockSize = 1 << blockShift;
- // TODO: Implement per-pixel z-clipping
+ setSize( canvas.width, canvas.height );
+ }
+
+ // TODO: Implement per-pixel z-clipping
if ( v1.z < -1 || v1.z > 1 || v2.z < -1 || v2.z > 1 ) return;
-
- var halfLineWidth = Math.floor( (material.linewidth-1) * 0.5 );
+
+ var halfLineWidth = Math.floor( (material.linewidth-1) * 0.5 );
- // https://gist.github.com/2486101
+ // https://gist.github.com/2486101
// explanation: http://pouet.net/topic.php?which=8760&page=1
// 28.4 fixed-point coordinates
var x1 = (v1.x * viewportXScale + viewportXOffs) | 0;
- var x2 = (v2.x * viewportXScale + viewportXOffs) | 0;
+ var x2 = (v2.x * viewportXScale + viewportXOffs) | 0;
var y1 = (v1.y * viewportYScale + viewportYOffs) | 0;
- var y2 = (v2.y * viewportYScale + viewportYOffs) | 0;
+ var y2 = (v2.y * viewportYScale + viewportYOffs) | 0;
var z1 = (v1.z * viewportZScale + viewportZOffs) | 0;
var z2 = (v2.z * viewportZScale + viewportZOffs) | 0;
-
+
// Deltas
var dx12 = x1 - x2, dy12 = y1 - y2, dz12 = z1 - z2;
@@ -1106,75 +1106,75 @@ THREE.SoftwareRenderer = function ( parameters ) {
var maxx = Math.min( ( Math.max( x1, x2 ) + subpixelBias ) >> subpixelBits, canvasWidth );
var miny = Math.max( ( Math.min( y1, y2 ) + subpixelBias ) >> subpixelBits, 0 );
var maxy = Math.min( ( Math.max( y1, y2 ) + subpixelBias ) >> subpixelBits, canvasHeight );
- var minz = Math.max( ( Math.min( z1, z2 ) + subpixelBias ) >> subpixelBits, 0 );
- var maxz = Math.min( ( Math.max( z1, z2 ) + subpixelBias ) >> subpixelBits, 0 );
-
+ var minz = Math.max( ( Math.min( z1, z2 ) + subpixelBias ) >> subpixelBits, 0 );
+ var maxz = Math.min( ( Math.max( z1, z2 ) + subpixelBias ) >> subpixelBits, 0 );
+
rectx1 = Math.min( minx, rectx1 );
rectx2 = Math.max( maxx, rectx2 );
recty1 = Math.min( miny, recty1 );
recty2 = Math.max( maxy, recty2 );
-
- // Get the line's unit vector and cross vector
- var length = Math.sqrt((dy12 * dy12) + (dx12 * dx12));
- var unitX = (dx12 / length);
- var unitY = (dy12 / length);
- var unitZ = (dz12 / length);
- var pixelX, pixelY, pixelZ;
- var pX, pY, pZ;
- crossVector.set( unitX, unitY, unitZ );
- crossVector.cross( lookVector );
- crossVector.normalize();
+
+ // Get the line's unit vector and cross vector
+ var length = Math.sqrt((dy12 * dy12) + (dx12 * dx12));
+ var unitX = (dx12 / length);
+ var unitY = (dy12 / length);
+ var unitZ = (dz12 / length);
+ var pixelX, pixelY, pixelZ;
+ var pX, pY, pZ;
+ crossVector.set( unitX, unitY, unitZ );
+ crossVector.cross( lookVector );
+ crossVector.normalize();
- while (length > 0) {
+ while (length > 0) {
- // Get this pixel.
- pixelX = (x2 + length * unitX);
- pixelY = (y2 + length * unitY);
- pixelZ = (z2 + length * unitZ);
+ // Get this pixel.
+ pixelX = (x2 + length * unitX);
+ pixelY = (y2 + length * unitY);
+ pixelZ = (z2 + length * unitZ);
- pixelX = (pixelX + subpixelBias) >> subpixelBits;
- pixelY = (pixelY + subpixelBias) >> subpixelBits;
- pZ = (pixelZ + subpixelBias) >> subpixelBits;
+ pixelX = (pixelX + subpixelBias) >> subpixelBits;
+ pixelY = (pixelY + subpixelBias) >> subpixelBits;
+ pZ = (pixelZ + subpixelBias) >> subpixelBits;
- // Draw line with line width
- for ( var i = -halfLineWidth; i <= halfLineWidth; ++i ) {
+ // Draw line with line width
+ for ( var i = -halfLineWidth; i <= halfLineWidth; ++i ) {
- // Compute the line pixels.
- // Get the pixels on the vector that crosses to the line vector
- pX = Math.floor((pixelX + crossVector.x * i));
- pY = Math.floor((pixelY + crossVector.y * i));
+ // Compute the line pixels.
+ // Get the pixels on the vector that crosses to the line vector
+ pX = Math.floor((pixelX + crossVector.x * i));
+ pY = Math.floor((pixelY + crossVector.y * i));
- // if pixel is over the rect. Continue
- if ( rectx1 >= pX || rectx2 <= pX || recty1 >= pY
- || recty2 <= pY )
- continue;
+ // if pixel is over the rect. Continue
+ if ( rectx1 >= pX || rectx2 <= pX || recty1 >= pY
+ || recty2 <= pY )
+ continue;
- // Find this pixel at which block
- var blockX = pX >> blockShift;
- var blockY = pY >> blockShift;
- var blockId = blockX + blockY * canvasWBlocks;
+ // Find this pixel at which block
+ var blockX = pX >> blockShift;
+ var blockY = pY >> blockShift;
+ var blockId = blockX + blockY * canvasWBlocks;
- // Compare the pixel depth width z block.
- if ( blockMaxZ[ blockId ] < minz ) continue;
+ // Compare the pixel depth width z block.
+ if ( blockMaxZ[ blockId ] < minz ) continue;
- blockMaxZ[ blockId ] = Math.min( blockMaxZ[ blockId ], maxz );
+ blockMaxZ[ blockId ] = Math.min( blockMaxZ[ blockId ], maxz );
- var bflags = blockFlags[ blockId ];
- if ( bflags & BLOCK_NEEDCLEAR ) clearBlock( blockX, blockY );
- blockFlags[ blockId ] = bflags & ~( BLOCK_ISCLEAR | BLOCK_NEEDCLEAR );
-
- // draw pixel
- var offset = pX + pY * canvasWidth;
-
- if ( pZ < zbuffer[ offset ] ) {
- shader( data, zbuffer, offset, pZ, color1, color2, material );
- }
- }
+ var bflags = blockFlags[ blockId ];
+ if ( bflags & BLOCK_NEEDCLEAR ) clearBlock( blockX, blockY );
+ blockFlags[ blockId ] = bflags & ~( BLOCK_ISCLEAR | BLOCK_NEEDCLEAR );
+
+ // draw pixel
+ var offset = pX + pY * canvasWidth;
+
+ if ( pZ < zbuffer[ offset ] ) {
+ shader( data, zbuffer, offset, pZ, color1, color2, material );
+ }
+ }
- --length;
- }
+ --length;
+ }
- }
+ }
function clearBlock( blockX, blockY ) {
| false |
Other | mrdoob | three.js | 83f774cd2bfc925e02c3d566031580de9f578c5f.json | Use Raycaster.setFromCamera() method
Convert two uses of raycaster to using setFromCamera(). One touches
TransformControls but should not affect #6795.
Also fix an error in webgl_interactive_draggablecubes.html when the
cursor is dragged outside of the backing "plane" (which is a large
planar mesh, not an infinite plane), returning no intersections. Now,
when the limit of the bounded plane is reached, the cubes just stop
following the cursor but no error is produced.
Fix tested with webgl_interactive_draggablecubes.html and the editor. | examples/js/controls/TransformControls.js | @@ -1086,9 +1086,7 @@
var y = ( pointer.clientY - rect.top ) / rect.height;
pointerVector.set( ( x * 2 ) - 1, - ( y * 2 ) + 1, 0.5 );
- pointerVector.unproject( camera );
-
- ray.set( camPosition, pointerVector.sub( camPosition ).normalize() );
+ ray.setFromCamera( pointerVector, camera );
var intersections = ray.intersectObjects( objects, true );
return intersections[0] ? intersections[0] : false; | true |
Other | mrdoob | three.js | 83f774cd2bfc925e02c3d566031580de9f578c5f.json | Use Raycaster.setFromCamera() method
Convert two uses of raycaster to using setFromCamera(). One touches
TransformControls but should not affect #6795.
Also fix an error in webgl_interactive_draggablecubes.html when the
cursor is dragged outside of the backing "plane" (which is a large
planar mesh, not an infinite plane), returning no intersections. Now,
when the limit of the bounded plane is reached, the cubes just stop
following the cursor but no error is produced.
Fix tested with webgl_interactive_draggablecubes.html and the editor. | examples/webgl_interactive_draggablecubes.html | @@ -162,7 +162,13 @@
if ( SELECTED ) {
var intersects = raycaster.intersectObject( plane );
- SELECTED.position.copy( intersects[ 0 ].point.sub( offset ) );
+
+ if ( intersects.length > 0 ) {
+
+ SELECTED.position.copy( intersects[ 0 ].point.sub( offset ) );
+
+ }
+
return;
}
@@ -201,9 +207,7 @@
event.preventDefault();
- var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 ).unproject( camera );
-
- var raycaster = new THREE.Raycaster( camera.position, vector.sub( camera.position ).normalize() );
+ raycaster.setFromCamera( mouse, camera );
var intersects = raycaster.intersectObjects( objects );
@@ -214,7 +218,12 @@
SELECTED = intersects[ 0 ].object;
var intersects = raycaster.intersectObject( plane );
- offset.copy( intersects[ 0 ].point ).sub( plane.position );
+
+ if ( intersects.length > 0 ) {
+
+ offset.copy( intersects[ 0 ].point ).sub( plane.position );
+
+ }
container.style.cursor = 'move';
| true |
Other | mrdoob | three.js | aaf6a26bc30e73987632115b4326b8c62e90ab62.json | Remove unnecessary copy | src/extras/geometries/WireframeGeometry.js | @@ -70,7 +70,7 @@ THREE.WireframeGeometry = function ( geometry ) {
var vertices = geometry.attributes.position;
var indices = geometry.attributes.index.array;
- var drawcalls = geometry.drawcalls.slice();
+ var drawcalls = geometry.drawcalls;
var numEdges = 0;
if ( drawcalls.length === 0 ) { | false |
Other | mrdoob | three.js | d0dff857167024492400423eb03991155fdecec6.json | Remove uses of .offsets
Store reading and writing to `.offsets`.
Avoid mutations to `.drawcalls` from outside the `BufferGeometry`. | examples/js/renderers/Projector.js | @@ -392,7 +392,7 @@ THREE.Projector = function () {
if ( geometry instanceof THREE.BufferGeometry ) {
var attributes = geometry.attributes;
- var offsets = geometry.offsets;
+ var offsets = geometry.drawcalls;
if ( attributes.position === undefined ) continue;
| true |
Other | mrdoob | three.js | d0dff857167024492400423eb03991155fdecec6.json | Remove uses of .offsets
Store reading and writing to `.offsets`.
Avoid mutations to `.drawcalls` from outside the `BufferGeometry`. | examples/js/wip/ProxyGeometry.js | @@ -744,7 +744,7 @@ THREE.ProxyGeometry.prototype.clone = function () {
var buff = THREE.BufferGeometry.prototype.clone.call(this);
var geo = new THREE.ProxyGeometry();
geo.attributes = buff.attributes;
- geo.offsets = buff.offsets;
+ geo.offsets = buff.drawcalls;
return geo;
| true |
Other | mrdoob | three.js | d0dff857167024492400423eb03991155fdecec6.json | Remove uses of .offsets
Store reading and writing to `.offsets`.
Avoid mutations to `.drawcalls` from outside the `BufferGeometry`. | examples/webgl_buffergeometry.html | @@ -200,9 +200,9 @@
geometry.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
geometry.addAttribute( 'color', new THREE.BufferAttribute( colors, 3 ) );
- var offsets = triangles / chunkSize;
+ var num_offsets = triangles / chunkSize;
- for ( var i = 0; i < offsets; i ++ ) {
+ for ( var i = 0; i < num_offsets; i ++ ) {
var indexStart = i * chunkSize * 3;
var indexCount = Math.min( triangles - ( i * chunkSize ), chunkSize ) * 3; | true |
Other | mrdoob | three.js | d0dff857167024492400423eb03991155fdecec6.json | Remove uses of .offsets
Store reading and writing to `.offsets`.
Avoid mutations to `.drawcalls` from outside the `BufferGeometry`. | src/core/BufferGeometry.js | @@ -110,7 +110,7 @@ THREE.BufferGeometry.prototype = {
// TODO Clear attributes? Clear drawcalls? Copy morphTargets?
var attributes = geometry.attributes;
- var offsets = geometry.offsets;
+ var offsets = geometry.drawcalls;
for ( var name in attributes ) {
@@ -1064,7 +1064,7 @@ THREE.BufferGeometry.prototype = {
data.data = { attributes: {} };
var attributes = this.attributes;
- var offsets = this.offsets;
+ var offsets = this.drawcalls;
var boundingSphere = this.boundingSphere;
for ( var key in attributes ) {
@@ -1111,9 +1111,9 @@ THREE.BufferGeometry.prototype = {
}
- for ( var i = 0, il = this.offsets.length; i < il; i ++ ) {
+ for ( var i = 0, il = this.drawcalls.length; i < il; i ++ ) {
- var offset = this.offsets[ i ];
+ var offset = this.drawcalls[ i ];
geometry.addDrawCall( offset.start, offset.count, offset.index );
| true |
Other | mrdoob | three.js | d0dff857167024492400423eb03991155fdecec6.json | Remove uses of .offsets
Store reading and writing to `.offsets`.
Avoid mutations to `.drawcalls` from outside the `BufferGeometry`. | src/loaders/BufferGeometryLoader.js | @@ -51,7 +51,18 @@ THREE.BufferGeometryLoader.prototype = {
if ( offsets !== undefined ) {
- geometry.offsets = JSON.parse( JSON.stringify( offsets ) );
+ var offsetsArray = JSON.parse( JSON.stringify( offsets ) );
+
+ for ( var i = 0; i < offsetsArray.length; i ++ ) {
+
+ var offset = offsetsArray[i];
+ var indexStart = offset.start;
+ var indexCount = offset.count;
+ var indexOffset = offset.index;
+
+ geometry.addAttribute( indexStart, indexCount, indexOffset );
+
+ }
}
| true |
Other | mrdoob | three.js | d0dff857167024492400423eb03991155fdecec6.json | Remove uses of .offsets
Store reading and writing to `.offsets`.
Avoid mutations to `.drawcalls` from outside the `BufferGeometry`. | src/objects/Line.js | @@ -65,7 +65,7 @@ THREE.Line.prototype.raycast = ( function () {
var indices = attributes.index.array;
var positions = attributes.position.array;
- var offsets = geometry.offsets;
+ var offsets = geometry.drawcalls.slice();
if ( offsets.length === 0 ) {
| true |
Other | mrdoob | three.js | d0dff857167024492400423eb03991155fdecec6.json | Remove uses of .offsets
Store reading and writing to `.offsets`.
Avoid mutations to `.drawcalls` from outside the `BufferGeometry`. | src/objects/Mesh.js | @@ -111,7 +111,7 @@ THREE.Mesh.prototype.raycast = ( function () {
var indices = attributes.index.array;
var positions = attributes.position.array;
- var offsets = geometry.offsets;
+ var offsets = geometry.drawcalls.slice();
if ( offsets.length === 0 ) {
| true |
Other | mrdoob | three.js | d0dff857167024492400423eb03991155fdecec6.json | Remove uses of .offsets
Store reading and writing to `.offsets`.
Avoid mutations to `.drawcalls` from outside the `BufferGeometry`. | src/objects/PointCloud.js | @@ -81,13 +81,13 @@ THREE.PointCloud.prototype.raycast = ( function () {
var indices = attributes.index.array;
- if ( geometry.offsets.length === 0 ) {
+ if ( geometry.drawcalls.length === 0 ) {
offsets.addDrawCall( 0, indices.length, 0 );
}
- var offsets = geometry.offsets;
+ var offsets = geometry.drawcalls;
for ( var oi = 0, ol = offsets.length; oi < ol; ++ oi ) {
| true |
Other | mrdoob | three.js | d0dff857167024492400423eb03991155fdecec6.json | Remove uses of .offsets
Store reading and writing to `.offsets`.
Avoid mutations to `.drawcalls` from outside the `BufferGeometry`. | src/renderers/WebGLRenderer.js | @@ -1072,7 +1072,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
- var offsets = geometry.offsets;
+ var offsets = geometry.drawcalls;
if ( offsets.length === 0 ) {
@@ -1157,7 +1157,7 @@ THREE.WebGLRenderer = function ( parameters ) {
// non-indexed triangles
- var offsets = geometry.offsets;
+ var offsets = geometry.drawcalls;
if ( offsets.length === 0 ) {
@@ -1278,7 +1278,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
- var offsets = geometry.offsets;
+ var offsets = geometry.drawcalls;
if ( offsets.length === 0 ) {
@@ -1335,7 +1335,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
var position = geometry.attributes.position;
- var offsets = geometry.offsets;
+ var offsets = geometry.drawcalls;
if ( offsets.length === 0 ) {
@@ -1387,7 +1387,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
- var offsets = geometry.offsets;
+ var offsets = geometry.drawcalls;
if ( offsets.length === 0 ) {
@@ -1444,7 +1444,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
var position = geometry.attributes.position;
- var offsets = geometry.offsets;
+ var offsets = geometry.drawcalls;
if ( offsets.length === 0 ) {
| true |
Other | mrdoob | three.js | 1753badadedeea82ef33200a565e6c62f833a373.json | Add count to InterleavedBuffer | src/core/InterleavedBuffer.js | @@ -26,6 +26,12 @@ THREE.InterleavedBuffer.prototype = {
},
+ get count () {
+
+ return this.array.length / this.stride;
+
+ },
+
copyAt: function ( index1, attribute, index2 ) {
index1 *= this.stride; | true |
Other | mrdoob | three.js | 1753badadedeea82ef33200a565e6c62f833a373.json | Add count to InterleavedBuffer | src/core/InterleavedBufferAttribute.js | @@ -19,8 +19,8 @@ THREE.InterleavedBufferAttribute.prototype = {
get length() {
- console.warn( 'THREE.InterleavedBufferAttribute: .length has been renamed to .count.' );
- return this.count;
+ console.warn( 'THREE.BufferAttribute: .length has been deprecated. Please use .count.' );
+ return this.array.length;
},
| true |
Other | mrdoob | three.js | 1753badadedeea82ef33200a565e6c62f833a373.json | Add count to InterleavedBuffer | src/renderers/WebGLRenderer.js | @@ -929,7 +929,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( geometry.maxInstancedCount === undefined ) {
- geometry.maxInstancedCount = data.meshPerAttribute * ( data.array.length / data.stride );
+ geometry.maxInstancedCount = data.meshPerAttribute * data.count;
}
@@ -953,7 +953,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( geometry.maxInstancedCount === undefined ) {
- geometry.maxInstancedCount = geometryAttribute.meshPerAttribute * ( geometryAttribute.array.length / geometryAttribute.itemSize );
+ geometry.maxInstancedCount = geometryAttribute.meshPerAttribute * geometryAttribute.count;
}
@@ -1184,31 +1184,31 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( position instanceof THREE.InterleavedBufferAttribute ) {
- extension.drawArraysInstancedANGLE( mode, 0, position.data.array.length / position.data.stride, geometry.maxInstancedCount ); // Draw the instanced meshes
+ extension.drawArraysInstancedANGLE( mode, 0, position.data.count, geometry.maxInstancedCount ); // Draw the instanced meshes
} else {
- extension.drawArraysInstancedANGLE( mode, 0, position.array.length / position.itemSize, geometry.maxInstancedCount ); // Draw the instanced meshes
+ extension.drawArraysInstancedANGLE( mode, 0, position.count, geometry.maxInstancedCount ); // Draw the instanced meshes
}
} else {
if ( position instanceof THREE.InterleavedBufferAttribute ) {
- _gl.drawArrays( mode, 0, position.data.array.length / position.data.stride );
+ _gl.drawArrays( mode, 0, position.data.count );
} else {
- _gl.drawArrays( mode, 0, position.array.length / position.itemSize );
+ _gl.drawArrays( mode, 0, position.count );
}
}
_this.info.render.calls++;
- _this.info.render.vertices += position.array.length / position.itemSize;
- _this.info.render.faces += position.array.length / ( 3 * position.itemSize );
+ _this.info.render.vertices += position.count;
+ _this.info.render.faces += position.count / 3;
} else {
| true |
Other | mrdoob | three.js | 85117608653fa3fd65544b6842f789727a4925e4.json | Update license attribute
There are a few new license changes in newer versions of npm.
https://docs.npmjs.com/files/package.json#license
http://npm1k.org/ | utils/npm/three.package.json | @@ -33,10 +33,7 @@
"url" : "git://github.com/mrdoob/three.js.git"
},
- "license" : {
- "type" : "The MIT License",
- "url" : "https://raw.github.com/mrdoob/three.js/master/LICENSE"
- },
+ "license" : "MIT",
"engines" : {
"node" : "*" | false |
Other | mrdoob | three.js | b439904eb935bc4938c3c7d3825d3848f3230ec5.json | add geometry normalization | docs/api/core/Geometry.html | @@ -185,6 +185,11 @@ <h3>[method:null applyMatrix]( [page:Matrix4 matrix] )</h3>
Bakes matrix transform directly into vertex coordinates.
</div>
+ <h3>[method:null center]()</h3>
+ <div>
+ Center the geometry based on the bounding box.
+ </div>
+
<h3>[method:null computeFaceNormals]()</h3>
<div>
Computes face normals.
@@ -228,6 +233,12 @@ <h3>[method:null mergeVertices]()</h3>
Checks for duplicate vertices using hashmap.<br />
Duplicated vertices are removed and faces' vertices are updated.
</div>
+
+ <h3>[method:null normalize]()</h3>
+ <div>
+ Normalize the geometry. <br />
+ Make the geometry centered and has a bounding sphere whose raidus equals to 1.0.
+ </div>
<h3>[method:Geometry clone]()</h3>
<div> | true |
Other | mrdoob | three.js | b439904eb935bc4938c3c7d3825d3848f3230ec5.json | add geometry normalization | src/core/Geometry.js | @@ -224,6 +224,23 @@ THREE.Geometry.prototype = {
},
+ normalize: function() {
+ var COM = this.boundingSphere.center;
+ var R = this.boundingSphere.radius;
+
+ var s = (R === 0 ? 1 : 1.0 / R);
+
+ var m = new THREE.Matrix4().set(
+ s, 0, 0, -s*COM.x,
+ 0, s, 0, -s*COM.y,
+ 0, 0, s, -s*COM.z,
+ 0, 0, 0, 1);
+
+ this.applyMatrix(m);
+
+ return this;
+ },
+
computeFaceNormals: function () {
var cb = new THREE.Vector3(), ab = new THREE.Vector3(); | true |
Other | mrdoob | three.js | 8b201481846a936986c3d0cc3de3d087b90e6c0e.json | Avoid exception from "new ShaderMaterial()". | src/materials/ShaderMaterial.js | @@ -38,13 +38,6 @@ THREE.ShaderMaterial = function ( parameters ) {
this.uniforms = {};
this.attributes = [];
- if ( parameters.attributes !== undefined && Array.isArray( parameters.attributes ) === false ) {
-
- console.warn( 'THREE.ShaderMaterial: attributes should now be an array of attribute names.' );
- parameters.attributes = Object.keys( parameters.attributes );
-
- }
-
this.vertexShader = 'void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}';
this.fragmentShader = 'void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}';
@@ -78,7 +71,18 @@ THREE.ShaderMaterial = function ( parameters ) {
this.index0AttributeName = undefined;
- this.setValues( parameters );
+ if ( parameters !== undefined ) {
+
+ if ( parameters.attributes !== undefined && Array.isArray( parameters.attributes ) === false ) {
+
+ console.warn( 'THREE.ShaderMaterial: attributes should now be an array of attribute names.' );
+ parameters.attributes = Object.keys( parameters.attributes );
+
+ }
+
+ this.setValues( parameters );
+
+ }
};
| false |
Other | mrdoob | three.js | 146cd3dfecd13f9eb5063da9e9ee8433470d1402.json | Add doctype and meta charset to example HTML | docs/manual/introduction/Creating-a-scene.html | @@ -21,8 +21,10 @@ <h2>Before we start</h2>
<div>Before you can use Three.js, you need somewhere to display it. Save the following HTML to a file on your computer, along with a copy of <a href="http://threejs.org/build/three.min.js">three.min.js</a> in the js/ directory, and open it in your browser.</div>
<code>
+ <!DOCTYPE html>
<html>
<head>
+ <meta charset=utf-8>
<title>My first Three.js app</title>
<style>
body { margin: 0; } | false |
Other | mrdoob | three.js | 0833ca528ecdcd1889bb2e6cb384faa3c32370b5.json | Fix inverted rows and realign destination labels
Fix rows on the blend table being incorrectly inverted on webgl_materials_blending_custom.html example
You can verify the rows are currently inverted by hardcoding blendSrc and blendDist
(insert these lines at line 231):
material.blendSrc = THREE["ZeroFactor"];
material.blendDst = THREE[ "SrcColorFactor" ];
and compare the result against what the table says this should look like. | examples/webgl_materials_blending_custom.html | @@ -233,7 +233,7 @@
var y = ( i - dst.length / 2 ) * 110 + 50;
var mesh = new THREE.Mesh( geo1, material );
- mesh.position.set( x, y, z );
+ mesh.position.set( x, -y, z );
mesh.matrixAutoUpdate = false;
mesh.updateMatrix();
scene.add( mesh );
@@ -269,7 +269,7 @@
var y = ( i - dst.length / 2 ) * 110 + 165;
var mesh = new THREE.Mesh( geo2, generateLabelMaterial( blendDst.replace( "Factor", "" ), "rgba( 150, 0, 0, 1 )" ) );
- mesh.position.set( x, - (y - 70), z );
+ mesh.position.set( x, - (y - 120), z );
mesh.matrixAutoUpdate = false;
mesh.updateMatrix();
scene.add( mesh ); | false |
Other | mrdoob | three.js | 53c10bf7e570a8914e4ac49ced614f8bdb1405a5.json | Use keydown instead of keypress for keyboard event | examples/webgl_loader_gltf.html | @@ -132,7 +132,7 @@
function onload() {
window.addEventListener( 'resize', onWindowResize, false );
- document.addEventListener( 'keypress', function(e) { onKeyPress(e); }, false );
+ document.addEventListener( 'keydown', function(e) { onKeyDown(e); }, false );
buildSceneList();
switchScene(0);
@@ -343,7 +343,7 @@
renderer.render( scene, camera );
}
- function onKeyPress(event) {
+ function onKeyDown(event) {
var chr = String.fromCharCode(event.keyCode);
| false |
Other | mrdoob | three.js | a48902f7464ef96b6afe4d07bbcb82d462906805.json | Use keydown instead of keypress for keyboard event | examples/webgl_geometry_colors_lookuptable.html | @@ -112,7 +112,7 @@
window.addEventListener( 'resize', onWindowResize, false );
- window.addEventListener( "keypress", onKeyPress, true);
+ window.addEventListener( "keydown", onKeyDown, true);
}
@@ -272,7 +272,7 @@
}
- function onKeyPress ( e ) {
+ function onKeyDown ( e ) {
var maps = [ 'rainbow', 'cooltowarm', 'blackbody', 'grayscale' ];
| false |
Other | mrdoob | three.js | dd74de1edfd027eb413cf01b8b5422567489a688.json | Remove console log from PlaneGeometry
Doesn't seem like we need a console log every time PlaneGeometry is used. Is PlaneGeometry really that bad? | src/extras/geometries/PlaneGeometry.js | @@ -5,8 +5,6 @@
THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments ) {
- console.log( 'THREE.PlaneGeometry: Consider using THREE.PlaneBufferGeometry for lower memory footprint.' );
-
THREE.Geometry.call( this );
this.type = 'PlaneGeometry'; | false |
Other | mrdoob | three.js | 96a5ed509753f9a02e3fae8480a0969f2c667fbe.json | Fix info div blocks config menu. | examples/webgl_postprocessing_ssao.html | @@ -28,12 +28,12 @@
#info {
color:#fff;
- position: absolute;
+ position: relative;
top: 0px;
- width: 100%;
+ width: 40em;
+ margin: 0 auto -1.86em;
padding: 5px;
z-index:100;
- text-align: center;
}
</style>
</head> | false |
Other | mrdoob | three.js | cd5e9888d54e82aea98752601879ba931b77290b.json | Fix EffectComposer memory problem | examples/js/postprocessing/EffectComposer.js | @@ -117,7 +117,9 @@ THREE.EffectComposer.prototype = {
}
+ this.renderTarget1.dispose();
this.renderTarget1 = renderTarget;
+ this.renderTarget2.dispose();
this.renderTarget2 = renderTarget.clone();
this.writeBuffer = this.renderTarget1;
@@ -127,12 +129,8 @@ THREE.EffectComposer.prototype = {
setSize: function ( width, height ) {
- var renderTarget = this.renderTarget1.clone();
-
- renderTarget.width = width;
- renderTarget.height = height;
-
- this.reset( renderTarget );
+ this.renderTarget1.setSize( width, height );
+ this.renderTarget2.setSize( width, height );
}
| true |
Other | mrdoob | three.js | cd5e9888d54e82aea98752601879ba931b77290b.json | Fix EffectComposer memory problem | src/renderers/WebGLRenderer.js | @@ -697,7 +697,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
- properties.delete( renderTargetProperties );
+ properties.delete( renderTarget );
}
| true |
Other | mrdoob | three.js | 5456e02a145105374f1fc6365b1f462e407d0301.json | Remove wip / TypedGeometry
Minecraft demo modified to use a mix of Geometry and BufferGeometry. See
#6803. | examples/js/wip/CircleTypedGeometry.js | @@ -1,76 +0,0 @@
-/**
- * @author hughes
- * @author mrdoob / http://mrdoob.com/
- */
-
-THREE.CircleTypedGeometry = function ( radius, segments, thetaStart, thetaLength ) {
-
- this.parameters = {
- radius: radius,
- segments: segments,
- thetaStart: thetaStart,
- thetaLength: thetaLength
- };
-
- radius = radius || 50;
- segments = segments !== undefined ? Math.max( 3, segments ) : 8;
-
- thetaStart = thetaStart !== undefined ? thetaStart : 0;
- thetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;
-
- //
-
- var elements = segments + 2;
-
- var indices = new Uint16Array( segments * 3 );
- var vertices = new Float32Array( elements * 3 );
- var normals = new Float32Array( elements * 3 );
- var uvs = new Float32Array( elements * 2 );
-
- // center
-
- normals[ 2 ] = 1;
-
- uvs[ 0 ] = 0.5;
- uvs[ 1 ] = 0.5;
-
- var offset = 0, offset2 = 2, offset3 = 3;
-
- for ( var i = 0; i <= segments; i ++ ) {
-
- var segment = thetaStart + i / segments * thetaLength;
-
- var x = radius * Math.cos( segment );
- var y = radius * Math.sin( segment );
-
- vertices[ offset3 ] = x;
- vertices[ offset3 + 1 ] = y;
-
- normals[ offset3 + 2 ] = 1;
-
- uvs[ offset2 ] = ( x / radius + 1 ) / 2;
- uvs[ offset2 + 1 ] = ( y / radius + 1 ) / 2;
-
- offset2 += 2;
- offset3 += 3;
-
- //
-
- indices[ offset ] = 0;
- indices[ offset + 1 ] = i + 1;
- indices[ offset + 2 ] = i + 2;
-
- offset += 3;
-
- }
-
- THREE.IndexedTypedGeometry.call( this );
-
- this.setArrays( indices, vertices, normals, uvs );
-
- this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );
-
-};
-
-THREE.CircleTypedGeometry.prototype = Object.create( THREE.IndexedTypedGeometry.prototype );
-THREE.CircleTypedGeometry.prototype.constructor = THREE.CircleTypedGeometry; | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.