UNPKG

ami.js

Version:

<p align="center"> <img src="https://cloud.githubusercontent.com/assets/214063/23213764/78ade038-f90c-11e6-8208-4fcade5f3832.png" width="60%"> </p>

2,195 lines (1,504 loc) 2.75 MB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define("AMI", [], factory); else if(typeof exports === 'object') exports["AMI"] = factory(); else root["AMI"] = factory(); })(this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 83); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* unused harmony export WebGLRenderTargetCube */ /* unused harmony export WebGLRenderTarget */ /* unused harmony export WebGLRenderer */ /* unused harmony export ShaderLib */ /* unused harmony export UniformsLib */ /* unused harmony export UniformsUtils */ /* unused harmony export ShaderChunk */ /* unused harmony export FogExp2 */ /* unused harmony export Fog */ /* unused harmony export Scene */ /* unused harmony export LensFlare */ /* unused harmony export Sprite */ /* unused harmony export LOD */ /* unused harmony export SkinnedMesh */ /* unused harmony export Skeleton */ /* unused harmony export Bone */ /* unused harmony export Mesh */ /* unused harmony export LineSegments */ /* unused harmony export LineLoop */ /* unused harmony export Line */ /* unused harmony export Points */ /* unused harmony export Group */ /* unused harmony export VideoTexture */ /* unused harmony export DataTexture */ /* unused harmony export CompressedTexture */ /* unused harmony export CubeTexture */ /* unused harmony export CanvasTexture */ /* unused harmony export DepthTexture */ /* unused harmony export Texture */ /* unused harmony export CompressedTextureLoader */ /* unused harmony export DataTextureLoader */ /* unused harmony export CubeTextureLoader */ /* unused harmony export TextureLoader */ /* unused harmony export ObjectLoader */ /* unused harmony export MaterialLoader */ /* unused harmony export BufferGeometryLoader */ /* unused harmony export DefaultLoadingManager */ /* unused harmony export LoadingManager */ /* unused harmony export JSONLoader */ /* unused harmony export ImageLoader */ /* unused harmony export FontLoader */ /* unused harmony export FileLoader */ /* unused harmony export Loader */ /* unused harmony export Cache */ /* unused harmony export AudioLoader */ /* unused harmony export SpotLightShadow */ /* unused harmony export SpotLight */ /* unused harmony export PointLight */ /* unused harmony export RectAreaLight */ /* unused harmony export HemisphereLight */ /* unused harmony export DirectionalLightShadow */ /* unused harmony export DirectionalLight */ /* unused harmony export AmbientLight */ /* unused harmony export LightShadow */ /* unused harmony export Light */ /* unused harmony export StereoCamera */ /* unused harmony export PerspectiveCamera */ /* unused harmony export OrthographicCamera */ /* unused harmony export CubeCamera */ /* unused harmony export ArrayCamera */ /* unused harmony export Camera */ /* unused harmony export AudioListener */ /* unused harmony export PositionalAudio */ /* unused harmony export AudioContext */ /* unused harmony export AudioAnalyser */ /* unused harmony export Audio */ /* unused harmony export VectorKeyframeTrack */ /* unused harmony export StringKeyframeTrack */ /* unused harmony export QuaternionKeyframeTrack */ /* unused harmony export NumberKeyframeTrack */ /* unused harmony export ColorKeyframeTrack */ /* unused harmony export BooleanKeyframeTrack */ /* unused harmony export PropertyMixer */ /* unused harmony export PropertyBinding */ /* unused harmony export KeyframeTrack */ /* unused harmony export AnimationUtils */ /* unused harmony export AnimationObjectGroup */ /* unused harmony export AnimationMixer */ /* unused harmony export AnimationClip */ /* unused harmony export Uniform */ /* unused harmony export InstancedBufferGeometry */ /* unused harmony export BufferGeometry */ /* unused harmony export GeometryIdCount */ /* unused harmony export Geometry */ /* unused harmony export InterleavedBufferAttribute */ /* unused harmony export InstancedInterleavedBuffer */ /* unused harmony export InterleavedBuffer */ /* unused harmony export InstancedBufferAttribute */ /* unused harmony export Face3 */ /* unused harmony export Object3D */ /* unused harmony export Raycaster */ /* unused harmony export Layers */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return EventDispatcher; }); /* unused harmony export Clock */ /* unused harmony export QuaternionLinearInterpolant */ /* unused harmony export LinearInterpolant */ /* unused harmony export DiscreteInterpolant */ /* unused harmony export CubicInterpolant */ /* unused harmony export Interpolant */ /* unused harmony export Triangle */ /* unused harmony export Math */ /* unused harmony export Spherical */ /* unused harmony export Cylindrical */ /* unused harmony export Plane */ /* unused harmony export Frustum */ /* unused harmony export Sphere */ /* unused harmony export Ray */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return Matrix4; }); /* unused harmony export Matrix3 */ /* unused harmony export Box3 */ /* unused harmony export Box2 */ /* unused harmony export Line3 */ /* unused harmony export Euler */ /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return Vector4; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return Vector3; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return Vector2; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return Quaternion; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Color; }); /* unused harmony export ImmediateRenderObject */ /* unused harmony export VertexNormalsHelper */ /* unused harmony export SpotLightHelper */ /* unused harmony export SkeletonHelper */ /* unused harmony export PointLightHelper */ /* unused harmony export RectAreaLightHelper */ /* unused harmony export HemisphereLightHelper */ /* unused harmony export GridHelper */ /* unused harmony export PolarGridHelper */ /* unused harmony export FaceNormalsHelper */ /* unused harmony export DirectionalLightHelper */ /* unused harmony export CameraHelper */ /* unused harmony export BoxHelper */ /* unused harmony export Box3Helper */ /* unused harmony export PlaneHelper */ /* unused harmony export ArrowHelper */ /* unused harmony export AxisHelper */ /* unused harmony export CatmullRomCurve3 */ /* unused harmony export CubicBezierCurve3 */ /* unused harmony export QuadraticBezierCurve3 */ /* unused harmony export LineCurve3 */ /* unused harmony export ArcCurve */ /* unused harmony export EllipseCurve */ /* unused harmony export SplineCurve */ /* unused harmony export CubicBezierCurve */ /* unused harmony export QuadraticBezierCurve */ /* unused harmony export LineCurve */ /* unused harmony export Shape */ /* unused harmony export Path */ /* unused harmony export ShapePath */ /* unused harmony export Font */ /* unused harmony export CurvePath */ /* unused harmony export Curve */ /* unused harmony export ShapeUtils */ /* unused harmony export SceneUtils */ /* unused harmony export WebGLUtils */ /* unused harmony export WireframeGeometry */ /* unused harmony export ParametricGeometry */ /* unused harmony export ParametricBufferGeometry */ /* unused harmony export TetrahedronGeometry */ /* unused harmony export TetrahedronBufferGeometry */ /* unused harmony export OctahedronGeometry */ /* unused harmony export OctahedronBufferGeometry */ /* unused harmony export IcosahedronGeometry */ /* unused harmony export IcosahedronBufferGeometry */ /* unused harmony export DodecahedronGeometry */ /* unused harmony export DodecahedronBufferGeometry */ /* unused harmony export PolyhedronGeometry */ /* unused harmony export PolyhedronBufferGeometry */ /* unused harmony export TubeGeometry */ /* unused harmony export TubeBufferGeometry */ /* unused harmony export TorusKnotGeometry */ /* unused harmony export TorusKnotBufferGeometry */ /* unused harmony export TorusGeometry */ /* unused harmony export TorusBufferGeometry */ /* unused harmony export TextGeometry */ /* unused harmony export TextBufferGeometry */ /* unused harmony export SphereGeometry */ /* unused harmony export SphereBufferGeometry */ /* unused harmony export RingGeometry */ /* unused harmony export RingBufferGeometry */ /* unused harmony export PlaneGeometry */ /* unused harmony export PlaneBufferGeometry */ /* unused harmony export LatheGeometry */ /* unused harmony export LatheBufferGeometry */ /* unused harmony export ShapeGeometry */ /* unused harmony export ShapeBufferGeometry */ /* unused harmony export ExtrudeGeometry */ /* unused harmony export ExtrudeBufferGeometry */ /* unused harmony export EdgesGeometry */ /* unused harmony export ConeGeometry */ /* unused harmony export ConeBufferGeometry */ /* unused harmony export CylinderGeometry */ /* unused harmony export CylinderBufferGeometry */ /* unused harmony export CircleGeometry */ /* unused harmony export CircleBufferGeometry */ /* unused harmony export BoxGeometry */ /* unused harmony export BoxBufferGeometry */ /* unused harmony export ShadowMaterial */ /* unused harmony export SpriteMaterial */ /* unused harmony export RawShaderMaterial */ /* unused harmony export ShaderMaterial */ /* unused harmony export PointsMaterial */ /* unused harmony export MeshPhysicalMaterial */ /* unused harmony export MeshStandardMaterial */ /* unused harmony export MeshPhongMaterial */ /* unused harmony export MeshToonMaterial */ /* unused harmony export MeshNormalMaterial */ /* unused harmony export MeshLambertMaterial */ /* unused harmony export MeshDepthMaterial */ /* unused harmony export MeshDistanceMaterial */ /* unused harmony export MeshBasicMaterial */ /* unused harmony export LineDashedMaterial */ /* unused harmony export LineBasicMaterial */ /* unused harmony export Material */ /* unused harmony export Float64BufferAttribute */ /* unused harmony export Float32BufferAttribute */ /* unused harmony export Uint32BufferAttribute */ /* unused harmony export Int32BufferAttribute */ /* unused harmony export Uint16BufferAttribute */ /* unused harmony export Int16BufferAttribute */ /* unused harmony export Uint8ClampedBufferAttribute */ /* unused harmony export Uint8BufferAttribute */ /* unused harmony export Int8BufferAttribute */ /* unused harmony export BufferAttribute */ /* unused harmony export REVISION */ /* unused harmony export MOUSE */ /* unused harmony export CullFaceNone */ /* unused harmony export CullFaceBack */ /* unused harmony export CullFaceFront */ /* unused harmony export CullFaceFrontBack */ /* unused harmony export FrontFaceDirectionCW */ /* unused harmony export FrontFaceDirectionCCW */ /* unused harmony export BasicShadowMap */ /* unused harmony export PCFShadowMap */ /* unused harmony export PCFSoftShadowMap */ /* unused harmony export FrontSide */ /* unused harmony export BackSide */ /* unused harmony export DoubleSide */ /* unused harmony export FlatShading */ /* unused harmony export SmoothShading */ /* unused harmony export NoColors */ /* unused harmony export FaceColors */ /* unused harmony export VertexColors */ /* unused harmony export NoBlending */ /* unused harmony export NormalBlending */ /* unused harmony export AdditiveBlending */ /* unused harmony export SubtractiveBlending */ /* unused harmony export MultiplyBlending */ /* unused harmony export CustomBlending */ /* unused harmony export AddEquation */ /* unused harmony export SubtractEquation */ /* unused harmony export ReverseSubtractEquation */ /* unused harmony export MinEquation */ /* unused harmony export MaxEquation */ /* unused harmony export ZeroFactor */ /* unused harmony export OneFactor */ /* unused harmony export SrcColorFactor */ /* unused harmony export OneMinusSrcColorFactor */ /* unused harmony export SrcAlphaFactor */ /* unused harmony export OneMinusSrcAlphaFactor */ /* unused harmony export DstAlphaFactor */ /* unused harmony export OneMinusDstAlphaFactor */ /* unused harmony export DstColorFactor */ /* unused harmony export OneMinusDstColorFactor */ /* unused harmony export SrcAlphaSaturateFactor */ /* unused harmony export NeverDepth */ /* unused harmony export AlwaysDepth */ /* unused harmony export LessDepth */ /* unused harmony export LessEqualDepth */ /* unused harmony export EqualDepth */ /* unused harmony export GreaterEqualDepth */ /* unused harmony export GreaterDepth */ /* unused harmony export NotEqualDepth */ /* unused harmony export MultiplyOperation */ /* unused harmony export MixOperation */ /* unused harmony export AddOperation */ /* unused harmony export NoToneMapping */ /* unused harmony export LinearToneMapping */ /* unused harmony export ReinhardToneMapping */ /* unused harmony export Uncharted2ToneMapping */ /* unused harmony export CineonToneMapping */ /* unused harmony export UVMapping */ /* unused harmony export CubeReflectionMapping */ /* unused harmony export CubeRefractionMapping */ /* unused harmony export EquirectangularReflectionMapping */ /* unused harmony export EquirectangularRefractionMapping */ /* unused harmony export SphericalReflectionMapping */ /* unused harmony export CubeUVReflectionMapping */ /* unused harmony export CubeUVRefractionMapping */ /* unused harmony export RepeatWrapping */ /* unused harmony export ClampToEdgeWrapping */ /* unused harmony export MirroredRepeatWrapping */ /* unused harmony export NearestFilter */ /* unused harmony export NearestMipMapNearestFilter */ /* unused harmony export NearestMipMapLinearFilter */ /* unused harmony export LinearFilter */ /* unused harmony export LinearMipMapNearestFilter */ /* unused harmony export LinearMipMapLinearFilter */ /* unused harmony export UnsignedByteType */ /* unused harmony export ByteType */ /* unused harmony export ShortType */ /* unused harmony export UnsignedShortType */ /* unused harmony export IntType */ /* unused harmony export UnsignedIntType */ /* unused harmony export FloatType */ /* unused harmony export HalfFloatType */ /* unused harmony export UnsignedShort4444Type */ /* unused harmony export UnsignedShort5551Type */ /* unused harmony export UnsignedShort565Type */ /* unused harmony export UnsignedInt248Type */ /* unused harmony export AlphaFormat */ /* unused harmony export RGBFormat */ /* unused harmony export RGBAFormat */ /* unused harmony export LuminanceFormat */ /* unused harmony export LuminanceAlphaFormat */ /* unused harmony export RGBEFormat */ /* unused harmony export DepthFormat */ /* unused harmony export DepthStencilFormat */ /* unused harmony export RGB_S3TC_DXT1_Format */ /* unused harmony export RGBA_S3TC_DXT1_Format */ /* unused harmony export RGBA_S3TC_DXT3_Format */ /* unused harmony export RGBA_S3TC_DXT5_Format */ /* unused harmony export RGB_PVRTC_4BPPV1_Format */ /* unused harmony export RGB_PVRTC_2BPPV1_Format */ /* unused harmony export RGBA_PVRTC_4BPPV1_Format */ /* unused harmony export RGBA_PVRTC_2BPPV1_Format */ /* unused harmony export RGB_ETC1_Format */ /* unused harmony export LoopOnce */ /* unused harmony export LoopRepeat */ /* unused harmony export LoopPingPong */ /* unused harmony export InterpolateDiscrete */ /* unused harmony export InterpolateLinear */ /* unused harmony export InterpolateSmooth */ /* unused harmony export ZeroCurvatureEnding */ /* unused harmony export ZeroSlopeEnding */ /* unused harmony export WrapAroundEnding */ /* unused harmony export TrianglesDrawMode */ /* unused harmony export TriangleStripDrawMode */ /* unused harmony export TriangleFanDrawMode */ /* unused harmony export LinearEncoding */ /* unused harmony export sRGBEncoding */ /* unused harmony export GammaEncoding */ /* unused harmony export RGBEEncoding */ /* unused harmony export LogLuvEncoding */ /* unused harmony export RGBM7Encoding */ /* unused harmony export RGBM16Encoding */ /* unused harmony export RGBDEncoding */ /* unused harmony export BasicDepthPacking */ /* unused harmony export RGBADepthPacking */ /* unused harmony export CubeGeometry */ /* unused harmony export Face4 */ /* unused harmony export LineStrip */ /* unused harmony export LinePieces */ /* unused harmony export MeshFaceMaterial */ /* unused harmony export MultiMaterial */ /* unused harmony export PointCloud */ /* unused harmony export Particle */ /* unused harmony export ParticleSystem */ /* unused harmony export PointCloudMaterial */ /* unused harmony export ParticleBasicMaterial */ /* unused harmony export ParticleSystemMaterial */ /* unused harmony export Vertex */ /* unused harmony export DynamicBufferAttribute */ /* unused harmony export Int8Attribute */ /* unused harmony export Uint8Attribute */ /* unused harmony export Uint8ClampedAttribute */ /* unused harmony export Int16Attribute */ /* unused harmony export Uint16Attribute */ /* unused harmony export Int32Attribute */ /* unused harmony export Uint32Attribute */ /* unused harmony export Float32Attribute */ /* unused harmony export Float64Attribute */ /* unused harmony export ClosedSplineCurve3 */ /* unused harmony export SplineCurve3 */ /* unused harmony export Spline */ /* unused harmony export BoundingBoxHelper */ /* unused harmony export EdgesHelper */ /* unused harmony export WireframeHelper */ /* unused harmony export XHRLoader */ /* unused harmony export BinaryTextureLoader */ /* unused harmony export GeometryUtils */ /* unused harmony export ImageUtils */ /* unused harmony export Projector */ /* unused harmony export CanvasRenderer */ // Polyfills if ( Number.EPSILON === undefined ) { Number.EPSILON = Math.pow( 2, - 52 ); } if ( Number.isInteger === undefined ) { // Missing in IE // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger Number.isInteger = function ( value ) { return typeof value === 'number' && isFinite( value ) && Math.floor( value ) === value; }; } // if ( Math.sign === undefined ) { // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign Math.sign = function ( x ) { return ( x < 0 ) ? - 1 : ( x > 0 ) ? 1 : + x; }; } if ( Function.prototype.name === undefined ) { // Missing in IE // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name Object.defineProperty( Function.prototype, 'name', { get: function () { return this.toString().match( /^\s*function\s*([^\(\s]*)/ )[ 1 ]; } } ); } if ( Object.assign === undefined ) { // Missing in IE // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign ( function () { Object.assign = function ( target ) { 'use strict'; if ( target === undefined || target === null ) { throw new TypeError( 'Cannot convert undefined or null to object' ); } var output = Object( target ); for ( var index = 1; index < arguments.length; index ++ ) { var source = arguments[ index ]; if ( source !== undefined && source !== null ) { for ( var nextKey in source ) { if ( Object.prototype.hasOwnProperty.call( source, nextKey ) ) { output[ nextKey ] = source[ nextKey ]; } } } } return output; }; } )(); } /** * https://github.com/mrdoob/eventdispatcher.js/ */ function EventDispatcher() {} Object.assign( EventDispatcher.prototype, { addEventListener: function ( type, listener ) { if ( this._listeners === undefined ) this._listeners = {}; var listeners = this._listeners; if ( listeners[ type ] === undefined ) { listeners[ type ] = []; } if ( listeners[ type ].indexOf( listener ) === - 1 ) { listeners[ type ].push( listener ); } }, hasEventListener: function ( type, listener ) { if ( this._listeners === undefined ) return false; var listeners = this._listeners; return listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1; }, removeEventListener: function ( type, listener ) { if ( this._listeners === undefined ) return; var listeners = this._listeners; var listenerArray = listeners[ type ]; if ( listenerArray !== undefined ) { var index = listenerArray.indexOf( listener ); if ( index !== - 1 ) { listenerArray.splice( index, 1 ); } } }, dispatchEvent: function ( event ) { if ( this._listeners === undefined ) return; var listeners = this._listeners; var listenerArray = listeners[ event.type ]; if ( listenerArray !== undefined ) { event.target = this; var array = listenerArray.slice( 0 ); for ( var i = 0, l = array.length; i < l; i ++ ) { array[ i ].call( this, event ); } } } } ); var REVISION = '87'; var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2 }; var CullFaceNone = 0; var CullFaceBack = 1; var CullFaceFront = 2; var CullFaceFrontBack = 3; var FrontFaceDirectionCW = 0; var FrontFaceDirectionCCW = 1; var BasicShadowMap = 0; var PCFShadowMap = 1; var PCFSoftShadowMap = 2; var FrontSide = 0; var BackSide = 1; var DoubleSide = 2; var FlatShading = 1; var SmoothShading = 2; var NoColors = 0; var FaceColors = 1; var VertexColors = 2; var NoBlending = 0; var NormalBlending = 1; var AdditiveBlending = 2; var SubtractiveBlending = 3; var MultiplyBlending = 4; var CustomBlending = 5; var AddEquation = 100; var SubtractEquation = 101; var ReverseSubtractEquation = 102; var MinEquation = 103; var MaxEquation = 104; var ZeroFactor = 200; var OneFactor = 201; var SrcColorFactor = 202; var OneMinusSrcColorFactor = 203; var SrcAlphaFactor = 204; var OneMinusSrcAlphaFactor = 205; var DstAlphaFactor = 206; var OneMinusDstAlphaFactor = 207; var DstColorFactor = 208; var OneMinusDstColorFactor = 209; var SrcAlphaSaturateFactor = 210; var NeverDepth = 0; var AlwaysDepth = 1; var LessDepth = 2; var LessEqualDepth = 3; var EqualDepth = 4; var GreaterEqualDepth = 5; var GreaterDepth = 6; var NotEqualDepth = 7; var MultiplyOperation = 0; var MixOperation = 1; var AddOperation = 2; var NoToneMapping = 0; var LinearToneMapping = 1; var ReinhardToneMapping = 2; var Uncharted2ToneMapping = 3; var CineonToneMapping = 4; var UVMapping = 300; var CubeReflectionMapping = 301; var CubeRefractionMapping = 302; var EquirectangularReflectionMapping = 303; var EquirectangularRefractionMapping = 304; var SphericalReflectionMapping = 305; var CubeUVReflectionMapping = 306; var CubeUVRefractionMapping = 307; var RepeatWrapping = 1000; var ClampToEdgeWrapping = 1001; var MirroredRepeatWrapping = 1002; var NearestFilter = 1003; var NearestMipMapNearestFilter = 1004; var NearestMipMapLinearFilter = 1005; var LinearFilter = 1006; var LinearMipMapNearestFilter = 1007; var LinearMipMapLinearFilter = 1008; var UnsignedByteType = 1009; var ByteType = 1010; var ShortType = 1011; var UnsignedShortType = 1012; var IntType = 1013; var UnsignedIntType = 1014; var FloatType = 1015; var HalfFloatType = 1016; var UnsignedShort4444Type = 1017; var UnsignedShort5551Type = 1018; var UnsignedShort565Type = 1019; var UnsignedInt248Type = 1020; var AlphaFormat = 1021; var RGBFormat = 1022; var RGBAFormat = 1023; var LuminanceFormat = 1024; var LuminanceAlphaFormat = 1025; var RGBEFormat = RGBAFormat; var DepthFormat = 1026; var DepthStencilFormat = 1027; var RGB_S3TC_DXT1_Format = 2001; var RGBA_S3TC_DXT1_Format = 2002; var RGBA_S3TC_DXT3_Format = 2003; var RGBA_S3TC_DXT5_Format = 2004; var RGB_PVRTC_4BPPV1_Format = 2100; var RGB_PVRTC_2BPPV1_Format = 2101; var RGBA_PVRTC_4BPPV1_Format = 2102; var RGBA_PVRTC_2BPPV1_Format = 2103; var RGB_ETC1_Format = 2151; var LoopOnce = 2200; var LoopRepeat = 2201; var LoopPingPong = 2202; var InterpolateDiscrete = 2300; var InterpolateLinear = 2301; var InterpolateSmooth = 2302; var ZeroCurvatureEnding = 2400; var ZeroSlopeEnding = 2401; var WrapAroundEnding = 2402; var TrianglesDrawMode = 0; var TriangleStripDrawMode = 1; var TriangleFanDrawMode = 2; var LinearEncoding = 3000; var sRGBEncoding = 3001; var GammaEncoding = 3007; var RGBEEncoding = 3002; var LogLuvEncoding = 3003; var RGBM7Encoding = 3004; var RGBM16Encoding = 3005; var RGBDEncoding = 3006; var BasicDepthPacking = 3200; var RGBADepthPacking = 3201; /** * @author alteredq / http://alteredqualia.com/ * @author mrdoob / http://mrdoob.com/ */ var _Math = { DEG2RAD: Math.PI / 180, RAD2DEG: 180 / Math.PI, generateUUID: function () { // http://www.broofa.com/Tools/Math.uuid.htm var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split( '' ); var uuid = new Array( 36 ); var rnd = 0, r; return function generateUUID() { for ( var i = 0; i < 36; i ++ ) { if ( i === 8 || i === 13 || i === 18 || i === 23 ) { uuid[ i ] = '-'; } else if ( i === 14 ) { uuid[ i ] = '4'; } else { if ( rnd <= 0x02 ) rnd = 0x2000000 + ( Math.random() * 0x1000000 ) | 0; r = rnd & 0xf; rnd = rnd >> 4; uuid[ i ] = chars[ ( i === 19 ) ? ( r & 0x3 ) | 0x8 : r ]; } } return uuid.join( '' ); }; }(), clamp: function ( value, min, max ) { return Math.max( min, Math.min( max, value ) ); }, // compute euclidian modulo of m % n // https://en.wikipedia.org/wiki/Modulo_operation euclideanModulo: function ( n, m ) { return ( ( n % m ) + m ) % m; }, // Linear mapping from range <a1, a2> to range <b1, b2> mapLinear: function ( x, a1, a2, b1, b2 ) { return b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 ); }, // https://en.wikipedia.org/wiki/Linear_interpolation lerp: function ( x, y, t ) { return ( 1 - t ) * x + t * y; }, // http://en.wikipedia.org/wiki/Smoothstep smoothstep: function ( x, min, max ) { if ( x <= min ) return 0; if ( x >= max ) return 1; x = ( x - min ) / ( max - min ); return x * x * ( 3 - 2 * x ); }, smootherstep: function ( x, min, max ) { if ( x <= min ) return 0; if ( x >= max ) return 1; x = ( x - min ) / ( max - min ); return x * x * x * ( x * ( x * 6 - 15 ) + 10 ); }, // Random integer from <low, high> interval randInt: function ( low, high ) { return low + Math.floor( Math.random() * ( high - low + 1 ) ); }, // Random float from <low, high> interval randFloat: function ( low, high ) { return low + Math.random() * ( high - low ); }, // Random float from <-range/2, range/2> interval randFloatSpread: function ( range ) { return range * ( 0.5 - Math.random() ); }, degToRad: function ( degrees ) { return degrees * _Math.DEG2RAD; }, radToDeg: function ( radians ) { return radians * _Math.RAD2DEG; }, isPowerOfTwo: function ( value ) { return ( value & ( value - 1 ) ) === 0 && value !== 0; }, nearestPowerOfTwo: function ( value ) { return Math.pow( 2, Math.round( Math.log( value ) / Math.LN2 ) ); }, nextPowerOfTwo: function ( value ) { value --; value |= value >> 1; value |= value >> 2; value |= value >> 4; value |= value >> 8; value |= value >> 16; value ++; return value; } }; /** * @author mrdoob / http://mrdoob.com/ * @author philogb / http://blog.thejit.org/ * @author egraether / http://egraether.com/ * @author zz85 / http://www.lab4games.net/zz85/blog */ function Vector2( x, y ) { this.x = x || 0; this.y = y || 0; } Object.defineProperties( Vector2.prototype, { "width" : { get: function () { return this.x; }, set: function ( value ) { this.x = value; } }, "height" : { get: function () { return this.y; }, set: function ( value ) { this.y = value; } } } ); Object.assign( Vector2.prototype, { isVector2: true, set: function ( x, y ) { this.x = x; this.y = y; return this; }, setScalar: function ( scalar ) { this.x = scalar; this.y = scalar; return this; }, setX: function ( x ) { this.x = x; return this; }, setY: function ( y ) { this.y = y; return this; }, setComponent: function ( index, value ) { switch ( index ) { case 0: this.x = value; break; case 1: this.y = value; break; default: throw new Error( 'index is out of range: ' + index ); } return this; }, getComponent: function ( index ) { switch ( index ) { case 0: return this.x; case 1: return this.y; default: throw new Error( 'index is out of range: ' + index ); } }, clone: function () { return new this.constructor( this.x, this.y ); }, copy: function ( v ) { this.x = v.x; this.y = v.y; return this; }, add: function ( v, w ) { if ( w !== undefined ) { console.warn( 'THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); return this.addVectors( v, w ); } this.x += v.x; this.y += v.y; return this; }, addScalar: function ( s ) { this.x += s; this.y += s; return this; }, addVectors: function ( a, b ) { this.x = a.x + b.x; this.y = a.y + b.y; return this; }, addScaledVector: function ( v, s ) { this.x += v.x * s; this.y += v.y * s; return this; }, sub: function ( v, w ) { if ( w !== undefined ) { console.warn( 'THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); return this.subVectors( v, w ); } this.x -= v.x; this.y -= v.y; return this; }, subScalar: function ( s ) { this.x -= s; this.y -= s; return this; }, subVectors: function ( a, b ) { this.x = a.x - b.x; this.y = a.y - b.y; return this; }, multiply: function ( v ) { this.x *= v.x; this.y *= v.y; return this; }, multiplyScalar: function ( scalar ) { this.x *= scalar; this.y *= scalar; return this; }, divide: function ( v ) { this.x /= v.x; this.y /= v.y; return this; }, divideScalar: function ( scalar ) { return this.multiplyScalar( 1 / scalar ); }, min: function ( v ) { this.x = Math.min( this.x, v.x ); this.y = Math.min( this.y, v.y ); return this; }, max: function ( v ) { this.x = Math.max( this.x, v.x ); this.y = Math.max( this.y, v.y ); return this; }, clamp: function ( min, max ) { // assumes min < max, componentwise this.x = Math.max( min.x, Math.min( max.x, this.x ) ); this.y = Math.max( min.y, Math.min( max.y, this.y ) ); return this; }, clampScalar: function () { var min = new Vector2(); var max = new Vector2(); return function clampScalar( minVal, maxVal ) { min.set( minVal, minVal ); max.set( maxVal, maxVal ); return this.clamp( min, max ); }; }(), clampLength: function ( min, max ) { var length = this.length(); return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) ); }, floor: function () { this.x = Math.floor( this.x ); this.y = Math.floor( this.y ); return this; }, ceil: function () { this.x = Math.ceil( this.x ); this.y = Math.ceil( this.y ); return this; }, round: function () { this.x = Math.round( this.x ); this.y = Math.round( this.y ); return this; }, roundToZero: function () { this.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x ); this.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y ); return this; }, negate: function () { this.x = - this.x; this.y = - this.y; return this; }, dot: function ( v ) { return this.x * v.x + this.y * v.y; }, lengthSq: function () { return this.x * this.x + this.y * this.y; }, length: function () { return Math.sqrt( this.x * this.x + this.y * this.y ); }, lengthManhattan: function() { return Math.abs( this.x ) + Math.abs( this.y ); }, normalize: function () { return this.divideScalar( this.length() || 1 ); }, angle: function () { // computes the angle in radians with respect to the positive x-axis var angle = Math.atan2( this.y, this.x ); if ( angle < 0 ) angle += 2 * Math.PI; return angle; }, distanceTo: function ( v ) { return Math.sqrt( this.distanceToSquared( v ) ); }, distanceToSquared: function ( v ) { var dx = this.x - v.x, dy = this.y - v.y; return dx * dx + dy * dy; }, distanceToManhattan: function ( v ) { return Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ); }, setLength: function ( length ) { return this.normalize().multiplyScalar( length ); }, lerp: function ( v, alpha ) { this.x += ( v.x - this.x ) * alpha; this.y += ( v.y - this.y ) * alpha; return this; }, lerpVectors: function ( v1, v2, alpha ) { return this.subVectors( v2, v1 ).multiplyScalar( alpha ).add( v1 ); }, equals: function ( v ) { return ( ( v.x === this.x ) && ( v.y === this.y ) ); }, fromArray: function ( array, offset ) { if ( offset === undefined ) offset = 0; this.x = array[ offset ]; this.y = array[ offset + 1 ]; return this; }, toArray: function ( array, offset ) { if ( array === undefined ) array = []; if ( offset === undefined ) offset = 0; array[ offset ] = this.x; array[ offset + 1 ] = this.y; return array; }, fromBufferAttribute: function ( attribute, index, offset ) { if ( offset !== undefined ) { console.warn( 'THREE.Vector2: offset has been removed from .fromBufferAttribute().' ); } this.x = attribute.getX( index ); this.y = attribute.getY( index ); return this; }, rotateAround: function ( center, angle ) { var c = Math.cos( angle ), s = Math.sin( angle ); var x = this.x - center.x; var y = this.y - center.y; this.x = x * c - y * s + center.x; this.y = x * s + y * c + center.y; return this; } } ); /** * @author mrdoob / http://mrdoob.com/ * @author alteredq / http://alteredqualia.com/ * @author szimek / https://github.com/szimek/ */ var textureId = 0; function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) { Object.defineProperty( this, 'id', { value: textureId ++ } ); this.uuid = _Math.generateUUID(); this.name = ''; this.image = image !== undefined ? image : Texture.DEFAULT_IMAGE; this.mipmaps = []; this.mapping = mapping !== undefined ? mapping : Texture.DEFAULT_MAPPING; this.wrapS = wrapS !== undefined ? wrapS : ClampToEdgeWrapping; this.wrapT = wrapT !== undefined ? wrapT : ClampToEdgeWrapping; this.magFilter = magFilter !== undefined ? magFilter : LinearFilter; this.minFilter = minFilter !== undefined ? minFilter : LinearMipMapLinearFilter; this.anisotropy = anisotropy !== undefined ? anisotropy : 1; this.format = format !== undefined ? format : RGBAFormat; this.type = type !== undefined ? type : UnsignedByteType; this.offset = new Vector2( 0, 0 ); this.repeat = new Vector2( 1, 1 ); this.generateMipmaps = true; this.premultiplyAlpha = false; this.flipY = true; this.unpackAlignment = 4; // valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml) // Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap. // // Also changing the encoding after already used by a Material will not automatically make the Material // update. You need to explicitly call Material.needsUpdate to trigger it to recompile. this.encoding = encoding !== undefined ? encoding : LinearEncoding; this.version = 0; this.onUpdate = null; } Texture.DEFAULT_IMAGE = undefined; Texture.DEFAULT_MAPPING = UVMapping; Object.defineProperty( Texture.prototype, "needsUpdate", { set: function ( value ) { if ( value === true ) this.version ++; } } ); Object.assign( Texture.prototype, EventDispatcher.prototype, { constructor: Texture, isTexture: true, clone: function () { return new this.constructor().copy( this ); }, copy: function ( source ) { this.name = source.name; this.image = source.image; this.mipmaps = source.mipmaps.slice( 0 ); this.mapping = source.mapping; this.wrapS = source.wrapS; this.wrapT = source.wrapT; this.magFilter = source.magFilter; this.minFilter = source.minFilter; this.anisotropy = source.anisotropy; this.format = source.format; this.type = source.type; this.offset.copy( source.offset ); this.repeat.copy( source.repeat ); this.generateMipmaps = source.generateMipmaps; this.premultiplyAlpha = source.premultiplyAlpha; this.flipY = source.flipY; this.unpackAlignment = source.unpackAlignment; this.encoding = source.encoding; return this; }, toJSON: function ( meta ) { if ( meta.textures[ this.uuid ] !== undefined ) { return meta.textures[ this.uuid ]; } function getDataURL( image ) { var canvas; if ( image instanceof HTMLCanvasElement ) { canvas = image; } else { canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ); canvas.width = image.width; canvas.height = image.height; var context = canvas.getContext( '2d' ); if ( image instanceof ImageData ) { context.putImageData( image, 0, 0 ); } else { context.drawImage( image, 0, 0, image.width, image.height ); } } if ( canvas.width > 2048 || canvas.height > 2048 ) { return canvas.toDataURL( 'image/jpeg', 0.6 ); } else { return canvas.toDataURL( 'image/png' ); } } var output = { metadata: { version: 4.5, type: 'Texture', generator: 'Texture.toJSON' }, uuid: this.uuid, 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, flipY: this.flipY }; if ( this.image !== undefined ) { // TODO: Move to THREE.Image var image = this.image; if ( image.uuid === undefined ) { image.uuid = _Math.generateUUID(); // UGH } if ( meta.images[ image.uuid ] === undefined ) { meta.images[ image.uuid ] = { uuid: image.uuid, url: getDataURL( image ) }; } output.image = image.uuid; } meta.textures[ this.uuid ] = output; return output; }, dispose: function () { this.dispatchEvent( { type: 'dispose' } ); }, transformUv: function ( uv ) { if ( this.mapping !== UVMapping ) return; uv.multiply( this.repeat ); uv.add( this.offset ); if ( uv.x < 0 || uv.x > 1 ) { switch ( this.wrapS ) { case RepeatWrapping: uv.x = uv.x - Math.floor( uv.x ); break; case ClampToEdgeWrapping: uv.x = uv.x < 0 ? 0 : 1; break; case MirroredRepeatWrapping: if ( Math.abs( Math.floor( uv.x ) % 2 ) === 1 ) { uv.x = Math.ceil( uv.x ) - uv.x; } else { uv.x = uv.x - Math.floor( uv.x ); } break; } } if ( uv.y < 0 || uv.y > 1 ) { switch ( this.wrapT ) { case RepeatWrapping: uv.y = uv.y - Math.floor( uv.y ); break; case ClampToEdgeWrapping: uv.y = uv.y < 0 ? 0 : 1; break; case MirroredRepeatWrapping: if ( Math.abs( Math.floor( uv.y ) % 2 ) === 1 ) { uv.y = Math.ceil( uv.y ) - uv.y; } else { uv.y = uv.y - Math.floor( uv.y ); } break; } } if ( this.flipY ) { uv.y = 1 - uv.y; } } } ); /** * @author supereggbert / http://www.paulbrunt.co.uk/ * @author philogb / http://blog.thejit.org/ * @author mikael emtinger / http://gomo.se/ * @author egraether / http://egraether.com/ * @author WestLangley / http://github.com/WestLangley */ function Vector4( x, y, z, w ) { this.x = x || 0; this.y = y || 0; this.z = z || 0; this.w = ( w !== undefined ) ? w : 1; } Object.assign( Vector4.prototype, { isVector4: true, set: function ( x, y, z, w ) { this.x = x; this.y = y; this.z = z; this.w = w; return this; }, setScalar: function ( scalar ) { this.x = scalar; this.y = scalar; this.z = scalar; this.w = scalar; return this; }, setX: function ( x ) { this.x = x; return this; }, setY: function ( y ) { this.y = y; return this; }, setZ: function ( z ) { this.z = z; return this; }, setW: function ( w ) { this.w = w; return this; }, setComponent: function ( index, value ) { switch ( index ) { case 0: this.x = value; break; case 1: this.y = value; break; case 2: this.z = value; break; case 3: this.w = value; break; default: throw new Error( 'index is out of range: ' + index ); } return this; }, getComponent: function ( index ) { switch ( index ) { case 0: return this.x; case 1: return this.y; case 2: return this.z; case 3: return this.w; default: throw new Error( 'index is out of range: ' + index ); } }, clone: function () { return new this.constructor( this.x, this.y, this.z, this.w ); }, copy: function ( v ) { this.x = v.x; this.y = v.y; this.z = v.z; this.w = ( v.w !== undefined ) ? v.w : 1; return this; }, add: function ( v, w ) { if ( w !== undefined ) { console.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' ); return this.addVectors( v, w ); } this.x += v.x; this.y += v.y; this.z += v.z; this.w += v.w; return this; }, addScalar: function ( s ) { this.x += s; this.y += s; this.z += s; this.w += s; return this; }, addVectors: function ( a, b ) { this.x = a.x + b.x; this.y = a.y + b.y; this.z = a.z + b.z; this.w = a.w + b.w; return this; }, addScaledVector: function ( v, s ) { this.x += v.x * s; this.y += v.y * s; this.z += v.z * s; this.w += v.w * s; return this; }, sub: function ( v, w ) { if ( w !== undefined ) { console.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' ); return this.subVectors( v, w ); } this.x -= v.x; this.y -= v.y; this.z -= v.z; this.w -= v.w; return this; }, subScalar: function ( s ) { this.x -= s; this.y -= s; this.z -= s; this.w -= s; return this; }, subVectors: function ( a, b ) { this.x = a.x - b.x; this.y = a.y - b.y; this.z = a.z - b.z; this.w = a.w - b.w; return this; }, multiplyScalar: function ( scalar ) { this.x *= scalar; this.y *= scalar; this.z *= scalar; this.w *= scalar; return this; }, applyMatrix4: function ( m ) { var x = this.x, y = this.y, z = this.z, w = this.w; var e = m.elements; this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] * w; this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] * w; this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] * w; this.w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] * w; return this; }, divideScalar: function ( scalar ) { return this.multiplyScalar( 1 / scalar ); }, setAxisAngleFromQuaternion: function ( q ) { // http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm // q is assumed to be normalized this.w = 2 * Math.acos( q.w ); var s = Math.sqrt( 1 - q.w * q.w ); if ( s < 0.0001 ) { this.x = 1; this.y = 0; this.z = 0; } else { this.x = q.x / s; this.y = q.y / s; this.z = q.z / s; } return this; }, setAxisAngleFromRotationMatrix: function ( m ) { // http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm // assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled) var angle, x, y, z, // variables for result epsilon = 0.01, // margin to allow for rounding errors epsilon2 = 0.1, // margin to distinguish between 0 and 180 degrees te = m.elements, m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ], m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ], m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ]; if ( ( Math.abs( m12 - m21 ) < epsilon ) && ( Math.abs( m13 - m31 ) < epsilon ) && ( Math.abs( m23 - m32 ) < epsilon ) ) { // singularity found // first check for identity matrix which must have +1 for all terms // in leading diagonal and zero in other terms if ( ( Math.abs( m12 + m21 ) < epsilon2 ) && ( Math.abs( m13 + m31 ) < epsilon2 ) && ( Math.abs( m23 + m32 ) < epsilon2 ) && ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) { // this singularity is identity matrix so angle = 0 this.set( 1, 0, 0, 0 ); return this; // zero angle, arbitrary axis } // otherwise this singularity is angle = 180 angle = Math.PI; var xx = ( m11 + 1 ) / 2; var yy = ( m22 + 1 ) / 2; var zz = ( m33 + 1 ) / 2; var xy = ( m12 + m21 ) / 4; var xz = ( m13 + m31 ) / 4; var yz = ( m23 + m32 ) / 4; if ( ( xx > yy ) && ( xx > zz ) ) { // m11 is the largest diagonal term if ( xx < epsilon ) { x = 0; y = 0.707106781; z = 0.707106781; } else { x = Math.sqrt( xx ); y = xy / x; z = xz / x; } } else if ( yy > zz ) { // m22 is the largest diagonal term if ( yy < epsilon ) { x = 0.707106781; y = 0; z = 0.707106781; } else { y = Math.sqrt( yy ); x = xy / y; z = yz / y; } } else { // m33 is the largest diagonal term so base result on this if ( zz < epsilon ) { x = 0.707106781; y = 0.707106781; z = 0; } else { z = Math.sqrt( zz ); x = xz / z; y = yz / z; } } this.set( x, y, z, angle ); return this; // return 180 deg rotation } // as we have reached here there are no singularities so we can handle normally var s = Math.sqrt( ( m32 - m23 ) * ( m32 - m23 ) + ( m13 - m31 ) * ( m13 - m31 ) + ( m21 - m12 ) * ( m21 - m12 ) ); // used to normalize if ( Math.abs( s ) < 0.001 ) s = 1; // prevent divide by zero, should not happen if matrix is orthogonal and should be // caught by singularity test above, but I've left it in just in case this.x = ( m32 - m23 ) / s; this.y = ( m13 - m31 ) / s; this.z = ( m21 - m12 ) / s; this.w = Math.acos( ( m11 + m22 + m33 - 1 ) / 2 ); return this; }, min: function ( v ) { this.x = Math.min( this.x, v.x ); this.y = Math.min( this.y, v.y ); this.z = Math.min( this.z, v.z ); this.w = Math.min( this.w, v.w ); return this; }, max: function ( v ) { this.x = Math.max( this.x, v.x ); this.y = Math.max( this.y, v.y ); this.z = Math.max( this.z, v.z ); this.w = Math.max( this.w, v.w ); return this; }, clamp: function ( min, max ) { // assumes min < max, componentwise this.x = Math.max( min.x, Math.min( max.x, this.x ) ); this.y = Math.max( min.y, Math.min( max.y, this.y ) ); this.z = Math.max( min.z, Math.min( max.z, this.z ) ); this.w = Math.max( min.w, Math.min( max.w, this.w ) ); return this; }, clampScalar: function () { var min, max; return function clampScalar( minVal, maxVal ) { if ( min === undefined ) { min = new Vector4(); max = new Vector4(); } min.set( minVal, minVal, minVal, minVal ); max.set( maxVal, maxVal, maxVal, maxVal ); return this.clamp( min, max ); }; }(), clampLength: function ( min, max ) { var length = this.length(); return this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) ); }, floor: function () { this.x = Math.floor( this.x ); this.y = Math.floor( this.y ); this.z = Math.floor( this.z ); this.w = Math.floor( this.w ); return this; }, ceil: function () { this.x = Math.ceil( this.x ); this.y = Math.ce