···156156 return new Vector( this );
157157};
158158159159+function round( num ) {
160160+ return Math.round( num * 1000 ) / 1000;
161161+}
162162+163163+Vector.prototype.toJSON = function() {
164164+ var x = this.x;
165165+ var y = this.y;
166166+ var z = this.z;
167167+168168+ if ( x === y && y === z ) {
169169+ return x !== 0 ? round( x ) : undefined;
170170+ }
171171+172172+ var obj = { x: x, y: y, z: z };
173173+ var result = {};
174174+175175+ Object.keys( obj ).forEach( function( key ) {
176176+ var value = obj[ key ];
177177+ if ( value !== 0 ) {
178178+ result[ key ] = round( value );
179179+ }
180180+ });
181181+182182+ return Object.keys( result ).length ? result : undefined;
183183+};
184184+159185return Vector;
160186161187} ) );