123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- /**
- * @author Mark Kellogg - http://www.github.com/mkkellogg
- */
- THREE.Particles = THREE.Particles || {};
- THREE.Particles.RangeType = Object.freeze( {
- Cube: 1,
- Sphere: 2,
- Plane: 3
- } );
- THREE.Particles.Constants = Object.freeze( {
- VerticesPerParticle: 6,
- DegreesToRadians: Math.PI / 180.0
- } );
- THREE.Particles.Random = THREE.Particles.Random || {};
- THREE.Particles.Random.getRandomVectorCube = function( vector, offset, range, edgeClamp ) {
- var x = Math.random() - 0.5;
- var y = Math.random() - 0.5;
- var z = Math.random() - 0.5;
- var w = Math.random() - 0.5;
- vector.set( x, y, z, w );
- if ( edgeClamp ) {
- var max = Math.max ( Math.abs( vector.x ), Math.max ( Math.abs( vector.y ), Math.abs( vector.z ) ) );
- vector.multiplyScalar( 1.0 / max );
- }
- vector.multiplyVectors( range, vector );
- vector.addVectors( offset, vector );
- }
- THREE.Particles.Random.getRandomVectorSphere = function( vector, offset, range, edgeClamp ) {
- var x = Math.random() - 0.5;
- var y = Math.random() - 0.5;
- var z = Math.random() - 0.5;
- var w = Math.random() - 0.5;
- vector.set( x, y, z, w );
- vector.normalize();
- vector.multiplyVectors( vector, range );
- if ( ! edgeClamp ) {
- var adjust = Math.random() * 2.0 - 1.0;
- vector.multiplyScalar( adjust );
- }
- vector.addVectors( vector, offset );
- }
- THREE.Particles.SingularVector = function( x ) {
- this.x = x;
- }
- THREE.Particles.SingularVector.prototype.copy = function( dest ) {
- this.x = dest.x;
- }
- THREE.Particles.SingularVector.prototype.set = function( x ) {
- this.x = x;
- }
- THREE.Particles.SingularVector.prototype.normalize = function() {
- //return this;
- }
- THREE.Particles.SingularVector.prototype.multiplyScalar = function( x ) {
- this.x *= x;
- }
- THREE.Particles.SingularVector.prototype.lerp = function( dest, f ) {
- this.x = this.x + f * ( dest.x - this.x );
- }
- THREE.Particles.SingularVector.prototype.addVectors = function( vector, offset ) {
- vector.x += offset;
- }
- THREE.Particles.SingularVector.prototype.multiplyVectors = function( vector, rangeVector ) {
- vector.x *= rangeVector.x;
- }
|